@t402/wdk 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/cjs/adapters/index.d.ts +5 -0
- package/dist/cjs/adapters/index.js +455 -0
- package/dist/cjs/adapters/index.js.map +1 -0
- package/dist/cjs/adapters/svm-adapter.d.ts +125 -0
- package/dist/cjs/adapters/svm-adapter.js +132 -0
- package/dist/cjs/adapters/svm-adapter.js.map +1 -0
- package/dist/cjs/adapters/ton-adapter.d.ts +139 -0
- package/dist/cjs/adapters/ton-adapter.js +152 -0
- package/dist/cjs/adapters/ton-adapter.js.map +1 -0
- package/dist/cjs/adapters/tron-adapter.d.ts +139 -0
- package/dist/cjs/adapters/tron-adapter.js +221 -0
- package/dist/cjs/adapters/tron-adapter.js.map +1 -0
- package/dist/cjs/index.d.ts +292 -217
- package/dist/cjs/index.js +1042 -23
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types-V7c-qhn6.d.ts +489 -0
- package/dist/esm/adapters/index.d.mts +5 -0
- package/dist/esm/adapters/index.mjs +21 -0
- package/dist/esm/adapters/index.mjs.map +1 -0
- package/dist/esm/adapters/svm-adapter.d.mts +125 -0
- package/dist/esm/adapters/svm-adapter.mjs +9 -0
- package/dist/esm/adapters/svm-adapter.mjs.map +1 -0
- package/dist/esm/adapters/ton-adapter.d.mts +139 -0
- package/dist/esm/adapters/ton-adapter.mjs +9 -0
- package/dist/esm/adapters/ton-adapter.mjs.map +1 -0
- package/dist/esm/adapters/tron-adapter.d.mts +139 -0
- package/dist/esm/adapters/tron-adapter.mjs +9 -0
- package/dist/esm/adapters/tron-adapter.mjs.map +1 -0
- package/dist/esm/chunk-HB2DGKQ3.mjs +196 -0
- package/dist/esm/chunk-HB2DGKQ3.mjs.map +1 -0
- package/dist/esm/chunk-MCFHZSF7.mjs +107 -0
- package/dist/esm/chunk-MCFHZSF7.mjs.map +1 -0
- package/dist/esm/chunk-YWBJJV5M.mjs +117 -0
- package/dist/esm/chunk-YWBJJV5M.mjs.map +1 -0
- package/dist/esm/index.d.mts +292 -217
- package/dist/esm/index.mjs +640 -23
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/types-V7c-qhn6.d.mts +489 -0
- package/package.json +70 -6
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,214 +1,15 @@
|
|
|
1
1
|
import { Address } from 'viem';
|
|
2
|
+
import { c as WDKInstance, d as WDKConstructor, e as WDKModulesConfig, f as WDKWalletModules, g as WDKProtocolModules, T as T402WDKCreateConfig, h as T402WDKConfig, F as FromWDKOptions, i as T402WDKOptions, G as GetAllSignersOptions, S as SignerEntry, N as NormalizedChainConfig, C as ChainFamily, j as ChainBalance, A as AggregatedBalance, B as BridgeParams, k as BridgeResult, l as SwapQuote, m as SwapParams, n as SwapResult, E as EvmChainConfig } from './types-V7c-qhn6.js';
|
|
3
|
+
export { M as MultiChainConfig, v as SvmChainConfig, o as T402BalanceCacheConfig, s as T402WDKSigner, p as TokenBalance, w as TonChainConfig, x as TronChainConfig, q as TypedDataDomain, r as TypedDataTypes, t as WDKAccount, y as WDKInstanceMultiChain, W as WDKSolanaAccount, a as WDKTonAccount, b as WDKTronAccount, u as WdkAccount } from './types-V7c-qhn6.js';
|
|
4
|
+
import { ClientTonSigner } from './adapters/ton-adapter.js';
|
|
5
|
+
export { SignMessageParams as TonSignMessageParams, WDKTonSignerAdapter, createWDKTonSigner } from './adapters/ton-adapter.js';
|
|
6
|
+
import { TransactionSigner } from './adapters/svm-adapter.js';
|
|
7
|
+
export { SolanaAddress, WDKSvmSignerAdapter, createWDKSvmSigner } from './adapters/svm-adapter.js';
|
|
8
|
+
import { ClientTronSigner } from './adapters/tron-adapter.js';
|
|
9
|
+
export { BlockInfo as TronBlockInfo, SignTransactionParams as TronSignTransactionParams, WDKTronSignerAdapter, createWDKTronSigner } from './adapters/tron-adapter.js';
|
|
2
10
|
import { ClientEvmSigner, Usdt0Bridge, BridgeSigner } from '@t402/evm';
|
|
3
11
|
export { BridgeQuote, BridgeSigner, LAYERZERO_ENDPOINT_IDS, USDT0_OFT_ADDRESSES, Usdt0Bridge, getBridgeableChains, supportsBridging } from '@t402/evm';
|
|
4
12
|
|
|
5
|
-
/**
|
|
6
|
-
* Type definitions for T402 WDK integration
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* EVM chain configuration
|
|
11
|
-
*/
|
|
12
|
-
interface EvmChainConfig {
|
|
13
|
-
/** RPC endpoint URL */
|
|
14
|
-
provider: string;
|
|
15
|
-
/** Chain ID */
|
|
16
|
-
chainId: number;
|
|
17
|
-
/** CAIP-2 network identifier */
|
|
18
|
-
network: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* T402 WDK configuration options
|
|
22
|
-
*/
|
|
23
|
-
interface T402WDKConfig {
|
|
24
|
-
/** Ethereum mainnet configuration */
|
|
25
|
-
ethereum?: EvmChainConfig | string;
|
|
26
|
-
/** Arbitrum One configuration */
|
|
27
|
-
arbitrum?: EvmChainConfig | string;
|
|
28
|
-
/** Base mainnet configuration */
|
|
29
|
-
base?: EvmChainConfig | string;
|
|
30
|
-
/** Ink mainnet configuration */
|
|
31
|
-
ink?: EvmChainConfig | string;
|
|
32
|
-
/** Berachain mainnet configuration */
|
|
33
|
-
berachain?: EvmChainConfig | string;
|
|
34
|
-
/** Unichain mainnet configuration */
|
|
35
|
-
unichain?: EvmChainConfig | string;
|
|
36
|
-
/** Polygon mainnet configuration */
|
|
37
|
-
polygon?: EvmChainConfig | string;
|
|
38
|
-
/** Custom chains */
|
|
39
|
-
[key: string]: EvmChainConfig | string | undefined;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Normalized chain configuration
|
|
43
|
-
*/
|
|
44
|
-
interface NormalizedChainConfig {
|
|
45
|
-
provider: string;
|
|
46
|
-
chainId: number;
|
|
47
|
-
network: string;
|
|
48
|
-
name: string;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Token balance information
|
|
52
|
-
*/
|
|
53
|
-
interface TokenBalance {
|
|
54
|
-
/** Token contract address */
|
|
55
|
-
token: Address;
|
|
56
|
-
/** Token symbol */
|
|
57
|
-
symbol: string;
|
|
58
|
-
/** Balance in smallest units */
|
|
59
|
-
balance: bigint;
|
|
60
|
-
/** Formatted balance (human-readable) */
|
|
61
|
-
formatted: string;
|
|
62
|
-
/** Decimals */
|
|
63
|
-
decimals: number;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Chain balance information
|
|
67
|
-
*/
|
|
68
|
-
interface ChainBalance {
|
|
69
|
-
/** Chain name (e.g., "arbitrum") */
|
|
70
|
-
chain: string;
|
|
71
|
-
/** CAIP-2 network identifier */
|
|
72
|
-
network: string;
|
|
73
|
-
/** Native token balance */
|
|
74
|
-
native: bigint;
|
|
75
|
-
/** Token balances */
|
|
76
|
-
tokens: TokenBalance[];
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Aggregated balance across all chains
|
|
80
|
-
*/
|
|
81
|
-
interface AggregatedBalance {
|
|
82
|
-
/** Total USDT0 balance across all chains */
|
|
83
|
-
totalUsdt0: bigint;
|
|
84
|
-
/** Total USDC balance across all chains */
|
|
85
|
-
totalUsdc: bigint;
|
|
86
|
-
/** Per-chain balances */
|
|
87
|
-
chains: ChainBalance[];
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Bridge parameters for cross-chain transfers
|
|
91
|
-
*/
|
|
92
|
-
interface BridgeParams {
|
|
93
|
-
/** Source chain name */
|
|
94
|
-
fromChain: string;
|
|
95
|
-
/** Destination chain name */
|
|
96
|
-
toChain: string;
|
|
97
|
-
/** Amount to bridge in smallest units */
|
|
98
|
-
amount: bigint;
|
|
99
|
-
/** Recipient address (optional, defaults to same wallet on target chain) */
|
|
100
|
-
recipient?: Address;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Bridge result
|
|
104
|
-
*/
|
|
105
|
-
interface BridgeResult {
|
|
106
|
-
/** Transaction hash on source chain */
|
|
107
|
-
txHash: string;
|
|
108
|
-
/** Estimated time for bridge completion in seconds */
|
|
109
|
-
estimatedTime: number;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* EIP-712 typed data domain
|
|
113
|
-
*/
|
|
114
|
-
interface TypedDataDomain {
|
|
115
|
-
name: string;
|
|
116
|
-
version: string;
|
|
117
|
-
chainId: number;
|
|
118
|
-
verifyingContract: Address;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* EIP-712 typed data types
|
|
122
|
-
*/
|
|
123
|
-
type TypedDataTypes = Record<string, Array<{
|
|
124
|
-
name: string;
|
|
125
|
-
type: string;
|
|
126
|
-
}>>;
|
|
127
|
-
/**
|
|
128
|
-
* T402 Signer interface for WDK
|
|
129
|
-
* Compatible with @t402/core signer requirements
|
|
130
|
-
*/
|
|
131
|
-
interface T402WDKSigner {
|
|
132
|
-
/** Get wallet address */
|
|
133
|
-
readonly address: Address;
|
|
134
|
-
/** Sign EIP-712 typed data */
|
|
135
|
-
signTypedData(params: {
|
|
136
|
-
domain: TypedDataDomain;
|
|
137
|
-
types: TypedDataTypes;
|
|
138
|
-
primaryType: string;
|
|
139
|
-
message: Record<string, unknown>;
|
|
140
|
-
}): Promise<`0x${string}`>;
|
|
141
|
-
/** Sign a message */
|
|
142
|
-
signMessage?(message: string | Uint8Array): Promise<`0x${string}`>;
|
|
143
|
-
/** Get token balance */
|
|
144
|
-
getTokenBalance?(tokenAddress: Address): Promise<bigint>;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* WDK Account interface (matches @tetherto/wdk account structure)
|
|
148
|
-
*/
|
|
149
|
-
interface WDKAccount {
|
|
150
|
-
getAddress(): Promise<string>;
|
|
151
|
-
getBalance(): Promise<bigint>;
|
|
152
|
-
getTokenBalance(tokenAddress: string): Promise<bigint>;
|
|
153
|
-
signMessage(message: string): Promise<string>;
|
|
154
|
-
signTypedData(params: {
|
|
155
|
-
domain: Record<string, unknown>;
|
|
156
|
-
types: Record<string, unknown>;
|
|
157
|
-
primaryType: string;
|
|
158
|
-
message: Record<string, unknown>;
|
|
159
|
-
}): Promise<string>;
|
|
160
|
-
sendTransaction(params: {
|
|
161
|
-
to: string;
|
|
162
|
-
value?: bigint | string;
|
|
163
|
-
data?: string;
|
|
164
|
-
}): Promise<string>;
|
|
165
|
-
estimateGas(params: {
|
|
166
|
-
to: string;
|
|
167
|
-
value?: bigint | string;
|
|
168
|
-
data?: string;
|
|
169
|
-
}): Promise<bigint>;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* WDK instance interface (matches @tetherto/wdk structure)
|
|
173
|
-
*/
|
|
174
|
-
interface WDKInstance {
|
|
175
|
-
registerWallet<T>(name: string, manager: T, config: Record<string, unknown>): WDKInstance;
|
|
176
|
-
registerProtocol<T>(name: string, protocol: T): WDKInstance;
|
|
177
|
-
getAccount(chain: string, index: number): Promise<WDKAccount>;
|
|
178
|
-
executeProtocol(name: string, params: Record<string, unknown>): Promise<{
|
|
179
|
-
txHash: string;
|
|
180
|
-
}>;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* WDK constructor type
|
|
184
|
-
*/
|
|
185
|
-
interface WDKConstructor {
|
|
186
|
-
new (seedPhrase: string): WDKInstance;
|
|
187
|
-
getRandomSeedPhrase(): string;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Balance cache configuration for T402WDK
|
|
191
|
-
*/
|
|
192
|
-
interface T402BalanceCacheConfig {
|
|
193
|
-
/** Whether caching is enabled (default: true) */
|
|
194
|
-
enabled?: boolean;
|
|
195
|
-
/** TTL for native balance in milliseconds (default: 15000 = 15 seconds) */
|
|
196
|
-
nativeBalanceTTL?: number;
|
|
197
|
-
/** TTL for token balance in milliseconds (default: 30000 = 30 seconds) */
|
|
198
|
-
tokenBalanceTTL?: number;
|
|
199
|
-
/** TTL for aggregated balances in milliseconds (default: 60000 = 60 seconds) */
|
|
200
|
-
aggregatedBalanceTTL?: number;
|
|
201
|
-
/** Maximum cache entries (default: 500) */
|
|
202
|
-
maxSize?: number;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Extended T402 WDK configuration with cache options
|
|
206
|
-
*/
|
|
207
|
-
interface T402WDKOptions {
|
|
208
|
-
/** Balance cache configuration */
|
|
209
|
-
cache?: T402BalanceCacheConfig;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
13
|
/**
|
|
213
14
|
* TTL Cache implementation for balance caching
|
|
214
15
|
*
|
|
@@ -713,24 +514,43 @@ declare class T402WDK {
|
|
|
713
514
|
private static _WDK;
|
|
714
515
|
private static _WalletManagerEvm;
|
|
715
516
|
private static _BridgeUsdt0Evm;
|
|
517
|
+
private static _WalletModules;
|
|
518
|
+
private static _ProtocolModules;
|
|
519
|
+
private _tonSignerCache;
|
|
520
|
+
private _svmSignerCache;
|
|
521
|
+
private _tronSignerCache;
|
|
716
522
|
/**
|
|
717
523
|
* Register the Tether WDK modules
|
|
718
524
|
*
|
|
719
525
|
* This must be called before creating T402WDK instances if you want
|
|
720
526
|
* to use the actual WDK. Otherwise, a mock implementation is used.
|
|
721
527
|
*
|
|
722
|
-
*
|
|
528
|
+
* Supports two registration patterns:
|
|
723
529
|
*
|
|
724
|
-
*
|
|
725
|
-
*
|
|
726
|
-
*
|
|
727
|
-
*
|
|
728
|
-
* import BridgeUsdt0Evm from '@tetherto/wdk-protocol-bridge-usdt0-evm';
|
|
530
|
+
* 1. Legacy (EVM-only):
|
|
531
|
+
* ```typescript
|
|
532
|
+
* T402WDK.registerWDK(WDK, WalletManagerEvm, BridgeUsdt0Evm);
|
|
533
|
+
* ```
|
|
729
534
|
*
|
|
730
|
-
*
|
|
731
|
-
*
|
|
535
|
+
* 2. Unified (multi-chain):
|
|
536
|
+
* ```typescript
|
|
537
|
+
* T402WDK.registerWDK(WDK, {
|
|
538
|
+
* wallets: {
|
|
539
|
+
* evm: WalletManagerEvm,
|
|
540
|
+
* ton: WalletManagerTon,
|
|
541
|
+
* solana: WalletManagerSolana,
|
|
542
|
+
* tron: WalletManagerTron,
|
|
543
|
+
* },
|
|
544
|
+
* protocols: {
|
|
545
|
+
* bridgeUsdt0Evm: BridgeUsdt0Evm,
|
|
546
|
+
* bridgeUsdt0Ton: BridgeUsdt0Ton,
|
|
547
|
+
* }
|
|
548
|
+
* });
|
|
549
|
+
* ```
|
|
550
|
+
*
|
|
551
|
+
* @throws {WDKInitializationError} If registration fails
|
|
732
552
|
*/
|
|
733
|
-
static registerWDK(WDK: WDKConstructor,
|
|
553
|
+
static registerWDK(WDK: WDKConstructor, modulesOrWalletManager?: WDKModulesConfig | unknown, BridgeUsdt0Evm?: unknown): void;
|
|
734
554
|
/**
|
|
735
555
|
* Check if WDK is registered
|
|
736
556
|
*/
|
|
@@ -743,6 +563,26 @@ declare class T402WDK {
|
|
|
743
563
|
* Check if bridge protocol is registered
|
|
744
564
|
*/
|
|
745
565
|
static isBridgeRegistered(): boolean;
|
|
566
|
+
/**
|
|
567
|
+
* Check if TON wallet manager is registered
|
|
568
|
+
*/
|
|
569
|
+
static isTonRegistered(): boolean;
|
|
570
|
+
/**
|
|
571
|
+
* Check if Solana wallet manager is registered
|
|
572
|
+
*/
|
|
573
|
+
static isSolanaRegistered(): boolean;
|
|
574
|
+
/**
|
|
575
|
+
* Check if TRON wallet manager is registered
|
|
576
|
+
*/
|
|
577
|
+
static isTronRegistered(): boolean;
|
|
578
|
+
/**
|
|
579
|
+
* Get all registered wallet modules
|
|
580
|
+
*/
|
|
581
|
+
static getRegisteredWalletModules(): (keyof WDKWalletModules)[];
|
|
582
|
+
/**
|
|
583
|
+
* Get all registered protocol modules
|
|
584
|
+
*/
|
|
585
|
+
static getRegisteredProtocolModules(): (keyof WDKProtocolModules)[];
|
|
746
586
|
/**
|
|
747
587
|
* Generate a new random seed phrase
|
|
748
588
|
*
|
|
@@ -750,6 +590,56 @@ declare class T402WDK {
|
|
|
750
590
|
* @returns A new BIP-39 mnemonic seed phrase
|
|
751
591
|
*/
|
|
752
592
|
static generateSeedPhrase(): string;
|
|
593
|
+
/**
|
|
594
|
+
* Quick setup: seed phrase + chains + modules → ready-to-use T402WDK.
|
|
595
|
+
*
|
|
596
|
+
* Registers all provided wallet/protocol modules and creates a fully
|
|
597
|
+
* configured instance in a single call.
|
|
598
|
+
*
|
|
599
|
+
* @example
|
|
600
|
+
* ```typescript
|
|
601
|
+
* import WDK from '@tetherto/wdk';
|
|
602
|
+
* import WalletManagerEvm from '@tetherto/wdk-wallet-evm';
|
|
603
|
+
* import BridgeUsdt0Evm from '@tetherto/wdk-protocol-bridge-usdt0-evm';
|
|
604
|
+
*
|
|
605
|
+
* const wallet = T402WDK.create({
|
|
606
|
+
* seedPhrase: 'your twelve word seed phrase ...',
|
|
607
|
+
* chains: {
|
|
608
|
+
* arbitrum: 'https://arb1.arbitrum.io/rpc',
|
|
609
|
+
* base: 'https://mainnet.base.org',
|
|
610
|
+
* },
|
|
611
|
+
* modules: {
|
|
612
|
+
* wallets: { evm: WalletManagerEvm },
|
|
613
|
+
* protocols: { bridgeUsdt0Evm: BridgeUsdt0Evm },
|
|
614
|
+
* },
|
|
615
|
+
* });
|
|
616
|
+
* ```
|
|
617
|
+
*/
|
|
618
|
+
static create(WDK: WDKConstructor, config: T402WDKCreateConfig): T402WDK;
|
|
619
|
+
/**
|
|
620
|
+
* Create a T402WDK from a pre-configured @tetherto/wdk instance.
|
|
621
|
+
*
|
|
622
|
+
* Wraps an existing WDK instance (already has wallets/protocols registered)
|
|
623
|
+
* into a T402WDK without re-registering modules.
|
|
624
|
+
*
|
|
625
|
+
* @param wdkInstance - A pre-configured WDK instance
|
|
626
|
+
* @param config - EVM chain configuration (RPC endpoints)
|
|
627
|
+
* @param options - Additional options
|
|
628
|
+
*/
|
|
629
|
+
static fromWDK(wdkInstance: WDKInstance, config?: T402WDKConfig, options?: FromWDKOptions & T402WDKOptions): T402WDK;
|
|
630
|
+
/**
|
|
631
|
+
* Get all signers as an array ready for T402 HTTP clients.
|
|
632
|
+
*
|
|
633
|
+
* Returns signer entries for all configured EVM chains, plus any
|
|
634
|
+
* registered non-EVM chains (TON, Solana, TRON).
|
|
635
|
+
*
|
|
636
|
+
* @example
|
|
637
|
+
* ```typescript
|
|
638
|
+
* const signers = await wallet.getAllSigners();
|
|
639
|
+
* const client = createT402HTTPClient({ signers });
|
|
640
|
+
* ```
|
|
641
|
+
*/
|
|
642
|
+
getAllSigners(options?: GetAllSignersOptions): Promise<SignerEntry[]>;
|
|
753
643
|
/**
|
|
754
644
|
* Create a new T402WDK instance
|
|
755
645
|
*
|
|
@@ -808,6 +698,80 @@ declare class T402WDK {
|
|
|
808
698
|
* Useful for forcing re-initialization of signers
|
|
809
699
|
*/
|
|
810
700
|
clearSignerCache(): void;
|
|
701
|
+
/**
|
|
702
|
+
* Get a TON signer for T402 payments
|
|
703
|
+
*
|
|
704
|
+
* @param accountIndex - HD wallet account index (default: 0)
|
|
705
|
+
* @throws {ChainError} If TON wallet manager is not registered
|
|
706
|
+
* @returns An initialized ClientTonSigner
|
|
707
|
+
*
|
|
708
|
+
* @example
|
|
709
|
+
* ```typescript
|
|
710
|
+
* const tonSigner = await wallet.getTonSigner();
|
|
711
|
+
*
|
|
712
|
+
* const client = createT402HTTPClient({
|
|
713
|
+
* signers: [{ scheme: 'exact', network: 'ton:mainnet', signer: tonSigner }]
|
|
714
|
+
* });
|
|
715
|
+
* ```
|
|
716
|
+
*/
|
|
717
|
+
getTonSigner(accountIndex?: number): Promise<ClientTonSigner>;
|
|
718
|
+
/**
|
|
719
|
+
* Get a Solana (SVM) signer for T402 payments
|
|
720
|
+
*
|
|
721
|
+
* @param accountIndex - HD wallet account index (default: 0)
|
|
722
|
+
* @throws {ChainError} If Solana wallet manager is not registered
|
|
723
|
+
* @returns An initialized TransactionSigner (ClientSvmSigner)
|
|
724
|
+
*
|
|
725
|
+
* @example
|
|
726
|
+
* ```typescript
|
|
727
|
+
* const svmSigner = await wallet.getSvmSigner();
|
|
728
|
+
*
|
|
729
|
+
* const client = createT402HTTPClient({
|
|
730
|
+
* signers: [{ scheme: 'exact', network: 'solana:mainnet', signer: svmSigner }]
|
|
731
|
+
* });
|
|
732
|
+
* ```
|
|
733
|
+
*/
|
|
734
|
+
getSvmSigner(accountIndex?: number): Promise<TransactionSigner>;
|
|
735
|
+
/**
|
|
736
|
+
* Get a TRON signer for T402 payments
|
|
737
|
+
*
|
|
738
|
+
* @param accountIndex - HD wallet account index (default: 0)
|
|
739
|
+
* @param rpcUrl - Optional custom RPC URL (default: https://api.trongrid.io)
|
|
740
|
+
* @throws {ChainError} If TRON wallet manager is not registered
|
|
741
|
+
* @returns An initialized ClientTronSigner
|
|
742
|
+
*
|
|
743
|
+
* @example
|
|
744
|
+
* ```typescript
|
|
745
|
+
* const tronSigner = await wallet.getTronSigner();
|
|
746
|
+
*
|
|
747
|
+
* const client = createT402HTTPClient({
|
|
748
|
+
* signers: [{ scheme: 'exact', network: 'tron:mainnet', signer: tronSigner }]
|
|
749
|
+
* });
|
|
750
|
+
* ```
|
|
751
|
+
*/
|
|
752
|
+
getTronSigner(accountIndex?: number, rpcUrl?: string): Promise<ClientTronSigner>;
|
|
753
|
+
/**
|
|
754
|
+
* Get a signer for a specific chain family
|
|
755
|
+
*
|
|
756
|
+
* @param family - Chain family (evm, svm, ton, tron)
|
|
757
|
+
* @param chainOrIndex - Chain name for EVM, or account index for others
|
|
758
|
+
* @param accountIndex - Account index (only used for EVM)
|
|
759
|
+
* @throws {ChainError} If chain family is not supported or not configured
|
|
760
|
+
* @returns An appropriate signer for the chain family
|
|
761
|
+
*
|
|
762
|
+
* @example
|
|
763
|
+
* ```typescript
|
|
764
|
+
* // Get EVM signer for Arbitrum
|
|
765
|
+
* const evmSigner = await wallet.getSignerByFamily('evm', 'arbitrum');
|
|
766
|
+
*
|
|
767
|
+
* // Get TON signer
|
|
768
|
+
* const tonSigner = await wallet.getSignerByFamily('ton');
|
|
769
|
+
*
|
|
770
|
+
* // Get Solana signer with account index 1
|
|
771
|
+
* const svmSigner = await wallet.getSignerByFamily('svm', 1);
|
|
772
|
+
* ```
|
|
773
|
+
*/
|
|
774
|
+
getSignerByFamily(family: ChainFamily, chainOrIndex?: string | number, accountIndex?: number): Promise<WDKSigner | ClientTonSigner | TransactionSigner | ClientTronSigner>;
|
|
811
775
|
/**
|
|
812
776
|
* Get wallet address for a chain
|
|
813
777
|
*
|
|
@@ -893,6 +857,39 @@ declare class T402WDK {
|
|
|
893
857
|
* Get all possible bridge destinations from a chain
|
|
894
858
|
*/
|
|
895
859
|
getBridgeDestinations(fromChain: string): string[];
|
|
860
|
+
/**
|
|
861
|
+
* Check if the Velora swap protocol is registered and available
|
|
862
|
+
*/
|
|
863
|
+
canSwap(): boolean;
|
|
864
|
+
/**
|
|
865
|
+
* Get a swap quote for converting a token to USDT0
|
|
866
|
+
*
|
|
867
|
+
* @param chain - Chain name (e.g., "ethereum", "arbitrum")
|
|
868
|
+
* @param fromToken - Input token address
|
|
869
|
+
* @param amount - Amount to swap in smallest units
|
|
870
|
+
* @throws {WDKError} If swap protocol is not registered or quote fails
|
|
871
|
+
*/
|
|
872
|
+
getSwapQuote(chain: string, fromToken: string, amount: bigint): Promise<SwapQuote>;
|
|
873
|
+
/**
|
|
874
|
+
* Swap any token to USDT0 for payment
|
|
875
|
+
*
|
|
876
|
+
* Uses the Velora protocol to execute a token swap on the specified chain.
|
|
877
|
+
*
|
|
878
|
+
* @param params - Swap parameters
|
|
879
|
+
* @throws {WDKError} If swap protocol is not registered or swap fails
|
|
880
|
+
*
|
|
881
|
+
* @example
|
|
882
|
+
* ```typescript
|
|
883
|
+
* // Swap 0.1 WETH to USDT0 on Arbitrum
|
|
884
|
+
* const result = await wallet.swapAndPay({
|
|
885
|
+
* chain: 'arbitrum',
|
|
886
|
+
* fromToken: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1', // WETH
|
|
887
|
+
* amount: 100000000000000000n, // 0.1 WETH
|
|
888
|
+
* maxSlippage: 0.005,
|
|
889
|
+
* });
|
|
890
|
+
* ```
|
|
891
|
+
*/
|
|
892
|
+
swapAndPay(params: SwapParams): Promise<SwapResult>;
|
|
896
893
|
/**
|
|
897
894
|
* Check if balance caching is enabled
|
|
898
895
|
*/
|
|
@@ -1037,6 +1034,9 @@ declare enum WDKErrorCode {
|
|
|
1037
1034
|
RPC_TIMEOUT = 8002,
|
|
1038
1035
|
RPC_RATE_LIMITED = 8003,
|
|
1039
1036
|
RPC_CONNECTION_FAILED = 8004,
|
|
1037
|
+
PROTOCOL_NOT_REGISTERED = 8101,
|
|
1038
|
+
PROTOCOL_EXECUTION_FAILED = 8102,
|
|
1039
|
+
INVALID_PARAMETER = 8103,
|
|
1040
1040
|
UNKNOWN_ERROR = 9999
|
|
1041
1041
|
}
|
|
1042
1042
|
/**
|
|
@@ -1279,6 +1279,81 @@ declare class WdkBridge {
|
|
|
1279
1279
|
*/
|
|
1280
1280
|
declare function createDirectBridge(signer: BridgeSigner, chain: string): Usdt0Bridge;
|
|
1281
1281
|
|
|
1282
|
+
/**
|
|
1283
|
+
* Tether WDK Version Compatibility Tracking
|
|
1284
|
+
*
|
|
1285
|
+
* Tracks compatibility between @t402/wdk and @tetherto/wdk versions.
|
|
1286
|
+
*/
|
|
1287
|
+
/**
|
|
1288
|
+
* WDK compatibility information
|
|
1289
|
+
*/
|
|
1290
|
+
declare const WDK_COMPATIBILITY: {
|
|
1291
|
+
/** Minimum supported @tetherto/wdk version */
|
|
1292
|
+
readonly minVersion: "1.0.0-beta.0";
|
|
1293
|
+
/** Versions that have been tested */
|
|
1294
|
+
readonly testedVersions: readonly ["1.0.0-beta.3", "1.0.0-beta.4", "1.0.0-beta.5"];
|
|
1295
|
+
/** Tested wallet-evm module versions */
|
|
1296
|
+
readonly walletEvmVersions: readonly ["1.0.0-beta.5", "2.0.0-rc.1"];
|
|
1297
|
+
/** Feature availability by @tetherto/wdk core version */
|
|
1298
|
+
readonly features: {
|
|
1299
|
+
readonly signTypedData: "1.0.0-beta.0";
|
|
1300
|
+
readonly estimateGas: "1.0.0-beta.3";
|
|
1301
|
+
readonly multiChainWallets: "1.0.0-beta.0";
|
|
1302
|
+
readonly bridgeProtocol: "1.0.0-beta.3";
|
|
1303
|
+
readonly swapProtocol: "1.0.0-beta.4";
|
|
1304
|
+
};
|
|
1305
|
+
/** Known wallet module minimum versions */
|
|
1306
|
+
readonly walletModuleVersions: {
|
|
1307
|
+
readonly evm: "1.0.0-beta.5";
|
|
1308
|
+
readonly ton: "1.0.0-beta.7";
|
|
1309
|
+
readonly btc: "1.0.0-beta.5";
|
|
1310
|
+
readonly tron: "1.0.0-beta.4";
|
|
1311
|
+
readonly solana: "1.0.0-beta.5";
|
|
1312
|
+
readonly spark: "1.0.0-beta.6";
|
|
1313
|
+
};
|
|
1314
|
+
};
|
|
1315
|
+
/**
|
|
1316
|
+
* Result of a WDK compatibility check
|
|
1317
|
+
*/
|
|
1318
|
+
interface CompatibilityResult {
|
|
1319
|
+
/** Whether the version is compatible */
|
|
1320
|
+
compatible: boolean;
|
|
1321
|
+
/** Warning messages for potential issues */
|
|
1322
|
+
warnings: string[];
|
|
1323
|
+
}
|
|
1324
|
+
/**
|
|
1325
|
+
* Check if a @tetherto/wdk version is compatible with @t402/wdk.
|
|
1326
|
+
*
|
|
1327
|
+
* @param version - The @tetherto/wdk version to check
|
|
1328
|
+
* @returns Compatibility result with warnings
|
|
1329
|
+
*
|
|
1330
|
+
* @example
|
|
1331
|
+
* ```typescript
|
|
1332
|
+
* import { checkWdkCompatibility } from '@t402/wdk';
|
|
1333
|
+
*
|
|
1334
|
+
* const result = checkWdkCompatibility('1.0.0-beta.4');
|
|
1335
|
+
* if (!result.compatible) {
|
|
1336
|
+
* console.error('Incompatible WDK version');
|
|
1337
|
+
* }
|
|
1338
|
+
* result.warnings.forEach(w => console.warn(w));
|
|
1339
|
+
* ```
|
|
1340
|
+
*/
|
|
1341
|
+
declare function checkWdkCompatibility(version: string): CompatibilityResult;
|
|
1342
|
+
/**
|
|
1343
|
+
* Check if a @tetherto/wdk-wallet-evm version is compatible.
|
|
1344
|
+
*
|
|
1345
|
+
* @param version - The wallet-evm module version to check
|
|
1346
|
+
* @returns Compatibility result with warnings
|
|
1347
|
+
*/
|
|
1348
|
+
declare function checkWalletEvmCompatibility(version: string): CompatibilityResult;
|
|
1349
|
+
/**
|
|
1350
|
+
* Get the minimum required version for a specific wallet module.
|
|
1351
|
+
*
|
|
1352
|
+
* @param module - Wallet module name (e.g., "evm", "ton", "solana")
|
|
1353
|
+
* @returns The minimum version string, or undefined if unknown
|
|
1354
|
+
*/
|
|
1355
|
+
declare function getWalletModuleMinVersion(module: keyof typeof WDK_COMPATIBILITY.walletModuleVersions): string | undefined;
|
|
1356
|
+
|
|
1282
1357
|
/**
|
|
1283
1358
|
* Hardware wallet type definitions for T402 WDK
|
|
1284
1359
|
*/
|
|
@@ -1655,4 +1730,4 @@ declare function detectHardwareWalletSupport(): {
|
|
|
1655
1730
|
*/
|
|
1656
1731
|
declare function isHardwareWalletSupported(): boolean;
|
|
1657
1732
|
|
|
1658
|
-
export {
|
|
1733
|
+
export { AggregatedBalance, BalanceCache, type BalanceCacheConfig, type BalanceCacheStats, BalanceError, BridgeError, BridgeParams, type BridgeQuoteResult, BridgeResult, CHAIN_TOKENS, type CacheConfig, type CacheStats, ChainBalance, ChainError, ChainFamily, TransactionSigner as ClientSvmSigner, ClientTonSigner, ClientTronSigner, type CompatibilityResult, DEFAULT_BALANCE_CACHE_CONFIG, DEFAULT_CACHE_CONFIG, DEFAULT_CHAINS, DEFAULT_RETRY_CONFIG, DEFAULT_RPC_ENDPOINTS, type DeviceStatus, EvmChainConfig, FromWDKOptions, GetAllSignersOptions, type HardwareWalletConnectionOptions, type HardwareWalletDeviceInfo, HardwareWalletError, HardwareWalletErrorCode, type HardwareWalletSigner, type HardwareWalletType, type LedgerOptions, LedgerSigner, MockWDKSigner, NormalizedChainConfig, RPCError, type RetryConfig, SignerEntry, SignerError, SigningError, SwapParams, SwapQuote, SwapResult, T402WDK, T402WDKConfig, T402WDKCreateConfig, T402WDKOptions, TTLCache, type TokenInfo, TransactionError, type TrezorOptions, TrezorSigner, USDC_ADDRESSES, USDT0_ADDRESSES, USDT_LEGACY_ADDRESSES, WDKConstructor, WDKError, WDKErrorCode, WDKInitializationError, WDKInstance, WDKModulesConfig, WDKProtocolModules, WDKSigner, WDKWalletModules, WDK_COMPATIBILITY, WdkBridge, checkWalletEvmCompatibility, checkWdkCompatibility, createDirectBridge, createLedgerSigner, createTrezorSigner, createWDKSigner, detectHardwareWalletSupport, getChainFromNetwork, getChainId, getNetworkFromChain, getPreferredToken, getUsdt0Chains, getWalletModuleMinVersion, hasErrorCode, isHardwareWalletSupported, isWDKError, normalizeChainConfig, withRetry, withTimeout, wrapError };
|