@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
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type definitions for T402 WDK integration
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* EVM chain configuration
|
|
9
|
+
*/
|
|
10
|
+
interface EvmChainConfig {
|
|
11
|
+
/** RPC endpoint URL */
|
|
12
|
+
provider: string;
|
|
13
|
+
/** Chain ID */
|
|
14
|
+
chainId: number;
|
|
15
|
+
/** CAIP-2 network identifier */
|
|
16
|
+
network: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* T402 WDK configuration options
|
|
20
|
+
*/
|
|
21
|
+
interface T402WDKConfig {
|
|
22
|
+
/** Ethereum mainnet configuration */
|
|
23
|
+
ethereum?: EvmChainConfig | string;
|
|
24
|
+
/** Arbitrum One configuration */
|
|
25
|
+
arbitrum?: EvmChainConfig | string;
|
|
26
|
+
/** Base mainnet configuration */
|
|
27
|
+
base?: EvmChainConfig | string;
|
|
28
|
+
/** Ink mainnet configuration */
|
|
29
|
+
ink?: EvmChainConfig | string;
|
|
30
|
+
/** Berachain mainnet configuration */
|
|
31
|
+
berachain?: EvmChainConfig | string;
|
|
32
|
+
/** Unichain mainnet configuration */
|
|
33
|
+
unichain?: EvmChainConfig | string;
|
|
34
|
+
/** Polygon mainnet configuration */
|
|
35
|
+
polygon?: EvmChainConfig | string;
|
|
36
|
+
/** Custom chains */
|
|
37
|
+
[key: string]: EvmChainConfig | string | undefined;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Normalized chain configuration
|
|
41
|
+
*/
|
|
42
|
+
interface NormalizedChainConfig {
|
|
43
|
+
provider: string;
|
|
44
|
+
chainId: number;
|
|
45
|
+
network: string;
|
|
46
|
+
name: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Token balance information
|
|
50
|
+
*/
|
|
51
|
+
interface TokenBalance {
|
|
52
|
+
/** Token contract address */
|
|
53
|
+
token: Address;
|
|
54
|
+
/** Token symbol */
|
|
55
|
+
symbol: string;
|
|
56
|
+
/** Balance in smallest units */
|
|
57
|
+
balance: bigint;
|
|
58
|
+
/** Formatted balance (human-readable) */
|
|
59
|
+
formatted: string;
|
|
60
|
+
/** Decimals */
|
|
61
|
+
decimals: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Chain balance information
|
|
65
|
+
*/
|
|
66
|
+
interface ChainBalance {
|
|
67
|
+
/** Chain name (e.g., "arbitrum") */
|
|
68
|
+
chain: string;
|
|
69
|
+
/** CAIP-2 network identifier */
|
|
70
|
+
network: string;
|
|
71
|
+
/** Native token balance */
|
|
72
|
+
native: bigint;
|
|
73
|
+
/** Token balances */
|
|
74
|
+
tokens: TokenBalance[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Aggregated balance across all chains
|
|
78
|
+
*/
|
|
79
|
+
interface AggregatedBalance {
|
|
80
|
+
/** Total USDT0 balance across all chains */
|
|
81
|
+
totalUsdt0: bigint;
|
|
82
|
+
/** Total USDC balance across all chains */
|
|
83
|
+
totalUsdc: bigint;
|
|
84
|
+
/** Per-chain balances */
|
|
85
|
+
chains: ChainBalance[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Bridge parameters for cross-chain transfers
|
|
89
|
+
*/
|
|
90
|
+
interface BridgeParams {
|
|
91
|
+
/** Source chain name */
|
|
92
|
+
fromChain: string;
|
|
93
|
+
/** Destination chain name */
|
|
94
|
+
toChain: string;
|
|
95
|
+
/** Amount to bridge in smallest units */
|
|
96
|
+
amount: bigint;
|
|
97
|
+
/** Recipient address (optional, defaults to same wallet on target chain) */
|
|
98
|
+
recipient?: Address;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Bridge result
|
|
102
|
+
*/
|
|
103
|
+
interface BridgeResult {
|
|
104
|
+
/** Transaction hash on source chain */
|
|
105
|
+
txHash: string;
|
|
106
|
+
/** Estimated time for bridge completion in seconds */
|
|
107
|
+
estimatedTime: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* EIP-712 typed data domain
|
|
111
|
+
*/
|
|
112
|
+
interface TypedDataDomain {
|
|
113
|
+
name: string;
|
|
114
|
+
version: string;
|
|
115
|
+
chainId: number;
|
|
116
|
+
verifyingContract: Address;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* EIP-712 typed data types
|
|
120
|
+
*/
|
|
121
|
+
type TypedDataTypes = Record<string, Array<{
|
|
122
|
+
name: string;
|
|
123
|
+
type: string;
|
|
124
|
+
}>>;
|
|
125
|
+
/**
|
|
126
|
+
* T402 Signer interface for WDK
|
|
127
|
+
* Compatible with @t402/core signer requirements
|
|
128
|
+
*/
|
|
129
|
+
interface T402WDKSigner {
|
|
130
|
+
/** Get wallet address */
|
|
131
|
+
readonly address: Address;
|
|
132
|
+
/** Sign EIP-712 typed data */
|
|
133
|
+
signTypedData(params: {
|
|
134
|
+
domain: TypedDataDomain;
|
|
135
|
+
types: TypedDataTypes;
|
|
136
|
+
primaryType: string;
|
|
137
|
+
message: Record<string, unknown>;
|
|
138
|
+
}): Promise<`0x${string}`>;
|
|
139
|
+
/** Sign a message */
|
|
140
|
+
signMessage?(message: string | Uint8Array): Promise<`0x${string}`>;
|
|
141
|
+
/** Get token balance */
|
|
142
|
+
getTokenBalance?(tokenAddress: Address): Promise<bigint>;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* WDK Account interface (matches @tetherto/wdk account structure)
|
|
146
|
+
*
|
|
147
|
+
* This is the canonical definition used across all @t402/wdk-* packages.
|
|
148
|
+
* Implementors (Tether WDK) provide these methods; T402 code consumes them.
|
|
149
|
+
*/
|
|
150
|
+
interface WDKAccount {
|
|
151
|
+
/** Get the account's address */
|
|
152
|
+
getAddress(): Promise<string>;
|
|
153
|
+
/** Get the account's native balance */
|
|
154
|
+
getBalance(): Promise<bigint>;
|
|
155
|
+
/** Get the account's token balance */
|
|
156
|
+
getTokenBalance(tokenAddress: string): Promise<bigint>;
|
|
157
|
+
/** Sign a message */
|
|
158
|
+
signMessage(message: string): Promise<string>;
|
|
159
|
+
/** Sign typed data (EIP-712) */
|
|
160
|
+
signTypedData(params: {
|
|
161
|
+
domain: Record<string, unknown>;
|
|
162
|
+
types: Record<string, unknown>;
|
|
163
|
+
primaryType: string;
|
|
164
|
+
message: Record<string, unknown>;
|
|
165
|
+
}): Promise<string>;
|
|
166
|
+
/** Send a transaction */
|
|
167
|
+
sendTransaction(params: {
|
|
168
|
+
to: string;
|
|
169
|
+
value?: bigint;
|
|
170
|
+
data?: string;
|
|
171
|
+
}): Promise<string>;
|
|
172
|
+
/** Estimate gas for a transaction (optional — not all implementations support this) */
|
|
173
|
+
estimateGas?(params: {
|
|
174
|
+
to: string;
|
|
175
|
+
value?: bigint;
|
|
176
|
+
data?: string;
|
|
177
|
+
}): Promise<bigint>;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Alias for WDKAccount — preferred naming for use in @t402/wdk-* packages.
|
|
181
|
+
*/
|
|
182
|
+
type WdkAccount = WDKAccount;
|
|
183
|
+
/**
|
|
184
|
+
* WDK instance interface (matches @tetherto/wdk structure)
|
|
185
|
+
*/
|
|
186
|
+
interface WDKInstance {
|
|
187
|
+
registerWallet<T>(name: string, manager: T, config: Record<string, unknown>): WDKInstance;
|
|
188
|
+
registerProtocol<T>(name: string, protocol: T): WDKInstance;
|
|
189
|
+
getAccount(chain: string, index: number): Promise<WDKAccount>;
|
|
190
|
+
executeProtocol(name: string, params: Record<string, unknown>): Promise<{
|
|
191
|
+
txHash: string;
|
|
192
|
+
}>;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* WDK constructor type
|
|
196
|
+
*/
|
|
197
|
+
interface WDKConstructor {
|
|
198
|
+
new (seedPhrase: string): WDKInstance;
|
|
199
|
+
getRandomSeedPhrase(): string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Balance cache configuration for T402WDK
|
|
203
|
+
*/
|
|
204
|
+
interface T402BalanceCacheConfig {
|
|
205
|
+
/** Whether caching is enabled (default: true) */
|
|
206
|
+
enabled?: boolean;
|
|
207
|
+
/** TTL for native balance in milliseconds (default: 15000 = 15 seconds) */
|
|
208
|
+
nativeBalanceTTL?: number;
|
|
209
|
+
/** TTL for token balance in milliseconds (default: 30000 = 30 seconds) */
|
|
210
|
+
tokenBalanceTTL?: number;
|
|
211
|
+
/** TTL for aggregated balances in milliseconds (default: 60000 = 60 seconds) */
|
|
212
|
+
aggregatedBalanceTTL?: number;
|
|
213
|
+
/** Maximum cache entries (default: 500) */
|
|
214
|
+
maxSize?: number;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Extended T402 WDK configuration with cache options
|
|
218
|
+
*/
|
|
219
|
+
interface T402WDKOptions {
|
|
220
|
+
/** Balance cache configuration */
|
|
221
|
+
cache?: T402BalanceCacheConfig;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Supported blockchain families
|
|
225
|
+
*/
|
|
226
|
+
type ChainFamily = 'evm' | 'svm' | 'ton' | 'tron';
|
|
227
|
+
/**
|
|
228
|
+
* Solana chain configuration
|
|
229
|
+
*/
|
|
230
|
+
interface SvmChainConfig {
|
|
231
|
+
/** RPC endpoint URL */
|
|
232
|
+
rpcUrl: string;
|
|
233
|
+
/** Commitment level */
|
|
234
|
+
commitment?: 'processed' | 'confirmed' | 'finalized';
|
|
235
|
+
/** Network type */
|
|
236
|
+
network?: 'mainnet' | 'testnet' | 'devnet';
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* TON chain configuration
|
|
240
|
+
*/
|
|
241
|
+
interface TonChainConfig {
|
|
242
|
+
/** API endpoint URL */
|
|
243
|
+
endpoint: string;
|
|
244
|
+
/** Network type */
|
|
245
|
+
network?: 'mainnet' | 'testnet';
|
|
246
|
+
/** API key for TON Center */
|
|
247
|
+
apiKey?: string;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* TRON chain configuration
|
|
251
|
+
*/
|
|
252
|
+
interface TronChainConfig {
|
|
253
|
+
/** Full host URL (e.g., https://api.trongrid.io) */
|
|
254
|
+
fullHost: string;
|
|
255
|
+
/** Network type */
|
|
256
|
+
network?: 'mainnet' | 'shasta' | 'nile';
|
|
257
|
+
/** API key for TronGrid */
|
|
258
|
+
apiKey?: string;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Multi-chain configuration
|
|
262
|
+
*/
|
|
263
|
+
interface MultiChainConfig {
|
|
264
|
+
/** EVM chains configuration */
|
|
265
|
+
evm?: Record<string, EvmChainConfig | string>;
|
|
266
|
+
/** Solana configuration */
|
|
267
|
+
svm?: SvmChainConfig;
|
|
268
|
+
/** TON configuration */
|
|
269
|
+
ton?: TonChainConfig;
|
|
270
|
+
/** TRON configuration */
|
|
271
|
+
tron?: TronChainConfig;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* WDK wallet modules registry
|
|
275
|
+
* All modules are optional - only register what you need
|
|
276
|
+
*/
|
|
277
|
+
interface WDKWalletModules {
|
|
278
|
+
/** EVM wallet manager (@tetherto/wdk-wallet-evm) */
|
|
279
|
+
evm?: unknown;
|
|
280
|
+
/** EVM ERC-4337 wallet manager (@tetherto/wdk-wallet-evm-erc4337) */
|
|
281
|
+
evmErc4337?: unknown;
|
|
282
|
+
/** Solana wallet manager (@tetherto/wdk-wallet-solana) */
|
|
283
|
+
solana?: unknown;
|
|
284
|
+
/** TON wallet manager (@tetherto/wdk-wallet-ton) */
|
|
285
|
+
ton?: unknown;
|
|
286
|
+
/** TON gasless wallet manager (@tetherto/wdk-wallet-ton-gasless) */
|
|
287
|
+
tonGasless?: unknown;
|
|
288
|
+
/** TRON wallet manager (@tetherto/wdk-wallet-tron) */
|
|
289
|
+
tron?: unknown;
|
|
290
|
+
/** Bitcoin wallet manager (@tetherto/wdk-wallet-btc) */
|
|
291
|
+
btc?: unknown;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* WDK protocol modules registry
|
|
295
|
+
* All modules are optional - only register what you need
|
|
296
|
+
*/
|
|
297
|
+
interface WDKProtocolModules {
|
|
298
|
+
/** USDT0 bridge for EVM (@tetherto/wdk-protocol-bridge-usdt0-evm) */
|
|
299
|
+
bridgeUsdt0Evm?: unknown;
|
|
300
|
+
/** USDT0 bridge for TON (@tetherto/wdk-protocol-bridge-usdt0-ton) */
|
|
301
|
+
bridgeUsdt0Ton?: unknown;
|
|
302
|
+
/** Velora swap for EVM (@tetherto/wdk-protocol-swap-velora-evm) */
|
|
303
|
+
swapVeloraEvm?: unknown;
|
|
304
|
+
/** Aave lending for EVM (@tetherto/wdk-protocol-lending-aave-evm) */
|
|
305
|
+
lendingAaveEvm?: unknown;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Unified WDK modules registration
|
|
309
|
+
*/
|
|
310
|
+
interface WDKModulesConfig {
|
|
311
|
+
/** Wallet modules */
|
|
312
|
+
wallets?: WDKWalletModules;
|
|
313
|
+
/** Protocol modules */
|
|
314
|
+
protocols?: WDKProtocolModules;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* WDK TON account interface (compatible with @tetherto/wdk-wallet-ton)
|
|
318
|
+
*/
|
|
319
|
+
interface WDKTonAccount {
|
|
320
|
+
/** Get wallet address */
|
|
321
|
+
getAddress(): Promise<string>;
|
|
322
|
+
/** Get TON balance */
|
|
323
|
+
getBalance(): Promise<bigint>;
|
|
324
|
+
/** Get Jetton balance */
|
|
325
|
+
getJettonBalance(jettonMaster: string): Promise<bigint>;
|
|
326
|
+
/** Sign a message */
|
|
327
|
+
signMessage(message: Uint8Array): Promise<Uint8Array>;
|
|
328
|
+
/** Send TON transaction */
|
|
329
|
+
sendTransaction(params: {
|
|
330
|
+
to: string;
|
|
331
|
+
value: bigint;
|
|
332
|
+
body?: string;
|
|
333
|
+
bounce?: boolean;
|
|
334
|
+
}): Promise<string>;
|
|
335
|
+
/** Get current sequence number */
|
|
336
|
+
getSeqno(): Promise<number>;
|
|
337
|
+
/** Transfer Jettons */
|
|
338
|
+
transferJetton?(params: {
|
|
339
|
+
jettonMaster: string;
|
|
340
|
+
to: string;
|
|
341
|
+
amount: bigint;
|
|
342
|
+
forwardPayload?: string;
|
|
343
|
+
}): Promise<string>;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* WDK Solana account interface (compatible with @tetherto/wdk-wallet-solana)
|
|
347
|
+
*/
|
|
348
|
+
interface WDKSolanaAccount {
|
|
349
|
+
/** Get wallet address (base58) */
|
|
350
|
+
getAddress(): Promise<string>;
|
|
351
|
+
/** Get SOL balance */
|
|
352
|
+
getBalance(): Promise<bigint>;
|
|
353
|
+
/** Get SPL token balance */
|
|
354
|
+
getTokenBalance(mint: string): Promise<bigint>;
|
|
355
|
+
/** Sign a message */
|
|
356
|
+
sign(message: Uint8Array): Promise<Uint8Array>;
|
|
357
|
+
/** Sign a transaction */
|
|
358
|
+
signTransaction(transaction: Uint8Array): Promise<Uint8Array>;
|
|
359
|
+
/** Send SOL */
|
|
360
|
+
sendTransaction(params: {
|
|
361
|
+
recipient: string;
|
|
362
|
+
value: bigint;
|
|
363
|
+
}): Promise<string>;
|
|
364
|
+
/** Transfer SPL token */
|
|
365
|
+
transfer(params: {
|
|
366
|
+
token: string;
|
|
367
|
+
recipient: string;
|
|
368
|
+
amount: bigint;
|
|
369
|
+
}): Promise<string>;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* WDK TRON account interface (compatible with @tetherto/wdk-wallet-tron)
|
|
373
|
+
*/
|
|
374
|
+
interface WDKTronAccount {
|
|
375
|
+
/** Get wallet address (base58) */
|
|
376
|
+
getAddress(): Promise<string>;
|
|
377
|
+
/** Get TRX balance */
|
|
378
|
+
getBalance(): Promise<bigint>;
|
|
379
|
+
/** Get TRC20 token balance */
|
|
380
|
+
getTrc20Balance(contractAddress: string): Promise<bigint>;
|
|
381
|
+
/** Sign a transaction */
|
|
382
|
+
signTransaction(transaction: unknown): Promise<unknown>;
|
|
383
|
+
/** Send signed transaction */
|
|
384
|
+
sendTransaction(signedTx: unknown): Promise<string>;
|
|
385
|
+
/** Transfer TRC20 token */
|
|
386
|
+
transferTrc20?(params: {
|
|
387
|
+
contractAddress: string;
|
|
388
|
+
to: string;
|
|
389
|
+
amount: bigint;
|
|
390
|
+
}): Promise<string>;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Extended WDK instance interface with multi-chain support
|
|
394
|
+
*/
|
|
395
|
+
interface WDKInstanceMultiChain extends WDKInstance {
|
|
396
|
+
/** Get TON account */
|
|
397
|
+
getTonAccount?(index: number): Promise<WDKTonAccount>;
|
|
398
|
+
/** Get Solana account */
|
|
399
|
+
getSolanaAccount?(index: number): Promise<WDKSolanaAccount>;
|
|
400
|
+
/** Get TRON account */
|
|
401
|
+
getTronAccount?(index: number): Promise<WDKTronAccount>;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Configuration for T402WDK.create() factory method
|
|
405
|
+
*/
|
|
406
|
+
interface T402WDKCreateConfig {
|
|
407
|
+
/** BIP-39 mnemonic seed phrase */
|
|
408
|
+
seedPhrase: string;
|
|
409
|
+
/** Chain name → RPC URL mapping for EVM chains */
|
|
410
|
+
chains: Record<string, string>;
|
|
411
|
+
/** WDK modules to register */
|
|
412
|
+
modules: WDKModulesConfig;
|
|
413
|
+
/** Additional options */
|
|
414
|
+
options?: T402WDKOptions;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* A signer entry for use with T402 HTTP clients
|
|
418
|
+
*/
|
|
419
|
+
interface SignerEntry {
|
|
420
|
+
/** Payment scheme (e.g., "exact") */
|
|
421
|
+
scheme: string;
|
|
422
|
+
/** CAIP-2 network identifier (e.g., "eip155:42161") */
|
|
423
|
+
network: string;
|
|
424
|
+
/** The signer instance */
|
|
425
|
+
signer: unknown;
|
|
426
|
+
/** Chain family (evm, ton, svm, tron) */
|
|
427
|
+
family: ChainFamily;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Options for getAllSigners()
|
|
431
|
+
*/
|
|
432
|
+
interface GetAllSignersOptions {
|
|
433
|
+
/** HD wallet account index (default: 0) */
|
|
434
|
+
accountIndex?: number;
|
|
435
|
+
/** Filter by payment schemes (default: ["exact"]) */
|
|
436
|
+
schemes?: string[];
|
|
437
|
+
/** Include non-EVM chain signers (default: true) */
|
|
438
|
+
includeNonEvm?: boolean;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Options for T402WDK.fromWDK()
|
|
442
|
+
*/
|
|
443
|
+
interface FromWDKOptions {
|
|
444
|
+
/** HD wallet account index for auto-discovery (default: 0) */
|
|
445
|
+
defaultAccountIndex?: number;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Swap quote result
|
|
449
|
+
*/
|
|
450
|
+
interface SwapQuote {
|
|
451
|
+
/** Input token address */
|
|
452
|
+
inputToken: string;
|
|
453
|
+
/** Output token address */
|
|
454
|
+
outputToken: string;
|
|
455
|
+
/** Input amount in smallest units */
|
|
456
|
+
inputAmount: bigint;
|
|
457
|
+
/** Expected output amount in smallest units */
|
|
458
|
+
outputAmount: bigint;
|
|
459
|
+
/** Price impact percentage */
|
|
460
|
+
priceImpact: number;
|
|
461
|
+
/** Swap route (token addresses) */
|
|
462
|
+
route: string[];
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Swap execution result
|
|
466
|
+
*/
|
|
467
|
+
interface SwapResult {
|
|
468
|
+
/** Transaction hash */
|
|
469
|
+
txHash: string;
|
|
470
|
+
/** Actual input amount */
|
|
471
|
+
inputAmount: bigint;
|
|
472
|
+
/** Actual output amount */
|
|
473
|
+
outputAmount: bigint;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Parameters for swap operations
|
|
477
|
+
*/
|
|
478
|
+
interface SwapParams {
|
|
479
|
+
/** Chain name (e.g., "ethereum", "arbitrum") */
|
|
480
|
+
chain: string;
|
|
481
|
+
/** Input token address */
|
|
482
|
+
fromToken: string;
|
|
483
|
+
/** Amount to swap in smallest units */
|
|
484
|
+
amount: bigint;
|
|
485
|
+
/** Maximum slippage tolerance (0-1, default: 0.005 = 0.5%) */
|
|
486
|
+
maxSlippage?: number;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
export type { AggregatedBalance as A, BridgeParams as B, ChainFamily as C, EvmChainConfig as E, FromWDKOptions as F, GetAllSignersOptions as G, MultiChainConfig as M, NormalizedChainConfig as N, SignerEntry as S, T402WDKCreateConfig as T, WDKSolanaAccount as W, WDKTonAccount as a, WDKTronAccount as b, WDKInstance as c, WDKConstructor as d, WDKModulesConfig as e, WDKWalletModules as f, WDKProtocolModules as g, T402WDKConfig as h, T402WDKOptions as i, ChainBalance as j, BridgeResult as k, SwapQuote as l, SwapParams as m, SwapResult as n, T402BalanceCacheConfig as o, TokenBalance as p, TypedDataDomain as q, TypedDataTypes as r, T402WDKSigner as s, WDKAccount as t, WdkAccount as u, SvmChainConfig as v, TonChainConfig as w, TronChainConfig as x, WDKInstanceMultiChain as y };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { WDKTonSignerAdapter, createWDKTonSigner } from './ton-adapter.mjs';
|
|
2
|
+
export { WDKSvmSignerAdapter, createWDKSvmSigner } from './svm-adapter.mjs';
|
|
3
|
+
export { WDKTronSignerAdapter, createWDKTronSigner } from './tron-adapter.mjs';
|
|
4
|
+
import '../types-V7c-qhn6.mjs';
|
|
5
|
+
import 'viem';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WDKSvmSignerAdapter,
|
|
3
|
+
createWDKSvmSigner
|
|
4
|
+
} from "../chunk-MCFHZSF7.mjs";
|
|
5
|
+
import {
|
|
6
|
+
WDKTonSignerAdapter,
|
|
7
|
+
createWDKTonSigner
|
|
8
|
+
} from "../chunk-YWBJJV5M.mjs";
|
|
9
|
+
import {
|
|
10
|
+
WDKTronSignerAdapter,
|
|
11
|
+
createWDKTronSigner
|
|
12
|
+
} from "../chunk-HB2DGKQ3.mjs";
|
|
13
|
+
export {
|
|
14
|
+
WDKSvmSignerAdapter,
|
|
15
|
+
WDKTonSignerAdapter,
|
|
16
|
+
WDKTronSignerAdapter,
|
|
17
|
+
createWDKSvmSigner,
|
|
18
|
+
createWDKTonSigner,
|
|
19
|
+
createWDKTronSigner
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { W as WDKSolanaAccount } from '../types-V7c-qhn6.mjs';
|
|
2
|
+
import 'viem';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Solana (SVM) Signer Adapter for WDK
|
|
6
|
+
*
|
|
7
|
+
* Wraps a Tether WDK Solana account to implement T402's ClientSvmSigner interface.
|
|
8
|
+
* ClientSvmSigner is just TransactionSigner from @solana/kit.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Address type from @solana/kit (base58 string)
|
|
13
|
+
* We use a branded type for compatibility
|
|
14
|
+
*/
|
|
15
|
+
type SolanaAddress = string & {
|
|
16
|
+
readonly __brand?: unique symbol;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* TransactionSigner interface matching @solana/kit
|
|
20
|
+
* This is what T402's ClientSvmSigner expects
|
|
21
|
+
*/
|
|
22
|
+
interface TransactionSigner {
|
|
23
|
+
readonly address: SolanaAddress;
|
|
24
|
+
signTransactions<T extends {
|
|
25
|
+
messageBytes: Uint8Array;
|
|
26
|
+
signatures: Record<string, unknown>;
|
|
27
|
+
}>(transactions: readonly T[]): Promise<readonly Record<string, Uint8Array>[]>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* WDKSvmSignerAdapter - Adapts a WDK Solana account to T402's ClientSvmSigner
|
|
31
|
+
*
|
|
32
|
+
* ClientSvmSigner is TransactionSigner from @solana/kit which requires:
|
|
33
|
+
* - address: The public key as Address type
|
|
34
|
+
* - signTransactions: Sign multiple transactions, returning signature dictionaries
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const adapter = await createWDKSvmSigner(wdkSolanaAccount);
|
|
39
|
+
*
|
|
40
|
+
* // Use with T402 client
|
|
41
|
+
* const client = createT402HTTPClient({
|
|
42
|
+
* signers: [{ scheme: 'exact', network: 'solana:mainnet', signer: adapter }]
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare class WDKSvmSignerAdapter implements TransactionSigner {
|
|
47
|
+
private _account;
|
|
48
|
+
private _address;
|
|
49
|
+
private _initialized;
|
|
50
|
+
constructor(account: WDKSolanaAccount);
|
|
51
|
+
/**
|
|
52
|
+
* Get the wallet address (base58)
|
|
53
|
+
* @throws Error if not initialized
|
|
54
|
+
*/
|
|
55
|
+
get address(): SolanaAddress;
|
|
56
|
+
/**
|
|
57
|
+
* Check if the adapter is initialized
|
|
58
|
+
*/
|
|
59
|
+
get isInitialized(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Initialize the adapter by fetching the address
|
|
62
|
+
* Must be called before using the signer
|
|
63
|
+
*/
|
|
64
|
+
initialize(): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Sign transactions with this signer
|
|
67
|
+
*
|
|
68
|
+
* This method signs the message bytes of each transaction and returns
|
|
69
|
+
* signature dictionaries mapping address to signature.
|
|
70
|
+
*
|
|
71
|
+
* @param transactions - Array of transactions to sign
|
|
72
|
+
* @returns Array of signature dictionaries
|
|
73
|
+
*/
|
|
74
|
+
signTransactions<T extends {
|
|
75
|
+
messageBytes: Uint8Array;
|
|
76
|
+
signatures: Record<string, unknown>;
|
|
77
|
+
}>(transactions: readonly T[]): Promise<readonly Record<string, Uint8Array>[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Sign a single message (utility method)
|
|
80
|
+
* @param message - Message bytes to sign
|
|
81
|
+
* @returns Signature bytes
|
|
82
|
+
*/
|
|
83
|
+
sign(message: Uint8Array): Promise<Uint8Array>;
|
|
84
|
+
/**
|
|
85
|
+
* Get SOL balance in lamports
|
|
86
|
+
*/
|
|
87
|
+
getBalance(): Promise<bigint>;
|
|
88
|
+
/**
|
|
89
|
+
* Get SPL token balance
|
|
90
|
+
* @param mint - Token mint address
|
|
91
|
+
*/
|
|
92
|
+
getTokenBalance(mint: string): Promise<bigint>;
|
|
93
|
+
/**
|
|
94
|
+
* Transfer SPL tokens
|
|
95
|
+
* @param params - Transfer parameters
|
|
96
|
+
* @returns Transaction signature
|
|
97
|
+
*/
|
|
98
|
+
transfer(params: {
|
|
99
|
+
token: string;
|
|
100
|
+
recipient: string;
|
|
101
|
+
amount: bigint;
|
|
102
|
+
}): Promise<string>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create an initialized WDK Solana signer
|
|
106
|
+
*
|
|
107
|
+
* @param account - WDK Solana account from @tetherto/wdk-wallet-solana
|
|
108
|
+
* @returns Initialized TransactionSigner (ClientSvmSigner)
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* import { T402WDK } from '@t402/wdk';
|
|
113
|
+
*
|
|
114
|
+
* const wallet = new T402WDK(seedPhrase, config);
|
|
115
|
+
* const svmSigner = await wallet.getSvmSigner();
|
|
116
|
+
*
|
|
117
|
+
* // Use with T402 client
|
|
118
|
+
* const client = createT402HTTPClient({
|
|
119
|
+
* signers: [{ scheme: 'exact', network: 'solana:mainnet', signer: svmSigner }]
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
declare function createWDKSvmSigner(account: WDKSolanaAccount): Promise<WDKSvmSignerAdapter>;
|
|
124
|
+
|
|
125
|
+
export { type SolanaAddress, type TransactionSigner, WDKSvmSignerAdapter, createWDKSvmSigner };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|