@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
@@ -1,107 +0,0 @@
1
- // src/adapters/svm-adapter.ts
2
- var WDKSvmSignerAdapter = class {
3
- _account;
4
- _address = null;
5
- _initialized = false;
6
- constructor(account) {
7
- if (!account) {
8
- throw new Error("WDK Solana account is required");
9
- }
10
- this._account = account;
11
- }
12
- /**
13
- * Get the wallet address (base58)
14
- * @throws Error if not initialized
15
- */
16
- get address() {
17
- if (!this._address) {
18
- throw new Error(
19
- "Solana signer not initialized. Call initialize() first or use createWDKSvmSigner()."
20
- );
21
- }
22
- return this._address;
23
- }
24
- /**
25
- * Check if the adapter is initialized
26
- */
27
- get isInitialized() {
28
- return this._initialized;
29
- }
30
- /**
31
- * Initialize the adapter by fetching the address
32
- * Must be called before using the signer
33
- */
34
- async initialize() {
35
- if (this._initialized) {
36
- return;
37
- }
38
- const addressStr = await this._account.getAddress();
39
- this._address = addressStr;
40
- this._initialized = true;
41
- }
42
- /**
43
- * Sign transactions with this signer
44
- *
45
- * This method signs the message bytes of each transaction and returns
46
- * signature dictionaries mapping address to signature.
47
- *
48
- * @param transactions - Array of transactions to sign
49
- * @returns Array of signature dictionaries
50
- */
51
- async signTransactions(transactions) {
52
- if (!transactions || transactions.length === 0) {
53
- return [];
54
- }
55
- const results = [];
56
- for (const tx of transactions) {
57
- if (!tx.messageBytes || tx.messageBytes.length === 0) {
58
- throw new Error("Transaction messageBytes must not be empty");
59
- }
60
- const signature = await this._account.sign(tx.messageBytes);
61
- results.push({
62
- [this._address]: signature
63
- });
64
- }
65
- return results;
66
- }
67
- /**
68
- * Sign a single message (utility method)
69
- * @param message - Message bytes to sign
70
- * @returns Signature bytes
71
- */
72
- async sign(message) {
73
- return this._account.sign(message);
74
- }
75
- /**
76
- * Get SOL balance in lamports
77
- */
78
- async getBalance() {
79
- return this._account.getBalance();
80
- }
81
- /**
82
- * Get SPL token balance
83
- * @param mint - Token mint address
84
- */
85
- async getTokenBalance(mint) {
86
- return this._account.getTokenBalance(mint);
87
- }
88
- /**
89
- * Transfer SPL tokens
90
- * @param params - Transfer parameters
91
- * @returns Transaction signature
92
- */
93
- async transfer(params) {
94
- return this._account.transfer(params);
95
- }
96
- };
97
- async function createWDKSvmSigner(account) {
98
- const adapter = new WDKSvmSignerAdapter(account);
99
- await adapter.initialize();
100
- return adapter;
101
- }
102
-
103
- export {
104
- WDKSvmSignerAdapter,
105
- createWDKSvmSigner
106
- };
107
- //# sourceMappingURL=chunk-MCFHZSF7.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/adapters/svm-adapter.ts"],"sourcesContent":["/**\n * Solana (SVM) Signer Adapter for WDK\n *\n * Wraps a Tether WDK Solana account to implement T402's ClientSvmSigner interface.\n * ClientSvmSigner is just TransactionSigner from @solana/kit.\n */\n\nimport type { WDKSolanaAccount } from '../types.js'\n\n/**\n * Address type from @solana/kit (base58 string)\n * We use a branded type for compatibility\n */\nexport type SolanaAddress = string & { readonly __brand?: unique symbol }\n\n/**\n * TransactionSigner interface matching @solana/kit\n * This is what T402's ClientSvmSigner expects\n */\nexport interface TransactionSigner {\n readonly address: SolanaAddress\n signTransactions<T extends { messageBytes: Uint8Array; signatures: Record<string, unknown> }>(\n transactions: readonly T[],\n ): Promise<readonly Record<string, Uint8Array>[]>\n}\n\n/**\n * WDKSvmSignerAdapter - Adapts a WDK Solana account to T402's ClientSvmSigner\n *\n * ClientSvmSigner is TransactionSigner from @solana/kit which requires:\n * - address: The public key as Address type\n * - signTransactions: Sign multiple transactions, returning signature dictionaries\n *\n * @example\n * ```typescript\n * const adapter = await createWDKSvmSigner(wdkSolanaAccount);\n *\n * // Use with T402 client\n * const client = createT402HTTPClient({\n * signers: [{ scheme: 'exact', network: 'solana:mainnet', signer: adapter }]\n * });\n * ```\n */\nexport class WDKSvmSignerAdapter implements TransactionSigner {\n private _account: WDKSolanaAccount\n private _address: SolanaAddress | null = null\n private _initialized = false\n\n constructor(account: WDKSolanaAccount) {\n if (!account) {\n throw new Error('WDK Solana account is required')\n }\n this._account = account\n }\n\n /**\n * Get the wallet address (base58)\n * @throws Error if not initialized\n */\n get address(): SolanaAddress {\n if (!this._address) {\n throw new Error(\n 'Solana signer not initialized. Call initialize() first or use createWDKSvmSigner().',\n )\n }\n return this._address\n }\n\n /**\n * Check if the adapter is initialized\n */\n get isInitialized(): boolean {\n return this._initialized\n }\n\n /**\n * Initialize the adapter by fetching the address\n * Must be called before using the signer\n */\n async initialize(): Promise<void> {\n if (this._initialized) {\n return\n }\n\n const addressStr = await this._account.getAddress()\n this._address = addressStr as SolanaAddress\n this._initialized = true\n }\n\n /**\n * Sign transactions with this signer\n *\n * This method signs the message bytes of each transaction and returns\n * signature dictionaries mapping address to signature.\n *\n * @param transactions - Array of transactions to sign\n * @returns Array of signature dictionaries\n */\n async signTransactions<\n T extends { messageBytes: Uint8Array; signatures: Record<string, unknown> },\n >(transactions: readonly T[]): Promise<readonly Record<string, Uint8Array>[]> {\n if (!transactions || transactions.length === 0) {\n return []\n }\n\n const results: Record<string, Uint8Array>[] = []\n\n for (const tx of transactions) {\n if (!tx.messageBytes || tx.messageBytes.length === 0) {\n throw new Error('Transaction messageBytes must not be empty')\n }\n\n // Sign the message bytes using WDK account\n const signature = await this._account.sign(tx.messageBytes)\n\n // Return as a dictionary mapping our address to the signature\n results.push({\n [this._address as string]: signature,\n })\n }\n\n return results\n }\n\n /**\n * Sign a single message (utility method)\n * @param message - Message bytes to sign\n * @returns Signature bytes\n */\n async sign(message: Uint8Array): Promise<Uint8Array> {\n return this._account.sign(message)\n }\n\n /**\n * Get SOL balance in lamports\n */\n async getBalance(): Promise<bigint> {\n return this._account.getBalance()\n }\n\n /**\n * Get SPL token balance\n * @param mint - Token mint address\n */\n async getTokenBalance(mint: string): Promise<bigint> {\n return this._account.getTokenBalance(mint)\n }\n\n /**\n * Transfer SPL tokens\n * @param params - Transfer parameters\n * @returns Transaction signature\n */\n async transfer(params: { token: string; recipient: string; amount: bigint }): Promise<string> {\n return this._account.transfer(params)\n }\n}\n\n/**\n * Create an initialized WDK Solana signer\n *\n * @param account - WDK Solana account from @tetherto/wdk-wallet-solana\n * @returns Initialized TransactionSigner (ClientSvmSigner)\n *\n * @example\n * ```typescript\n * import { T402WDK } from '@t402/wdk';\n *\n * const wallet = new T402WDK(seedPhrase, config);\n * const svmSigner = await wallet.getSvmSigner();\n *\n * // Use with T402 client\n * const client = createT402HTTPClient({\n * signers: [{ scheme: 'exact', network: 'solana:mainnet', signer: svmSigner }]\n * });\n * ```\n */\nexport async function createWDKSvmSigner(account: WDKSolanaAccount): Promise<WDKSvmSignerAdapter> {\n const adapter = new WDKSvmSignerAdapter(account)\n await adapter.initialize()\n return adapter\n}\n"],"mappings":";AA2CO,IAAM,sBAAN,MAAuD;AAAA,EACpD;AAAA,EACA,WAAiC;AAAA,EACjC,eAAe;AAAA,EAEvB,YAAY,SAA2B;AACrC,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,MAAM,gCAAgC;AAAA,IAClD;AACA,SAAK,WAAW;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,UAAyB;AAC3B,QAAI,CAAC,KAAK,UAAU;AAClB,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AACA,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,gBAAyB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,aAA4B;AAChC,QAAI,KAAK,cAAc;AACrB;AAAA,IACF;AAEA,UAAM,aAAa,MAAM,KAAK,SAAS,WAAW;AAClD,SAAK,WAAW;AAChB,SAAK,eAAe;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,iBAEJ,cAA4E;AAC5E,QAAI,CAAC,gBAAgB,aAAa,WAAW,GAAG;AAC9C,aAAO,CAAC;AAAA,IACV;AAEA,UAAM,UAAwC,CAAC;AAE/C,eAAW,MAAM,cAAc;AAC7B,UAAI,CAAC,GAAG,gBAAgB,GAAG,aAAa,WAAW,GAAG;AACpD,cAAM,IAAI,MAAM,4CAA4C;AAAA,MAC9D;AAGA,YAAM,YAAY,MAAM,KAAK,SAAS,KAAK,GAAG,YAAY;AAG1D,cAAQ,KAAK;AAAA,QACX,CAAC,KAAK,QAAkB,GAAG;AAAA,MAC7B,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,KAAK,SAA0C;AACnD,WAAO,KAAK,SAAS,KAAK,OAAO;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAA8B;AAClC,WAAO,KAAK,SAAS,WAAW;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,gBAAgB,MAA+B;AACnD,WAAO,KAAK,SAAS,gBAAgB,IAAI;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,SAAS,QAA+E;AAC5F,WAAO,KAAK,SAAS,SAAS,MAAM;AAAA,EACtC;AACF;AAqBA,eAAsB,mBAAmB,SAAyD;AAChG,QAAM,UAAU,IAAI,oBAAoB,OAAO;AAC/C,QAAM,QAAQ,WAAW;AACzB,SAAO;AACT;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/adapters/ton-adapter.ts"],"sourcesContent":["/**\n * TON Signer Adapter for WDK\n *\n * Wraps a Tether WDK TON account to implement T402's ClientTonSigner interface.\n * This allows WDK-managed TON wallets to be used for T402 payments.\n */\n\nimport type { WDKTonAccount } from '../types.js'\n\n/**\n * TON Address type (compatible with @ton/core Address)\n * We define our own interface to avoid direct import\n */\nexport interface TonAddress {\n toString(): string\n toRawString(): string\n}\n\n/**\n * TON Cell type (compatible with @ton/core Cell)\n * We define our own interface to avoid direct import\n */\nexport interface TonCell {\n hash(): Uint8Array\n toBoc(): Uint8Array\n}\n\n/**\n * SignMessageParams type matching T402's @t402/ton interface\n */\nexport interface SignMessageParams {\n /** Destination address */\n to: TonAddress\n /** Amount of TON to attach (for gas) in nanoTON */\n value: bigint\n /** Message body (Jetton transfer cell) */\n body: TonCell\n /** Send mode flags (from @ton/core SendMode) */\n sendMode?: number\n /** Bounce flag */\n bounce?: boolean\n /** Message validity timeout in seconds */\n timeout?: number\n}\n\n/**\n * ClientTonSigner interface matching T402's @t402/ton\n */\nexport interface ClientTonSigner {\n readonly address: TonAddress\n signMessage(params: SignMessageParams): Promise<TonCell>\n getSeqno(): Promise<number>\n}\n\n/**\n * Simple TonAddress implementation for WDK\n */\nclass WDKTonAddress implements TonAddress {\n constructor(private _address: string) {}\n\n toString(): string {\n return this._address\n }\n\n toRawString(): string {\n return this._address\n }\n}\n\n/**\n * WDKTonSignerAdapter - Adapts a WDK TON account to T402's ClientTonSigner\n *\n * This adapter wraps a Tether WDK TON account and provides T402-compatible\n * signing functionality. The actual message building and signing is delegated\n * to the WDK account, which handles TON-specific details internally.\n *\n * @example\n * ```typescript\n * const adapter = await createWDKTonSigner(wdkTonAccount);\n * const signed = await adapter.signMessage({\n * to: jettonWalletAddress,\n * value: toNano('0.05'),\n * body: jettonTransferBody,\n * });\n * ```\n */\nexport class WDKTonSignerAdapter implements ClientTonSigner {\n private _account: WDKTonAccount\n private _address: TonAddress | null = null\n private _initialized = false\n\n constructor(account: WDKTonAccount) {\n if (!account) {\n throw new Error('WDK TON account is required')\n }\n this._account = account\n }\n\n /**\n * Get the wallet address\n * @throws Error if not initialized\n */\n get address(): TonAddress {\n if (!this._address) {\n throw new Error(\n 'TON signer not initialized. Call initialize() first or use createWDKTonSigner().',\n )\n }\n return this._address\n }\n\n /**\n * Check if the adapter is initialized\n */\n get isInitialized(): boolean {\n return this._initialized\n }\n\n /**\n * Initialize the adapter by fetching the address\n * Must be called before using the signer\n */\n async initialize(): Promise<void> {\n if (this._initialized) {\n return\n }\n\n const addressStr = await this._account.getAddress()\n this._address = new WDKTonAddress(addressStr)\n this._initialized = true\n }\n\n /**\n * Sign an internal message for Jetton transfer\n *\n * Attempts to build a proper signed Cell using @ton/core if available.\n * Falls back to a simplified wrapper that embeds the raw signature.\n *\n * @param params - Message parameters\n * @returns Signed external message as Cell (BOC)\n */\n async signMessage(params: SignMessageParams): Promise<TonCell> {\n const msgHash = params.body.hash()\n const signature = await this._account.signMessage(msgHash)\n\n // Try to use @ton/core for proper Cell construction\n try {\n const tonCore = await import('@ton/core')\n const sigBuffer = Buffer.from(signature.buffer, signature.byteOffset, signature.byteLength)\n const bodyBoc = params.body.toBoc()\n const bocBuffer = Buffer.from(bodyBoc.buffer, bodyBoc.byteOffset, bodyBoc.byteLength)\n const signedCell = tonCore\n .beginCell()\n .storeBuffer(sigBuffer)\n .storeSlice(tonCore.Cell.fromBoc(bocBuffer)[0]!.beginParse())\n .endCell()\n return signedCell as unknown as TonCell\n } catch {\n // @ton/core not available — return simplified wrapper.\n // The signature is accessible via toBoc() and the original\n // message hash via hash(), which is sufficient for T402\n // facilitator verification.\n return {\n hash: () => msgHash,\n toBoc: () => signature,\n }\n }\n }\n\n /**\n * Get current seqno for the wallet\n * Used for replay protection\n */\n async getSeqno(): Promise<number> {\n return this._account.getSeqno()\n }\n\n /**\n * Get TON balance in nanoTON\n */\n async getBalance(): Promise<bigint> {\n return this._account.getBalance()\n }\n\n /**\n * Get Jetton balance\n * @param jettonMaster - Jetton master contract address\n */\n async getJettonBalance(jettonMaster: string): Promise<bigint> {\n return this._account.getJettonBalance(jettonMaster)\n }\n\n /**\n * Get the underlying WDK account\n * Useful for advanced operations not covered by this adapter\n */\n getWDKAccount(): WDKTonAccount {\n return this._account\n }\n}\n\n/**\n * Create an initialized WDK TON signer\n *\n * @param account - WDK TON account from @tetherto/wdk-wallet-ton\n * @returns Initialized ClientTonSigner\n *\n * @example\n * ```typescript\n * import { T402WDK } from '@t402/wdk';\n *\n * const wallet = new T402WDK(seedPhrase, config);\n * const tonSigner = await wallet.getTonSigner();\n *\n * // Use with T402 client\n * const client = createT402HTTPClient({\n * signers: [{ scheme: 'exact', network: 'ton:mainnet', signer: tonSigner }]\n * });\n * ```\n */\nexport async function createWDKTonSigner(account: WDKTonAccount): Promise<WDKTonSignerAdapter> {\n const adapter = new WDKTonSignerAdapter(account)\n await adapter.initialize()\n return adapter\n}\n"],"mappings":";AAyDA,IAAM,gBAAN,MAA0C;AAAA,EACxC,YAAoB,UAAkB;AAAlB;AAAA,EAAmB;AAAA,EAEvC,WAAmB;AACjB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,cAAsB;AACpB,WAAO,KAAK;AAAA,EACd;AACF;AAmBO,IAAM,sBAAN,MAAqD;AAAA,EAClD;AAAA,EACA,WAA8B;AAAA,EAC9B,eAAe;AAAA,EAEvB,YAAY,SAAwB;AAClC,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,MAAM,6BAA6B;AAAA,IAC/C;AACA,SAAK,WAAW;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,UAAsB;AACxB,QAAI,CAAC,KAAK,UAAU;AAClB,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AACA,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,gBAAyB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,aAA4B;AAChC,QAAI,KAAK,cAAc;AACrB;AAAA,IACF;AAEA,UAAM,aAAa,MAAM,KAAK,SAAS,WAAW;AAClD,SAAK,WAAW,IAAI,cAAc,UAAU;AAC5C,SAAK,eAAe;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,YAAY,QAA6C;AAC7D,UAAM,UAAU,OAAO,KAAK,KAAK;AACjC,UAAM,YAAY,MAAM,KAAK,SAAS,YAAY,OAAO;AAGzD,QAAI;AACF,YAAM,UAAU,MAAM,OAAO,WAAW;AACxC,YAAM,YAAY,OAAO,KAAK,UAAU,QAAQ,UAAU,YAAY,UAAU,UAAU;AAC1F,YAAM,UAAU,OAAO,KAAK,MAAM;AAClC,YAAM,YAAY,OAAO,KAAK,QAAQ,QAAQ,QAAQ,YAAY,QAAQ,UAAU;AACpF,YAAM,aAAa,QAChB,UAAU,EACV,YAAY,SAAS,EACrB,WAAW,QAAQ,KAAK,QAAQ,SAAS,EAAE,CAAC,EAAG,WAAW,CAAC,EAC3D,QAAQ;AACX,aAAO;AAAA,IACT,QAAQ;AAKN,aAAO;AAAA,QACL,MAAM,MAAM;AAAA,QACZ,OAAO,MAAM;AAAA,MACf;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WAA4B;AAChC,WAAO,KAAK,SAAS,SAAS;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAA8B;AAClC,WAAO,KAAK,SAAS,WAAW;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,iBAAiB,cAAuC;AAC5D,WAAO,KAAK,SAAS,iBAAiB,YAAY;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,gBAA+B;AAC7B,WAAO,KAAK;AAAA,EACd;AACF;AAqBA,eAAsB,mBAAmB,SAAsD;AAC7F,QAAM,UAAU,IAAI,oBAAoB,OAAO;AAC/C,QAAM,QAAQ,WAAW;AACzB,SAAO;AACT;","names":[]}
@@ -1,489 +0,0 @@
1
- import { Address } from 'viem';
2
-
3
- /**
4
- * Type definitions for T402 WDK integration
5
- */
6
-
7
- /**
8
- * EVM chain configuration
9
- */
10
- interface EvmChainConfig {
11
- /** RPC endpoint URL */
12
- provider: string;
13
- /** Chain ID */
14
- chainId: number;
15
- /** CAIP-2 network identifier */
16
- network: string;
17
- }
18
- /**
19
- * T402 WDK configuration options
20
- */
21
- interface T402WDKConfig {
22
- /** Ethereum mainnet configuration */
23
- ethereum?: EvmChainConfig | string;
24
- /** Arbitrum One configuration */
25
- arbitrum?: EvmChainConfig | string;
26
- /** Base mainnet configuration */
27
- base?: EvmChainConfig | string;
28
- /** Ink mainnet configuration */
29
- ink?: EvmChainConfig | string;
30
- /** Berachain mainnet configuration */
31
- berachain?: EvmChainConfig | string;
32
- /** Unichain mainnet configuration */
33
- unichain?: EvmChainConfig | string;
34
- /** Polygon mainnet configuration */
35
- polygon?: EvmChainConfig | string;
36
- /** Custom chains */
37
- [key: string]: EvmChainConfig | string | undefined;
38
- }
39
- /**
40
- * Normalized chain configuration
41
- */
42
- interface NormalizedChainConfig {
43
- provider: string;
44
- chainId: number;
45
- network: string;
46
- name: string;
47
- }
48
- /**
49
- * Token balance information
50
- */
51
- interface TokenBalance {
52
- /** Token contract address */
53
- token: Address;
54
- /** Token symbol */
55
- symbol: string;
56
- /** Balance in smallest units */
57
- balance: bigint;
58
- /** Formatted balance (human-readable) */
59
- formatted: string;
60
- /** Decimals */
61
- decimals: number;
62
- }
63
- /**
64
- * Chain balance information
65
- */
66
- interface ChainBalance {
67
- /** Chain name (e.g., "arbitrum") */
68
- chain: string;
69
- /** CAIP-2 network identifier */
70
- network: string;
71
- /** Native token balance */
72
- native: bigint;
73
- /** Token balances */
74
- tokens: TokenBalance[];
75
- }
76
- /**
77
- * Aggregated balance across all chains
78
- */
79
- interface AggregatedBalance {
80
- /** Total USDT0 balance across all chains */
81
- totalUsdt0: bigint;
82
- /** Total USDC balance across all chains */
83
- totalUsdc: bigint;
84
- /** Per-chain balances */
85
- chains: ChainBalance[];
86
- }
87
- /**
88
- * Bridge parameters for cross-chain transfers
89
- */
90
- interface BridgeParams {
91
- /** Source chain name */
92
- fromChain: string;
93
- /** Destination chain name */
94
- toChain: string;
95
- /** Amount to bridge in smallest units */
96
- amount: bigint;
97
- /** Recipient address (optional, defaults to same wallet on target chain) */
98
- recipient?: Address;
99
- }
100
- /**
101
- * Bridge result
102
- */
103
- interface BridgeResult {
104
- /** Transaction hash on source chain */
105
- txHash: string;
106
- /** Estimated time for bridge completion in seconds */
107
- estimatedTime: number;
108
- }
109
- /**
110
- * EIP-712 typed data domain
111
- */
112
- interface TypedDataDomain {
113
- name: string;
114
- version: string;
115
- chainId: number;
116
- verifyingContract: Address;
117
- }
118
- /**
119
- * EIP-712 typed data types
120
- */
121
- type TypedDataTypes = Record<string, Array<{
122
- name: string;
123
- type: string;
124
- }>>;
125
- /**
126
- * T402 Signer interface for WDK
127
- * Compatible with @t402/core signer requirements
128
- */
129
- interface T402WDKSigner {
130
- /** Get wallet address */
131
- readonly address: Address;
132
- /** Sign EIP-712 typed data */
133
- signTypedData(params: {
134
- domain: TypedDataDomain;
135
- types: TypedDataTypes;
136
- primaryType: string;
137
- message: Record<string, unknown>;
138
- }): Promise<`0x${string}`>;
139
- /** Sign a message */
140
- signMessage?(message: string | Uint8Array): Promise<`0x${string}`>;
141
- /** Get token balance */
142
- getTokenBalance?(tokenAddress: Address): Promise<bigint>;
143
- }
144
- /**
145
- * WDK Account interface (matches @tetherto/wdk account structure)
146
- *
147
- * This is the canonical definition used across all @t402/wdk-* packages.
148
- * Implementors (Tether WDK) provide these methods; T402 code consumes them.
149
- */
150
- interface WDKAccount {
151
- /** Get the account's address */
152
- getAddress(): Promise<string>;
153
- /** Get the account's native balance */
154
- getBalance(): Promise<bigint>;
155
- /** Get the account's token balance */
156
- getTokenBalance(tokenAddress: string): Promise<bigint>;
157
- /** Sign a message */
158
- signMessage(message: string): Promise<string>;
159
- /** Sign typed data (EIP-712) */
160
- signTypedData(params: {
161
- domain: Record<string, unknown>;
162
- types: Record<string, unknown>;
163
- primaryType: string;
164
- message: Record<string, unknown>;
165
- }): Promise<string>;
166
- /** Send a transaction */
167
- sendTransaction(params: {
168
- to: string;
169
- value?: bigint;
170
- data?: string;
171
- }): Promise<string>;
172
- /** Estimate gas for a transaction (optional — not all implementations support this) */
173
- estimateGas?(params: {
174
- to: string;
175
- value?: bigint;
176
- data?: string;
177
- }): Promise<bigint>;
178
- }
179
- /**
180
- * Alias for WDKAccount — preferred naming for use in @t402/wdk-* packages.
181
- */
182
- type WdkAccount = WDKAccount;
183
- /**
184
- * WDK instance interface (matches @tetherto/wdk structure)
185
- */
186
- interface WDKInstance {
187
- registerWallet<T>(name: string, manager: T, config: Record<string, unknown>): WDKInstance;
188
- registerProtocol<T>(name: string, protocol: T): WDKInstance;
189
- getAccount(chain: string, index: number): Promise<WDKAccount>;
190
- executeProtocol(name: string, params: Record<string, unknown>): Promise<{
191
- txHash: string;
192
- }>;
193
- }
194
- /**
195
- * WDK constructor type
196
- */
197
- interface WDKConstructor {
198
- new (seedPhrase: string): WDKInstance;
199
- getRandomSeedPhrase(): string;
200
- }
201
- /**
202
- * Balance cache configuration for T402WDK
203
- */
204
- interface T402BalanceCacheConfig {
205
- /** Whether caching is enabled (default: true) */
206
- enabled?: boolean;
207
- /** TTL for native balance in milliseconds (default: 15000 = 15 seconds) */
208
- nativeBalanceTTL?: number;
209
- /** TTL for token balance in milliseconds (default: 30000 = 30 seconds) */
210
- tokenBalanceTTL?: number;
211
- /** TTL for aggregated balances in milliseconds (default: 60000 = 60 seconds) */
212
- aggregatedBalanceTTL?: number;
213
- /** Maximum cache entries (default: 500) */
214
- maxSize?: number;
215
- }
216
- /**
217
- * Extended T402 WDK configuration with cache options
218
- */
219
- interface T402WDKOptions {
220
- /** Balance cache configuration */
221
- cache?: T402BalanceCacheConfig;
222
- }
223
- /**
224
- * Supported blockchain families
225
- */
226
- type ChainFamily = 'evm' | 'svm' | 'ton' | 'tron';
227
- /**
228
- * Solana chain configuration
229
- */
230
- interface SvmChainConfig {
231
- /** RPC endpoint URL */
232
- rpcUrl: string;
233
- /** Commitment level */
234
- commitment?: 'processed' | 'confirmed' | 'finalized';
235
- /** Network type */
236
- network?: 'mainnet' | 'testnet' | 'devnet';
237
- }
238
- /**
239
- * TON chain configuration
240
- */
241
- interface TonChainConfig {
242
- /** API endpoint URL */
243
- endpoint: string;
244
- /** Network type */
245
- network?: 'mainnet' | 'testnet';
246
- /** API key for TON Center */
247
- apiKey?: string;
248
- }
249
- /**
250
- * TRON chain configuration
251
- */
252
- interface TronChainConfig {
253
- /** Full host URL (e.g., https://api.trongrid.io) */
254
- fullHost: string;
255
- /** Network type */
256
- network?: 'mainnet' | 'shasta' | 'nile';
257
- /** API key for TronGrid */
258
- apiKey?: string;
259
- }
260
- /**
261
- * Multi-chain configuration
262
- */
263
- interface MultiChainConfig {
264
- /** EVM chains configuration */
265
- evm?: Record<string, EvmChainConfig | string>;
266
- /** Solana configuration */
267
- svm?: SvmChainConfig;
268
- /** TON configuration */
269
- ton?: TonChainConfig;
270
- /** TRON configuration */
271
- tron?: TronChainConfig;
272
- }
273
- /**
274
- * WDK wallet modules registry
275
- * All modules are optional - only register what you need
276
- */
277
- interface WDKWalletModules {
278
- /** EVM wallet manager (@tetherto/wdk-wallet-evm) */
279
- evm?: unknown;
280
- /** EVM ERC-4337 wallet manager (@tetherto/wdk-wallet-evm-erc4337) */
281
- evmErc4337?: unknown;
282
- /** Solana wallet manager (@tetherto/wdk-wallet-solana) */
283
- solana?: unknown;
284
- /** TON wallet manager (@tetherto/wdk-wallet-ton) */
285
- ton?: unknown;
286
- /** TON gasless wallet manager (@tetherto/wdk-wallet-ton-gasless) */
287
- tonGasless?: unknown;
288
- /** TRON wallet manager (@tetherto/wdk-wallet-tron) */
289
- tron?: unknown;
290
- /** Bitcoin wallet manager (@tetherto/wdk-wallet-btc) */
291
- btc?: unknown;
292
- }
293
- /**
294
- * WDK protocol modules registry
295
- * All modules are optional - only register what you need
296
- */
297
- interface WDKProtocolModules {
298
- /** USDT0 bridge for EVM (@tetherto/wdk-protocol-bridge-usdt0-evm) */
299
- bridgeUsdt0Evm?: unknown;
300
- /** USDT0 bridge for TON (@tetherto/wdk-protocol-bridge-usdt0-ton) */
301
- bridgeUsdt0Ton?: unknown;
302
- /** Velora swap for EVM (@tetherto/wdk-protocol-swap-velora-evm) */
303
- swapVeloraEvm?: unknown;
304
- /** Aave lending for EVM (@tetherto/wdk-protocol-lending-aave-evm) */
305
- lendingAaveEvm?: unknown;
306
- }
307
- /**
308
- * Unified WDK modules registration
309
- */
310
- interface WDKModulesConfig {
311
- /** Wallet modules */
312
- wallets?: WDKWalletModules;
313
- /** Protocol modules */
314
- protocols?: WDKProtocolModules;
315
- }
316
- /**
317
- * WDK TON account interface (compatible with @tetherto/wdk-wallet-ton)
318
- */
319
- interface WDKTonAccount {
320
- /** Get wallet address */
321
- getAddress(): Promise<string>;
322
- /** Get TON balance */
323
- getBalance(): Promise<bigint>;
324
- /** Get Jetton balance */
325
- getJettonBalance(jettonMaster: string): Promise<bigint>;
326
- /** Sign a message */
327
- signMessage(message: Uint8Array): Promise<Uint8Array>;
328
- /** Send TON transaction */
329
- sendTransaction(params: {
330
- to: string;
331
- value: bigint;
332
- body?: string;
333
- bounce?: boolean;
334
- }): Promise<string>;
335
- /** Get current sequence number */
336
- getSeqno(): Promise<number>;
337
- /** Transfer Jettons */
338
- transferJetton?(params: {
339
- jettonMaster: string;
340
- to: string;
341
- amount: bigint;
342
- forwardPayload?: string;
343
- }): Promise<string>;
344
- }
345
- /**
346
- * WDK Solana account interface (compatible with @tetherto/wdk-wallet-solana)
347
- */
348
- interface WDKSolanaAccount {
349
- /** Get wallet address (base58) */
350
- getAddress(): Promise<string>;
351
- /** Get SOL balance */
352
- getBalance(): Promise<bigint>;
353
- /** Get SPL token balance */
354
- getTokenBalance(mint: string): Promise<bigint>;
355
- /** Sign a message */
356
- sign(message: Uint8Array): Promise<Uint8Array>;
357
- /** Sign a transaction */
358
- signTransaction(transaction: Uint8Array): Promise<Uint8Array>;
359
- /** Send SOL */
360
- sendTransaction(params: {
361
- recipient: string;
362
- value: bigint;
363
- }): Promise<string>;
364
- /** Transfer SPL token */
365
- transfer(params: {
366
- token: string;
367
- recipient: string;
368
- amount: bigint;
369
- }): Promise<string>;
370
- }
371
- /**
372
- * WDK TRON account interface (compatible with @tetherto/wdk-wallet-tron)
373
- */
374
- interface WDKTronAccount {
375
- /** Get wallet address (base58) */
376
- getAddress(): Promise<string>;
377
- /** Get TRX balance */
378
- getBalance(): Promise<bigint>;
379
- /** Get TRC20 token balance */
380
- getTrc20Balance(contractAddress: string): Promise<bigint>;
381
- /** Sign a transaction */
382
- signTransaction(transaction: unknown): Promise<unknown>;
383
- /** Send signed transaction */
384
- sendTransaction(signedTx: unknown): Promise<string>;
385
- /** Transfer TRC20 token */
386
- transferTrc20?(params: {
387
- contractAddress: string;
388
- to: string;
389
- amount: bigint;
390
- }): Promise<string>;
391
- }
392
- /**
393
- * Extended WDK instance interface with multi-chain support
394
- */
395
- interface WDKInstanceMultiChain extends WDKInstance {
396
- /** Get TON account */
397
- getTonAccount?(index: number): Promise<WDKTonAccount>;
398
- /** Get Solana account */
399
- getSolanaAccount?(index: number): Promise<WDKSolanaAccount>;
400
- /** Get TRON account */
401
- getTronAccount?(index: number): Promise<WDKTronAccount>;
402
- }
403
- /**
404
- * Configuration for T402WDK.create() factory method
405
- */
406
- interface T402WDKCreateConfig {
407
- /** BIP-39 mnemonic seed phrase */
408
- seedPhrase: string;
409
- /** Chain name → RPC URL mapping for EVM chains */
410
- chains: Record<string, string>;
411
- /** WDK modules to register */
412
- modules: WDKModulesConfig;
413
- /** Additional options */
414
- options?: T402WDKOptions;
415
- }
416
- /**
417
- * A signer entry for use with T402 HTTP clients
418
- */
419
- interface SignerEntry {
420
- /** Payment scheme (e.g., "exact") */
421
- scheme: string;
422
- /** CAIP-2 network identifier (e.g., "eip155:42161") */
423
- network: string;
424
- /** The signer instance */
425
- signer: unknown;
426
- /** Chain family (evm, ton, svm, tron) */
427
- family: ChainFamily;
428
- }
429
- /**
430
- * Options for getAllSigners()
431
- */
432
- interface GetAllSignersOptions {
433
- /** HD wallet account index (default: 0) */
434
- accountIndex?: number;
435
- /** Filter by payment schemes (default: ["exact"]) */
436
- schemes?: string[];
437
- /** Include non-EVM chain signers (default: true) */
438
- includeNonEvm?: boolean;
439
- }
440
- /**
441
- * Options for T402WDK.fromWDK()
442
- */
443
- interface FromWDKOptions {
444
- /** HD wallet account index for auto-discovery (default: 0) */
445
- defaultAccountIndex?: number;
446
- }
447
- /**
448
- * Swap quote result
449
- */
450
- interface SwapQuote {
451
- /** Input token address */
452
- inputToken: string;
453
- /** Output token address */
454
- outputToken: string;
455
- /** Input amount in smallest units */
456
- inputAmount: bigint;
457
- /** Expected output amount in smallest units */
458
- outputAmount: bigint;
459
- /** Price impact percentage */
460
- priceImpact: number;
461
- /** Swap route (token addresses) */
462
- route: string[];
463
- }
464
- /**
465
- * Swap execution result
466
- */
467
- interface SwapResult {
468
- /** Transaction hash */
469
- txHash: string;
470
- /** Actual input amount */
471
- inputAmount: bigint;
472
- /** Actual output amount */
473
- outputAmount: bigint;
474
- }
475
- /**
476
- * Parameters for swap operations
477
- */
478
- interface SwapParams {
479
- /** Chain name (e.g., "ethereum", "arbitrum") */
480
- chain: string;
481
- /** Input token address */
482
- fromToken: string;
483
- /** Amount to swap in smallest units */
484
- amount: bigint;
485
- /** Maximum slippage tolerance (0-1, default: 0.005 = 0.5%) */
486
- maxSlippage?: number;
487
- }
488
-
489
- export type { AggregatedBalance as A, BridgeParams as B, ChainFamily as C, EvmChainConfig as E, FromWDKOptions as F, GetAllSignersOptions as G, MultiChainConfig as M, NormalizedChainConfig as N, SignerEntry as S, T402WDKCreateConfig as T, WDKSolanaAccount as W, WDKTonAccount as a, WDKTronAccount as b, WDKInstance as c, WDKConstructor as d, WDKModulesConfig as e, WDKWalletModules as f, WDKProtocolModules as g, T402WDKConfig as h, T402WDKOptions as i, ChainBalance as j, BridgeResult as k, SwapQuote as l, SwapParams as m, SwapResult as n, T402BalanceCacheConfig as o, TokenBalance as p, TypedDataDomain as q, TypedDataTypes as r, T402WDKSigner as s, WDKAccount as t, WdkAccount as u, SvmChainConfig as v, TonChainConfig as w, TronChainConfig as x, WDKInstanceMultiChain as y };