@t402/wdk 2.4.0 → 2.6.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/dist/cjs/adapters/index.d.ts +198 -1
- package/dist/cjs/adapters/index.js +255 -0
- package/dist/cjs/adapters/index.js.map +1 -1
- package/dist/cjs/adapters/svm-adapter.d.ts +146 -2
- package/dist/cjs/adapters/svm-adapter.js +255 -2
- package/dist/cjs/adapters/svm-adapter.js.map +1 -1
- package/dist/cjs/adapters/ton-adapter.d.ts +57 -2
- package/dist/cjs/adapters/ton-adapter.js +75 -2
- package/dist/cjs/adapters/ton-adapter.js.map +1 -1
- package/dist/cjs/adapters/tron-adapter.d.ts +57 -2
- package/dist/cjs/adapters/tron-adapter.js +101 -0
- package/dist/cjs/adapters/tron-adapter.js.map +1 -1
- package/dist/cjs/index-DnEI5M6d.d.ts +1798 -0
- package/dist/cjs/index.d.ts +702 -1118
- package/dist/cjs/index.js +3905 -246
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/integrations/index.d.ts +9 -0
- package/dist/cjs/integrations/index.js +249 -0
- package/dist/cjs/integrations/index.js.map +1 -0
- package/dist/cjs/testing/index.d.ts +62 -0
- package/dist/cjs/testing/index.js +129 -0
- package/dist/cjs/testing/index.js.map +1 -0
- package/dist/cjs/types-BwK8Xgvg.d.ts +967 -0
- package/dist/esm/adapters/index.d.mts +198 -1
- package/dist/esm/adapters/index.mjs +14 -3
- package/dist/esm/adapters/svm-adapter.d.mts +146 -2
- package/dist/esm/adapters/svm-adapter.mjs +18 -3
- package/dist/esm/adapters/ton-adapter.d.mts +57 -2
- package/dist/esm/adapters/ton-adapter.mjs +8 -3
- package/dist/esm/adapters/tron-adapter.d.mts +57 -2
- package/dist/esm/adapters/tron-adapter.mjs +2 -1
- package/dist/esm/chunk-2KWVW77U.mjs +353 -0
- package/dist/esm/chunk-2KWVW77U.mjs.map +1 -0
- package/dist/esm/chunk-7CG77QAN.mjs +153 -0
- package/dist/esm/chunk-7CG77QAN.mjs.map +1 -0
- package/dist/esm/chunk-BJTO5JO5.mjs +11 -0
- package/dist/esm/chunk-BJTO5JO5.mjs.map +1 -0
- package/dist/esm/{chunk-YWBJJV5M.mjs → chunk-KWX6CJIH.mjs} +72 -1
- package/dist/esm/chunk-KWX6CJIH.mjs.map +1 -0
- package/dist/esm/{chunk-HB2DGKQ3.mjs → chunk-QZKUU2O6.mjs} +102 -1
- package/dist/esm/chunk-QZKUU2O6.mjs.map +1 -0
- package/dist/esm/chunk-TVSNUSFZ.mjs +219 -0
- package/dist/esm/chunk-TVSNUSFZ.mjs.map +1 -0
- package/dist/esm/index-D5kvtDfm.d.mts +1798 -0
- package/dist/esm/index.d.mts +702 -1118
- package/dist/esm/index.mjs +2934 -70
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/integrations/index.d.mts +9 -0
- package/dist/esm/integrations/index.mjs +16 -0
- package/dist/esm/integrations/index.mjs.map +1 -0
- package/dist/esm/testing/index.d.mts +62 -0
- package/dist/esm/testing/index.mjs +101 -0
- package/dist/esm/testing/index.mjs.map +1 -0
- package/dist/esm/types-BwK8Xgvg.d.mts +967 -0
- package/package.json +69 -20
- package/dist/cjs/types-V7c-qhn6.d.ts +0 -489
- package/dist/esm/chunk-HB2DGKQ3.mjs.map +0 -1
- package/dist/esm/chunk-MCFHZSF7.mjs +0 -107
- package/dist/esm/chunk-MCFHZSF7.mjs.map +0 -1
- package/dist/esm/chunk-YWBJJV5M.mjs.map +0 -1
- package/dist/esm/types-V7c-qhn6.d.mts +0 -489
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,934 +1,60 @@
|
|
|
1
|
+
import { W as WDKSigner, E as EnrichedReceipt } from './index-DnEI5M6d.js';
|
|
2
|
+
export { A as A2APaymentPayload, a as A2APaymentRequired, B as BackupMetadata, b as BalanceCache, c as BalanceCacheConfig, d as BalanceCacheStats, C as CacheConfig, e as CacheStats, D as DEFAULT_BALANCE_CACHE_CONFIG, f as DEFAULT_CACHE_CONFIG, g as EncryptedSeed, F as FacilitatorWdkSigner, h as FacilitatorWdkSignerOptions, I as InMemoryReceiptStore, M as MiddlewareFunction, i as MockWDKSigner, P as PaymentCostEstimate, j as PaymentReceiptStore, k as PricingProvider, l as PricingProviderConfig, R as ReceiptFilter, S as SIWxSigner, m as SUPPORTED_WDK_RANGE, n as SecretManager, T as T402EventEmitter, o as T402Events, p as T402WDK, q as TTLCache, r as WdkA2AOptions, s as WdkA2APaymentClient, t as compareSemver, u as createBackup, v as createFacilitatorSigners, w as createSIWxSigners, x as createWDKSigner, y as createWdkA2APaymentClient, z as createWdkMoneyParser, G as decryptSeed, H as encryptSeed, J as getPricingProvider, K as getSecretManager, L as isPricingProviderRegistered, N as parseSemver, O as registerPricingProvider, Q as registerSecretManager, U as resolveAssetForNetwork, V as rotateSeedPassword, X as satisfiesSemverRange, Y as toAtomicUnits, Z as toFacilitatorWdkSigner, _ as toSIWxSigner, $ as verifyBackup } from './index-DnEI5M6d.js';
|
|
3
|
+
import { C as ChainFamily, N as NormalizedChainConfig, E as EvmChainConfig, B as BridgeResult, F as FiatOnRampProvider, e as FiatOnRampParams, f as FiatOnRampQuote, g as FiatOnRampResult } from './types-BwK8Xgvg.js';
|
|
4
|
+
export { A as AggregatedBalance, h as BalanceError, i as BorrowParams, j as BorrowResult, k as BridgeError, l as BridgeParams, m as ChainBalance, n as ChainError, D as DEFAULT_RETRY_CONFIG, o as FailoverConfig, p as FailoverProvider, q as FromWDKOptions, G as GetAllSignersOptions, M as MetricCallback, r as MultiChainConfig, P as ProviderStatus, R as RPCError, s as RetryConfig, S as SignerEntry, t as SignerError, u as SigningError, v as SvmChainConfig, w as SwapParams, x as SwapQuote, y as SwapResult, T as T402BalanceCacheConfig, z as T402Logger, H as T402WDKConfig, I as T402WDKCreateConfig, J as T402WDKOptions, K as T402WDKSigner, L as TokenBalance, O as TonChainConfig, Q as TransactionError, U as TronChainConfig, V as TypedDataDomain, X as TypedDataTypes, c as WDKAccount, Y as WDKAutoDiscoveryResult, Z as WDKConstructor, _ as WDKError, $ as WDKErrorCode, a0 as WDKInitializationError, d as WDKInstance, a1 as WDKInstanceMultiChain, a2 as WDKModulesConfig, a3 as WDKProtocolModules, W as WDKSolanaAccount, a as WDKTonAccount, b as WDKTronAccount, a4 as WDKWalletModules, a5 as WdkAccount, a6 as createCorrelationId, a7 as createFailoverProvider, a8 as defaultLogger, a9 as hasErrorCode, aa as isWDKError, ab as noopLogger, ac as resolveRpcUrl, ad as withRetry, ae as withTimeout, af as wrapError } from './types-BwK8Xgvg.js';
|
|
5
|
+
export { ClientTonSigner, JettonTransferResult, JettonTransferStatus, SignMessageParams as TonSignMessageParams, WDKTonSignerAdapter, WaitForJettonTransferParams, createWDKTonSigner, getJettonWalletAddress, waitForJettonTransfer } from './adapters/ton-adapter.js';
|
|
6
|
+
export { ATAResolution, BuildVersionedTransactionParams, TransactionSigner as ClientSvmSigner, PriorityFeeEstimate, SerializedInstruction, SolanaAddress, TokenProgramType, TransferFeeInfo, TransferWithPriorityFeeParams, WDKSvmSignerAdapter, buildVersionedTransaction, createWDKSvmSigner, deriveATAAddress, getRecentPriorityFees, getTokenProgram, getTransferFee, resolveATA, transferWithPriorityFee } from './adapters/svm-adapter.js';
|
|
7
|
+
export { ClientTronSigner, EnergyEstimate, EnergyProvider, BlockInfo as TronBlockInfo, SignTransactionParams as TronSignTransactionParams, WDKTronSignerAdapter, createWDKTronSigner } from './adapters/tron-adapter.js';
|
|
1
8
|
import { Address } from 'viem';
|
|
2
|
-
import {
|
|
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';
|
|
10
|
-
import { ClientEvmSigner, Usdt0Bridge, BridgeSigner } from '@t402/evm';
|
|
9
|
+
import { Usdt0Bridge, BridgeSigner } from '@t402/evm';
|
|
11
10
|
export { BridgeQuote, BridgeSigner, LAYERZERO_ENDPOINT_IDS, USDT0_OFT_ADDRESSES, Usdt0Bridge, getBridgeableChains, supportsBridging } from '@t402/evm';
|
|
11
|
+
import './adapters/index.js';
|
|
12
|
+
import '@t402/core/types';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
+
* Multi-chain address validation for T402 WDK
|
|
15
16
|
*
|
|
16
|
-
* Provides
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* Cache configuration options
|
|
21
|
-
*/
|
|
22
|
-
interface CacheConfig {
|
|
23
|
-
/** Default TTL in milliseconds (default: 30000 = 30 seconds) */
|
|
24
|
-
defaultTTL: number;
|
|
25
|
-
/** Maximum number of entries (default: 1000) */
|
|
26
|
-
maxSize: number;
|
|
27
|
-
/** Whether to refresh TTL on access (default: false) */
|
|
28
|
-
refreshOnAccess: boolean;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Default cache configuration
|
|
32
|
-
*/
|
|
33
|
-
declare const DEFAULT_CACHE_CONFIG: CacheConfig;
|
|
34
|
-
/**
|
|
35
|
-
* Generic TTL cache implementation
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* const cache = new TTLCache<bigint>({ defaultTTL: 60000 });
|
|
40
|
-
*
|
|
41
|
-
* // Set with default TTL
|
|
42
|
-
* cache.set('balance:arbitrum:0x123', 1000000n);
|
|
43
|
-
*
|
|
44
|
-
* // Set with custom TTL
|
|
45
|
-
* cache.set('balance:ethereum:0x456', 2000000n, 120000);
|
|
46
|
-
*
|
|
47
|
-
* // Get value (returns undefined if expired)
|
|
48
|
-
* const balance = cache.get('balance:arbitrum:0x123');
|
|
49
|
-
*
|
|
50
|
-
* // Check if key exists and is not expired
|
|
51
|
-
* if (cache.has('balance:arbitrum:0x123')) {
|
|
52
|
-
* // Use cached value
|
|
53
|
-
* }
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
declare class TTLCache<T> {
|
|
57
|
-
private _cache;
|
|
58
|
-
private _config;
|
|
59
|
-
private _cleanupInterval;
|
|
60
|
-
constructor(config?: Partial<CacheConfig>);
|
|
61
|
-
/**
|
|
62
|
-
* Get a value from the cache
|
|
63
|
-
*
|
|
64
|
-
* @param key - Cache key
|
|
65
|
-
* @returns The cached value or undefined if not found/expired
|
|
66
|
-
*/
|
|
67
|
-
get(key: string): T | undefined;
|
|
68
|
-
/**
|
|
69
|
-
* Set a value in the cache
|
|
70
|
-
*
|
|
71
|
-
* @param key - Cache key
|
|
72
|
-
* @param value - Value to cache
|
|
73
|
-
* @param ttl - TTL in milliseconds (optional, uses default if not provided)
|
|
74
|
-
*/
|
|
75
|
-
set(key: string, value: T, ttl?: number): void;
|
|
76
|
-
/**
|
|
77
|
-
* Check if a key exists and is not expired
|
|
78
|
-
*
|
|
79
|
-
* @param key - Cache key
|
|
80
|
-
* @returns true if key exists and is not expired
|
|
81
|
-
*/
|
|
82
|
-
has(key: string): boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Delete a key from the cache
|
|
85
|
-
*
|
|
86
|
-
* @param key - Cache key
|
|
87
|
-
* @returns true if key was deleted
|
|
88
|
-
*/
|
|
89
|
-
delete(key: string): boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Delete all keys matching a prefix
|
|
92
|
-
*
|
|
93
|
-
* @param prefix - Key prefix to match
|
|
94
|
-
* @returns Number of keys deleted
|
|
95
|
-
*/
|
|
96
|
-
deleteByPrefix(prefix: string): number;
|
|
97
|
-
/**
|
|
98
|
-
* Clear all entries from the cache
|
|
99
|
-
*/
|
|
100
|
-
clear(): void;
|
|
101
|
-
/**
|
|
102
|
-
* Get the number of entries in the cache (including expired)
|
|
103
|
-
*/
|
|
104
|
-
get size(): number;
|
|
105
|
-
/**
|
|
106
|
-
* Get the number of valid (non-expired) entries
|
|
107
|
-
*/
|
|
108
|
-
get validSize(): number;
|
|
109
|
-
/**
|
|
110
|
-
* Get all valid keys
|
|
111
|
-
*/
|
|
112
|
-
keys(): string[];
|
|
113
|
-
/**
|
|
114
|
-
* Get remaining TTL for a key in milliseconds
|
|
115
|
-
*
|
|
116
|
-
* @param key - Cache key
|
|
117
|
-
* @returns Remaining TTL in ms, or -1 if not found/expired
|
|
118
|
-
*/
|
|
119
|
-
getTTL(key: string): number;
|
|
120
|
-
/**
|
|
121
|
-
* Update TTL for an existing key
|
|
122
|
-
*
|
|
123
|
-
* @param key - Cache key
|
|
124
|
-
* @param ttl - New TTL in milliseconds
|
|
125
|
-
* @returns true if key exists and TTL was updated
|
|
126
|
-
*/
|
|
127
|
-
touch(key: string, ttl?: number): boolean;
|
|
128
|
-
/**
|
|
129
|
-
* Get or set a value using a factory function
|
|
130
|
-
*
|
|
131
|
-
* @param key - Cache key
|
|
132
|
-
* @param factory - Function to create value if not cached
|
|
133
|
-
* @param ttl - TTL in milliseconds (optional)
|
|
134
|
-
* @returns The cached or newly created value
|
|
135
|
-
*/
|
|
136
|
-
getOrSet(key: string, factory: () => Promise<T>, ttl?: number): Promise<T>;
|
|
137
|
-
/**
|
|
138
|
-
* Get cache statistics
|
|
139
|
-
*/
|
|
140
|
-
getStats(): CacheStats;
|
|
141
|
-
/**
|
|
142
|
-
* Stop the cleanup interval
|
|
143
|
-
*/
|
|
144
|
-
dispose(): void;
|
|
145
|
-
/**
|
|
146
|
-
* Start periodic cleanup of expired entries
|
|
147
|
-
*/
|
|
148
|
-
private _startCleanup;
|
|
149
|
-
/**
|
|
150
|
-
* Remove all expired entries
|
|
151
|
-
*/
|
|
152
|
-
private _removeExpired;
|
|
153
|
-
/**
|
|
154
|
-
* Evict oldest entries to make room
|
|
155
|
-
*/
|
|
156
|
-
private _evictOldest;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Cache statistics
|
|
160
|
-
*/
|
|
161
|
-
interface CacheStats {
|
|
162
|
-
/** Total entries including expired */
|
|
163
|
-
totalSize: number;
|
|
164
|
-
/** Valid (non-expired) entries */
|
|
165
|
-
validSize: number;
|
|
166
|
-
/** Expired entries pending cleanup */
|
|
167
|
-
expiredSize: number;
|
|
168
|
-
/** Maximum cache size */
|
|
169
|
-
maxSize: number;
|
|
170
|
-
/** Default TTL in milliseconds */
|
|
171
|
-
defaultTTL: number;
|
|
172
|
-
/** Time until oldest entry expires (ms) */
|
|
173
|
-
oldestExpiryMs: number;
|
|
174
|
-
/** Time until newest entry expires (ms) */
|
|
175
|
-
newestExpiryMs: number;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Balance cache configuration
|
|
179
|
-
*/
|
|
180
|
-
interface BalanceCacheConfig {
|
|
181
|
-
/** Whether caching is enabled (default: true) */
|
|
182
|
-
enabled: boolean;
|
|
183
|
-
/** TTL for native balance in milliseconds (default: 15000 = 15 seconds) */
|
|
184
|
-
nativeBalanceTTL: number;
|
|
185
|
-
/** TTL for token balance in milliseconds (default: 30000 = 30 seconds) */
|
|
186
|
-
tokenBalanceTTL: number;
|
|
187
|
-
/** TTL for aggregated balances in milliseconds (default: 60000 = 60 seconds) */
|
|
188
|
-
aggregatedBalanceTTL: number;
|
|
189
|
-
/** Maximum cache entries (default: 500) */
|
|
190
|
-
maxSize: number;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Default balance cache configuration
|
|
194
|
-
*/
|
|
195
|
-
declare const DEFAULT_BALANCE_CACHE_CONFIG: BalanceCacheConfig;
|
|
196
|
-
/**
|
|
197
|
-
* Specialized balance cache for WDK
|
|
198
|
-
*
|
|
199
|
-
* Provides separate TTL settings for different balance types
|
|
200
|
-
* and convenient methods for balance-specific caching.
|
|
201
|
-
*
|
|
202
|
-
* @example
|
|
203
|
-
* ```typescript
|
|
204
|
-
* const cache = new BalanceCache({
|
|
205
|
-
* tokenBalanceTTL: 60000, // 1 minute for token balances
|
|
206
|
-
* });
|
|
207
|
-
*
|
|
208
|
-
* // Cache token balance
|
|
209
|
-
* cache.setTokenBalance('arbitrum', '0xUSDT', '0xWallet', 1000000n);
|
|
210
|
-
*
|
|
211
|
-
* // Get cached balance (returns undefined if expired)
|
|
212
|
-
* const balance = cache.getTokenBalance('arbitrum', '0xUSDT', '0xWallet');
|
|
213
|
-
*
|
|
214
|
-
* // Or use getOrFetch pattern
|
|
215
|
-
* const balance = await cache.getOrFetchTokenBalance(
|
|
216
|
-
* 'arbitrum',
|
|
217
|
-
* '0xUSDT',
|
|
218
|
-
* '0xWallet',
|
|
219
|
-
* async () => await signer.getTokenBalance('0xUSDT')
|
|
220
|
-
* );
|
|
221
|
-
* ```
|
|
222
|
-
*/
|
|
223
|
-
declare class BalanceCache {
|
|
224
|
-
private _cache;
|
|
225
|
-
private _aggregatedCache;
|
|
226
|
-
private _config;
|
|
227
|
-
constructor(config?: Partial<BalanceCacheConfig>);
|
|
228
|
-
/**
|
|
229
|
-
* Check if caching is enabled
|
|
230
|
-
*/
|
|
231
|
-
get enabled(): boolean;
|
|
232
|
-
/**
|
|
233
|
-
* Get cache configuration
|
|
234
|
-
*/
|
|
235
|
-
get config(): BalanceCacheConfig;
|
|
236
|
-
/**
|
|
237
|
-
* Get cached native balance
|
|
238
|
-
*/
|
|
239
|
-
getNativeBalance(chain: string, address: string): bigint | undefined;
|
|
240
|
-
/**
|
|
241
|
-
* Set native balance in cache
|
|
242
|
-
*/
|
|
243
|
-
setNativeBalance(chain: string, address: string, balance: bigint): void;
|
|
244
|
-
/**
|
|
245
|
-
* Get or fetch native balance
|
|
246
|
-
*/
|
|
247
|
-
getOrFetchNativeBalance(chain: string, address: string, fetcher: () => Promise<bigint>): Promise<bigint>;
|
|
248
|
-
/**
|
|
249
|
-
* Get cached token balance
|
|
250
|
-
*/
|
|
251
|
-
getTokenBalance(chain: string, token: string, address: string): bigint | undefined;
|
|
252
|
-
/**
|
|
253
|
-
* Set token balance in cache
|
|
254
|
-
*/
|
|
255
|
-
setTokenBalance(chain: string, token: string, address: string, balance: bigint): void;
|
|
256
|
-
/**
|
|
257
|
-
* Get or fetch token balance
|
|
258
|
-
*/
|
|
259
|
-
getOrFetchTokenBalance(chain: string, token: string, address: string, fetcher: () => Promise<bigint>): Promise<bigint>;
|
|
260
|
-
/**
|
|
261
|
-
* Get cached aggregated balance
|
|
262
|
-
*/
|
|
263
|
-
getAggregatedBalance<T>(key: string): T | undefined;
|
|
264
|
-
/**
|
|
265
|
-
* Set aggregated balance in cache
|
|
266
|
-
*/
|
|
267
|
-
setAggregatedBalance<T>(key: string, value: T): void;
|
|
268
|
-
/**
|
|
269
|
-
* Get or fetch aggregated balance
|
|
270
|
-
*/
|
|
271
|
-
getOrFetchAggregatedBalance<T>(key: string, fetcher: () => Promise<T>): Promise<T>;
|
|
272
|
-
/**
|
|
273
|
-
* Invalidate all balances for a chain
|
|
274
|
-
*/
|
|
275
|
-
invalidateChain(chain: string): number;
|
|
276
|
-
/**
|
|
277
|
-
* Invalidate all balances for an address
|
|
278
|
-
*/
|
|
279
|
-
invalidateAddress(address: string): number;
|
|
280
|
-
/**
|
|
281
|
-
* Invalidate specific token balance
|
|
282
|
-
*/
|
|
283
|
-
invalidateTokenBalance(chain: string, token: string, address: string): boolean;
|
|
284
|
-
/**
|
|
285
|
-
* Clear all caches
|
|
286
|
-
*/
|
|
287
|
-
clear(): void;
|
|
288
|
-
/**
|
|
289
|
-
* Get cache statistics
|
|
290
|
-
*/
|
|
291
|
-
getStats(): BalanceCacheStats;
|
|
292
|
-
/**
|
|
293
|
-
* Dispose of cache resources
|
|
294
|
-
*/
|
|
295
|
-
dispose(): void;
|
|
296
|
-
private _nativeKey;
|
|
297
|
-
private _tokenKey;
|
|
298
|
-
private _aggregatedKey;
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Balance cache statistics
|
|
302
|
-
*/
|
|
303
|
-
interface BalanceCacheStats {
|
|
304
|
-
balanceCache: CacheStats;
|
|
305
|
-
aggregatedCache: CacheStats;
|
|
306
|
-
config: BalanceCacheConfig;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* WDK Signer implementation for T402 payments
|
|
311
|
-
*
|
|
312
|
-
* This signer wraps the Tether WDK account to provide a T402-compatible
|
|
313
|
-
* signing interface for EVM chains.
|
|
17
|
+
* Provides address validation and normalization across supported chain families.
|
|
18
|
+
* Includes cross-chain mismatch detection to help users avoid sending to wrong chains.
|
|
314
19
|
*/
|
|
315
20
|
|
|
316
21
|
/**
|
|
317
|
-
*
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
*
|
|
329
|
-
* // Use with T402 client
|
|
330
|
-
* const client = createT402HTTPClient({
|
|
331
|
-
* signers: [{ scheme: 'exact', signer }]
|
|
332
|
-
* });
|
|
333
|
-
* ```
|
|
334
|
-
*/
|
|
335
|
-
declare class WDKSigner implements ClientEvmSigner {
|
|
336
|
-
private _wdk;
|
|
337
|
-
private _chain;
|
|
338
|
-
private _accountIndex;
|
|
339
|
-
private _account;
|
|
340
|
-
private _address;
|
|
341
|
-
private _timeoutMs;
|
|
342
|
-
/**
|
|
343
|
-
* Create a new WDK signer
|
|
344
|
-
*
|
|
345
|
-
* @param wdk - The WDK instance
|
|
346
|
-
* @param chain - Chain name (e.g., "arbitrum", "ethereum")
|
|
347
|
-
* @param accountIndex - HD wallet account index (default: 0)
|
|
348
|
-
* @param timeoutMs - Timeout for operations in milliseconds (default: 30000)
|
|
349
|
-
*/
|
|
350
|
-
constructor(wdk: WDKInstance, chain: string, accountIndex?: number, timeoutMs?: number);
|
|
351
|
-
/**
|
|
352
|
-
* Get the wallet address
|
|
353
|
-
* Throws if signer is not initialized
|
|
354
|
-
*/
|
|
355
|
-
get address(): Address;
|
|
356
|
-
/**
|
|
357
|
-
* Check if the signer is initialized
|
|
358
|
-
*/
|
|
359
|
-
get isInitialized(): boolean;
|
|
360
|
-
/**
|
|
361
|
-
* Initialize the signer by fetching the account
|
|
362
|
-
* Must be called before using the signer
|
|
363
|
-
*
|
|
364
|
-
* @throws {SignerError} If account fetch fails
|
|
365
|
-
*/
|
|
366
|
-
initialize(): Promise<void>;
|
|
367
|
-
/**
|
|
368
|
-
* Get the underlying WDK account
|
|
369
|
-
* Initializes if not already done
|
|
370
|
-
*
|
|
371
|
-
* @throws {SignerError} If initialization fails
|
|
372
|
-
*/
|
|
373
|
-
private getAccount;
|
|
374
|
-
/**
|
|
375
|
-
* Sign EIP-712 typed data for T402 payments
|
|
376
|
-
*
|
|
377
|
-
* This is the primary signing method used by T402 for EIP-3009
|
|
378
|
-
* transferWithAuthorization payments.
|
|
379
|
-
*
|
|
380
|
-
* @throws {SigningError} If signing fails
|
|
381
|
-
*/
|
|
382
|
-
signTypedData(message: {
|
|
383
|
-
domain: Record<string, unknown>;
|
|
384
|
-
types: Record<string, unknown>;
|
|
385
|
-
primaryType: string;
|
|
386
|
-
message: Record<string, unknown>;
|
|
387
|
-
}): Promise<`0x${string}`>;
|
|
388
|
-
/**
|
|
389
|
-
* Sign a personal message
|
|
390
|
-
*
|
|
391
|
-
* @throws {SigningError} If signing fails
|
|
392
|
-
*/
|
|
393
|
-
signMessage(message: string | Uint8Array): Promise<`0x${string}`>;
|
|
394
|
-
/**
|
|
395
|
-
* Get the chain name
|
|
396
|
-
*/
|
|
397
|
-
getChain(): string;
|
|
398
|
-
/**
|
|
399
|
-
* Get the chain ID
|
|
400
|
-
*/
|
|
401
|
-
getChainId(): number;
|
|
402
|
-
/**
|
|
403
|
-
* Get the account index
|
|
404
|
-
*/
|
|
405
|
-
getAccountIndex(): number;
|
|
406
|
-
/**
|
|
407
|
-
* Get native token balance (ETH, etc.)
|
|
408
|
-
*
|
|
409
|
-
* @throws {BalanceError} If balance fetch fails
|
|
410
|
-
*/
|
|
411
|
-
getBalance(): Promise<bigint>;
|
|
412
|
-
/**
|
|
413
|
-
* Get ERC20 token balance
|
|
414
|
-
*
|
|
415
|
-
* @throws {BalanceError} If balance fetch fails
|
|
416
|
-
*/
|
|
417
|
-
getTokenBalance(tokenAddress: Address): Promise<bigint>;
|
|
418
|
-
/**
|
|
419
|
-
* Estimate gas for a transaction
|
|
420
|
-
*
|
|
421
|
-
* @throws {TransactionError} If gas estimation fails
|
|
422
|
-
*/
|
|
423
|
-
estimateGas(params: {
|
|
424
|
-
to: Address;
|
|
425
|
-
value?: bigint;
|
|
426
|
-
data?: string;
|
|
427
|
-
}): Promise<bigint>;
|
|
428
|
-
/**
|
|
429
|
-
* Send a transaction (for advanced use cases)
|
|
430
|
-
*
|
|
431
|
-
* @throws {TransactionError} If transaction fails
|
|
432
|
-
*/
|
|
433
|
-
sendTransaction(params: {
|
|
434
|
-
to: Address;
|
|
435
|
-
value?: bigint;
|
|
436
|
-
data?: string;
|
|
437
|
-
}): Promise<{
|
|
438
|
-
hash: `0x${string}`;
|
|
439
|
-
}>;
|
|
22
|
+
* Result of validating a payment address
|
|
23
|
+
*/
|
|
24
|
+
interface AddressValidationResult {
|
|
25
|
+
/** Whether the address is valid for the specified chain family */
|
|
26
|
+
valid: boolean;
|
|
27
|
+
/** Normalized form of the address (e.g., checksummed, lowercased) */
|
|
28
|
+
normalized?: string;
|
|
29
|
+
/** Error message if validation failed */
|
|
30
|
+
error?: string;
|
|
31
|
+
/** Detected chain family if the address appears to belong to a different chain */
|
|
32
|
+
detectedFamily?: ChainFamily;
|
|
440
33
|
}
|
|
441
34
|
/**
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
* This async factory function creates and initializes a WDK signer,
|
|
445
|
-
* ensuring the address is available immediately.
|
|
446
|
-
*
|
|
447
|
-
* @throws {SignerError} If initialization fails
|
|
448
|
-
*
|
|
449
|
-
* @example
|
|
450
|
-
* ```typescript
|
|
451
|
-
* const signer = await createWDKSigner(wdkInstance, 'arbitrum');
|
|
452
|
-
* console.log('Address:', signer.address); // Works immediately
|
|
453
|
-
* ```
|
|
454
|
-
*/
|
|
455
|
-
declare function createWDKSigner(wdk: WDKInstance, chain: string, accountIndex?: number, timeoutMs?: number): Promise<WDKSigner>;
|
|
456
|
-
/**
|
|
457
|
-
* Mock WDK signer for testing purposes
|
|
35
|
+
* Validate a payment address for a given chain family.
|
|
458
36
|
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*/
|
|
462
|
-
declare class MockWDKSigner implements ClientEvmSigner {
|
|
463
|
-
readonly address: Address;
|
|
464
|
-
constructor(address: Address, _privateKey: `0x${string}`);
|
|
465
|
-
signTypedData(_message: {
|
|
466
|
-
domain: Record<string, unknown>;
|
|
467
|
-
types: Record<string, unknown>;
|
|
468
|
-
primaryType: string;
|
|
469
|
-
message: Record<string, unknown>;
|
|
470
|
-
}): Promise<`0x${string}`>;
|
|
471
|
-
signMessage(_message: string | Uint8Array): Promise<`0x${string}`>;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* T402WDK - Main class for T402 integration with Tether WDK
|
|
37
|
+
* Supports EVM, TON, TRON, Solana (SVM), Bitcoin (BTC/Spark), and Cosmos.
|
|
38
|
+
* Returns validation result with optional normalization and cross-chain mismatch detection.
|
|
476
39
|
*
|
|
477
|
-
*
|
|
478
|
-
* -
|
|
479
|
-
*
|
|
480
|
-
* - Balance aggregation
|
|
481
|
-
* - Cross-chain bridging (USDT0)
|
|
482
|
-
*/
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* T402WDK - Tether WDK integration for T402 payments
|
|
40
|
+
* @param address - The address to validate
|
|
41
|
+
* @param family - The target chain family
|
|
42
|
+
* @returns Validation result
|
|
486
43
|
*
|
|
487
44
|
* @example
|
|
488
45
|
* ```typescript
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
* // Get signer for T402 payments
|
|
499
|
-
* const signer = await wdk.getSigner('arbitrum');
|
|
500
|
-
*
|
|
501
|
-
* // Use with T402 client
|
|
502
|
-
* const client = createT402HTTPClient({
|
|
503
|
-
* signers: [{ scheme: 'exact', signer }]
|
|
504
|
-
* });
|
|
46
|
+
* const result = validatePaymentAddress('0x1234...', 'evm');
|
|
47
|
+
* if (result.valid) {
|
|
48
|
+
* console.log('Normalized:', result.normalized);
|
|
49
|
+
* } else {
|
|
50
|
+
* console.error(result.error);
|
|
51
|
+
* if (result.detectedFamily) {
|
|
52
|
+
* console.error(`Did you mean to use ${result.detectedFamily}?`);
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
505
55
|
* ```
|
|
506
56
|
*/
|
|
507
|
-
declare
|
|
508
|
-
private _wdk;
|
|
509
|
-
private _normalizedChains;
|
|
510
|
-
private _seedPhrase;
|
|
511
|
-
private _signerCache;
|
|
512
|
-
private _balanceCache;
|
|
513
|
-
private _initializationError;
|
|
514
|
-
private static _WDK;
|
|
515
|
-
private static _WalletManagerEvm;
|
|
516
|
-
private static _BridgeUsdt0Evm;
|
|
517
|
-
private static _WalletModules;
|
|
518
|
-
private static _ProtocolModules;
|
|
519
|
-
private _tonSignerCache;
|
|
520
|
-
private _svmSignerCache;
|
|
521
|
-
private _tronSignerCache;
|
|
522
|
-
/**
|
|
523
|
-
* Register the Tether WDK modules
|
|
524
|
-
*
|
|
525
|
-
* This must be called before creating T402WDK instances if you want
|
|
526
|
-
* to use the actual WDK. Otherwise, a mock implementation is used.
|
|
527
|
-
*
|
|
528
|
-
* Supports two registration patterns:
|
|
529
|
-
*
|
|
530
|
-
* 1. Legacy (EVM-only):
|
|
531
|
-
* ```typescript
|
|
532
|
-
* T402WDK.registerWDK(WDK, WalletManagerEvm, BridgeUsdt0Evm);
|
|
533
|
-
* ```
|
|
534
|
-
*
|
|
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
|
|
552
|
-
*/
|
|
553
|
-
static registerWDK(WDK: WDKConstructor, modulesOrWalletManager?: WDKModulesConfig | unknown, BridgeUsdt0Evm?: unknown): void;
|
|
554
|
-
/**
|
|
555
|
-
* Check if WDK is registered
|
|
556
|
-
*/
|
|
557
|
-
static isWDKRegistered(): boolean;
|
|
558
|
-
/**
|
|
559
|
-
* Check if wallet manager is registered
|
|
560
|
-
*/
|
|
561
|
-
static isWalletManagerRegistered(): boolean;
|
|
562
|
-
/**
|
|
563
|
-
* Check if bridge protocol is registered
|
|
564
|
-
*/
|
|
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)[];
|
|
586
|
-
/**
|
|
587
|
-
* Generate a new random seed phrase
|
|
588
|
-
*
|
|
589
|
-
* @throws {WDKInitializationError} If WDK is not registered
|
|
590
|
-
* @returns A new BIP-39 mnemonic seed phrase
|
|
591
|
-
*/
|
|
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[]>;
|
|
643
|
-
/**
|
|
644
|
-
* Create a new T402WDK instance
|
|
645
|
-
*
|
|
646
|
-
* @param seedPhrase - BIP-39 mnemonic seed phrase
|
|
647
|
-
* @param config - Chain configuration (RPC endpoints)
|
|
648
|
-
* @param options - Additional options (cache configuration, etc.)
|
|
649
|
-
* @throws {WDKInitializationError} If seed phrase is invalid
|
|
650
|
-
*/
|
|
651
|
-
constructor(seedPhrase: string, config?: T402WDKConfig, options?: T402WDKOptions);
|
|
652
|
-
/**
|
|
653
|
-
* Add default chain configurations for common chains
|
|
654
|
-
*/
|
|
655
|
-
private _addDefaultChainsIfNeeded;
|
|
656
|
-
/**
|
|
657
|
-
* Initialize the underlying WDK instance
|
|
658
|
-
*/
|
|
659
|
-
private _initializeWDK;
|
|
660
|
-
/**
|
|
661
|
-
* Get the underlying WDK instance
|
|
662
|
-
*
|
|
663
|
-
* @throws {WDKInitializationError} If WDK is not initialized
|
|
664
|
-
*/
|
|
665
|
-
get wdk(): WDKInstance;
|
|
666
|
-
/**
|
|
667
|
-
* Check if WDK is properly initialized
|
|
668
|
-
*/
|
|
669
|
-
get isInitialized(): boolean;
|
|
670
|
-
/**
|
|
671
|
-
* Get initialization error if any
|
|
672
|
-
*/
|
|
673
|
-
get initializationError(): Error | null;
|
|
674
|
-
/**
|
|
675
|
-
* Get all configured chains
|
|
676
|
-
*/
|
|
677
|
-
getConfiguredChains(): string[];
|
|
678
|
-
/**
|
|
679
|
-
* Get chain configuration
|
|
680
|
-
*/
|
|
681
|
-
getChainConfig(chain: string): NormalizedChainConfig | undefined;
|
|
682
|
-
/**
|
|
683
|
-
* Check if a chain is configured
|
|
684
|
-
*/
|
|
685
|
-
isChainConfigured(chain: string): boolean;
|
|
686
|
-
/**
|
|
687
|
-
* Get a T402-compatible signer for a chain
|
|
688
|
-
*
|
|
689
|
-
* @param chain - Chain name (e.g., "arbitrum", "ethereum")
|
|
690
|
-
* @param accountIndex - HD wallet account index (default: 0)
|
|
691
|
-
* @throws {ChainError} If chain is not configured
|
|
692
|
-
* @throws {SignerError} If signer creation fails
|
|
693
|
-
* @returns An initialized WDKSigner
|
|
694
|
-
*/
|
|
695
|
-
getSigner(chain: string, accountIndex?: number): Promise<WDKSigner>;
|
|
696
|
-
/**
|
|
697
|
-
* Clear the signer cache
|
|
698
|
-
* Useful for forcing re-initialization of signers
|
|
699
|
-
*/
|
|
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>;
|
|
775
|
-
/**
|
|
776
|
-
* Get wallet address for a chain
|
|
777
|
-
*
|
|
778
|
-
* @param chain - Chain name
|
|
779
|
-
* @param accountIndex - HD wallet account index (default: 0)
|
|
780
|
-
* @throws {ChainError} If chain is not configured
|
|
781
|
-
* @throws {SignerError} If address fetch fails
|
|
782
|
-
*/
|
|
783
|
-
getAddress(chain: string, accountIndex?: number): Promise<Address>;
|
|
784
|
-
/**
|
|
785
|
-
* Get USDT0 balance for a chain
|
|
786
|
-
*
|
|
787
|
-
* Uses cache if enabled to reduce RPC calls.
|
|
788
|
-
*
|
|
789
|
-
* @throws {BalanceError} If balance fetch fails
|
|
790
|
-
*/
|
|
791
|
-
getUsdt0Balance(chain: string, accountIndex?: number): Promise<bigint>;
|
|
792
|
-
/**
|
|
793
|
-
* Get USDC balance for a chain
|
|
794
|
-
*
|
|
795
|
-
* Uses cache if enabled to reduce RPC calls.
|
|
796
|
-
*
|
|
797
|
-
* @throws {BalanceError} If balance fetch fails
|
|
798
|
-
*/
|
|
799
|
-
getUsdcBalance(chain: string, accountIndex?: number): Promise<bigint>;
|
|
800
|
-
/**
|
|
801
|
-
* Get all token balances for a chain
|
|
802
|
-
*
|
|
803
|
-
* Uses cache if enabled to reduce RPC calls.
|
|
804
|
-
*
|
|
805
|
-
* @throws {ChainError} If chain is not configured
|
|
806
|
-
* @throws {BalanceError} If balance fetch fails
|
|
807
|
-
*/
|
|
808
|
-
getChainBalances(chain: string, accountIndex?: number): Promise<ChainBalance>;
|
|
809
|
-
/**
|
|
810
|
-
* Get aggregated balances across all configured chains
|
|
811
|
-
*
|
|
812
|
-
* @param accountIndex - HD wallet account index (default: 0)
|
|
813
|
-
* @param options - Options for balance aggregation
|
|
814
|
-
*/
|
|
815
|
-
getAggregatedBalances(accountIndex?: number, options?: {
|
|
816
|
-
continueOnError?: boolean;
|
|
817
|
-
}): Promise<AggregatedBalance>;
|
|
818
|
-
/**
|
|
819
|
-
* Find the best chain for a payment
|
|
820
|
-
*
|
|
821
|
-
* Looks for the chain with sufficient balance, prioritizing USDT0.
|
|
822
|
-
*
|
|
823
|
-
* @param amount - Required amount in smallest units
|
|
824
|
-
* @param preferredToken - Preferred token ("USDT0" | "USDC")
|
|
825
|
-
* @throws {BalanceError} If balance aggregation fails
|
|
826
|
-
*/
|
|
827
|
-
findBestChainForPayment(amount: bigint, preferredToken?: 'USDT0' | 'USDC'): Promise<{
|
|
828
|
-
chain: string;
|
|
829
|
-
token: string;
|
|
830
|
-
balance: bigint;
|
|
831
|
-
} | null>;
|
|
832
|
-
/**
|
|
833
|
-
* Bridge USDT0 between chains
|
|
834
|
-
*
|
|
835
|
-
* Uses LayerZero OFT for cross-chain transfers.
|
|
836
|
-
*
|
|
837
|
-
* @param params - Bridge parameters
|
|
838
|
-
* @throws {BridgeError} If bridge is not available or fails
|
|
839
|
-
* @returns Bridge result with transaction hash
|
|
840
|
-
*/
|
|
841
|
-
bridgeUsdt0(params: BridgeParams): Promise<BridgeResult>;
|
|
842
|
-
/**
|
|
843
|
-
* Get chains that support USDT0
|
|
844
|
-
*/
|
|
845
|
-
getUsdt0Chains(): string[];
|
|
846
|
-
/**
|
|
847
|
-
* Get chains that support USDT0 bridging
|
|
848
|
-
*
|
|
849
|
-
* Returns configured chains that have LayerZero OFT bridge support.
|
|
850
|
-
*/
|
|
851
|
-
getBridgeableChains(): string[];
|
|
852
|
-
/**
|
|
853
|
-
* Check if bridging is supported between two chains
|
|
854
|
-
*/
|
|
855
|
-
canBridge(fromChain: string, toChain: string): boolean;
|
|
856
|
-
/**
|
|
857
|
-
* Get all possible bridge destinations from a chain
|
|
858
|
-
*/
|
|
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>;
|
|
893
|
-
/**
|
|
894
|
-
* Check if balance caching is enabled
|
|
895
|
-
*/
|
|
896
|
-
get isCacheEnabled(): boolean;
|
|
897
|
-
/**
|
|
898
|
-
* Get cache configuration
|
|
899
|
-
*/
|
|
900
|
-
getCacheConfig(): BalanceCacheConfig;
|
|
901
|
-
/**
|
|
902
|
-
* Get cache statistics
|
|
903
|
-
*/
|
|
904
|
-
getCacheStats(): BalanceCacheStats;
|
|
905
|
-
/**
|
|
906
|
-
* Invalidate all cached balances
|
|
907
|
-
*
|
|
908
|
-
* Call this after sending transactions to ensure fresh balance data.
|
|
909
|
-
*/
|
|
910
|
-
invalidateBalanceCache(): void;
|
|
911
|
-
/**
|
|
912
|
-
* Invalidate cached balances for a specific chain
|
|
913
|
-
*
|
|
914
|
-
* @param chain - Chain name to invalidate
|
|
915
|
-
* @returns Number of cache entries invalidated
|
|
916
|
-
*/
|
|
917
|
-
invalidateChainCache(chain: string): number;
|
|
918
|
-
/**
|
|
919
|
-
* Invalidate cached balances for a specific address
|
|
920
|
-
*
|
|
921
|
-
* @param address - Address to invalidate (case-insensitive)
|
|
922
|
-
* @returns Number of cache entries invalidated
|
|
923
|
-
*/
|
|
924
|
-
invalidateAddressCache(address: string): number;
|
|
925
|
-
/**
|
|
926
|
-
* Dispose of cache resources
|
|
927
|
-
*
|
|
928
|
-
* Call this when the T402WDK instance is no longer needed.
|
|
929
|
-
*/
|
|
930
|
-
dispose(): void;
|
|
931
|
-
}
|
|
57
|
+
declare function validatePaymentAddress(address: string, family: ChainFamily | 'cosmos'): AddressValidationResult;
|
|
932
58
|
|
|
933
59
|
/**
|
|
934
60
|
* Chain configuration and token addresses for T402 WDK
|
|
@@ -968,230 +94,106 @@ interface TokenInfo {
|
|
|
968
94
|
}
|
|
969
95
|
declare const CHAIN_TOKENS: Record<string, TokenInfo[]>;
|
|
970
96
|
/**
|
|
971
|
-
*
|
|
972
|
-
*/
|
|
973
|
-
declare function normalizeChainConfig(chainName: string, config: string | EvmChainConfig): NormalizedChainConfig;
|
|
974
|
-
/**
|
|
975
|
-
* Get CAIP-2 network ID from chain name
|
|
97
|
+
* Token entry in the chain registry (address is string to support non-EVM)
|
|
976
98
|
*/
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
declare function getChainFromNetwork(network: string): string | undefined;
|
|
982
|
-
/**
|
|
983
|
-
* Get chain ID from chain name
|
|
984
|
-
*/
|
|
985
|
-
declare function getChainId(chain: string): number;
|
|
986
|
-
/**
|
|
987
|
-
* Get all chains that support USDT0
|
|
988
|
-
*/
|
|
989
|
-
declare function getUsdt0Chains(): string[];
|
|
990
|
-
/**
|
|
991
|
-
* Get preferred token for a chain (USDT0 > USDC > USDT)
|
|
992
|
-
*/
|
|
993
|
-
declare function getPreferredToken(chain: string): TokenInfo | undefined;
|
|
994
|
-
|
|
995
|
-
/**
|
|
996
|
-
* Error classes for T402 WDK integration
|
|
997
|
-
*
|
|
998
|
-
* Provides structured error handling with error codes for
|
|
999
|
-
* programmatic error handling and debugging.
|
|
1000
|
-
*/
|
|
1001
|
-
/**
|
|
1002
|
-
* Error codes for WDK operations
|
|
1003
|
-
*/
|
|
1004
|
-
declare enum WDKErrorCode {
|
|
1005
|
-
WDK_NOT_REGISTERED = 1001,
|
|
1006
|
-
WDK_NOT_INITIALIZED = 1002,
|
|
1007
|
-
INVALID_SEED_PHRASE = 1003,
|
|
1008
|
-
WALLET_MANAGER_NOT_REGISTERED = 1004,
|
|
1009
|
-
CHAIN_NOT_CONFIGURED = 2001,
|
|
1010
|
-
CHAIN_NOT_SUPPORTED = 2002,
|
|
1011
|
-
INVALID_CHAIN_CONFIG = 2003,
|
|
1012
|
-
UNKNOWN_CHAIN_ID = 2004,
|
|
1013
|
-
SIGNER_NOT_INITIALIZED = 3001,
|
|
1014
|
-
ACCOUNT_FETCH_FAILED = 3002,
|
|
1015
|
-
ADDRESS_FETCH_FAILED = 3003,
|
|
1016
|
-
SIGN_TYPED_DATA_FAILED = 4001,
|
|
1017
|
-
SIGN_MESSAGE_FAILED = 4002,
|
|
1018
|
-
INVALID_TYPED_DATA = 4003,
|
|
1019
|
-
INVALID_MESSAGE = 4004,
|
|
1020
|
-
USER_REJECTED_SIGNATURE = 4005,
|
|
1021
|
-
BALANCE_FETCH_FAILED = 5001,
|
|
1022
|
-
TOKEN_BALANCE_FETCH_FAILED = 5002,
|
|
1023
|
-
INVALID_TOKEN_ADDRESS = 5003,
|
|
1024
|
-
TRANSACTION_FAILED = 6001,
|
|
1025
|
-
GAS_ESTIMATION_FAILED = 6002,
|
|
1026
|
-
INSUFFICIENT_BALANCE = 6003,
|
|
1027
|
-
TRANSACTION_REVERTED = 6004,
|
|
1028
|
-
TRANSACTION_TIMEOUT = 6005,
|
|
1029
|
-
BRIDGE_NOT_AVAILABLE = 7001,
|
|
1030
|
-
BRIDGE_NOT_SUPPORTED = 7002,
|
|
1031
|
-
BRIDGE_FAILED = 7003,
|
|
1032
|
-
INSUFFICIENT_BRIDGE_FEE = 7004,
|
|
1033
|
-
RPC_ERROR = 8001,
|
|
1034
|
-
RPC_TIMEOUT = 8002,
|
|
1035
|
-
RPC_RATE_LIMITED = 8003,
|
|
1036
|
-
RPC_CONNECTION_FAILED = 8004,
|
|
1037
|
-
PROTOCOL_NOT_REGISTERED = 8101,
|
|
1038
|
-
PROTOCOL_EXECUTION_FAILED = 8102,
|
|
1039
|
-
INVALID_PARAMETER = 8103,
|
|
1040
|
-
UNKNOWN_ERROR = 9999
|
|
1041
|
-
}
|
|
1042
|
-
/**
|
|
1043
|
-
* Base error class for WDK operations
|
|
1044
|
-
*/
|
|
1045
|
-
declare class WDKError extends Error {
|
|
1046
|
-
readonly code: WDKErrorCode;
|
|
1047
|
-
readonly cause?: Error;
|
|
1048
|
-
readonly context?: Record<string, unknown>;
|
|
1049
|
-
constructor(code: WDKErrorCode, message: string, options?: {
|
|
1050
|
-
cause?: Error;
|
|
1051
|
-
context?: Record<string, unknown>;
|
|
1052
|
-
});
|
|
1053
|
-
/**
|
|
1054
|
-
* Create a JSON-serializable representation
|
|
1055
|
-
*/
|
|
1056
|
-
toJSON(): Record<string, unknown>;
|
|
1057
|
-
/**
|
|
1058
|
-
* Check if error is retryable
|
|
1059
|
-
*/
|
|
1060
|
-
isRetryable(): boolean;
|
|
1061
|
-
}
|
|
1062
|
-
/**
|
|
1063
|
-
* Error thrown when WDK is not properly initialized
|
|
1064
|
-
*/
|
|
1065
|
-
declare class WDKInitializationError extends WDKError {
|
|
1066
|
-
constructor(message: string, options?: {
|
|
1067
|
-
cause?: Error;
|
|
1068
|
-
context?: Record<string, unknown>;
|
|
1069
|
-
});
|
|
1070
|
-
}
|
|
1071
|
-
/**
|
|
1072
|
-
* Error thrown for chain-related issues
|
|
1073
|
-
*/
|
|
1074
|
-
declare class ChainError extends WDKError {
|
|
1075
|
-
readonly chain?: string;
|
|
1076
|
-
constructor(code: WDKErrorCode, message: string, options?: {
|
|
1077
|
-
chain?: string;
|
|
1078
|
-
cause?: Error;
|
|
1079
|
-
context?: Record<string, unknown>;
|
|
1080
|
-
});
|
|
1081
|
-
}
|
|
1082
|
-
/**
|
|
1083
|
-
* Error thrown for signer-related issues
|
|
1084
|
-
*/
|
|
1085
|
-
declare class SignerError extends WDKError {
|
|
1086
|
-
readonly chain?: string;
|
|
1087
|
-
readonly address?: string;
|
|
1088
|
-
constructor(code: WDKErrorCode, message: string, options?: {
|
|
1089
|
-
chain?: string;
|
|
1090
|
-
address?: string;
|
|
1091
|
-
cause?: Error;
|
|
1092
|
-
context?: Record<string, unknown>;
|
|
1093
|
-
});
|
|
99
|
+
interface RegistryToken {
|
|
100
|
+
address: string;
|
|
101
|
+
symbol: string;
|
|
102
|
+
decimals: number;
|
|
1094
103
|
}
|
|
1095
104
|
/**
|
|
1096
|
-
*
|
|
105
|
+
* Unified chain registry entry
|
|
1097
106
|
*/
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
});
|
|
107
|
+
interface ChainRegistryEntry {
|
|
108
|
+
family: ChainFamily;
|
|
109
|
+
chainId?: number;
|
|
110
|
+
caip2: string;
|
|
111
|
+
rpcEndpoints: string[];
|
|
112
|
+
tokens: RegistryToken[];
|
|
1105
113
|
}
|
|
1106
114
|
/**
|
|
1107
|
-
*
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
chain?: string;
|
|
1114
|
-
token?: string;
|
|
1115
|
-
cause?: Error;
|
|
1116
|
-
context?: Record<string, unknown>;
|
|
1117
|
-
});
|
|
1118
|
-
}
|
|
1119
|
-
/**
|
|
1120
|
-
* Error thrown for transaction operations
|
|
115
|
+
* Unified chain registry mapping chain names to metadata.
|
|
116
|
+
*
|
|
117
|
+
* Includes EVM chains (derived from existing data), plus TON, TRON, Solana.
|
|
118
|
+
* Existing exports (DEFAULT_CHAINS, USDT0_ADDRESSES, etc.) remain the
|
|
119
|
+
* canonical source for EVM data; the registry provides a single lookup
|
|
120
|
+
* for cross-chain code paths.
|
|
1121
121
|
*/
|
|
1122
|
-
declare
|
|
1123
|
-
readonly chain?: string;
|
|
1124
|
-
readonly txHash?: string;
|
|
1125
|
-
constructor(code: WDKErrorCode, message: string, options?: {
|
|
1126
|
-
chain?: string;
|
|
1127
|
-
txHash?: string;
|
|
1128
|
-
cause?: Error;
|
|
1129
|
-
context?: Record<string, unknown>;
|
|
1130
|
-
});
|
|
1131
|
-
}
|
|
122
|
+
declare const CHAIN_REGISTRY: Record<string, ChainRegistryEntry>;
|
|
1132
123
|
/**
|
|
1133
|
-
*
|
|
1134
|
-
*/
|
|
1135
|
-
declare
|
|
1136
|
-
readonly fromChain?: string;
|
|
1137
|
-
readonly toChain?: string;
|
|
1138
|
-
constructor(code: WDKErrorCode, message: string, options?: {
|
|
1139
|
-
fromChain?: string;
|
|
1140
|
-
toChain?: string;
|
|
1141
|
-
cause?: Error;
|
|
1142
|
-
context?: Record<string, unknown>;
|
|
1143
|
-
});
|
|
1144
|
-
}
|
|
124
|
+
* Look up a chain registry entry by CAIP-2 identifier.
|
|
125
|
+
*/
|
|
126
|
+
declare function getRegistryByCaip2(caip2: string): ChainRegistryEntry | undefined;
|
|
1145
127
|
/**
|
|
1146
|
-
*
|
|
1147
|
-
*/
|
|
1148
|
-
declare
|
|
1149
|
-
readonly endpoint?: string;
|
|
1150
|
-
readonly rpcCode?: number;
|
|
1151
|
-
constructor(code: WDKErrorCode, message: string, options?: {
|
|
1152
|
-
endpoint?: string;
|
|
1153
|
-
rpcCode?: number;
|
|
1154
|
-
cause?: Error;
|
|
1155
|
-
context?: Record<string, unknown>;
|
|
1156
|
-
});
|
|
1157
|
-
}
|
|
128
|
+
* Get all chain names for a given chain family.
|
|
129
|
+
*/
|
|
130
|
+
declare function getChainsByFamily(family: ChainFamily): string[];
|
|
1158
131
|
/**
|
|
1159
|
-
*
|
|
132
|
+
* Normalize chain configuration from string or object
|
|
1160
133
|
*/
|
|
1161
|
-
declare function
|
|
134
|
+
declare function normalizeChainConfig(chainName: string, config: string | EvmChainConfig): NormalizedChainConfig;
|
|
1162
135
|
/**
|
|
1163
|
-
*
|
|
136
|
+
* Get CAIP-2 network ID from chain name
|
|
1164
137
|
*/
|
|
1165
|
-
declare function
|
|
138
|
+
declare function getNetworkFromChain(chain: string): string;
|
|
1166
139
|
/**
|
|
1167
|
-
*
|
|
140
|
+
* Get chain name from CAIP-2 network ID
|
|
1168
141
|
*/
|
|
1169
|
-
declare function
|
|
142
|
+
declare function getChainFromNetwork(network: string): string | undefined;
|
|
1170
143
|
/**
|
|
1171
|
-
*
|
|
144
|
+
* Get chain ID from chain name
|
|
1172
145
|
*/
|
|
1173
|
-
|
|
1174
|
-
/** Maximum number of retries */
|
|
1175
|
-
maxRetries: number;
|
|
1176
|
-
/** Base delay in milliseconds */
|
|
1177
|
-
baseDelay: number;
|
|
1178
|
-
/** Maximum delay in milliseconds */
|
|
1179
|
-
maxDelay: number;
|
|
1180
|
-
/** Whether to use exponential backoff */
|
|
1181
|
-
exponentialBackoff: boolean;
|
|
1182
|
-
}
|
|
146
|
+
declare function getChainId(chain: string): number;
|
|
1183
147
|
/**
|
|
1184
|
-
*
|
|
148
|
+
* Get all chains that support USDT0
|
|
1185
149
|
*/
|
|
1186
|
-
declare
|
|
150
|
+
declare function getUsdt0Chains(): string[];
|
|
1187
151
|
/**
|
|
1188
|
-
*
|
|
152
|
+
* Get preferred token for a chain (USDT0 > USDC > USDT)
|
|
1189
153
|
*/
|
|
1190
|
-
declare function
|
|
154
|
+
declare function getPreferredToken(chain: string): TokenInfo | undefined;
|
|
155
|
+
|
|
1191
156
|
/**
|
|
1192
|
-
*
|
|
157
|
+
* Bridge Delivery Tracking
|
|
158
|
+
*
|
|
159
|
+
* Tracks LayerZero cross-chain bridge message delivery status
|
|
160
|
+
* by polling the LayerZero Scan API.
|
|
1193
161
|
*/
|
|
1194
|
-
|
|
162
|
+
/** Bridge delivery status (mirrors @t402/wdk-bridge BridgeDeliveryStatus) */
|
|
163
|
+
type BridgeDeliveryStatus = 'INFLIGHT' | 'CONFIRMING' | 'DELIVERED' | 'FAILED' | 'BLOCKED';
|
|
164
|
+
/** Options for waiting for delivery */
|
|
165
|
+
interface WaitOptions {
|
|
166
|
+
timeout?: number;
|
|
167
|
+
pollInterval?: number;
|
|
168
|
+
onStatusChange?: (status: BridgeDeliveryStatus) => void;
|
|
169
|
+
}
|
|
170
|
+
/** Result of delivery confirmation */
|
|
171
|
+
interface DeliveryResult {
|
|
172
|
+
success: boolean;
|
|
173
|
+
status: BridgeDeliveryStatus;
|
|
174
|
+
dstTxHash?: `0x${string}`;
|
|
175
|
+
srcTxHash: `0x${string}`;
|
|
176
|
+
messageGuid: `0x${string}`;
|
|
177
|
+
error?: string;
|
|
178
|
+
}
|
|
179
|
+
interface BridgeTrackerConfig {
|
|
180
|
+
apiBaseUrl?: string;
|
|
181
|
+
}
|
|
182
|
+
declare class BridgeTracker {
|
|
183
|
+
private apiBaseUrl;
|
|
184
|
+
constructor(config?: BridgeTrackerConfig);
|
|
185
|
+
/** Get current status of a bridge message */
|
|
186
|
+
getStatus(txHash: string): Promise<{
|
|
187
|
+
status: BridgeDeliveryStatus;
|
|
188
|
+
dstTxHash?: string;
|
|
189
|
+
}>;
|
|
190
|
+
/** Wait for delivery with polling */
|
|
191
|
+
waitForDelivery(txHash: string, options?: WaitOptions): Promise<DeliveryResult>;
|
|
192
|
+
}
|
|
193
|
+
declare function mapLayerZeroStatus(data: unknown): {
|
|
194
|
+
status: BridgeDeliveryStatus;
|
|
195
|
+
dstTxHash?: string;
|
|
196
|
+
};
|
|
1195
197
|
|
|
1196
198
|
/**
|
|
1197
199
|
* USDT0 Bridge integration for T402 WDK
|
|
@@ -1222,14 +224,23 @@ interface BridgeQuoteResult extends BridgeResult {
|
|
|
1222
224
|
*/
|
|
1223
225
|
declare class WdkBridge {
|
|
1224
226
|
private bridges;
|
|
227
|
+
readonly tracker: BridgeTracker;
|
|
228
|
+
constructor(trackerConfig?: BridgeTrackerConfig);
|
|
1225
229
|
/**
|
|
1226
|
-
* Create bridge signer adapter from WDK signer
|
|
230
|
+
* Create bridge signer adapter from WDK signer.
|
|
231
|
+
*
|
|
232
|
+
* Uses JSON-RPC calls for readContract / waitForTransactionReceipt,
|
|
233
|
+
* and delegates writeContract to the WDK signer's sendTransaction.
|
|
1227
234
|
*/
|
|
1228
235
|
private createBridgeSigner;
|
|
1229
236
|
/**
|
|
1230
237
|
* Get or create a bridge instance for a chain
|
|
238
|
+
*
|
|
239
|
+
* @param chain - Chain name (e.g., "arbitrum", "ethereum")
|
|
240
|
+
* @param signer - WDK signer for the chain
|
|
241
|
+
* @param rpcUrl - JSON-RPC endpoint URL for the chain
|
|
1231
242
|
*/
|
|
1232
|
-
getBridge(chain: string, signer: WDKSigner): Usdt0Bridge;
|
|
243
|
+
getBridge(chain: string, signer: WDKSigner, rpcUrl: string): Usdt0Bridge;
|
|
1233
244
|
/**
|
|
1234
245
|
* Check if a chain supports USDT0 bridging
|
|
1235
246
|
*/
|
|
@@ -1354,6 +365,486 @@ declare function checkWalletEvmCompatibility(version: string): CompatibilityResu
|
|
|
1354
365
|
*/
|
|
1355
366
|
declare function getWalletModuleMinVersion(module: keyof typeof WDK_COMPATIBILITY.walletModuleVersions): string | undefined;
|
|
1356
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Idempotent Payment Protection
|
|
370
|
+
*
|
|
371
|
+
* Prevents duplicate payments through idempotency key tracking
|
|
372
|
+
* and nonce management for EVM permits and other chain-specific operations.
|
|
373
|
+
*/
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Idempotency manager interface for preventing duplicate payments
|
|
377
|
+
*/
|
|
378
|
+
interface IdempotencyManager {
|
|
379
|
+
/** Check if a payment with this key has already been processed */
|
|
380
|
+
checkDuplicate(key: string): Promise<boolean>;
|
|
381
|
+
/** Record a completed payment */
|
|
382
|
+
recordPayment(key: string, receipt: EnrichedReceipt): Promise<void>;
|
|
383
|
+
/** Get the current nonce for an address on a chain */
|
|
384
|
+
getNonce(address: string, chain: string): Promise<bigint>;
|
|
385
|
+
/** Increment and return the next nonce for an address on a chain */
|
|
386
|
+
incrementNonce(address: string, chain: string): Promise<bigint>;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* In-memory idempotency manager
|
|
390
|
+
*
|
|
391
|
+
* Tracks payment keys and nonces in memory. Suitable for single-process
|
|
392
|
+
* applications. For distributed systems, implement IdempotencyManager
|
|
393
|
+
* with a shared store (Redis, database, etc.).
|
|
394
|
+
*/
|
|
395
|
+
declare class InMemoryIdempotencyManager implements IdempotencyManager {
|
|
396
|
+
private _payments;
|
|
397
|
+
private _nonces;
|
|
398
|
+
private _recentTxHashes;
|
|
399
|
+
private _maxRecentTxHashes;
|
|
400
|
+
/**
|
|
401
|
+
* @param maxRecentTxHashes - Maximum number of recent tx hashes to track for dedup (default: 1000)
|
|
402
|
+
*/
|
|
403
|
+
constructor(maxRecentTxHashes?: number);
|
|
404
|
+
checkDuplicate(key: string): Promise<boolean>;
|
|
405
|
+
recordPayment(key: string, receipt: EnrichedReceipt): Promise<void>;
|
|
406
|
+
getNonce(address: string, chain: string): Promise<bigint>;
|
|
407
|
+
incrementNonce(address: string, chain: string): Promise<bigint>;
|
|
408
|
+
/**
|
|
409
|
+
* Check if a transaction hash has been seen recently
|
|
410
|
+
*/
|
|
411
|
+
hasTxHash(txHash: string): boolean;
|
|
412
|
+
/**
|
|
413
|
+
* Get a recorded payment by its idempotency key
|
|
414
|
+
*/
|
|
415
|
+
getPayment(key: string): EnrichedReceipt | undefined;
|
|
416
|
+
/**
|
|
417
|
+
* Get the number of recorded payments
|
|
418
|
+
*/
|
|
419
|
+
get size(): number;
|
|
420
|
+
/**
|
|
421
|
+
* Clear all recorded payments and nonces
|
|
422
|
+
*/
|
|
423
|
+
clear(): void;
|
|
424
|
+
private _nonceKey;
|
|
425
|
+
private _addTxHash;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Nonce manager for EVM permit signatures
|
|
429
|
+
*
|
|
430
|
+
* Caches on-chain nonces locally and increments after each use.
|
|
431
|
+
* Supports querying the on-chain nonce to resync.
|
|
432
|
+
*/
|
|
433
|
+
declare class NonceManager {
|
|
434
|
+
private _nonces;
|
|
435
|
+
/**
|
|
436
|
+
* Get the current nonce for an address on a chain.
|
|
437
|
+
* If no cached value exists, uses the provided fetcher to query on-chain.
|
|
438
|
+
*
|
|
439
|
+
* @param address - Wallet address
|
|
440
|
+
* @param chain - Chain identifier
|
|
441
|
+
* @param fetchOnChainNonce - Optional function to query the on-chain nonce
|
|
442
|
+
*/
|
|
443
|
+
getNonce(address: string, chain: string, fetchOnChainNonce?: () => Promise<bigint>): Promise<bigint>;
|
|
444
|
+
/**
|
|
445
|
+
* Increment the nonce after a successful signature/transaction
|
|
446
|
+
*/
|
|
447
|
+
increment(address: string, chain: string): bigint;
|
|
448
|
+
/**
|
|
449
|
+
* Set the nonce to a specific value (e.g., after querying on-chain)
|
|
450
|
+
*/
|
|
451
|
+
set(address: string, chain: string, nonce: bigint): void;
|
|
452
|
+
/**
|
|
453
|
+
* Reset the nonce for an address on a chain (forces re-fetch on next use)
|
|
454
|
+
*/
|
|
455
|
+
reset(address: string, chain: string): void;
|
|
456
|
+
/**
|
|
457
|
+
* Clear all cached nonces
|
|
458
|
+
*/
|
|
459
|
+
clear(): void;
|
|
460
|
+
private _key;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Generate an idempotency key from payment parameters
|
|
464
|
+
*
|
|
465
|
+
* Creates a deterministic key based on the payment details to
|
|
466
|
+
* prevent the same logical payment from being processed twice.
|
|
467
|
+
*/
|
|
468
|
+
declare function generateIdempotencyKey(params: {
|
|
469
|
+
url: string;
|
|
470
|
+
network: string;
|
|
471
|
+
amount: string;
|
|
472
|
+
payTo: string;
|
|
473
|
+
from: string;
|
|
474
|
+
}): string;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Transaction Screening / Compliance
|
|
478
|
+
*
|
|
479
|
+
* Provides a pluggable compliance framework for screening transactions
|
|
480
|
+
* before execution. Supports multiple providers and maintains an audit trail.
|
|
481
|
+
*/
|
|
482
|
+
/**
|
|
483
|
+
* Parameters for a compliance check
|
|
484
|
+
*/
|
|
485
|
+
interface ComplianceCheckParams {
|
|
486
|
+
from: string;
|
|
487
|
+
to: string;
|
|
488
|
+
chain: string;
|
|
489
|
+
amount: bigint;
|
|
490
|
+
asset: string;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Result of a compliance check
|
|
494
|
+
*/
|
|
495
|
+
interface ComplianceResult {
|
|
496
|
+
allowed: boolean;
|
|
497
|
+
reason?: string;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* A provider that performs compliance checks
|
|
501
|
+
*/
|
|
502
|
+
interface ComplianceProvider {
|
|
503
|
+
check(params: ComplianceCheckParams): Promise<ComplianceResult>;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* An audit trail entry for a compliance check
|
|
507
|
+
*/
|
|
508
|
+
interface ComplianceEvent {
|
|
509
|
+
timestamp: number;
|
|
510
|
+
action: 'payment' | 'bridge' | 'swap';
|
|
511
|
+
params: ComplianceCheckParams;
|
|
512
|
+
result: ComplianceResult;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Manages compliance checks across multiple providers
|
|
516
|
+
*
|
|
517
|
+
* All registered providers are checked in order. If any provider
|
|
518
|
+
* returns `allowed: false`, the transaction is blocked.
|
|
519
|
+
*
|
|
520
|
+
* @example
|
|
521
|
+
* ```typescript
|
|
522
|
+
* const manager = new ComplianceManager();
|
|
523
|
+
* manager.registerProvider(new BlacklistProvider(new Set(['0xbad...'])));
|
|
524
|
+
*
|
|
525
|
+
* const result = await manager.check({
|
|
526
|
+
* from: '0xsender...',
|
|
527
|
+
* to: '0xreceiver...',
|
|
528
|
+
* chain: 'eip155:42161',
|
|
529
|
+
* amount: 1000000n,
|
|
530
|
+
* asset: 'USDT0',
|
|
531
|
+
* });
|
|
532
|
+
*
|
|
533
|
+
* if (!result.allowed) {
|
|
534
|
+
* console.log('Blocked:', result.reason);
|
|
535
|
+
* }
|
|
536
|
+
* ```
|
|
537
|
+
*/
|
|
538
|
+
declare class ComplianceManager {
|
|
539
|
+
private _providers;
|
|
540
|
+
private _auditTrail;
|
|
541
|
+
/**
|
|
542
|
+
* Register a compliance provider
|
|
543
|
+
*/
|
|
544
|
+
registerProvider(provider: ComplianceProvider): void;
|
|
545
|
+
/**
|
|
546
|
+
* Run all registered providers against the given parameters.
|
|
547
|
+
* Returns the first rejection, or `{ allowed: true }` if all pass.
|
|
548
|
+
*
|
|
549
|
+
* @param params - The transaction parameters to check
|
|
550
|
+
* @param action - The type of action being performed (default: 'payment')
|
|
551
|
+
*/
|
|
552
|
+
check(params: ComplianceCheckParams, action?: 'payment' | 'bridge' | 'swap'): Promise<ComplianceResult>;
|
|
553
|
+
/**
|
|
554
|
+
* Get the full audit trail of compliance checks
|
|
555
|
+
*/
|
|
556
|
+
getAuditTrail(): ComplianceEvent[];
|
|
557
|
+
/**
|
|
558
|
+
* Clear the audit trail
|
|
559
|
+
*/
|
|
560
|
+
clearAuditTrail(): void;
|
|
561
|
+
/**
|
|
562
|
+
* Get the number of registered providers
|
|
563
|
+
*/
|
|
564
|
+
get providerCount(): number;
|
|
565
|
+
private _recordEvent;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Built-in blacklist compliance provider
|
|
569
|
+
*
|
|
570
|
+
* Blocks transactions involving addresses in the blacklist.
|
|
571
|
+
* Checks both `from` and `to` addresses.
|
|
572
|
+
*/
|
|
573
|
+
declare class BlacklistProvider implements ComplianceProvider {
|
|
574
|
+
private _addresses;
|
|
575
|
+
constructor(addresses?: Set<string>);
|
|
576
|
+
check(params: ComplianceCheckParams): Promise<ComplianceResult>;
|
|
577
|
+
/**
|
|
578
|
+
* Add an address to the blacklist
|
|
579
|
+
*/
|
|
580
|
+
addAddress(address: string): void;
|
|
581
|
+
/**
|
|
582
|
+
* Remove an address from the blacklist
|
|
583
|
+
*/
|
|
584
|
+
removeAddress(address: string): void;
|
|
585
|
+
/**
|
|
586
|
+
* Check if an address is blacklisted
|
|
587
|
+
*/
|
|
588
|
+
hasAddress(address: string): boolean;
|
|
589
|
+
/**
|
|
590
|
+
* Get the number of blacklisted addresses
|
|
591
|
+
*/
|
|
592
|
+
get size(): number;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Amount limit compliance provider
|
|
596
|
+
*
|
|
597
|
+
* Blocks transactions that exceed a configurable per-transaction or
|
|
598
|
+
* cumulative amount limit.
|
|
599
|
+
*/
|
|
600
|
+
declare class AmountLimitProvider implements ComplianceProvider {
|
|
601
|
+
private _maxPerTransaction;
|
|
602
|
+
private _cumulativeAmounts;
|
|
603
|
+
private _maxCumulative;
|
|
604
|
+
/**
|
|
605
|
+
* @param maxPerTransaction - Maximum amount per single transaction
|
|
606
|
+
* @param maxCumulative - Optional maximum cumulative amount per address
|
|
607
|
+
*/
|
|
608
|
+
constructor(maxPerTransaction: bigint, maxCumulative?: bigint);
|
|
609
|
+
check(params: ComplianceCheckParams): Promise<ComplianceResult>;
|
|
610
|
+
/**
|
|
611
|
+
* Reset cumulative tracking for an address
|
|
612
|
+
*/
|
|
613
|
+
resetCumulative(address: string): void;
|
|
614
|
+
/**
|
|
615
|
+
* Reset all cumulative tracking
|
|
616
|
+
*/
|
|
617
|
+
resetAllCumulative(): void;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Webhook Notifications
|
|
622
|
+
*
|
|
623
|
+
* Sends payment event notifications to configured webhook endpoints
|
|
624
|
+
* with HMAC-SHA256 signature verification and retry support.
|
|
625
|
+
*/
|
|
626
|
+
/**
|
|
627
|
+
* Configuration for a webhook endpoint
|
|
628
|
+
*/
|
|
629
|
+
interface WebhookConfig {
|
|
630
|
+
/** The URL to send webhook payloads to */
|
|
631
|
+
url: string;
|
|
632
|
+
/** Secret key for HMAC-SHA256 signing */
|
|
633
|
+
secret: string;
|
|
634
|
+
/** Event types to subscribe to (default: all events) */
|
|
635
|
+
events?: string[];
|
|
636
|
+
/** Number of retry attempts on failure (default: 3) */
|
|
637
|
+
retries?: number;
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Webhook payload for payment events
|
|
641
|
+
*/
|
|
642
|
+
interface PaymentWebhookPayload {
|
|
643
|
+
event: 'payment.completed' | 'payment.failed';
|
|
644
|
+
timestamp: string;
|
|
645
|
+
payment: {
|
|
646
|
+
network: string;
|
|
647
|
+
txHash?: string;
|
|
648
|
+
amount: string;
|
|
649
|
+
asset: string;
|
|
650
|
+
payer: string;
|
|
651
|
+
resource: string;
|
|
652
|
+
};
|
|
653
|
+
signature: string;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Result of a webhook delivery attempt
|
|
657
|
+
*/
|
|
658
|
+
interface WebhookDeliveryResult {
|
|
659
|
+
url: string;
|
|
660
|
+
success: boolean;
|
|
661
|
+
statusCode?: number;
|
|
662
|
+
error?: string;
|
|
663
|
+
attempts: number;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Manages webhook notifications for payment events
|
|
667
|
+
*
|
|
668
|
+
* @example
|
|
669
|
+
* ```typescript
|
|
670
|
+
* const webhooks = new WebhookManager([{
|
|
671
|
+
* url: 'https://example.com/webhooks',
|
|
672
|
+
* secret: 'whsec_...',
|
|
673
|
+
* events: ['payment.completed'],
|
|
674
|
+
* }]);
|
|
675
|
+
*
|
|
676
|
+
* await webhooks.send('payment.completed', {
|
|
677
|
+
* network: 'eip155:42161',
|
|
678
|
+
* amount: '1000000',
|
|
679
|
+
* asset: 'USDT0',
|
|
680
|
+
* payer: '0x...',
|
|
681
|
+
* resource: '/api/premium',
|
|
682
|
+
* });
|
|
683
|
+
* ```
|
|
684
|
+
*/
|
|
685
|
+
declare class WebhookManager {
|
|
686
|
+
private _configs;
|
|
687
|
+
private _deliveryResults;
|
|
688
|
+
private _maxDeliveryHistory;
|
|
689
|
+
/**
|
|
690
|
+
* @param configs - Array of webhook endpoint configurations
|
|
691
|
+
* @param maxDeliveryHistory - Maximum number of delivery results to retain (default: 100)
|
|
692
|
+
*/
|
|
693
|
+
constructor(configs: WebhookConfig[], maxDeliveryHistory?: number);
|
|
694
|
+
/**
|
|
695
|
+
* Send a webhook event to all subscribed endpoints
|
|
696
|
+
*
|
|
697
|
+
* @param event - Event type (e.g., 'payment.completed')
|
|
698
|
+
* @param payload - Event payload data
|
|
699
|
+
* @returns Array of delivery results for each endpoint
|
|
700
|
+
*/
|
|
701
|
+
send(event: string, payload: unknown): Promise<WebhookDeliveryResult[]>;
|
|
702
|
+
/**
|
|
703
|
+
* Sign a payload with HMAC-SHA256
|
|
704
|
+
*
|
|
705
|
+
* @param payload - The payload to sign (will be JSON.stringify'd if not a string)
|
|
706
|
+
* @param secret - The secret key
|
|
707
|
+
* @returns Hex-encoded HMAC-SHA256 signature
|
|
708
|
+
*/
|
|
709
|
+
signPayload(payload: unknown, secret: string): string;
|
|
710
|
+
/**
|
|
711
|
+
* Verify an HMAC-SHA256 signature on a payload
|
|
712
|
+
*
|
|
713
|
+
* @param payload - The raw payload string
|
|
714
|
+
* @param signature - The signature to verify
|
|
715
|
+
* @param secret - The secret key
|
|
716
|
+
* @returns True if the signature is valid
|
|
717
|
+
*/
|
|
718
|
+
verifySignature(payload: string, signature: string, secret: string): boolean;
|
|
719
|
+
/**
|
|
720
|
+
* Get recent delivery results
|
|
721
|
+
*/
|
|
722
|
+
getDeliveryResults(): WebhookDeliveryResult[];
|
|
723
|
+
/**
|
|
724
|
+
* Clear delivery history
|
|
725
|
+
*/
|
|
726
|
+
clearDeliveryResults(): void;
|
|
727
|
+
/**
|
|
728
|
+
* Get the number of configured webhook endpoints
|
|
729
|
+
*/
|
|
730
|
+
get endpointCount(): number;
|
|
731
|
+
private _deliver;
|
|
732
|
+
private _recordResult;
|
|
733
|
+
private _sleep;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* WDK Indexer Verifier - Unified cross-chain transaction verification.
|
|
738
|
+
*
|
|
739
|
+
* Uses wdk-indexer-http for querying transactions across EVM, TON, TRON, Solana.
|
|
740
|
+
* Falls back to chain-specific RPC verification if indexer is unavailable.
|
|
741
|
+
*/
|
|
742
|
+
/**
|
|
743
|
+
* Configuration for the WDK indexer verifier
|
|
744
|
+
*/
|
|
745
|
+
interface WdkIndexerConfig {
|
|
746
|
+
/** Indexer HTTP endpoint */
|
|
747
|
+
endpoint: string;
|
|
748
|
+
/** API key (optional) */
|
|
749
|
+
apiKey?: string;
|
|
750
|
+
/** Request timeout in ms (default: 10000) */
|
|
751
|
+
timeout?: number;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Query parameters for a transaction
|
|
755
|
+
*/
|
|
756
|
+
interface TransactionQuery {
|
|
757
|
+
/** Transaction hash */
|
|
758
|
+
txHash: string;
|
|
759
|
+
/** Network identifier (CAIP-2 or chain name) */
|
|
760
|
+
network: string;
|
|
761
|
+
/** Expected recipient address */
|
|
762
|
+
expectedTo?: string;
|
|
763
|
+
/** Expected amount in smallest units */
|
|
764
|
+
expectedAmount?: string;
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Result of a transaction query
|
|
768
|
+
*/
|
|
769
|
+
interface TransactionResult {
|
|
770
|
+
/** Whether the transaction was found */
|
|
771
|
+
found: boolean;
|
|
772
|
+
/** Whether the transaction is confirmed */
|
|
773
|
+
confirmed: boolean;
|
|
774
|
+
/** Sender address */
|
|
775
|
+
from: string;
|
|
776
|
+
/** Recipient address */
|
|
777
|
+
to: string;
|
|
778
|
+
/** Transfer amount in smallest units */
|
|
779
|
+
amount: string;
|
|
780
|
+
/** Token contract address or symbol */
|
|
781
|
+
token: string;
|
|
782
|
+
/** Block number (if confirmed) */
|
|
783
|
+
blockNumber?: number;
|
|
784
|
+
/** Block timestamp (if confirmed) */
|
|
785
|
+
timestamp?: number;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Verification result
|
|
789
|
+
*/
|
|
790
|
+
interface PaymentVerification {
|
|
791
|
+
/** Whether the payment is verified */
|
|
792
|
+
verified: boolean;
|
|
793
|
+
/** Reason for failure (if not verified) */
|
|
794
|
+
reason?: string;
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* WDK Indexer Verifier
|
|
798
|
+
*
|
|
799
|
+
* Provides unified cross-chain transaction verification by querying
|
|
800
|
+
* a wdk-indexer-http endpoint. This enables the facilitator to verify
|
|
801
|
+
* payments across all supported chains through a single API.
|
|
802
|
+
*
|
|
803
|
+
* @example
|
|
804
|
+
* ```typescript
|
|
805
|
+
* import { WdkIndexerVerifier } from '@t402/wdk';
|
|
806
|
+
*
|
|
807
|
+
* const verifier = new WdkIndexerVerifier({
|
|
808
|
+
* endpoint: 'https://indexer.example.com',
|
|
809
|
+
* apiKey: 'your-api-key',
|
|
810
|
+
* });
|
|
811
|
+
*
|
|
812
|
+
* // Verify a payment
|
|
813
|
+
* const result = await verifier.verifyPayment({
|
|
814
|
+
* txHash: '0xabc...',
|
|
815
|
+
* network: 'eip155:42161',
|
|
816
|
+
* expectedTo: '0xpayee...',
|
|
817
|
+
* expectedAmount: '1000000',
|
|
818
|
+
* });
|
|
819
|
+
*
|
|
820
|
+
* if (result.verified) {
|
|
821
|
+
* console.log('Payment verified');
|
|
822
|
+
* }
|
|
823
|
+
* ```
|
|
824
|
+
*/
|
|
825
|
+
declare class WdkIndexerVerifier {
|
|
826
|
+
private endpoint;
|
|
827
|
+
private apiKey?;
|
|
828
|
+
private timeout;
|
|
829
|
+
constructor(config: WdkIndexerConfig);
|
|
830
|
+
/**
|
|
831
|
+
* Query a transaction across any supported chain
|
|
832
|
+
*/
|
|
833
|
+
queryTransaction(query: TransactionQuery): Promise<TransactionResult>;
|
|
834
|
+
/**
|
|
835
|
+
* Verify a transaction matches expected payment parameters
|
|
836
|
+
*/
|
|
837
|
+
verifyPayment(query: TransactionQuery): Promise<PaymentVerification>;
|
|
838
|
+
/**
|
|
839
|
+
* Check indexer health
|
|
840
|
+
*/
|
|
841
|
+
healthCheck(): Promise<boolean>;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Create a WDK indexer verifier
|
|
845
|
+
*/
|
|
846
|
+
declare function createIndexerVerifier(config: WdkIndexerConfig): WdkIndexerVerifier;
|
|
847
|
+
|
|
1357
848
|
/**
|
|
1358
849
|
* Hardware wallet type definitions for T402 WDK
|
|
1359
850
|
*/
|
|
@@ -1730,4 +1221,97 @@ declare function detectHardwareWalletSupport(): {
|
|
|
1730
1221
|
*/
|
|
1731
1222
|
declare function isHardwareWalletSupported(): boolean;
|
|
1732
1223
|
|
|
1733
|
-
|
|
1224
|
+
/**
|
|
1225
|
+
* Moonpay fiat on-ramp provider for T402 WDK
|
|
1226
|
+
*
|
|
1227
|
+
* Enables zero-crypto users to purchase USDT/USDT0 directly
|
|
1228
|
+
* via Moonpay's widget and fund their wallet for T402 payments.
|
|
1229
|
+
*/
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* Moonpay provider configuration
|
|
1233
|
+
*/
|
|
1234
|
+
interface MoonpayConfig {
|
|
1235
|
+
/** Moonpay API key */
|
|
1236
|
+
apiKey: string;
|
|
1237
|
+
/** Environment (default: 'production') */
|
|
1238
|
+
environment?: 'sandbox' | 'production';
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
* MoonpayOnRampProvider - Fiat on-ramp via Moonpay
|
|
1242
|
+
*
|
|
1243
|
+
* @example
|
|
1244
|
+
* ```typescript
|
|
1245
|
+
* import { MoonpayOnRampProvider } from '@t402/wdk';
|
|
1246
|
+
*
|
|
1247
|
+
* const moonpay = new MoonpayOnRampProvider({
|
|
1248
|
+
* apiKey: 'pk_test_...',
|
|
1249
|
+
* environment: 'sandbox',
|
|
1250
|
+
* });
|
|
1251
|
+
*
|
|
1252
|
+
* // Get a quote
|
|
1253
|
+
* const quote = await moonpay.getQuote({
|
|
1254
|
+
* fiatAmount: 100,
|
|
1255
|
+
* fiatCurrency: 'USD',
|
|
1256
|
+
* network: 'eip155:42161',
|
|
1257
|
+
* });
|
|
1258
|
+
*
|
|
1259
|
+
* // Create widget URL for the user
|
|
1260
|
+
* const result = moonpay.createWidget({
|
|
1261
|
+
* fiatAmount: 100,
|
|
1262
|
+
* fiatCurrency: 'USD',
|
|
1263
|
+
* walletAddress: '0x...',
|
|
1264
|
+
* network: 'eip155:42161',
|
|
1265
|
+
* });
|
|
1266
|
+
*
|
|
1267
|
+
* // Open result.widgetUrl in browser/webview
|
|
1268
|
+
* ```
|
|
1269
|
+
*/
|
|
1270
|
+
declare class MoonpayOnRampProvider implements FiatOnRampProvider {
|
|
1271
|
+
readonly name = "moonpay";
|
|
1272
|
+
private _apiKey;
|
|
1273
|
+
private _environment;
|
|
1274
|
+
constructor(config: MoonpayConfig);
|
|
1275
|
+
/**
|
|
1276
|
+
* Get the base widget URL for the current environment
|
|
1277
|
+
*/
|
|
1278
|
+
get baseUrl(): string;
|
|
1279
|
+
/**
|
|
1280
|
+
* Get the API base URL for the current environment
|
|
1281
|
+
*/
|
|
1282
|
+
get apiUrl(): string;
|
|
1283
|
+
/**
|
|
1284
|
+
* Get a quote for fiat-to-crypto conversion
|
|
1285
|
+
*
|
|
1286
|
+
* This method fetches a real-time quote from Moonpay.
|
|
1287
|
+
* Override `_fetchQuote` for testing.
|
|
1288
|
+
*/
|
|
1289
|
+
getQuote(params: Pick<FiatOnRampParams, 'fiatAmount' | 'fiatCurrency' | 'network'>): Promise<FiatOnRampQuote>;
|
|
1290
|
+
/**
|
|
1291
|
+
* Fetch quote from Moonpay API (override in tests)
|
|
1292
|
+
*/
|
|
1293
|
+
_fetchQuote(url: string): Promise<Record<string, unknown>>;
|
|
1294
|
+
/**
|
|
1295
|
+
* Create a Moonpay widget URL for the user
|
|
1296
|
+
*/
|
|
1297
|
+
createWidget(params: FiatOnRampParams): FiatOnRampResult;
|
|
1298
|
+
/**
|
|
1299
|
+
* Get supported fiat currencies
|
|
1300
|
+
*/
|
|
1301
|
+
getSupportedCurrencies(): string[];
|
|
1302
|
+
/**
|
|
1303
|
+
* Get supported CAIP-2 networks
|
|
1304
|
+
*/
|
|
1305
|
+
getSupportedNetworks(): string[];
|
|
1306
|
+
/**
|
|
1307
|
+
* Map CAIP-2 network to Moonpay currency code
|
|
1308
|
+
*/
|
|
1309
|
+
private _getCurrencyCode;
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Get the Moonpay currency code for a CAIP-2 network
|
|
1313
|
+
* Exported for testing
|
|
1314
|
+
*/
|
|
1315
|
+
declare function getMoonpayCurrencyCode(network: string): string | undefined;
|
|
1316
|
+
|
|
1317
|
+
export { type AddressValidationResult, AmountLimitProvider, BlacklistProvider, type BridgeDeliveryStatus, type BridgeQuoteResult, BridgeResult, BridgeTracker, type BridgeTrackerConfig, CHAIN_REGISTRY, CHAIN_TOKENS, ChainFamily, type ChainRegistryEntry, type CompatibilityResult, type ComplianceCheckParams, type ComplianceEvent, ComplianceManager, type ComplianceProvider, type ComplianceResult, DEFAULT_CHAINS, DEFAULT_RPC_ENDPOINTS, type DeliveryResult, type DeviceStatus, EnrichedReceipt, EvmChainConfig, FiatOnRampParams, FiatOnRampProvider, FiatOnRampQuote, FiatOnRampResult, type HardwareWalletConnectionOptions, type HardwareWalletDeviceInfo, HardwareWalletError, HardwareWalletErrorCode, type HardwareWalletSigner, type HardwareWalletType, type IdempotencyManager, InMemoryIdempotencyManager, type LedgerOptions, LedgerSigner, type MoonpayConfig, MoonpayOnRampProvider, NonceManager, NormalizedChainConfig, type PaymentVerification, type PaymentWebhookPayload, type RegistryToken, type TokenInfo, type TransactionQuery, type TransactionResult, type TrezorOptions, TrezorSigner, USDC_ADDRESSES, USDT0_ADDRESSES, USDT_LEGACY_ADDRESSES, WDKSigner, WDK_COMPATIBILITY, type WaitOptions, WdkBridge, type WdkIndexerConfig, WdkIndexerVerifier, type WebhookConfig, type WebhookDeliveryResult, WebhookManager, checkWalletEvmCompatibility, checkWdkCompatibility, createDirectBridge, createIndexerVerifier, createLedgerSigner, createTrezorSigner, detectHardwareWalletSupport, generateIdempotencyKey, getChainFromNetwork, getChainId, getChainsByFamily, getMoonpayCurrencyCode, getNetworkFromChain, getPreferredToken, getRegistryByCaip2, getUsdt0Chains, getWalletModuleMinVersion, isHardwareWalletSupported, mapLayerZeroStatus, normalizeChainConfig, validatePaymentAddress };
|