// Copyright 2026 Tether Operations Limited // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * Core Type Definitions * * All network, token, and wallet type definitions for the WDK React Native Core library. */ import type { AssetConfig, IAsset } from './entities/asset' export type { AssetConfig, IAsset } import type { NetworkConfig, ProtocolConfig, WdkWorkletConfig, } from './types/hrpc' /** * Network Configurations (Generic) * Wrapper around NetworkConfigs to support typed config. */ export interface WdkNetworkConfig< T = Record, > extends NetworkConfig { config: T } /** * Protocol Configurations (Generic) * Wrapper around ProtocolConfigs to support typed config. */ export interface WdkProtocolConfig< T = Record, > extends ProtocolConfig { config: T } /** * WDK Configuration (Generic) * * The root configuration object passed to the WDK worklet. * Matches WdkWorkletConfig structure but with generics. */ export interface WdkConfigs< TNetwork = Record, TProtocol = Record, > extends WdkWorkletConfig { networks: { [blockchain: string]: WdkNetworkConfig } protocols?: { [protocolName: string]: WdkProtocolConfig } modules?: { [moduleName: string]: Record } } /** * Wallet Addresses * * Maps network -> accountIndex -> address * Structure: { [network]: { [accountIndex]: address } } */ export type WalletAddresses = Record> /** * Wallet Addresses by Wallet Identifier * * Maps walletId -> network -> accountIndex -> address * Structure: { [walletId]: { [network]: { [accountIndex]: address } } } */ export type WalletAddressesByWallet = Record /** * Wallet Balances * * Maps network -> accountIndex -> assetId -> balance * Structure: { [network]: { [accountIndex]: { [assetId]: balance } } } * Note: balance is stored as a string to handle BigInt values */ export type WalletBalances = Record< string, Record> > /** * Wallet Balances by Wallet Identifier * * Maps walletId -> network -> accountIndex -> assetId -> balance * Structure: { [walletId]: { [network]: { [accountIndex]: { [assetId]: balance } } } } */ export type WalletBalancesByWallet = Record /** * Balance Loading States * * Maps "network-accountIndex-assetId" -> boolean * Used to track which balances are currently being fetched. */ export type BalanceLoadingStates = Record /** * Balance Fetch Result * * Result of a balance fetch operation. */ export interface BalanceFetchResult { /** Whether the fetch was successful */ success: boolean /** Network name */ network: string /** Account index */ accountIndex: number /** Asset identifier */ assetId: string /** Balance as a string (null if fetch failed) */ balance: string | null /** Error message (only present if success is false) */ error?: string } /** * Wallet Store Interface * * Interface for wallet store implementations that provide account methods * and wallet initialization status. */ export interface WalletStore { /** Call a method on a wallet account * @param args - Single argument or array for multi-param methods (array gets spread) */ callAccountMethod: ( network: string, accountIndex: number, methodName: string, args?: unknown | unknown[], ) => Promise /** Check if the wallet is initialized */ isWalletInitialized: () => boolean } export { LogType, type LogRequest, type WorkletStartRequest, type WorkletStartResponse, type DisposeRequest, type CallMethodRequest, type CallMethodResponse, type HRPC, type BundleConfig, } from './types/hrpc' type AddressIdentifier = { network: string accountIndex: number } export type AddressInfo = AddressIdentifier & { address: string } export type AddressInfoResult = | (AddressIdentifier & { success: true address: string }) | (AddressIdentifier & { success: false reason: Error })