@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.
Files changed (61) hide show
  1. package/dist/cjs/adapters/index.d.ts +198 -1
  2. package/dist/cjs/adapters/index.js +255 -0
  3. package/dist/cjs/adapters/index.js.map +1 -1
  4. package/dist/cjs/adapters/svm-adapter.d.ts +146 -2
  5. package/dist/cjs/adapters/svm-adapter.js +255 -2
  6. package/dist/cjs/adapters/svm-adapter.js.map +1 -1
  7. package/dist/cjs/adapters/ton-adapter.d.ts +57 -2
  8. package/dist/cjs/adapters/ton-adapter.js +75 -2
  9. package/dist/cjs/adapters/ton-adapter.js.map +1 -1
  10. package/dist/cjs/adapters/tron-adapter.d.ts +57 -2
  11. package/dist/cjs/adapters/tron-adapter.js +101 -0
  12. package/dist/cjs/adapters/tron-adapter.js.map +1 -1
  13. package/dist/cjs/index-DnEI5M6d.d.ts +1798 -0
  14. package/dist/cjs/index.d.ts +702 -1118
  15. package/dist/cjs/index.js +3905 -246
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/integrations/index.d.ts +9 -0
  18. package/dist/cjs/integrations/index.js +249 -0
  19. package/dist/cjs/integrations/index.js.map +1 -0
  20. package/dist/cjs/testing/index.d.ts +62 -0
  21. package/dist/cjs/testing/index.js +129 -0
  22. package/dist/cjs/testing/index.js.map +1 -0
  23. package/dist/cjs/types-BwK8Xgvg.d.ts +967 -0
  24. package/dist/esm/adapters/index.d.mts +198 -1
  25. package/dist/esm/adapters/index.mjs +14 -3
  26. package/dist/esm/adapters/svm-adapter.d.mts +146 -2
  27. package/dist/esm/adapters/svm-adapter.mjs +18 -3
  28. package/dist/esm/adapters/ton-adapter.d.mts +57 -2
  29. package/dist/esm/adapters/ton-adapter.mjs +8 -3
  30. package/dist/esm/adapters/tron-adapter.d.mts +57 -2
  31. package/dist/esm/adapters/tron-adapter.mjs +2 -1
  32. package/dist/esm/chunk-2KWVW77U.mjs +353 -0
  33. package/dist/esm/chunk-2KWVW77U.mjs.map +1 -0
  34. package/dist/esm/chunk-7CG77QAN.mjs +153 -0
  35. package/dist/esm/chunk-7CG77QAN.mjs.map +1 -0
  36. package/dist/esm/chunk-BJTO5JO5.mjs +11 -0
  37. package/dist/esm/chunk-BJTO5JO5.mjs.map +1 -0
  38. package/dist/esm/{chunk-YWBJJV5M.mjs → chunk-KWX6CJIH.mjs} +72 -1
  39. package/dist/esm/chunk-KWX6CJIH.mjs.map +1 -0
  40. package/dist/esm/{chunk-HB2DGKQ3.mjs → chunk-QZKUU2O6.mjs} +102 -1
  41. package/dist/esm/chunk-QZKUU2O6.mjs.map +1 -0
  42. package/dist/esm/chunk-TVSNUSFZ.mjs +219 -0
  43. package/dist/esm/chunk-TVSNUSFZ.mjs.map +1 -0
  44. package/dist/esm/index-D5kvtDfm.d.mts +1798 -0
  45. package/dist/esm/index.d.mts +702 -1118
  46. package/dist/esm/index.mjs +2934 -70
  47. package/dist/esm/index.mjs.map +1 -1
  48. package/dist/esm/integrations/index.d.mts +9 -0
  49. package/dist/esm/integrations/index.mjs +16 -0
  50. package/dist/esm/integrations/index.mjs.map +1 -0
  51. package/dist/esm/testing/index.d.mts +62 -0
  52. package/dist/esm/testing/index.mjs +101 -0
  53. package/dist/esm/testing/index.mjs.map +1 -0
  54. package/dist/esm/types-BwK8Xgvg.d.mts +967 -0
  55. package/package.json +69 -20
  56. package/dist/cjs/types-V7c-qhn6.d.ts +0 -489
  57. package/dist/esm/chunk-HB2DGKQ3.mjs.map +0 -1
  58. package/dist/esm/chunk-MCFHZSF7.mjs +0 -107
  59. package/dist/esm/chunk-MCFHZSF7.mjs.map +0 -1
  60. package/dist/esm/chunk-YWBJJV5M.mjs.map +0 -1
  61. package/dist/esm/types-V7c-qhn6.d.mts +0 -489
@@ -0,0 +1,1798 @@
1
+ import { Address } from 'viem';
2
+ import { d as WDKInstance, Z as WDKConstructor, a4 as WDKWalletModules, a3 as WDKProtocolModules, F as FiatOnRampProvider, a2 as WDKModulesConfig, I as T402WDKCreateConfig, Y as WDKAutoDiscoveryResult, H as T402WDKConfig, q as FromWDKOptions, J as T402WDKOptions, G as GetAllSignersOptions, S as SignerEntry, N as NormalizedChainConfig, C as ChainFamily, m as ChainBalance, A as AggregatedBalance, l as BridgeParams, B as BridgeResult, x as SwapQuote, w as SwapParams, y as SwapResult, i as BorrowParams, j as BorrowResult, e as FiatOnRampParams, f as FiatOnRampQuote, g as FiatOnRampResult, P as ProviderStatus } from './types-BwK8Xgvg.js';
3
+ import { ClientTonSigner } from './adapters/ton-adapter.js';
4
+ import { TransactionSigner } from './adapters/svm-adapter.js';
5
+ import { ClientTronSigner } from './adapters/tron-adapter.js';
6
+ import { WDKSparkSignerAdapter, WDKBtcSignerAdapter } from './adapters/index.js';
7
+ import { ClientEvmSigner } from '@t402/evm';
8
+ import { MoneyParser, Network } from '@t402/core/types';
9
+
10
+ /**
11
+ * WDK Secret Manager
12
+ *
13
+ * Encrypted seed phrase storage and retrieval using
14
+ * AES-256-GCM with PBKDF2 key derivation.
15
+ *
16
+ * Includes:
17
+ * - Key rotation with KDF iteration upgrades
18
+ * - Pluggable SecretManager interface
19
+ * - Backup/recovery with metadata and verification
20
+ */
21
+ interface EncryptedSeed {
22
+ /** Encrypted seed data (base64) */
23
+ ciphertext: string;
24
+ /** Encryption algorithm identifier */
25
+ algorithm: string;
26
+ /** KDF parameters */
27
+ kdf: {
28
+ salt: string;
29
+ iterations: number;
30
+ keyLength: number;
31
+ hash: string;
32
+ };
33
+ /** Initialization vector (base64) */
34
+ iv: string;
35
+ /** Version for forward compatibility */
36
+ version: number;
37
+ }
38
+ /**
39
+ * Pluggable secret manager interface
40
+ *
41
+ * Allows custom encryption backends (e.g., HSM, cloud KMS).
42
+ * The default implementation uses Node.js crypto.
43
+ */
44
+ interface SecretManager {
45
+ encrypt(data: string, password: string): Promise<EncryptedSeed>;
46
+ decrypt(encrypted: EncryptedSeed, password: string): Promise<string>;
47
+ }
48
+ /**
49
+ * Metadata included with seed backups
50
+ */
51
+ interface BackupMetadata {
52
+ createdAt: string;
53
+ version: number;
54
+ supportedChains: string[];
55
+ /** Chain name -> first derived address hint for verification */
56
+ addressHints: Record<string, string>;
57
+ }
58
+ /**
59
+ * Encrypt a seed phrase using AES-256-GCM with PBKDF2 key derivation.
60
+ *
61
+ * When @tetherto/wdk-secret-manager is available, delegates to it.
62
+ * Falls back to Node.js crypto for standalone use.
63
+ *
64
+ * @param seedPhrase - The BIP-39 seed phrase to encrypt
65
+ * @param password - The password to derive the encryption key from
66
+ * @returns The encrypted seed data
67
+ */
68
+ declare function encryptSeed(seedPhrase: string, password: string): Promise<EncryptedSeed>;
69
+ /**
70
+ * Decrypt a seed phrase from encrypted storage.
71
+ *
72
+ * @param encrypted - The encrypted seed data
73
+ * @param password - The password to derive the decryption key from
74
+ * @returns The decrypted seed phrase
75
+ * @throws Error if password is wrong or data is corrupted
76
+ */
77
+ declare function decryptSeed(encrypted: EncryptedSeed, password: string): Promise<string>;
78
+ /**
79
+ * Rotate the password on an encrypted seed.
80
+ *
81
+ * Decrypts with the old password, then re-encrypts with the new password.
82
+ * Optionally upgrades KDF iterations (e.g., 100k -> 600k) and bumps version to 2.
83
+ *
84
+ * @param encrypted - The existing encrypted seed
85
+ * @param oldPassword - The current password
86
+ * @param newPassword - The new password to encrypt with
87
+ * @param options - Optional iteration upgrade
88
+ * @returns A new EncryptedSeed encrypted with the new password
89
+ */
90
+ declare function rotateSeedPassword(encrypted: EncryptedSeed, oldPassword: string, newPassword: string, options?: {
91
+ iterations?: number;
92
+ }): Promise<EncryptedSeed>;
93
+ /**
94
+ * Register a custom secret manager
95
+ *
96
+ * @param manager - The secret manager implementation to use
97
+ */
98
+ declare function registerSecretManager(manager: SecretManager): void;
99
+ /**
100
+ * Get the current secret manager
101
+ *
102
+ * Returns the registered secret manager, or a default implementation
103
+ * that uses the built-in encryptSeed/decryptSeed functions.
104
+ */
105
+ declare function getSecretManager(): SecretManager;
106
+ /**
107
+ * Create a JSON backup of an encrypted seed with metadata
108
+ *
109
+ * @param seedPhrase - The BIP-39 seed phrase to backup
110
+ * @param password - The password to encrypt the backup with
111
+ * @param metadata - Backup metadata (chains, address hints, etc.)
112
+ * @returns JSON string containing the encrypted seed and metadata
113
+ */
114
+ declare function createBackup(seedPhrase: string, password: string, metadata: BackupMetadata): Promise<string>;
115
+ /**
116
+ * Verify a backup by attempting to decrypt and optionally checking address hints
117
+ *
118
+ * @param backup - The JSON backup string
119
+ * @param password - The password to decrypt with
120
+ * @param expectedAddresses - Optional map of chain -> expected address for verification
121
+ * @returns Object with `valid` (decryption succeeded) and `addressMatch` (addresses match if provided)
122
+ */
123
+ declare function verifyBackup(backup: string, password: string, expectedAddresses?: Record<string, string>): Promise<{
124
+ valid: boolean;
125
+ addressMatch: boolean;
126
+ metadata?: BackupMetadata;
127
+ }>;
128
+
129
+ /**
130
+ * T402 Payment Event Emitter
131
+ *
132
+ * Provides typed event emission for tracking payment lifecycle,
133
+ * balance changes, bridge operations, and signer initialization.
134
+ */
135
+ /** T402 event types */
136
+ interface T402Events {
137
+ 'payment:start': {
138
+ url: string;
139
+ network: string;
140
+ amount: string;
141
+ };
142
+ 'payment:signed': {
143
+ url: string;
144
+ scheme: string;
145
+ network: string;
146
+ };
147
+ 'payment:submitted': {
148
+ url: string;
149
+ statusCode: number;
150
+ };
151
+ 'payment:complete': {
152
+ url: string;
153
+ success: boolean;
154
+ receipt?: unknown;
155
+ };
156
+ 'payment:failed': {
157
+ url: string;
158
+ error: string;
159
+ };
160
+ 'balance:changed': {
161
+ chain: string;
162
+ token: string;
163
+ previousBalance: bigint;
164
+ newBalance: bigint;
165
+ };
166
+ 'bridge:start': {
167
+ fromChain: string;
168
+ toChain: string;
169
+ amount: bigint;
170
+ };
171
+ 'bridge:confirmed': {
172
+ txHash: string;
173
+ fromChain: string;
174
+ toChain: string;
175
+ };
176
+ 'bridge:delivered': {
177
+ txHash: string;
178
+ dstTxHash?: string;
179
+ status: string;
180
+ };
181
+ 'signer:initialized': {
182
+ chain: string;
183
+ address: string;
184
+ family: string;
185
+ };
186
+ }
187
+ type EventHandler<T> = (data: T) => void;
188
+ declare class T402EventEmitter {
189
+ private handlers;
190
+ on<K extends keyof T402Events>(event: K, handler: EventHandler<T402Events[K]>): this;
191
+ off<K extends keyof T402Events>(event: K, handler: EventHandler<T402Events[K]>): this;
192
+ once<K extends keyof T402Events>(event: K, handler: EventHandler<T402Events[K]>): this;
193
+ emit<K extends keyof T402Events>(event: K, data: T402Events[K]): boolean;
194
+ removeAllListeners(event?: keyof T402Events): this;
195
+ listenerCount(event: keyof T402Events): number;
196
+ }
197
+
198
+ /**
199
+ * Payment Receipt History
200
+ *
201
+ * Provides in-memory storage and querying of enriched payment receipts.
202
+ * Custom backends can be plugged in by implementing PaymentReceiptStore.
203
+ */
204
+ interface EnrichedReceipt {
205
+ id: string;
206
+ timestamp: string;
207
+ url: string;
208
+ network: string;
209
+ scheme: string;
210
+ amount: string;
211
+ payTo: string;
212
+ success: boolean;
213
+ txHash?: string;
214
+ chainFamily: string;
215
+ error?: string;
216
+ }
217
+ interface ReceiptFilter {
218
+ network?: string;
219
+ chainFamily?: string;
220
+ success?: boolean;
221
+ fromDate?: string;
222
+ toDate?: string;
223
+ minAmount?: string;
224
+ maxAmount?: string;
225
+ limit?: number;
226
+ offset?: number;
227
+ }
228
+ interface PaymentReceiptStore {
229
+ save(receipt: EnrichedReceipt): Promise<void>;
230
+ getById(id: string): Promise<EnrichedReceipt | null>;
231
+ query(filter?: ReceiptFilter): Promise<EnrichedReceipt[]>;
232
+ getAll(): Promise<EnrichedReceipt[]>;
233
+ count(filter?: ReceiptFilter): Promise<number>;
234
+ clear(): Promise<void>;
235
+ exportJSON(): Promise<string>;
236
+ }
237
+ declare class InMemoryReceiptStore implements PaymentReceiptStore {
238
+ private receipts;
239
+ save(receipt: EnrichedReceipt): Promise<void>;
240
+ getById(id: string): Promise<EnrichedReceipt | null>;
241
+ query(filter?: ReceiptFilter): Promise<EnrichedReceipt[]>;
242
+ getAll(): Promise<EnrichedReceipt[]>;
243
+ count(filter?: ReceiptFilter): Promise<number>;
244
+ clear(): Promise<void>;
245
+ exportJSON(): Promise<string>;
246
+ }
247
+
248
+ /**
249
+ * TTL Cache implementation for balance caching
250
+ *
251
+ * Provides a generic cache with configurable TTL (Time To Live) for
252
+ * reducing RPC calls and improving performance.
253
+ */
254
+ /**
255
+ * Cache configuration options
256
+ */
257
+ interface CacheConfig {
258
+ /** Default TTL in milliseconds (default: 30000 = 30 seconds) */
259
+ defaultTTL: number;
260
+ /** Maximum number of entries (default: 1000) */
261
+ maxSize: number;
262
+ /** Whether to refresh TTL on access (default: false) */
263
+ refreshOnAccess: boolean;
264
+ }
265
+ /**
266
+ * Default cache configuration
267
+ */
268
+ declare const DEFAULT_CACHE_CONFIG: CacheConfig;
269
+ /**
270
+ * Generic TTL cache implementation
271
+ *
272
+ * @example
273
+ * ```typescript
274
+ * const cache = new TTLCache<bigint>({ defaultTTL: 60000 });
275
+ *
276
+ * // Set with default TTL
277
+ * cache.set('balance:arbitrum:0x123', 1000000n);
278
+ *
279
+ * // Set with custom TTL
280
+ * cache.set('balance:ethereum:0x456', 2000000n, 120000);
281
+ *
282
+ * // Get value (returns undefined if expired)
283
+ * const balance = cache.get('balance:arbitrum:0x123');
284
+ *
285
+ * // Check if key exists and is not expired
286
+ * if (cache.has('balance:arbitrum:0x123')) {
287
+ * // Use cached value
288
+ * }
289
+ * ```
290
+ */
291
+ declare class TTLCache<T> {
292
+ private _cache;
293
+ private _config;
294
+ private _cleanupInterval;
295
+ constructor(config?: Partial<CacheConfig>);
296
+ /**
297
+ * Get a value from the cache
298
+ *
299
+ * @param key - Cache key
300
+ * @returns The cached value or undefined if not found/expired
301
+ */
302
+ get(key: string): T | undefined;
303
+ /**
304
+ * Set a value in the cache
305
+ *
306
+ * @param key - Cache key
307
+ * @param value - Value to cache
308
+ * @param ttl - TTL in milliseconds (optional, uses default if not provided)
309
+ */
310
+ set(key: string, value: T, ttl?: number): void;
311
+ /**
312
+ * Check if a key exists and is not expired
313
+ *
314
+ * @param key - Cache key
315
+ * @returns true if key exists and is not expired
316
+ */
317
+ has(key: string): boolean;
318
+ /**
319
+ * Delete a key from the cache
320
+ *
321
+ * @param key - Cache key
322
+ * @returns true if key was deleted
323
+ */
324
+ delete(key: string): boolean;
325
+ /**
326
+ * Delete all keys matching a prefix
327
+ *
328
+ * @param prefix - Key prefix to match
329
+ * @returns Number of keys deleted
330
+ */
331
+ deleteByPrefix(prefix: string): number;
332
+ /**
333
+ * Clear all entries from the cache
334
+ */
335
+ clear(): void;
336
+ /**
337
+ * Get the number of entries in the cache (including expired)
338
+ */
339
+ get size(): number;
340
+ /**
341
+ * Get the number of valid (non-expired) entries
342
+ */
343
+ get validSize(): number;
344
+ /**
345
+ * Get all valid keys
346
+ */
347
+ keys(): string[];
348
+ /**
349
+ * Get remaining TTL for a key in milliseconds
350
+ *
351
+ * @param key - Cache key
352
+ * @returns Remaining TTL in ms, or -1 if not found/expired
353
+ */
354
+ getTTL(key: string): number;
355
+ /**
356
+ * Update TTL for an existing key
357
+ *
358
+ * @param key - Cache key
359
+ * @param ttl - New TTL in milliseconds
360
+ * @returns true if key exists and TTL was updated
361
+ */
362
+ touch(key: string, ttl?: number): boolean;
363
+ /**
364
+ * Get or set a value using a factory function
365
+ *
366
+ * @param key - Cache key
367
+ * @param factory - Function to create value if not cached
368
+ * @param ttl - TTL in milliseconds (optional)
369
+ * @returns The cached or newly created value
370
+ */
371
+ getOrSet(key: string, factory: () => Promise<T>, ttl?: number): Promise<T>;
372
+ /**
373
+ * Get cache statistics
374
+ */
375
+ getStats(): CacheStats;
376
+ /**
377
+ * Stop the cleanup interval
378
+ */
379
+ dispose(): void;
380
+ /**
381
+ * Start periodic cleanup of expired entries
382
+ */
383
+ private _startCleanup;
384
+ /**
385
+ * Remove all expired entries
386
+ */
387
+ private _removeExpired;
388
+ /**
389
+ * Evict oldest entries to make room
390
+ */
391
+ private _evictOldest;
392
+ }
393
+ /**
394
+ * Cache statistics
395
+ */
396
+ interface CacheStats {
397
+ /** Total entries including expired */
398
+ totalSize: number;
399
+ /** Valid (non-expired) entries */
400
+ validSize: number;
401
+ /** Expired entries pending cleanup */
402
+ expiredSize: number;
403
+ /** Maximum cache size */
404
+ maxSize: number;
405
+ /** Default TTL in milliseconds */
406
+ defaultTTL: number;
407
+ /** Time until oldest entry expires (ms) */
408
+ oldestExpiryMs: number;
409
+ /** Time until newest entry expires (ms) */
410
+ newestExpiryMs: number;
411
+ }
412
+ /**
413
+ * Balance cache configuration
414
+ */
415
+ interface BalanceCacheConfig {
416
+ /** Whether caching is enabled (default: true) */
417
+ enabled: boolean;
418
+ /** TTL for native balance in milliseconds (default: 15000 = 15 seconds) */
419
+ nativeBalanceTTL: number;
420
+ /** TTL for token balance in milliseconds (default: 30000 = 30 seconds) */
421
+ tokenBalanceTTL: number;
422
+ /** TTL for aggregated balances in milliseconds (default: 60000 = 60 seconds) */
423
+ aggregatedBalanceTTL: number;
424
+ /** Maximum cache entries (default: 500) */
425
+ maxSize: number;
426
+ }
427
+ /**
428
+ * Default balance cache configuration
429
+ */
430
+ declare const DEFAULT_BALANCE_CACHE_CONFIG: BalanceCacheConfig;
431
+ /**
432
+ * Specialized balance cache for WDK
433
+ *
434
+ * Provides separate TTL settings for different balance types
435
+ * and convenient methods for balance-specific caching.
436
+ *
437
+ * @example
438
+ * ```typescript
439
+ * const cache = new BalanceCache({
440
+ * tokenBalanceTTL: 60000, // 1 minute for token balances
441
+ * });
442
+ *
443
+ * // Cache token balance
444
+ * cache.setTokenBalance('arbitrum', '0xUSDT', '0xWallet', 1000000n);
445
+ *
446
+ * // Get cached balance (returns undefined if expired)
447
+ * const balance = cache.getTokenBalance('arbitrum', '0xUSDT', '0xWallet');
448
+ *
449
+ * // Or use getOrFetch pattern
450
+ * const balance = await cache.getOrFetchTokenBalance(
451
+ * 'arbitrum',
452
+ * '0xUSDT',
453
+ * '0xWallet',
454
+ * async () => await signer.getTokenBalance('0xUSDT')
455
+ * );
456
+ * ```
457
+ */
458
+ declare class BalanceCache {
459
+ private _cache;
460
+ private _aggregatedCache;
461
+ private _config;
462
+ constructor(config?: Partial<BalanceCacheConfig>);
463
+ /**
464
+ * Check if caching is enabled
465
+ */
466
+ get enabled(): boolean;
467
+ /**
468
+ * Get cache configuration
469
+ */
470
+ get config(): BalanceCacheConfig;
471
+ /**
472
+ * Get cached native balance
473
+ */
474
+ getNativeBalance(chain: string, address: string): bigint | undefined;
475
+ /**
476
+ * Set native balance in cache
477
+ */
478
+ setNativeBalance(chain: string, address: string, balance: bigint): void;
479
+ /**
480
+ * Get or fetch native balance
481
+ */
482
+ getOrFetchNativeBalance(chain: string, address: string, fetcher: () => Promise<bigint>): Promise<bigint>;
483
+ /**
484
+ * Get cached token balance
485
+ */
486
+ getTokenBalance(chain: string, token: string, address: string): bigint | undefined;
487
+ /**
488
+ * Set token balance in cache
489
+ */
490
+ setTokenBalance(chain: string, token: string, address: string, balance: bigint): void;
491
+ /**
492
+ * Get or fetch token balance
493
+ */
494
+ getOrFetchTokenBalance(chain: string, token: string, address: string, fetcher: () => Promise<bigint>): Promise<bigint>;
495
+ /**
496
+ * Get cached aggregated balance
497
+ */
498
+ getAggregatedBalance<T>(key: string): T | undefined;
499
+ /**
500
+ * Set aggregated balance in cache
501
+ */
502
+ setAggregatedBalance<T>(key: string, value: T): void;
503
+ /**
504
+ * Get or fetch aggregated balance
505
+ */
506
+ getOrFetchAggregatedBalance<T>(key: string, fetcher: () => Promise<T>): Promise<T>;
507
+ /**
508
+ * Invalidate all balances for a chain
509
+ */
510
+ invalidateChain(chain: string): number;
511
+ /**
512
+ * Invalidate all balances for an address
513
+ */
514
+ invalidateAddress(address: string): number;
515
+ /**
516
+ * Invalidate specific token balance
517
+ */
518
+ invalidateTokenBalance(chain: string, token: string, address: string): boolean;
519
+ /**
520
+ * Clear all caches
521
+ */
522
+ clear(): void;
523
+ /**
524
+ * Get cache statistics
525
+ */
526
+ getStats(): BalanceCacheStats;
527
+ /**
528
+ * Dispose of cache resources
529
+ */
530
+ dispose(): void;
531
+ private _nativeKey;
532
+ private _tokenKey;
533
+ private _aggregatedKey;
534
+ }
535
+ /**
536
+ * Balance cache statistics
537
+ */
538
+ interface BalanceCacheStats {
539
+ balanceCache: CacheStats;
540
+ aggregatedCache: CacheStats;
541
+ config: BalanceCacheConfig;
542
+ }
543
+
544
+ /**
545
+ * WDK Signer implementation for T402 payments
546
+ *
547
+ * This signer wraps the Tether WDK account to provide a T402-compatible
548
+ * signing interface for EVM chains.
549
+ */
550
+
551
+ /**
552
+ * WDK Signer for T402 EVM payments
553
+ *
554
+ * Implements the ClientEvmSigner interface from @t402/evm,
555
+ * wrapping a Tether WDK account for signing operations.
556
+ *
557
+ * @example
558
+ * ```typescript
559
+ * import { T402WDK } from '@t402/wdk';
560
+ *
561
+ * const wdk = new T402WDK(seedPhrase, { arbitrum: 'https://arb1.arbitrum.io/rpc' });
562
+ * const signer = await wdk.getSigner('arbitrum');
563
+ *
564
+ * // Use with T402 client
565
+ * const client = createT402HTTPClient({
566
+ * signers: [{ scheme: 'exact', signer }]
567
+ * });
568
+ * ```
569
+ */
570
+ declare class WDKSigner implements ClientEvmSigner {
571
+ private _wdk;
572
+ private _chain;
573
+ private _accountIndex;
574
+ private _account;
575
+ private _address;
576
+ private _timeoutMs;
577
+ /**
578
+ * Create a new WDK signer
579
+ *
580
+ * @param wdk - The WDK instance
581
+ * @param chain - Chain name (e.g., "arbitrum", "ethereum")
582
+ * @param accountIndex - HD wallet account index (default: 0)
583
+ * @param timeoutMs - Timeout for operations in milliseconds (default: 30000)
584
+ */
585
+ constructor(wdk: WDKInstance, chain: string, accountIndex?: number, timeoutMs?: number);
586
+ /**
587
+ * Get the wallet address
588
+ * Throws if signer is not initialized
589
+ */
590
+ get address(): Address;
591
+ /**
592
+ * Check if the signer is initialized
593
+ */
594
+ get isInitialized(): boolean;
595
+ /**
596
+ * Initialize the signer by fetching the account
597
+ * Must be called before using the signer
598
+ *
599
+ * @throws {SignerError} If account fetch fails
600
+ */
601
+ initialize(): Promise<void>;
602
+ /**
603
+ * Get the underlying WDK account
604
+ * Initializes if not already done
605
+ *
606
+ * @throws {SignerError} If initialization fails
607
+ */
608
+ private getAccount;
609
+ /**
610
+ * Sign EIP-712 typed data for T402 payments
611
+ *
612
+ * This is the primary signing method used by T402 for EIP-3009
613
+ * transferWithAuthorization payments.
614
+ *
615
+ * @throws {SigningError} If signing fails
616
+ */
617
+ signTypedData(message: {
618
+ domain: Record<string, unknown>;
619
+ types: Record<string, unknown>;
620
+ primaryType: string;
621
+ message: Record<string, unknown>;
622
+ }): Promise<`0x${string}`>;
623
+ /**
624
+ * Sign a personal message
625
+ *
626
+ * @throws {SigningError} If signing fails
627
+ */
628
+ signMessage(message: string | Uint8Array): Promise<`0x${string}`>;
629
+ /**
630
+ * Get the chain name
631
+ */
632
+ getChain(): string;
633
+ /**
634
+ * Get the chain ID
635
+ */
636
+ getChainId(): number;
637
+ /**
638
+ * Get the account index
639
+ */
640
+ getAccountIndex(): number;
641
+ /**
642
+ * Get native token balance (ETH, etc.)
643
+ *
644
+ * @throws {BalanceError} If balance fetch fails
645
+ */
646
+ getBalance(): Promise<bigint>;
647
+ /**
648
+ * Get ERC20 token balance
649
+ *
650
+ * @throws {BalanceError} If balance fetch fails
651
+ */
652
+ getTokenBalance(tokenAddress: Address): Promise<bigint>;
653
+ /**
654
+ * Estimate gas for a transaction
655
+ *
656
+ * @throws {TransactionError} If gas estimation fails
657
+ */
658
+ estimateGas(params: {
659
+ to: Address;
660
+ value?: bigint;
661
+ data?: string;
662
+ }): Promise<bigint>;
663
+ /**
664
+ * Sign an EIP-2612 permit for gasless token approvals
665
+ *
666
+ * @param params - Permit parameters
667
+ * @returns The permit signature components (v, r, s)
668
+ * @throws {SigningError} If signing fails
669
+ */
670
+ signPermit(params: {
671
+ token: Address;
672
+ spender: Address;
673
+ value: bigint;
674
+ deadline: number;
675
+ nonce?: bigint;
676
+ tokenName?: string;
677
+ tokenVersion?: string;
678
+ }): Promise<{
679
+ v: number;
680
+ r: `0x${string}`;
681
+ s: `0x${string}`;
682
+ }>;
683
+ /**
684
+ * Send a transaction (for advanced use cases)
685
+ *
686
+ * @throws {TransactionError} If transaction fails
687
+ */
688
+ sendTransaction(params: {
689
+ to: Address;
690
+ value?: bigint;
691
+ data?: string;
692
+ }): Promise<{
693
+ hash: `0x${string}`;
694
+ }>;
695
+ }
696
+ /**
697
+ * Create an initialized WDK signer
698
+ *
699
+ * This async factory function creates and initializes a WDK signer,
700
+ * ensuring the address is available immediately.
701
+ *
702
+ * @throws {SignerError} If initialization fails
703
+ *
704
+ * @example
705
+ * ```typescript
706
+ * const signer = await createWDKSigner(wdkInstance, 'arbitrum');
707
+ * console.log('Address:', signer.address); // Works immediately
708
+ * ```
709
+ */
710
+ declare function createWDKSigner(wdk: WDKInstance, chain: string, accountIndex?: number, timeoutMs?: number): Promise<WDKSigner>;
711
+ /**
712
+ * Mock WDK signer for testing purposes
713
+ *
714
+ * Implements the same interface but uses a fixed private key
715
+ * for deterministic testing.
716
+ */
717
+ declare class MockWDKSigner implements ClientEvmSigner {
718
+ readonly address: Address;
719
+ constructor(address: Address, _privateKey: `0x${string}`);
720
+ signTypedData(_message: {
721
+ domain: Record<string, unknown>;
722
+ types: Record<string, unknown>;
723
+ primaryType: string;
724
+ message: Record<string, unknown>;
725
+ }): Promise<`0x${string}`>;
726
+ signMessage(_message: string | Uint8Array): Promise<`0x${string}`>;
727
+ }
728
+
729
+ /**
730
+ * WDK Pricing Provider Integration
731
+ *
732
+ * Provides a MoneyParser that converts fiat/stablecoin amounts to
733
+ * on-chain AssetAmount values using WDK pricing data.
734
+ */
735
+
736
+ /** External pricing provider interface */
737
+ interface PricingProvider {
738
+ /** Get exchange rate from currency to token */
739
+ getRate(fromCurrency: string, toToken: string): Promise<number>;
740
+ /** Get list of supported currency pairs */
741
+ getSupportedPairs(): Array<{
742
+ from: string;
743
+ to: string;
744
+ }>;
745
+ }
746
+ declare function registerPricingProvider(provider: PricingProvider): void;
747
+ declare function getPricingProvider(): PricingProvider | null;
748
+ declare function isPricingProviderRegistered(): boolean;
749
+ interface PricingProviderConfig {
750
+ /** Cache TTL in milliseconds (default: 60000 = 60s) */
751
+ cacheTTL?: number;
752
+ /** Supported fiat currencies (default: ['USD', 'EUR', 'GBP', 'JPY']) */
753
+ supportedFiat?: string[];
754
+ }
755
+ /**
756
+ * Creates a MoneyParser that uses WDK pricing provider for fiat-to-crypto conversion.
757
+ *
758
+ * For stablecoin-denominated amounts (USDT, USDC, etc.), returns 1:1 ratio (no API call).
759
+ * For fiat currencies (USD, EUR, etc.), fetches live rates from the pricing provider.
760
+ *
761
+ * The MoneyParser interface receives a numeric amount (e.g., 1.50) and a CAIP-2 network.
762
+ *
763
+ * @example
764
+ * ```typescript
765
+ * import { createWdkMoneyParser } from '@t402/wdk'
766
+ *
767
+ * const parser = createWdkMoneyParser({ cacheTTL: 30_000 })
768
+ * const amount = await parser(1.50, 'eip155:8453') // Returns USDT amount on Base
769
+ * ```
770
+ */
771
+ declare function createWdkMoneyParser(config?: PricingProviderConfig): MoneyParser;
772
+ /**
773
+ * Convert a decimal amount to atomic units string.
774
+ *
775
+ * @example
776
+ * toAtomicUnits(1.5, 6) => "1500000"
777
+ * toAtomicUnits(0.001, 6) => "1000"
778
+ */
779
+ declare function toAtomicUnits(amount: number, decimals: number): string;
780
+ /**
781
+ * Resolve the asset address for a token on a given network.
782
+ */
783
+ declare function resolveAssetForNetwork(token: string, network: Network): string | null;
784
+
785
+ /**
786
+ * T402WDK - Main class for T402 integration with Tether WDK
787
+ *
788
+ * Provides a high-level API for:
789
+ * - Multi-chain wallet management
790
+ * - T402-compatible signers
791
+ * - Balance aggregation
792
+ * - Cross-chain bridging (USDT0)
793
+ */
794
+
795
+ /**
796
+ * Supported WDK semver range
797
+ */
798
+ declare const SUPPORTED_WDK_RANGE = ">=1.0.0-beta.5 <2.0.0";
799
+ /**
800
+ * Parse a semver version string into components.
801
+ * Handles pre-release tags like "1.0.0-beta.5".
802
+ */
803
+ declare function parseSemver(version: string): {
804
+ major: number;
805
+ minor: number;
806
+ patch: number;
807
+ prerelease: string;
808
+ } | null;
809
+ /**
810
+ * Compare two semver versions. Returns -1, 0, or 1.
811
+ */
812
+ declare function compareSemver(a: string, b: string): number;
813
+ /**
814
+ * Check if a version satisfies a simple range like ">=1.0.0-beta.5 <2.0.0".
815
+ * Supports: >=, >, <=, <, = comparators (space-separated AND).
816
+ */
817
+ declare function satisfiesSemverRange(version: string, range: string): boolean;
818
+ /**
819
+ * Payment cost estimate for a chain
820
+ */
821
+ interface PaymentCostEstimate {
822
+ paymentAmount: string;
823
+ estimatedGasCost: bigint;
824
+ nativeBalance: bigint;
825
+ canAffordGas: boolean;
826
+ chain: string;
827
+ network: string;
828
+ }
829
+ /** Middleware function type for chain account hooks */
830
+ type MiddlewareFunction = (account: unknown) => Promise<void>;
831
+ /**
832
+ * T402WDK - Tether WDK integration for T402 payments
833
+ *
834
+ * @example
835
+ * ```typescript
836
+ * import { T402WDK } from '@t402/wdk';
837
+ *
838
+ * // Initialize with seed phrase
839
+ * const seedPhrase = T402WDK.generateSeedPhrase();
840
+ * const wdk = new T402WDK(seedPhrase, {
841
+ * arbitrum: 'https://arb1.arbitrum.io/rpc',
842
+ * base: 'https://mainnet.base.org'
843
+ * });
844
+ *
845
+ * // Get signer for T402 payments
846
+ * const signer = await wdk.getSigner('arbitrum');
847
+ *
848
+ * // Use with T402 client
849
+ * const client = createT402HTTPClient({
850
+ * signers: [{ scheme: 'exact', signer }]
851
+ * });
852
+ * ```
853
+ */
854
+ declare class T402WDK {
855
+ private _wdk;
856
+ private _normalizedChains;
857
+ private _seedPhrase;
858
+ private _signerCache;
859
+ private _balanceCache;
860
+ private _initializationError;
861
+ private _events;
862
+ private _receiptStore;
863
+ private _disposed;
864
+ private _wdkConstructor;
865
+ private _walletManagerEvm;
866
+ private _bridgeUsdt0Evm;
867
+ private _walletModules;
868
+ private _protocolModules;
869
+ private _fiatOnRampProvider;
870
+ private _middlewares;
871
+ private _retryConfig;
872
+ private _failoverProviders;
873
+ private static _defaultModules;
874
+ static get _WDK(): WDKConstructor | null;
875
+ static set _WDK(val: WDKConstructor | null);
876
+ static get _WalletManagerEvm(): unknown;
877
+ static set _WalletManagerEvm(val: unknown);
878
+ static get _BridgeUsdt0Evm(): unknown;
879
+ static set _BridgeUsdt0Evm(val: unknown);
880
+ static get _WalletModules(): WDKWalletModules;
881
+ static set _WalletModules(val: WDKWalletModules);
882
+ static get _ProtocolModules(): WDKProtocolModules;
883
+ static set _ProtocolModules(val: WDKProtocolModules);
884
+ static get _fiatOnRampProvider(): FiatOnRampProvider | null;
885
+ static set _fiatOnRampProvider(val: FiatOnRampProvider | null);
886
+ static get _middlewares(): Map<string, Array<(account: unknown) => Promise<void>>>;
887
+ static set _middlewares(val: Map<string, Array<(account: unknown) => Promise<void>>>);
888
+ private _pathSignerCache;
889
+ private _tonSignerCache;
890
+ private _svmSignerCache;
891
+ private _tronSignerCache;
892
+ private _sparkSignerCache;
893
+ private _btcSignerCache;
894
+ /**
895
+ * Register the Tether WDK modules
896
+ *
897
+ * This must be called before creating T402WDK instances if you want
898
+ * to use the actual WDK. Otherwise, a mock implementation is used.
899
+ *
900
+ * Supports two registration patterns:
901
+ *
902
+ * 1. Legacy (EVM-only):
903
+ * ```typescript
904
+ * T402WDK.registerWDK(WDK, WalletManagerEvm, BridgeUsdt0Evm);
905
+ * ```
906
+ *
907
+ * 2. Unified (multi-chain):
908
+ * ```typescript
909
+ * T402WDK.registerWDK(WDK, {
910
+ * wallets: {
911
+ * evm: WalletManagerEvm,
912
+ * ton: WalletManagerTon,
913
+ * solana: WalletManagerSolana,
914
+ * tron: WalletManagerTron,
915
+ * },
916
+ * protocols: {
917
+ * bridgeUsdt0Evm: BridgeUsdt0Evm,
918
+ * bridgeUsdt0Ton: BridgeUsdt0Ton,
919
+ * }
920
+ * });
921
+ * ```
922
+ *
923
+ * @throws {WDKInitializationError} If registration fails
924
+ */
925
+ static registerWDK(WDK: WDKConstructor, modulesOrWalletManager?: WDKModulesConfig | unknown, BridgeUsdt0Evm?: unknown): void;
926
+ /**
927
+ * Check if WDK is registered
928
+ */
929
+ static isWDKRegistered(): boolean;
930
+ /**
931
+ * Check if wallet manager is registered
932
+ */
933
+ static isWalletManagerRegistered(): boolean;
934
+ /**
935
+ * Check if bridge protocol is registered
936
+ */
937
+ static isBridgeRegistered(): boolean;
938
+ /**
939
+ * Check if TON wallet manager is registered
940
+ */
941
+ static isTonRegistered(): boolean;
942
+ /**
943
+ * Check if Solana wallet manager is registered
944
+ */
945
+ static isSolanaRegistered(): boolean;
946
+ /**
947
+ * Check if TRON wallet manager is registered
948
+ */
949
+ static isTronRegistered(): boolean;
950
+ /**
951
+ * Check if Spark wallet manager is registered
952
+ */
953
+ static isSparkRegistered(): boolean;
954
+ /**
955
+ * Check if Bitcoin wallet manager is registered
956
+ */
957
+ static isBtcRegistered(): boolean;
958
+ /**
959
+ * Get all registered wallet modules
960
+ */
961
+ static getRegisteredWalletModules(): (keyof WDKWalletModules)[];
962
+ /**
963
+ * Get all registered protocol modules
964
+ */
965
+ static getRegisteredProtocolModules(): (keyof WDKProtocolModules)[];
966
+ /**
967
+ * Register a fiat on-ramp provider
968
+ *
969
+ * @param provider - A FiatOnRampProvider implementation (e.g., MoonpayOnRampProvider)
970
+ *
971
+ * @example
972
+ * ```typescript
973
+ * import { T402WDK, MoonpayOnRampProvider } from '@t402/wdk';
974
+ *
975
+ * T402WDK.registerFiatOnRamp(new MoonpayOnRampProvider({ apiKey: 'pk_test_...' }));
976
+ * ```
977
+ */
978
+ static registerFiatOnRamp(provider: FiatOnRampProvider): void;
979
+ /**
980
+ * Check if a fiat on-ramp provider is registered
981
+ */
982
+ static isFiatOnRampRegistered(): boolean;
983
+ /**
984
+ * Register a pricing provider for fiat-to-crypto rate conversion
985
+ */
986
+ static registerPricingProvider(provider: PricingProvider): void;
987
+ /**
988
+ * Check if a pricing provider is registered
989
+ */
990
+ static isPricingProviderRegistered(): boolean;
991
+ /**
992
+ * Register a middleware for a chain
993
+ */
994
+ static registerMiddleware(chain: string, fn: (account: unknown) => Promise<void>): void;
995
+ /**
996
+ * Get registered middlewares for a chain
997
+ */
998
+ static getMiddlewares(chain: string): Array<(account: unknown) => Promise<void>>;
999
+ /**
1000
+ * Clear all middlewares
1001
+ */
1002
+ static clearMiddlewares(): void;
1003
+ /**
1004
+ * Generate a new random seed phrase
1005
+ *
1006
+ * @throws {WDKInitializationError} If WDK is not registered
1007
+ * @returns A new BIP-39 mnemonic seed phrase
1008
+ */
1009
+ static generateSeedPhrase(): string;
1010
+ /**
1011
+ * Quick setup: seed phrase + chains + modules → ready-to-use T402WDK.
1012
+ *
1013
+ * Registers all provided wallet/protocol modules and creates a fully
1014
+ * configured instance in a single call.
1015
+ *
1016
+ * @example
1017
+ * ```typescript
1018
+ * import WDK from '@tetherto/wdk';
1019
+ * import WalletManagerEvm from '@tetherto/wdk-wallet-evm';
1020
+ * import BridgeUsdt0Evm from '@tetherto/wdk-protocol-bridge-usdt0-evm';
1021
+ *
1022
+ * const wallet = T402WDK.create({
1023
+ * seedPhrase: 'your twelve word seed phrase ...',
1024
+ * chains: {
1025
+ * arbitrum: 'https://arb1.arbitrum.io/rpc',
1026
+ * base: 'https://mainnet.base.org',
1027
+ * },
1028
+ * modules: {
1029
+ * wallets: { evm: WalletManagerEvm },
1030
+ * protocols: { bridgeUsdt0Evm: BridgeUsdt0Evm },
1031
+ * },
1032
+ * });
1033
+ * ```
1034
+ */
1035
+ static create(WDK: WDKConstructor, config: T402WDKCreateConfig): T402WDK;
1036
+ /**
1037
+ * Auto-discover installed WDK packages using dynamic imports.
1038
+ *
1039
+ * Probes known `@tetherto/wdk-*` packages and returns the ones that
1040
+ * are installed and importable.
1041
+ *
1042
+ * @returns Discovery result with available/unavailable packages and ready-to-use modules config
1043
+ *
1044
+ * @example
1045
+ * ```typescript
1046
+ * const result = await T402WDK.autoDiscover();
1047
+ * console.log('Found:', result.available);
1048
+ * console.log('Missing:', result.unavailable);
1049
+ * ```
1050
+ */
1051
+ static autoDiscover(): Promise<WDKAutoDiscoveryResult>;
1052
+ /**
1053
+ * Auto-discover installed WDK modules, then create a fully configured T402WDK.
1054
+ *
1055
+ * Combines `autoDiscover()` + `create()` in one call. Any explicit
1056
+ * modules you pass in `config.modules` take precedence over discovered ones.
1057
+ *
1058
+ * @param config - Same as `T402WDKCreateConfig` but `modules` is optional/partial
1059
+ * @returns A ready-to-use T402WDK instance
1060
+ *
1061
+ * @example
1062
+ * ```typescript
1063
+ * const wdk = await T402WDK.autoCreate({
1064
+ * seedPhrase: 'your twelve word seed phrase ...',
1065
+ * chains: { arbitrum: 'https://arb1.arbitrum.io/rpc' },
1066
+ * });
1067
+ * ```
1068
+ */
1069
+ static autoCreate(config: Omit<T402WDKCreateConfig, 'modules'> & {
1070
+ modules?: Partial<WDKModulesConfig>;
1071
+ }): Promise<T402WDK>;
1072
+ /**
1073
+ * Create a T402WDK from a pre-configured @tetherto/wdk instance.
1074
+ *
1075
+ * Wraps an existing WDK instance (already has wallets/protocols registered)
1076
+ * into a T402WDK without re-registering modules.
1077
+ *
1078
+ * @param wdkInstance - A pre-configured WDK instance
1079
+ * @param config - EVM chain configuration (RPC endpoints)
1080
+ * @param options - Additional options
1081
+ */
1082
+ static fromWDK(wdkInstance: WDKInstance, config?: T402WDKConfig, options?: FromWDKOptions & T402WDKOptions): T402WDK;
1083
+ /**
1084
+ * Create a T402WDK instance from an encrypted seed.
1085
+ *
1086
+ * @example
1087
+ * ```typescript
1088
+ * const encrypted = JSON.parse(fs.readFileSync('seed.enc.json', 'utf8'))
1089
+ * const wdk = await T402WDK.fromEncryptedSeed(encrypted, 'my-password', {
1090
+ * arbitrum: 'https://arb1.arbitrum.io/rpc',
1091
+ * })
1092
+ * ```
1093
+ */
1094
+ static fromEncryptedSeed(encrypted: EncryptedSeed, password: string, config?: T402WDKConfig, options?: T402WDKOptions): Promise<T402WDK>;
1095
+ /**
1096
+ * Encrypt the current seed phrase for secure storage.
1097
+ *
1098
+ * @param password - Password to encrypt with
1099
+ * @returns Encrypted seed data suitable for JSON serialization
1100
+ */
1101
+ encryptSeed(password: string): Promise<EncryptedSeed>;
1102
+ /**
1103
+ * Get all signers as an array ready for T402 HTTP clients.
1104
+ *
1105
+ * Returns signer entries for all configured EVM chains, plus any
1106
+ * registered non-EVM chains (TON, Solana, TRON).
1107
+ *
1108
+ * @example
1109
+ * ```typescript
1110
+ * const signers = await wallet.getAllSigners();
1111
+ * const client = createT402HTTPClient({ signers });
1112
+ * ```
1113
+ */
1114
+ getAllSigners(options?: GetAllSignersOptions): Promise<SignerEntry[]>;
1115
+ /**
1116
+ * Create a new T402WDK instance
1117
+ *
1118
+ * @param seedPhrase - BIP-39 mnemonic seed phrase
1119
+ * @param config - Chain configuration (RPC endpoints)
1120
+ * @param options - Additional options (cache configuration, etc.)
1121
+ * @throws {WDKInitializationError} If seed phrase is invalid
1122
+ */
1123
+ constructor(seedPhrase: string, config?: T402WDKConfig, options?: T402WDKOptions);
1124
+ /**
1125
+ * Guard: throw if this instance has been disposed (#194)
1126
+ */
1127
+ private assertNotDisposed;
1128
+ /**
1129
+ * Whether this instance has been disposed
1130
+ */
1131
+ get isDisposed(): boolean;
1132
+ /**
1133
+ * Add default chain configurations for common chains
1134
+ */
1135
+ private _addDefaultChainsIfNeeded;
1136
+ /**
1137
+ * Initialize the underlying WDK instance
1138
+ */
1139
+ private _initializeWDK;
1140
+ /**
1141
+ * Get the underlying WDK instance
1142
+ *
1143
+ * @throws {WDKInitializationError} If WDK is not initialized
1144
+ */
1145
+ get wdk(): WDKInstance;
1146
+ /**
1147
+ * Check if WDK is properly initialized
1148
+ */
1149
+ get isInitialized(): boolean;
1150
+ /**
1151
+ * Get initialization error if any
1152
+ */
1153
+ get initializationError(): Error | null;
1154
+ /**
1155
+ * Subscribe to a T402 event
1156
+ */
1157
+ on<K extends keyof T402Events>(event: K, handler: (data: T402Events[K]) => void): this;
1158
+ /**
1159
+ * Unsubscribe from a T402 event
1160
+ */
1161
+ off<K extends keyof T402Events>(event: K, handler: (data: T402Events[K]) => void): this;
1162
+ /**
1163
+ * Subscribe to a T402 event (fires once then auto-unsubscribes)
1164
+ */
1165
+ once<K extends keyof T402Events>(event: K, handler: (data: T402Events[K]) => void): this;
1166
+ /**
1167
+ * Emit a T402 event
1168
+ */
1169
+ emit<K extends keyof T402Events>(event: K, data: T402Events[K]): boolean;
1170
+ /**
1171
+ * Get the payment receipt store
1172
+ */
1173
+ getReceiptStore(): PaymentReceiptStore;
1174
+ /**
1175
+ * Set a custom payment receipt store backend
1176
+ */
1177
+ setReceiptStore(store: PaymentReceiptStore): void;
1178
+ /**
1179
+ * Get all configured chains
1180
+ */
1181
+ getConfiguredChains(): string[];
1182
+ /**
1183
+ * Get chain configuration
1184
+ */
1185
+ getChainConfig(chain: string): NormalizedChainConfig | undefined;
1186
+ /**
1187
+ * Check if a chain is configured
1188
+ */
1189
+ isChainConfigured(chain: string): boolean;
1190
+ /**
1191
+ * Get a T402-compatible signer for a chain
1192
+ *
1193
+ * @param chain - Chain name (e.g., "arbitrum", "ethereum")
1194
+ * @param accountIndex - HD wallet account index (default: 0)
1195
+ * @throws {ChainError} If chain is not configured
1196
+ * @throws {SignerError} If signer creation fails
1197
+ * @returns An initialized WDKSigner
1198
+ */
1199
+ getSigner(chain: string, accountIndex?: number): Promise<WDKSigner>;
1200
+ /**
1201
+ * Clear the signer cache
1202
+ * Useful for forcing re-initialization of signers
1203
+ */
1204
+ clearSignerCache(): void;
1205
+ /**
1206
+ * Get current fee rates for a chain
1207
+ */
1208
+ getFeeRates(chain: string): Promise<Record<string, bigint>>;
1209
+ /**
1210
+ * Estimate total cost of a payment on a chain
1211
+ */
1212
+ estimatePaymentCost(chain: string, amount: string): Promise<PaymentCostEstimate>;
1213
+ /**
1214
+ * Get a signer using a custom BIP-44 derivation path
1215
+ */
1216
+ getSignerByPath(chain: string, path: string): Promise<WDKSigner>;
1217
+ /**
1218
+ * Get a TON signer for T402 payments
1219
+ *
1220
+ * @param accountIndex - HD wallet account index (default: 0)
1221
+ * @throws {ChainError} If TON wallet manager is not registered
1222
+ * @returns An initialized ClientTonSigner
1223
+ *
1224
+ * @example
1225
+ * ```typescript
1226
+ * const tonSigner = await wallet.getTonSigner();
1227
+ *
1228
+ * const client = createT402HTTPClient({
1229
+ * signers: [{ scheme: 'exact', network: 'ton:mainnet', signer: tonSigner }]
1230
+ * });
1231
+ * ```
1232
+ */
1233
+ getTonSigner(accountIndex?: number): Promise<ClientTonSigner>;
1234
+ /**
1235
+ * Get a Solana (SVM) signer for T402 payments
1236
+ *
1237
+ * @param accountIndex - HD wallet account index (default: 0)
1238
+ * @throws {ChainError} If Solana wallet manager is not registered
1239
+ * @returns An initialized TransactionSigner (ClientSvmSigner)
1240
+ *
1241
+ * @example
1242
+ * ```typescript
1243
+ * const svmSigner = await wallet.getSvmSigner();
1244
+ *
1245
+ * const client = createT402HTTPClient({
1246
+ * signers: [{ scheme: 'exact', network: 'solana:mainnet', signer: svmSigner }]
1247
+ * });
1248
+ * ```
1249
+ */
1250
+ getSvmSigner(accountIndex?: number): Promise<TransactionSigner>;
1251
+ /**
1252
+ * Get a TRON signer for T402 payments
1253
+ *
1254
+ * @param accountIndex - HD wallet account index (default: 0)
1255
+ * @param rpcUrl - Optional custom RPC URL (default: https://api.trongrid.io)
1256
+ * @throws {ChainError} If TRON wallet manager is not registered
1257
+ * @returns An initialized ClientTronSigner
1258
+ *
1259
+ * @example
1260
+ * ```typescript
1261
+ * const tronSigner = await wallet.getTronSigner();
1262
+ *
1263
+ * const client = createT402HTTPClient({
1264
+ * signers: [{ scheme: 'exact', network: 'tron:mainnet', signer: tronSigner }]
1265
+ * });
1266
+ * ```
1267
+ */
1268
+ getTronSigner(accountIndex?: number, rpcUrl?: string): Promise<ClientTronSigner>;
1269
+ /**
1270
+ * Get a Spark (Bitcoin L2) signer for T402 payments
1271
+ *
1272
+ * @param accountIndex - HD wallet account index (default: 0)
1273
+ * @throws {ChainError} If Spark wallet manager is not registered
1274
+ * @returns An initialized WDKSparkSignerAdapter
1275
+ *
1276
+ * @example
1277
+ * ```typescript
1278
+ * const sparkSigner = await wallet.getSparkSigner();
1279
+ *
1280
+ * const client = createT402HTTPClient({
1281
+ * signers: [{ scheme: 'exact', network: 'spark:mainnet', signer: sparkSigner }]
1282
+ * });
1283
+ * ```
1284
+ */
1285
+ getSparkSigner(accountIndex?: number): Promise<WDKSparkSignerAdapter>;
1286
+ /**
1287
+ * Get a Bitcoin (BTC) on-chain signer for T402 payments
1288
+ *
1289
+ * @param accountIndex - HD wallet account index (default: 0)
1290
+ * @throws {ChainError} If Bitcoin wallet manager is not registered
1291
+ * @returns An initialized WDKBtcSignerAdapter
1292
+ *
1293
+ * @example
1294
+ * ```typescript
1295
+ * const btcSigner = await wallet.getBtcSigner();
1296
+ *
1297
+ * const client = createT402HTTPClient({
1298
+ * signers: [{ scheme: 'exact', network: 'bip122:000000000019d6689c085ae165831e93', signer: btcSigner }]
1299
+ * });
1300
+ * ```
1301
+ */
1302
+ getBtcSigner(accountIndex?: number): Promise<WDKBtcSignerAdapter>;
1303
+ /**
1304
+ * Get a signer for a specific chain family
1305
+ *
1306
+ * @param family - Chain family (evm, svm, ton, tron)
1307
+ * @param chainOrIndex - Chain name for EVM, or account index for others
1308
+ * @param accountIndex - Account index (only used for EVM)
1309
+ * @throws {ChainError} If chain family is not supported or not configured
1310
+ * @returns An appropriate signer for the chain family
1311
+ *
1312
+ * @example
1313
+ * ```typescript
1314
+ * // Get EVM signer for Arbitrum
1315
+ * const evmSigner = await wallet.getSignerByFamily('evm', 'arbitrum');
1316
+ *
1317
+ * // Get TON signer
1318
+ * const tonSigner = await wallet.getSignerByFamily('ton');
1319
+ *
1320
+ * // Get Solana signer with account index 1
1321
+ * const svmSigner = await wallet.getSignerByFamily('svm', 1);
1322
+ * ```
1323
+ */
1324
+ getSignerByFamily(family: ChainFamily, chainOrIndex?: string | number, accountIndex?: number): Promise<WDKSigner | ClientTonSigner | TransactionSigner | ClientTronSigner | WDKSparkSignerAdapter | WDKBtcSignerAdapter>;
1325
+ /**
1326
+ * Get wallet address for a chain
1327
+ *
1328
+ * @param chain - Chain name
1329
+ * @param accountIndex - HD wallet account index (default: 0)
1330
+ * @throws {ChainError} If chain is not configured
1331
+ * @throws {SignerError} If address fetch fails
1332
+ */
1333
+ getAddress(chain: string, accountIndex?: number): Promise<Address>;
1334
+ /**
1335
+ * Get USDT0 balance for a chain
1336
+ *
1337
+ * Uses cache if enabled to reduce RPC calls.
1338
+ *
1339
+ * @throws {BalanceError} If balance fetch fails
1340
+ */
1341
+ getUsdt0Balance(chain: string, accountIndex?: number): Promise<bigint>;
1342
+ /**
1343
+ * Get USDC balance for a chain
1344
+ *
1345
+ * Uses cache if enabled to reduce RPC calls.
1346
+ *
1347
+ * @throws {BalanceError} If balance fetch fails
1348
+ */
1349
+ getUsdcBalance(chain: string, accountIndex?: number): Promise<bigint>;
1350
+ /**
1351
+ * Get all token balances for a chain
1352
+ *
1353
+ * Uses cache if enabled to reduce RPC calls.
1354
+ *
1355
+ * @throws {ChainError} If chain is not configured
1356
+ * @throws {BalanceError} If balance fetch fails
1357
+ */
1358
+ getChainBalances(chain: string, accountIndex?: number): Promise<ChainBalance>;
1359
+ /**
1360
+ * Get aggregated balances across all configured chains
1361
+ *
1362
+ * @param accountIndex - HD wallet account index (default: 0)
1363
+ * @param options - Options for balance aggregation
1364
+ */
1365
+ getAggregatedBalances(accountIndex?: number, options?: {
1366
+ continueOnError?: boolean;
1367
+ }): Promise<AggregatedBalance>;
1368
+ /**
1369
+ * Find the best chain for a payment
1370
+ *
1371
+ * Looks for the chain with sufficient balance, prioritizing USDT0.
1372
+ *
1373
+ * @param amount - Required amount in smallest units
1374
+ * @param preferredToken - Preferred token ("USDT0" | "USDC")
1375
+ * @throws {BalanceError} If balance aggregation fails
1376
+ */
1377
+ findBestChainForPayment(amount: bigint, preferredToken?: 'USDT0' | 'USDC'): Promise<{
1378
+ chain: string;
1379
+ token: string;
1380
+ balance: bigint;
1381
+ } | null>;
1382
+ /**
1383
+ * Bridge USDT0 between chains
1384
+ *
1385
+ * Uses LayerZero OFT for cross-chain transfers.
1386
+ *
1387
+ * @param params - Bridge parameters
1388
+ * @throws {BridgeError} If bridge is not available or fails
1389
+ * @returns Bridge result with transaction hash
1390
+ */
1391
+ bridgeUsdt0(params: BridgeParams): Promise<BridgeResult>;
1392
+ /**
1393
+ * Get chains that support USDT0
1394
+ */
1395
+ getUsdt0Chains(): string[];
1396
+ /**
1397
+ * Get chains that support USDT0 bridging
1398
+ *
1399
+ * Returns configured chains that have LayerZero OFT bridge support.
1400
+ */
1401
+ getBridgeableChains(): string[];
1402
+ /**
1403
+ * Check if bridging is supported between two chains
1404
+ */
1405
+ canBridge(fromChain: string, toChain: string): boolean;
1406
+ /**
1407
+ * Get all possible bridge destinations from a chain
1408
+ */
1409
+ getBridgeDestinations(fromChain: string): string[];
1410
+ /**
1411
+ * Check if the Velora swap protocol is registered and available
1412
+ */
1413
+ canSwap(): boolean;
1414
+ /**
1415
+ * Get a swap quote for converting a token to USDT0
1416
+ *
1417
+ * @param chain - Chain name (e.g., "ethereum", "arbitrum")
1418
+ * @param fromToken - Input token address
1419
+ * @param amount - Amount to swap in smallest units
1420
+ * @throws {WDKError} If swap protocol is not registered or quote fails
1421
+ */
1422
+ getSwapQuote(chain: string, fromToken: string, amount: bigint): Promise<SwapQuote>;
1423
+ /**
1424
+ * Swap any token to USDT0 for payment
1425
+ *
1426
+ * Uses the Velora protocol to execute a token swap on the specified chain.
1427
+ *
1428
+ * @param params - Swap parameters
1429
+ * @throws {WDKError} If swap protocol is not registered or swap fails
1430
+ *
1431
+ * @example
1432
+ * ```typescript
1433
+ * // Swap 0.1 WETH to USDT0 on Arbitrum
1434
+ * const result = await wallet.swapAndPay({
1435
+ * chain: 'arbitrum',
1436
+ * fromToken: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1', // WETH
1437
+ * amount: 100000000000000000n, // 0.1 WETH
1438
+ * maxSlippage: 0.005,
1439
+ * });
1440
+ * ```
1441
+ */
1442
+ swapAndPay(params: SwapParams): Promise<SwapResult>;
1443
+ /**
1444
+ * Check if the Aave lending protocol is registered and available
1445
+ */
1446
+ canBorrow(): boolean;
1447
+ /**
1448
+ * Borrow USDT0 against collateral and pay
1449
+ *
1450
+ * Uses the Aave protocol to deposit collateral, borrow USDT0, then the
1451
+ * borrowed USDT0 is available for T402 payments.
1452
+ *
1453
+ * @param params - Borrow parameters
1454
+ * @throws {WDKError} If lending protocol is not registered or borrow fails
1455
+ *
1456
+ * @example
1457
+ * ```typescript
1458
+ * // Borrow 100 USDT0 against 0.05 WETH on Arbitrum
1459
+ * const result = await wallet.borrowAndPay({
1460
+ * chain: 'arbitrum',
1461
+ * collateralToken: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1', // WETH
1462
+ * collateralAmount: 50000000000000000n, // 0.05 WETH
1463
+ * borrowAmount: 100000000n, // 100 USDT0
1464
+ * });
1465
+ * ```
1466
+ */
1467
+ borrowAndPay(params: BorrowParams): Promise<BorrowResult>;
1468
+ /**
1469
+ * Get a fiat on-ramp quote
1470
+ *
1471
+ * @param params - Quote parameters (fiatAmount, fiatCurrency, network)
1472
+ * @throws {WDKError} If no fiat on-ramp provider is registered
1473
+ */
1474
+ getFiatOnRampQuote(params: Pick<FiatOnRampParams, 'fiatAmount' | 'fiatCurrency' | 'network'>): Promise<FiatOnRampQuote>;
1475
+ /**
1476
+ * Generate a fiat on-ramp widget URL for the user
1477
+ *
1478
+ * Returns a widget URL that the application should open in a browser
1479
+ * or webview so the user can complete the fiat purchase.
1480
+ *
1481
+ * @param params - On-ramp parameters
1482
+ * @throws {WDKError} If no fiat on-ramp provider is registered
1483
+ *
1484
+ * @example
1485
+ * ```typescript
1486
+ * const result = await wallet.onRampAndPay({
1487
+ * fiatAmount: 100,
1488
+ * fiatCurrency: 'USD',
1489
+ * walletAddress: '0x...',
1490
+ * network: 'eip155:42161',
1491
+ * });
1492
+ * // Open result.widgetUrl in browser/webview
1493
+ * ```
1494
+ */
1495
+ onRampAndPay(params: FiatOnRampParams): FiatOnRampResult;
1496
+ /**
1497
+ * Check if balance caching is enabled
1498
+ */
1499
+ get isCacheEnabled(): boolean;
1500
+ /**
1501
+ * Get cache configuration
1502
+ */
1503
+ getCacheConfig(): BalanceCacheConfig;
1504
+ /**
1505
+ * Get cache statistics
1506
+ */
1507
+ getCacheStats(): BalanceCacheStats;
1508
+ /**
1509
+ * Invalidate all cached balances
1510
+ *
1511
+ * Call this after sending transactions to ensure fresh balance data.
1512
+ */
1513
+ invalidateBalanceCache(): void;
1514
+ /**
1515
+ * Invalidate cached balances for a specific chain
1516
+ *
1517
+ * @param chain - Chain name to invalidate
1518
+ * @returns Number of cache entries invalidated
1519
+ */
1520
+ invalidateChainCache(chain: string): number;
1521
+ /**
1522
+ * Invalidate cached balances for a specific address
1523
+ *
1524
+ * @param address - Address to invalidate (case-insensitive)
1525
+ * @returns Number of cache entries invalidated
1526
+ */
1527
+ invalidateAddressCache(address: string): number;
1528
+ /**
1529
+ * Dispose of all resources held by this instance (#194).
1530
+ *
1531
+ * After disposal, any public method call will throw.
1532
+ * Safe to call multiple times.
1533
+ */
1534
+ dispose(): void;
1535
+ /**
1536
+ * Symbol.dispose support for `using` declarations (TC39 Explicit Resource Management)
1537
+ */
1538
+ [Symbol.dispose](): void;
1539
+ /**
1540
+ * Get the FailoverProvider status for a chain, if one exists.
1541
+ *
1542
+ * @param chain - Chain name
1543
+ * @returns Array of provider statuses, or null if no failover is configured for the chain
1544
+ */
1545
+ getProviderStatus(chain: string): ProviderStatus[] | null;
1546
+ /**
1547
+ * Simple online connectivity check.
1548
+ * Returns true if at least one configured chain's RPC responds.
1549
+ */
1550
+ get isOnline(): Promise<boolean>;
1551
+ private _checkOnline;
1552
+ /**
1553
+ * Wrap an async operation with the instance retry config (#202)
1554
+ */
1555
+ private _withRetry;
1556
+ }
1557
+
1558
+ /**
1559
+ * A2A + WDK Adapter
1560
+ *
1561
+ * Bridges T402WDK wallets with the A2A (Agent-to-Agent) payment transport,
1562
+ * enabling AI agents to make payments using WDK-managed wallets.
1563
+ */
1564
+
1565
+ /**
1566
+ * Payment requirements received from an A2A server (402 response).
1567
+ * Matches the core PaymentRequired type shape.
1568
+ */
1569
+ interface A2APaymentRequired {
1570
+ t402Version: number;
1571
+ resource: {
1572
+ url: string;
1573
+ description?: string;
1574
+ mimeType?: string;
1575
+ };
1576
+ accepts: Array<{
1577
+ scheme: string;
1578
+ network: string;
1579
+ asset: string;
1580
+ amount: string;
1581
+ payTo: string;
1582
+ maxTimeoutSeconds: number;
1583
+ extra: Record<string, unknown>;
1584
+ }>;
1585
+ extensions?: Record<string, unknown>;
1586
+ }
1587
+ /**
1588
+ * Payment payload to submit to an A2A server.
1589
+ * Matches the core PaymentPayload type shape.
1590
+ */
1591
+ interface A2APaymentPayload {
1592
+ t402Version: number;
1593
+ resource?: {
1594
+ url: string;
1595
+ description?: string;
1596
+ mimeType?: string;
1597
+ };
1598
+ accepted: A2APaymentRequired['accepts'][0];
1599
+ payload: Record<string, unknown>;
1600
+ extensions?: Record<string, unknown>;
1601
+ }
1602
+ /**
1603
+ * Options for the WDK A2A payment client adapter.
1604
+ */
1605
+ interface WdkA2AOptions {
1606
+ /** Maximum spending limit per payment (in atomic units) */
1607
+ spendingLimit?: bigint;
1608
+ /** Callback when manual approval is required */
1609
+ onApprovalRequired?: (payment: {
1610
+ amount: bigint;
1611
+ network: string;
1612
+ }) => Promise<boolean>;
1613
+ /** Auto-check balance before payment */
1614
+ autoBalance?: boolean;
1615
+ /** Auto-bridge if insufficient balance on target chain */
1616
+ autoBridge?: boolean;
1617
+ /** Preferred payment scheme (default: "exact") */
1618
+ preferredScheme?: string;
1619
+ }
1620
+ /**
1621
+ * Result of createWdkA2APaymentClient.
1622
+ */
1623
+ interface WdkA2APaymentClient {
1624
+ /** Signer entries from WDK for all configured chains */
1625
+ signers: SignerEntry[];
1626
+ /** Handle a 402 payment required response */
1627
+ paymentHandler: (req: A2APaymentRequired) => Promise<A2APaymentPayload>;
1628
+ }
1629
+ /**
1630
+ * Create a WDK-backed A2A payment client.
1631
+ *
1632
+ * Extracts all configured chain signers from WDK and wraps them for A2A use.
1633
+ * The returned `paymentHandler` selects the best signer for the payment
1634
+ * requirements, optionally checks balance, and creates a signed payment payload.
1635
+ *
1636
+ * @param wdk - An initialized T402WDK instance
1637
+ * @param options - Configuration options
1638
+ * @returns Object with signers and a paymentHandler function
1639
+ *
1640
+ * @example
1641
+ * ```typescript
1642
+ * const { signers, paymentHandler } = await createWdkA2APaymentClient(wdk, {
1643
+ * spendingLimit: 10_000_000n, // 10 USDT0
1644
+ * autoBalance: true,
1645
+ * });
1646
+ *
1647
+ * // When the A2A agent receives a 402 response:
1648
+ * const payload = await paymentHandler(paymentRequired);
1649
+ * // Submit payload back to the A2A server
1650
+ * ```
1651
+ */
1652
+ declare function createWdkA2APaymentClient(wdk: T402WDK, options?: WdkA2AOptions): Promise<WdkA2APaymentClient>;
1653
+
1654
+ /**
1655
+ * Facilitator + WDK Adapter
1656
+ *
1657
+ * Wraps a T402WDK wallet as a facilitator-compatible signer, enabling WDK
1658
+ * wallets to be used for on-chain settlement (verify + settle operations).
1659
+ */
1660
+
1661
+ /**
1662
+ * Options for the facilitator WDK signer adapter.
1663
+ */
1664
+ interface FacilitatorWdkSignerOptions {
1665
+ /** Automatically settle payments after verification */
1666
+ autoSettle?: boolean;
1667
+ /** Auto-bridge received payments to this chain (CAIP-2 network or chain name) */
1668
+ bridgeToMainChain?: string;
1669
+ }
1670
+ /**
1671
+ * Facilitator-compatible signer backed by WDK.
1672
+ */
1673
+ interface FacilitatorWdkSigner {
1674
+ /** Wallet address on the target chain */
1675
+ address: string;
1676
+ /** Sign a transaction for on-chain settlement */
1677
+ signTransaction: (tx: unknown) => Promise<string>;
1678
+ /** Sign typed data (EIP-712) */
1679
+ signTypedData: (data: {
1680
+ domain: Record<string, unknown>;
1681
+ types: Record<string, unknown>;
1682
+ primaryType: string;
1683
+ message: Record<string, unknown>;
1684
+ }) => Promise<string>;
1685
+ /** Send a signed transaction */
1686
+ sendTransaction: (params: {
1687
+ to: string;
1688
+ value?: bigint;
1689
+ data?: string;
1690
+ }) => Promise<string>;
1691
+ }
1692
+ /**
1693
+ * Convert a T402WDK instance into a facilitator-compatible signer for a given chain.
1694
+ *
1695
+ * The returned signer can be used with `toFacilitatorEvmSigner()` or directly
1696
+ * with a `t402Facilitator` instance for on-chain payment verification and settlement.
1697
+ *
1698
+ * @param wdk - An initialized T402WDK instance
1699
+ * @param chain - Chain name (e.g., "arbitrum", "base")
1700
+ * @param options - Optional configuration
1701
+ * @returns A facilitator-compatible signer object
1702
+ *
1703
+ * @example
1704
+ * ```typescript
1705
+ * const signer = await toFacilitatorWdkSigner(wdk, 'arbitrum', {
1706
+ * autoSettle: true,
1707
+ * bridgeToMainChain: 'arbitrum',
1708
+ * });
1709
+ *
1710
+ * // Use the signer with the facilitator
1711
+ * console.log('Facilitator address:', signer.address);
1712
+ * ```
1713
+ */
1714
+ declare function toFacilitatorWdkSigner(wdk: T402WDK, chain: string, options?: FacilitatorWdkSignerOptions): Promise<FacilitatorWdkSigner>;
1715
+ /**
1716
+ * Create facilitator signers for all configured WDK chains.
1717
+ *
1718
+ * @param wdk - An initialized T402WDK instance
1719
+ * @param options - Optional configuration applied to all signers
1720
+ * @returns Map of chain name to facilitator signer
1721
+ *
1722
+ * @example
1723
+ * ```typescript
1724
+ * const signers = await createFacilitatorSigners(wdk, {
1725
+ * bridgeToMainChain: 'arbitrum',
1726
+ * });
1727
+ *
1728
+ * for (const [chain, signer] of signers) {
1729
+ * console.log(`${chain}: ${signer.address}`);
1730
+ * }
1731
+ * ```
1732
+ */
1733
+ declare function createFacilitatorSigners(wdk: T402WDK, options?: FacilitatorWdkSignerOptions): Promise<Map<string, FacilitatorWdkSigner>>;
1734
+
1735
+ /**
1736
+ * SIWx + WDK Adapter
1737
+ *
1738
+ * Wraps a T402WDK wallet as a SIWx (Sign-In-With-X) signer, enabling
1739
+ * WDK wallets to sign CAIP-122 authentication messages.
1740
+ */
1741
+
1742
+ /**
1743
+ * SIWx signer interface, compatible with the SIWxSigner from @t402/extensions.
1744
+ */
1745
+ interface SIWxSigner {
1746
+ /** Wallet address */
1747
+ address: string;
1748
+ /** Sign a personal message (EIP-191) */
1749
+ signMessage(message: string): Promise<string>;
1750
+ /** Sign EIP-712 typed data */
1751
+ signTypedData(data: {
1752
+ domain: unknown;
1753
+ types: unknown;
1754
+ primaryType: string;
1755
+ message: unknown;
1756
+ }): Promise<string>;
1757
+ }
1758
+ /**
1759
+ * Convert a T402WDK instance into a SIWx-compatible signer for a given chain.
1760
+ *
1761
+ * The returned signer implements the `SIWxSigner` interface used by
1762
+ * `@t402/extensions` for CAIP-122 Sign-In-With-X authentication flows.
1763
+ *
1764
+ * @param wdk - An initialized T402WDK instance
1765
+ * @param chain - Chain name (e.g., "arbitrum", "base")
1766
+ * @returns A SIWx-compatible signer
1767
+ *
1768
+ * @example
1769
+ * ```typescript
1770
+ * import { toSIWxSigner } from '@t402/wdk';
1771
+ * import { createSIWxPayload, encodeSIWxHeader } from '@t402/extensions';
1772
+ *
1773
+ * const siwxSigner = await toSIWxSigner(wdk, 'arbitrum');
1774
+ *
1775
+ * // Create and sign SIWx payload
1776
+ * const payload = await createSIWxPayload(serverExtension, siwxSigner);
1777
+ * const header = encodeSIWxHeader(payload);
1778
+ *
1779
+ * // Include in request
1780
+ * fetch(url, { headers: { 'X-T402-SIWx': header } });
1781
+ * ```
1782
+ */
1783
+ declare function toSIWxSigner(wdk: T402WDK, chain: string): Promise<SIWxSigner>;
1784
+ /**
1785
+ * Create SIWx signers for all configured WDK chains.
1786
+ *
1787
+ * @param wdk - An initialized T402WDK instance
1788
+ * @returns Map of chain name to SIWx signer
1789
+ *
1790
+ * @example
1791
+ * ```typescript
1792
+ * const signers = await createSIWxSigners(wdk);
1793
+ * const arbSigner = signers.get('arbitrum');
1794
+ * ```
1795
+ */
1796
+ declare function createSIWxSigners(wdk: T402WDK): Promise<Map<string, SIWxSigner>>;
1797
+
1798
+ export { verifyBackup as $, type A2APaymentPayload as A, type BackupMetadata as B, type CacheConfig as C, DEFAULT_BALANCE_CACHE_CONFIG as D, type EnrichedReceipt as E, type FacilitatorWdkSigner as F, decryptSeed as G, encryptSeed as H, InMemoryReceiptStore as I, getPricingProvider as J, getSecretManager as K, isPricingProviderRegistered as L, type MiddlewareFunction as M, parseSemver as N, registerPricingProvider as O, type PaymentCostEstimate as P, registerSecretManager as Q, type ReceiptFilter as R, type SIWxSigner as S, T402EventEmitter as T, resolveAssetForNetwork as U, rotateSeedPassword as V, WDKSigner as W, satisfiesSemverRange as X, toAtomicUnits as Y, toFacilitatorWdkSigner as Z, toSIWxSigner as _, type A2APaymentRequired as a, BalanceCache as b, type BalanceCacheConfig as c, type BalanceCacheStats as d, type CacheStats as e, DEFAULT_CACHE_CONFIG as f, type EncryptedSeed as g, type FacilitatorWdkSignerOptions as h, MockWDKSigner as i, type PaymentReceiptStore as j, type PricingProvider as k, type PricingProviderConfig as l, SUPPORTED_WDK_RANGE as m, type SecretManager as n, type T402Events as o, T402WDK as p, TTLCache as q, type WdkA2AOptions as r, type WdkA2APaymentClient as s, compareSemver as t, createBackup as u, createFacilitatorSigners as v, createSIWxSigners as w, createWDKSigner as x, createWdkA2APaymentClient as y, createWdkMoneyParser as z };