@lendasat/lendaswap-sdk-pure 0.2.41 → 0.2.43

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 (252) hide show
  1. package/dist/_esm-6K2AP5GG.js +3663 -0
  2. package/dist/_esm-6K2AP5GG.js.map +1 -0
  3. package/dist/_esm-UGRDSVEV.cjs +3662 -0
  4. package/dist/_esm-UGRDSVEV.cjs.map +1 -0
  5. package/dist/api/client.d.ts +0 -4
  6. package/dist/api/client.d.ts.map +1 -1
  7. package/dist/base-2KYNAFR3.cjs +109 -0
  8. package/dist/base-2KYNAFR3.cjs.map +1 -0
  9. package/dist/base-HMHH3XPM.js +9 -0
  10. package/dist/base-HMHH3XPM.js.map +1 -0
  11. package/dist/ccip-EBXWV2U3.js +8 -0
  12. package/dist/ccip-EBXWV2U3.js.map +1 -0
  13. package/dist/ccip-PD37NJHA.cjs +26 -0
  14. package/dist/ccip-PD37NJHA.cjs.map +1 -0
  15. package/dist/cctp-bridge/index.cjs +67 -0
  16. package/dist/cctp-bridge/index.cjs.map +1 -0
  17. package/dist/cctp-bridge/index.js +53 -15
  18. package/dist/cctp-bridge/index.js.map +1 -1
  19. package/dist/cctp-inbound/client.d.ts +21 -19
  20. package/dist/cctp-inbound/client.d.ts.map +1 -1
  21. package/dist/cctp-inbound/smartAccount.d.ts +21 -19
  22. package/dist/cctp-inbound/smartAccount.d.ts.map +1 -1
  23. package/dist/chunk-4JXN4UPB.js +554 -0
  24. package/dist/chunk-4JXN4UPB.js.map +1 -0
  25. package/dist/chunk-A4GKKURK.cjs +430 -0
  26. package/dist/chunk-A4GKKURK.cjs.map +1 -0
  27. package/dist/chunk-BZU3R5DJ.cjs +554 -0
  28. package/dist/chunk-BZU3R5DJ.cjs.map +1 -0
  29. package/dist/chunk-DBBCKPZ5.js +421 -0
  30. package/dist/chunk-DBBCKPZ5.js.map +1 -0
  31. package/dist/chunk-DNSJDKTP.cjs +96 -0
  32. package/dist/chunk-DNSJDKTP.cjs.map +1 -0
  33. package/dist/chunk-EIK6BZWG.js +90 -0
  34. package/dist/chunk-EIK6BZWG.js.map +1 -0
  35. package/dist/chunk-GVAPVS4Z.js +6144 -0
  36. package/dist/chunk-GVAPVS4Z.js.map +1 -0
  37. package/dist/chunk-I7TGLGN6.js +46 -0
  38. package/dist/chunk-I7TGLGN6.js.map +1 -0
  39. package/dist/chunk-JBVKWKD4.cjs +50 -0
  40. package/dist/chunk-JBVKWKD4.cjs.map +1 -0
  41. package/dist/chunk-LA3YX2HD.js +47096 -0
  42. package/dist/chunk-LA3YX2HD.js.map +1 -0
  43. package/dist/chunk-PKDJZJMV.cjs +2214 -0
  44. package/dist/chunk-PKDJZJMV.cjs.map +1 -0
  45. package/dist/chunk-PRN5VZOM.js +370 -0
  46. package/dist/chunk-PRN5VZOM.js.map +1 -0
  47. package/dist/chunk-RIOT5VOJ.cjs +47240 -0
  48. package/dist/chunk-RIOT5VOJ.cjs.map +1 -0
  49. package/dist/chunk-WVZSHRV7.cjs +431 -0
  50. package/dist/chunk-WVZSHRV7.cjs.map +1 -0
  51. package/dist/chunk-YLWPBHMV.cjs +6311 -0
  52. package/dist/chunk-YLWPBHMV.cjs.map +1 -0
  53. package/dist/chunk-Z2FCTNRC.js +2210 -0
  54. package/dist/chunk-Z2FCTNRC.js.map +1 -0
  55. package/dist/client.d.ts +68 -1
  56. package/dist/client.d.ts.map +1 -1
  57. package/dist/compose-quote.d.ts +77 -0
  58. package/dist/compose-quote.d.ts.map +1 -0
  59. package/dist/delegate.cjs +23 -0
  60. package/dist/delegate.cjs.map +1 -0
  61. package/dist/delegate.js +8 -269
  62. package/dist/delegate.js.map +1 -1
  63. package/dist/dist-PWXNFVDF.js +8 -0
  64. package/dist/dist-PWXNFVDF.js.map +1 -0
  65. package/dist/dist-VEHYC67F.cjs +550 -0
  66. package/dist/dist-VEHYC67F.cjs.map +1 -0
  67. package/dist/esplora.d.ts +14 -0
  68. package/dist/esplora.d.ts.map +1 -1
  69. package/dist/generated/api.d.ts +235 -38
  70. package/dist/generated/api.d.ts.map +1 -1
  71. package/dist/index.cjs +35461 -0
  72. package/dist/index.cjs.map +1 -0
  73. package/dist/index.d.ts +2 -1
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +35312 -32
  76. package/dist/index.js.map +1 -1
  77. package/dist/mine.wasm-LUTPOAD2.js +12 -0
  78. package/dist/mine.wasm-LUTPOAD2.js.map +1 -0
  79. package/dist/mine.wasm-Z3ORSBKN.cjs +12 -0
  80. package/dist/mine.wasm-Z3ORSBKN.cjs.map +1 -0
  81. package/dist/node.cjs +166 -0
  82. package/dist/node.cjs.map +1 -0
  83. package/dist/node.js +159 -18
  84. package/dist/node.js.map +1 -1
  85. package/dist/secp256k1-B6OW5ZCM.js +8 -0
  86. package/dist/secp256k1-B6OW5ZCM.js.map +1 -0
  87. package/dist/secp256k1-PJCSE4N6.cjs +30 -0
  88. package/dist/secp256k1-PJCSE4N6.cjs.map +1 -0
  89. package/dist/tokens.d.ts +2 -1
  90. package/dist/tokens.d.ts.map +1 -1
  91. package/dist/types/chain-config.d.ts +50 -0
  92. package/dist/types/chain-config.d.ts.map +1 -0
  93. package/dist/types/chain.d.ts +11 -0
  94. package/dist/types/chain.d.ts.map +1 -0
  95. package/dist/types/dex-quote.d.ts +85 -0
  96. package/dist/types/dex-quote.d.ts.map +1 -0
  97. package/dist/types/index.d.ts +15 -0
  98. package/dist/types/index.d.ts.map +1 -0
  99. package/dist/types/network-fees.d.ts +43 -0
  100. package/dist/types/network-fees.d.ts.map +1 -0
  101. package/dist/types/quote.d.ts +87 -0
  102. package/dist/types/quote.d.ts.map +1 -0
  103. package/dist/types/swap-pairs.d.ts +37 -0
  104. package/dist/types/swap-pairs.d.ts.map +1 -0
  105. package/dist/version.d.ts +2 -2
  106. package/dist/wallet-4YGTKWNZ.js +7 -0
  107. package/dist/wallet-4YGTKWNZ.js.map +1 -0
  108. package/dist/wallet-SZJDXAY7.cjs +45 -0
  109. package/dist/wallet-SZJDXAY7.cjs.map +1 -0
  110. package/package.json +23 -10
  111. package/dist/api/client.js +0 -13
  112. package/dist/api/client.js.map +0 -1
  113. package/dist/arkade-network.js +0 -40
  114. package/dist/arkade-network.js.map +0 -1
  115. package/dist/arkade.js +0 -61
  116. package/dist/arkade.js.map +0 -1
  117. package/dist/cctp/attestation.js +0 -149
  118. package/dist/cctp/attestation.js.map +0 -1
  119. package/dist/cctp/constants.js +0 -92
  120. package/dist/cctp/constants.js.map +0 -1
  121. package/dist/cctp/fee.js +0 -70
  122. package/dist/cctp/fee.js.map +0 -1
  123. package/dist/cctp/index.js +0 -13
  124. package/dist/cctp/index.js.map +0 -1
  125. package/dist/cctp/types.js +0 -5
  126. package/dist/cctp/types.js.map +0 -1
  127. package/dist/cctp/utils.js +0 -91
  128. package/dist/cctp/utils.js.map +0 -1
  129. package/dist/cctp-bridge/bridge.js +0 -74
  130. package/dist/cctp-bridge/bridge.js.map +0 -1
  131. package/dist/cctp-inbound/approveAndBurn.js +0 -95
  132. package/dist/cctp-inbound/approveAndBurn.js.map +0 -1
  133. package/dist/cctp-inbound/burn.js +0 -66
  134. package/dist/cctp-inbound/burn.js.map +0 -1
  135. package/dist/cctp-inbound/chainMap.js +0 -128
  136. package/dist/cctp-inbound/chainMap.js.map +0 -1
  137. package/dist/cctp-inbound/client.js +0 -125
  138. package/dist/cctp-inbound/client.js.map +0 -1
  139. package/dist/cctp-inbound/eip2612.js +0 -95
  140. package/dist/cctp-inbound/eip2612.js.map +0 -1
  141. package/dist/cctp-inbound/evmSignerAdapter.js +0 -82
  142. package/dist/cctp-inbound/evmSignerAdapter.js.map +0 -1
  143. package/dist/cctp-inbound/fundSwap.js +0 -95
  144. package/dist/cctp-inbound/fundSwap.js.map +0 -1
  145. package/dist/cctp-inbound/index.js +0 -34
  146. package/dist/cctp-inbound/index.js.map +0 -1
  147. package/dist/cctp-inbound/permit2.js +0 -32
  148. package/dist/cctp-inbound/permit2.js.map +0 -1
  149. package/dist/cctp-inbound/preflight.js +0 -84
  150. package/dist/cctp-inbound/preflight.js.map +0 -1
  151. package/dist/cctp-inbound/recover.js +0 -177
  152. package/dist/cctp-inbound/recover.js.map +0 -1
  153. package/dist/cctp-inbound/smartAccount.js +0 -117
  154. package/dist/cctp-inbound/smartAccount.js.map +0 -1
  155. package/dist/cctp-inbound/submit.js +0 -136
  156. package/dist/cctp-inbound/submit.js.map +0 -1
  157. package/dist/cctp-inbound/types.js +0 -5
  158. package/dist/cctp-inbound/types.js.map +0 -1
  159. package/dist/cctp-inbound/userOp.js +0 -151
  160. package/dist/cctp-inbound/userOp.js.map +0 -1
  161. package/dist/client.js +0 -4126
  162. package/dist/client.js.map +0 -1
  163. package/dist/create/arkade-to-lightning.js +0 -76
  164. package/dist/create/arkade-to-lightning.js.map +0 -1
  165. package/dist/create/arkade.js +0 -86
  166. package/dist/create/arkade.js.map +0 -1
  167. package/dist/create/bitcoin-to-arkade.js +0 -76
  168. package/dist/create/bitcoin-to-arkade.js.map +0 -1
  169. package/dist/create/bitcoin.js +0 -77
  170. package/dist/create/bitcoin.js.map +0 -1
  171. package/dist/create/evm-to-arkade.js +0 -80
  172. package/dist/create/evm-to-arkade.js.map +0 -1
  173. package/dist/create/evm-to-bitcoin.js +0 -82
  174. package/dist/create/evm-to-bitcoin.js.map +0 -1
  175. package/dist/create/evm-to-lightning.js +0 -89
  176. package/dist/create/evm-to-lightning.js.map +0 -1
  177. package/dist/create/index.js +0 -21
  178. package/dist/create/index.js.map +0 -1
  179. package/dist/create/lightning-to-arkade.js +0 -69
  180. package/dist/create/lightning-to-arkade.js.map +0 -1
  181. package/dist/create/lightning.js +0 -61
  182. package/dist/create/lightning.js.map +0 -1
  183. package/dist/create/retry.js +0 -71
  184. package/dist/create/retry.js.map +0 -1
  185. package/dist/create/types.js +0 -5
  186. package/dist/create/types.js.map +0 -1
  187. package/dist/escrow/index.js +0 -115
  188. package/dist/escrow/index.js.map +0 -1
  189. package/dist/esplora.js +0 -47
  190. package/dist/esplora.js.map +0 -1
  191. package/dist/evm/coordinator.js +0 -714
  192. package/dist/evm/coordinator.js.map +0 -1
  193. package/dist/evm/htlc.js +0 -278
  194. package/dist/evm/htlc.js.map +0 -1
  195. package/dist/evm/index.js +0 -10
  196. package/dist/evm/index.js.map +0 -1
  197. package/dist/evm/signing.js +0 -70
  198. package/dist/evm/signing.js.map +0 -1
  199. package/dist/evm/wallet.js +0 -133
  200. package/dist/evm/wallet.js.map +0 -1
  201. package/dist/generated/api.js +0 -6
  202. package/dist/generated/api.js.map +0 -1
  203. package/dist/logging.js +0 -130
  204. package/dist/logging.js.map +0 -1
  205. package/dist/price-calculations.js +0 -135
  206. package/dist/price-calculations.js.map +0 -1
  207. package/dist/redeem/arkade.js +0 -416
  208. package/dist/redeem/arkade.js.map +0 -1
  209. package/dist/redeem/ethereum.js +0 -206
  210. package/dist/redeem/ethereum.js.map +0 -1
  211. package/dist/redeem/gasless.js +0 -73
  212. package/dist/redeem/gasless.js.map +0 -1
  213. package/dist/redeem/index.js +0 -189
  214. package/dist/redeem/index.js.map +0 -1
  215. package/dist/redeem/types.js +0 -36
  216. package/dist/redeem/types.js.map +0 -1
  217. package/dist/refund/arkade.js +0 -200
  218. package/dist/refund/arkade.js.map +0 -1
  219. package/dist/refund/collab-arkade-evm.js +0 -307
  220. package/dist/refund/collab-arkade-evm.js.map +0 -1
  221. package/dist/refund/collab-arkade-lightning.js +0 -245
  222. package/dist/refund/collab-arkade-lightning.js.map +0 -1
  223. package/dist/refund/index.js +0 -12
  224. package/dist/refund/index.js.map +0 -1
  225. package/dist/refund/onchain.js +0 -366
  226. package/dist/refund/onchain.js.map +0 -1
  227. package/dist/signer/index.js +0 -249
  228. package/dist/signer/index.js.map +0 -1
  229. package/dist/storage/idb.js +0 -236
  230. package/dist/storage/idb.js.map +0 -1
  231. package/dist/storage/index.js +0 -98
  232. package/dist/storage/index.js.map +0 -1
  233. package/dist/storage/sqlite.js +0 -206
  234. package/dist/storage/sqlite.js.map +0 -1
  235. package/dist/storage/types.js +0 -9
  236. package/dist/storage/types.js.map +0 -1
  237. package/dist/tokens.js +0 -322
  238. package/dist/tokens.js.map +0 -1
  239. package/dist/usd-price.js +0 -96
  240. package/dist/usd-price.js.map +0 -1
  241. package/dist/usdt0-bridge/constants.js +0 -71
  242. package/dist/usdt0-bridge/constants.js.map +0 -1
  243. package/dist/usdt0-bridge/index.js +0 -11
  244. package/dist/usdt0-bridge/index.js.map +0 -1
  245. package/dist/usdt0-bridge/tracking.js +0 -123
  246. package/dist/usdt0-bridge/tracking.js.map +0 -1
  247. package/dist/usdt0-bridge/utils.js +0 -51
  248. package/dist/usdt0-bridge/utils.js.map +0 -1
  249. package/dist/version.js +0 -6
  250. package/dist/version.js.map +0 -1
  251. package/dist/ws.js +0 -145
  252. package/dist/ws.js.map +0 -1
@@ -1,66 +0,0 @@
1
- /**
2
- * Source-chain burn calldata for the CCTP-inbound flow.
3
- *
4
- * Encodes `TokenMessenger.depositForBurn(...)` on CCTPv2. The user submits
5
- * this tx on the source chain (e.g. Optimism, Base); the resulting CCTP
6
- * message lets our backend's Multicall3 tx on Arbitrum call
7
- * `receiveMessage` to mint USDC to the SDK-derived Arbitrum address.
8
- *
9
- * Note: we intentionally use the plain `depositForBurn` (no hook), with
10
- * `destinationCaller = bytes32(0)` so anyone can call `receiveMessage`.
11
- * The HTLC-locking logic lives on the Arbitrum side inside the multicall,
12
- * not in a CCTP hook.
13
- */
14
- import { keccak_256 } from "@noble/hashes/sha3.js";
15
- import { bytesToHex } from "@noble/hashes/utils.js";
16
- import { FINALITY_FAST } from "../cctp/constants.js";
17
- import { addressToBytes32 } from "../cctp/utils.js";
18
- /**
19
- * Encodes the `depositForBurn` call data for CCTPv2 TokenMessenger.
20
- *
21
- * Returns a 0x-prefixed hex string ready to submit as a tx's `data` field
22
- * against the source chain's TokenMessenger address.
23
- */
24
- export function encodeDepositForBurn(params) {
25
- const destinationCaller = params.destinationCaller ??
26
- "0x0000000000000000000000000000000000000000000000000000000000000000";
27
- const minFinalityThreshold = params.minFinalityThreshold ?? FINALITY_FAST;
28
- // depositForBurn(uint256,uint32,bytes32,address,bytes32,uint256,uint32)
29
- const selector = keccak256Hex("depositForBurn(uint256,uint32,bytes32,address,bytes32,uint256,uint32)").slice(0, 10);
30
- const mintRecipientBytes32 = ensureBytes32(params.mintRecipient);
31
- const destinationCallerBytes32 = ensureBytes32(destinationCaller);
32
- const encoded = selector +
33
- encodeUint256(params.amount) +
34
- encodeUint256(BigInt(params.destinationDomain)) +
35
- stripHex(mintRecipientBytes32) +
36
- encodeAddress(params.burnToken) +
37
- stripHex(destinationCallerBytes32) +
38
- encodeUint256(params.maxFee) +
39
- encodeUint256(BigInt(minFinalityThreshold));
40
- return encoded;
41
- }
42
- function ensureBytes32(value) {
43
- const clean = value.replace(/^0x/, "");
44
- if (clean.length === 64) {
45
- return `0x${clean.toLowerCase()}`;
46
- }
47
- if (clean.length === 40) {
48
- return addressToBytes32(value);
49
- }
50
- throw new Error(`Invalid mintRecipient/destinationCaller: expected 20-byte address or 32-byte hex, got ${clean.length / 2} bytes`);
51
- }
52
- function keccak256Hex(input) {
53
- return `0x${bytesToHex(keccak_256(new TextEncoder().encode(input)))}`;
54
- }
55
- function encodeUint256(value) {
56
- if (value < 0n)
57
- throw new Error("uint256 cannot be negative");
58
- return value.toString(16).padStart(64, "0");
59
- }
60
- function encodeAddress(address) {
61
- return address.replace(/^0x/, "").toLowerCase().padStart(64, "0");
62
- }
63
- function stripHex(value) {
64
- return value.replace(/^0x/, "").toLowerCase();
65
- }
66
- //# sourceMappingURL=burn.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"burn.js","sourceRoot":"","sources":["../../src/cctp-inbound/burn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAA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;IACjC,CAAC;IACD,MAAM,IAAI,KAAK,CACb,yFAAyF,KAAK,CAAC,MAAM,GAAG,CAAC,QAAQ,CAClH,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK,UAAU,CAAC,UAAU,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACxE,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,IAAI,KAAK,GAAG,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAC9D,OAAO,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,aAAa,CAAC,OAAe;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AAChD,CAAC"}
@@ -1,128 +0,0 @@
1
- /**
2
- * Map EVM chain IDs to CCTPv2 source-chain metadata (domain + USDC
3
- * address) for the consuming side of the CCTP-inbound flow.
4
- *
5
- * Callers pass `signer.chainId`; the SDK derives the CCTP domain +
6
- * the source-chain USDC address from that alone, so the public API
7
- * doesn't need a redundant "sourceChain" string.
8
- */
9
- import { arbitrum, avalanche, base, hyperEvm, ink, linea, mainnet, monad, optimism, polygon, sei, sonic, unichain, worldchain, xdc, } from "viem/chains";
10
- import { CCTP_DOMAINS, FINALITY_FAST, FINALITY_STANDARD, USDC_ADDRESSES, } from "../cctp/constants.js";
11
- /** Canonical EVM chain id → CCTP chain name. */
12
- export const CHAIN_ID_TO_CCTP_NAME = {
13
- 1: "Ethereum",
14
- 10: "Optimism",
15
- 130: "Unichain",
16
- 137: "Polygon",
17
- 146: "Sonic",
18
- 1329: "Sei",
19
- 8453: "Base",
20
- 42161: "Arbitrum",
21
- 43114: "Avalanche",
22
- 59144: "Linea",
23
- 480: "World Chain",
24
- 57073: "Ink",
25
- 999: "HyperEVM",
26
- 143: "Monad",
27
- 50: "XDC",
28
- // Solana lands later (non-EVM, needs a different signer path).
29
- };
30
- /**
31
- * EVM chain ids the Lendaswap backend accepts directly as a swap
32
- * source via Permit2 — these chains are also CCTP-supported, but
33
- * we never route them through CCTP since a direct-Permit2 funding
34
- * is cheaper and faster.
35
- */
36
- export const DIRECT_SOURCE_CHAIN_IDS = new Set([
37
- 1, // Ethereum
38
- 137, // Polygon
39
- 42161, // Arbitrum
40
- ]);
41
- /**
42
- * `true` when `chainId` is a CCTP-supported source that the backend
43
- * does NOT accept directly — i.e. funding a swap from this chain
44
- * requires a CCTP hop to Arbitrum before the HTLC is created.
45
- */
46
- export function isCctpOnlySource(chainId) {
47
- return (chainId in CHAIN_ID_TO_CCTP_NAME && !DIRECT_SOURCE_CHAIN_IDS.has(chainId));
48
- }
49
- /**
50
- * CCTP source chains that do **not** support Fast Transfer (Circle's
51
- * supported-chains/finality docs mark "Fast Transfer: N/A"). Burns from
52
- * these chains must request Standard finality (2000); requesting fast
53
- * finality (1000) makes the fee/attestation assumptions wrong because no
54
- * fast-transfer fee tier exists for the route.
55
- */
56
- export const CCTP_STANDARD_ONLY_CHAIN_IDS = new Set([
57
- 50, // XDC
58
- ]);
59
- /**
60
- * The CCTP `minFinalityThreshold` to request when burning *from* `chainId`:
61
- * `FINALITY_FAST` (1000) where Fast Transfer is supported, `FINALITY_STANDARD`
62
- * (2000) for chains in [`CCTP_STANDARD_ONLY_CHAIN_IDS`].
63
- *
64
- * Callers should also query the IRIS fee for the returned threshold so the
65
- * `maxFee` matches the tier the burn will actually settle at.
66
- */
67
- export function finalityForChainId(chainId) {
68
- return CCTP_STANDARD_ONLY_CHAIN_IDS.has(chainId)
69
- ? FINALITY_STANDARD
70
- : FINALITY_FAST;
71
- }
72
- /**
73
- * Look up CCTPv2 domain id + native USDC address for a given chain id.
74
- * Throws with a clear error if the chain is unsupported.
75
- */
76
- export function cctpMetaForChainId(chainId) {
77
- const name = CHAIN_ID_TO_CCTP_NAME[chainId];
78
- if (!name) {
79
- throw new Error(`Chain id ${chainId} is not a supported CCTP source chain. Supported ids: ${Object.keys(CHAIN_ID_TO_CCTP_NAME).join(", ")}.`);
80
- }
81
- const usdc = USDC_ADDRESSES[name];
82
- if (!usdc) {
83
- throw new Error(`CCTP chain ${name} has no native USDC address in the SDK registry.`);
84
- }
85
- return {
86
- name,
87
- domain: CCTP_DOMAINS[name],
88
- usdc: usdc,
89
- };
90
- }
91
- /**
92
- * Map of CCTP source chain id → viem `Chain` object. Mirrors
93
- * [`CHAIN_ID_TO_CCTP_NAME`] — keep them in lockstep when adding chains.
94
- *
95
- * Exposed so browser consumers (wagmi, viem clients) don't have to maintain
96
- * their own parallel mapping; tree-shakable so non-browser consumers don't
97
- * pay the bundle cost.
98
- */
99
- export const CCTP_VIEM_CHAINS = {
100
- 1: mainnet,
101
- 10: optimism,
102
- 130: unichain,
103
- 137: polygon,
104
- 146: sonic,
105
- 1329: sei,
106
- 8453: base,
107
- 42161: arbitrum,
108
- 43114: avalanche,
109
- 59144: linea,
110
- 480: worldchain,
111
- 57073: ink,
112
- 999: hyperEvm,
113
- 143: monad,
114
- 50: xdc,
115
- };
116
- /** Look up the viem `Chain` for a CCTP source chain id, or `undefined`. */
117
- export function getCctpViemChain(chainId) {
118
- return CCTP_VIEM_CHAINS[chainId];
119
- }
120
- /** Look up the viem `Chain` for a CCTP source chain name, or `undefined`. */
121
- export function getCctpViemChainByName(name) {
122
- for (const [chainId, chainName] of Object.entries(CHAIN_ID_TO_CCTP_NAME)) {
123
- if (chainName === name)
124
- return CCTP_VIEM_CHAINS[Number(chainId)];
125
- }
126
- return undefined;
127
- }
128
- //# sourceMappingURL=chainMap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chainMap.js","sourceRoot":"","sources":["../../src/cctp-inbound/chainMap.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,GAAG,EACH,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,EACR,OAAO,EACP,GAAG,EACH,KAAK,EACL,QAAQ,EACR,UAAU,EACV,GAAG,GACJ,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EAEZ,aAAa,EACb,iBAAiB,EACjB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAE9B,gDAAgD;AAChD,MAAM,CAAC,MAAM,qBAAqB,GAAkC;IAClE,CAAC,EAAE,UAAU;IACb,EAAE,EAAE,UAAU;IACd,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,OAAO;IACZ,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,aAAa;IAClB,KAAK,EAAE,KAAK;IACZ,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,OAAO;IACZ,EAAE,EAAE,KAAK;IACT,+DAA+D;CAChE,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC;IAClE,CAAC,EAAE,WAAW;IACd,GAAG,EAAE,UAAU;IACf,KAAK,EAAE,WAAW;CACnB,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,CACL,OAAO,IAAI,qBAAqB,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,OAAO,CAAC,CAC1E,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,M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G;CACR,CAAC;AAEF,2EAA2E;AAC3E,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,KAAK,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAAE,CAAC;QACzE,IAAI,SAAS,KAAK,IAAI;YAAE,OAAO,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -1,125 +0,0 @@
1
- /**
2
- * `CctpInboundClient` — the `client.cctpInbound` namespace on the main
3
- * `Client`. Holds the AA (bundler + paymaster) config and will expose
4
- * the step-by-step primitives for the CCTP-inbound flow:
5
- *
6
- * - `approveAndBurn` (source-chain burn)
7
- * - `waitForAttestation` (IRIS polling)
8
- * - `submitUserOp` (settlement-chain UserOp via Kernel smart account)
9
- * - `createSmartAccountClient` (low-level Kernel account factory)
10
- *
11
- * The one-shot `Client.fundSwap(...)` is implemented on top of these
12
- * primitives — consumers wanting custom progress UX drop down to the
13
- * primitives directly; simple integrations just call `fundSwap`.
14
- *
15
- * Scaffolding only in this commit; primitives land in follow-up steps.
16
- */
17
- import { fetchAttestation, } from "../cctp/attestation.js";
18
- import { approveAndBurn, } from "./approveAndBurn.js";
19
- import { cctpFundSwap, } from "./fundSwap.js";
20
- import { createSwapSmartAccountClient, } from "./smartAccount.js";
21
- import { submitCctpInboundUserOp, } from "./submit.js";
22
- import { buildCctpInboundBatch, } from "./userOp.js";
23
- export class CctpInboundClient {
24
- #apiClient;
25
- #aa;
26
- #logger;
27
- #logLevel;
28
- constructor(config) {
29
- this.#apiClient = config.apiClient;
30
- this.#aa = config.aa;
31
- this.#logger = config.logger;
32
- this.#logLevel = config.logLevel;
33
- }
34
- /** The AA config this client was built with. */
35
- get aa() {
36
- return this.#aa;
37
- }
38
- /** The underlying typed API client. */
39
- get api() {
40
- return this.#apiClient;
41
- }
42
- /**
43
- * Build a Kernel smart-account client owned by `owner`.
44
- *
45
- * Low-level primitive — most consumers will use `submitUserOp` or
46
- * the one-shot `client.fundSwap` instead of constructing the AA
47
- * client themselves.
48
- */
49
- createSmartAccountClient(args) {
50
- const params = {
51
- signer: args.signer,
52
- aa: this.#aa,
53
- chain: args.chain,
54
- };
55
- return createSwapSmartAccountClient(params);
56
- }
57
- /**
58
- * Compose the 3-call UserOp batch (receiveMessage + USDC.approve +
59
- * executeAndCreateWithPermit2) that the smart account will execute
60
- * atomically. Produces the Permit2 signature via the caller-supplied
61
- * `signTypedData` — typically `kernelAccount.signTypedData`.
62
- *
63
- * Low-level primitive — most consumers call `submitUserOp` instead,
64
- * which composes batch + send + wait-for-receipt.
65
- */
66
- buildUserOpBatch(params) {
67
- return buildCctpInboundBatch(params);
68
- }
69
- /**
70
- * End-to-end settlement UserOp: fetch calldata, build Kernel client,
71
- * compose the batch, submit via the bundler, and (by default) wait
72
- * for the on-chain receipt.
73
- *
74
- * This is the main high-level entry point for the CCTP-inbound
75
- * settlement step. Pass the IRIS message + attestation (from
76
- * `waitForAttestation`, landing in a follow-up step) and the
77
- * caller's signer.
78
- */
79
- submitUserOp(params) {
80
- return submitCctpInboundUserOp({ apiClient: this.#apiClient, aa: this.#aa }, {
81
- ...params,
82
- logger: params.logger ?? this.#logger,
83
- logLevel: params.logLevel ?? this.#logLevel,
84
- });
85
- }
86
- /**
87
- * Source-chain USDC approve (if needed) + `depositForBurn`. The
88
- * minted USDC on the destination chain is pinned to
89
- * `smartAccountAddress`, and `destinationCaller` is pinned to the
90
- * same address — only that account can settle the message.
91
- *
92
- * Does not wait for CCTP attestation; returns as soon as both txs
93
- * are broadcast. The caller pairs this with `waitForAttestation`
94
- * (landing in the next step) and `submitUserOp`.
95
- */
96
- approveAndBurn(params) {
97
- return approveAndBurn(params);
98
- }
99
- /**
100
- * Poll Circle's IRIS V2 API until the CCTP attestation for a burn
101
- * tx is `complete`, then return the `message` + `attestation` bytes
102
- * ready to feed into `submitUserOp`.
103
- *
104
- * Typical wait: ~15 seconds for fast transfers, a few minutes for
105
- * standard. Defaults to a 15-minute timeout; callers can pass
106
- * `signal` (AbortSignal) to cancel early.
107
- */
108
- waitForAttestation(options) {
109
- return fetchAttestation(options);
110
- }
111
- /**
112
- * One-shot CCTP-inbound swap: approve + burn on the source chain,
113
- * poll IRIS for the attestation, then submit the settlement UserOp
114
- * via the Kernel smart account. Paymaster sponsors the settlement
115
- * so the user needs no ETH on the destination chain.
116
- *
117
- * The `walletClient.account` signs both the source-chain txs and
118
- * the destination-chain UserOp (as Kernel owner), and its address
119
- * anchors the deterministic smart-account address.
120
- */
121
- fundSwap(params) {
122
- return cctpFundSwap({ apiClient: this.#apiClient, aa: this.#aa }, params);
123
- }
124
- }
125
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/cctp-inbound/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAGL,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAGL,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAErB,OAAO,EAGL,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAWrB,MAAM,OAAO,iBAAiB;IACnB,UAAU,CAAY;IACtB,GAAG,CAAW;IACd,OAAO,CAAU;IACjB,SAAS,CAAY;IAE9B,YAAY,MAA+B;QACzC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,GAAG,GAAG,MAAM,CAA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AAC,EAAE,SAAS,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;IAC5E,CAAC;CACF"}
@@ -1,95 +0,0 @@
1
- /**
2
- * EIP-2612 permit signing for USDC → Permit2 approval using the SDK's
3
- * HD-derived EVM key.
4
- *
5
- * On a brand-new SDK-derived Arbitrum address, USDC's allowance for Permit2
6
- * is zero. Rather than doing an on-chain `approve` (which requires ETH the
7
- * user doesn't have), we sign an EIP-2612 `permit` off-chain; the backend's
8
- * multicall on Arbitrum includes `USDC.permit(...)` to establish the
9
- * allowance atomically before `executeAndCreateWithPermit2` pulls via Permit2.
10
- */
11
- import { keccak_256 } from "@noble/hashes/sha3.js";
12
- import { bytesToHex } from "@noble/hashes/utils.js";
13
- import { buildEip2612PermitDigest, PERMIT2_ADDRESS, } from "../evm/coordinator.js";
14
- import { signEvmDigest } from "../evm/signing.js";
15
- /** uint256 max — sign once, never need another permit. */
16
- export const MAX_UINT256 = (1n << 256n) - 1n;
17
- /**
18
- * Signs an EIP-2612 permit using the SDK's derived key, returning the
19
- * split signature + value/deadline in a shape the backend's gasless
20
- * endpoint accepts directly.
21
- */
22
- export function signEip2612Permit(params) {
23
- const spender = params.spender ?? PERMIT2_ADDRESS;
24
- const digestParams = {
25
- domainSeparator: params.domainSeparator,
26
- owner: params.owner,
27
- spender,
28
- value: params.value,
29
- nonce: params.nonce,
30
- deadline: params.deadline,
31
- };
32
- const digest = buildEip2612PermitDigest(digestParams);
33
- const sig = signEvmDigest(params.secretKey, digest);
34
- return {
35
- v: sig.v,
36
- r: sig.r,
37
- s: sig.s,
38
- value: params.value.toString(),
39
- deadline: Number(params.deadline),
40
- };
41
- }
42
- // ── Domain separator helper ──────────────────────────────────────────────────
43
- /**
44
- * Builds an EIP-712 domain separator from the standard 4-field domain.
45
- *
46
- * Use when you know the token's on-chain `name` and `version` and want to
47
- * avoid an RPC call to `token.DOMAIN_SEPARATOR()`. For USDC deployments,
48
- * both vary slightly — see {@link USDC_DOMAIN_FIELDS}.
49
- */
50
- export function buildDomainSeparator(params) {
51
- const TYPEHASH = keccak256Hex("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
52
- const encoded = strip(TYPEHASH) +
53
- strip(keccak256Hex(params.name)) +
54
- strip(keccak256Hex(params.version)) +
55
- uint256Hex(BigInt(params.chainId)) +
56
- addressHex(params.verifyingContract);
57
- return keccak256HexBytes(encoded);
58
- }
59
- /**
60
- * Known EIP-712 domain fields for native USDC on each CCTPv2-supported EVM
61
- * chain. Populate as needed — verify on-chain via `DOMAIN_SEPARATOR()` before
62
- * relying on these in production.
63
- *
64
- * Arbitrum native USDC (`0xaf88d065e77c8cC2239327C5EDb3A432268e5831`) reports
65
- * `name = "USD Coin"`, `version = "2"`. Most Circle-issued native USDC uses
66
- * the same; bridged USDC.e variants differ.
67
- */
68
- export const USDC_DOMAIN_FIELDS = {
69
- 42161: {
70
- name: "USD Coin",
71
- version: "2",
72
- address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
73
- },
74
- };
75
- // ── helpers ──────────────────────────────────────────────────────────────────
76
- function keccak256Hex(input) {
77
- return `0x${bytesToHex(keccak_256(new TextEncoder().encode(input)))}`;
78
- }
79
- function keccak256HexBytes(hexInput) {
80
- const bytes = new Uint8Array(hexInput.length / 2);
81
- for (let i = 0; i < bytes.length; i++) {
82
- bytes[i] = parseInt(hexInput.slice(i * 2, i * 2 + 2), 16);
83
- }
84
- return `0x${bytesToHex(keccak_256(bytes))}`;
85
- }
86
- function strip(hex) {
87
- return hex.replace(/^0x/, "").toLowerCase();
88
- }
89
- function uint256Hex(value) {
90
- return value.toString(16).padStart(64, "0");
91
- }
92
- function addressHex(address) {
93
- return address.replace(/^0x/, "").toLowerCase().padStart(64, "0");
94
- }
95
- //# sourceMappingURL=eip2612.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"eip2612.js","sourceRoot":"","sources":["../../src/cctp-inbound/eip2612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C,WAAW,EAAE,CAAC;AAC9C,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,UAAU,CAAC,OAAe;IACjC,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AACpE,CAAC"}
@@ -1,82 +0,0 @@
1
- /**
2
- * Bridge `EvmSigner` → a viem `LocalAccount` that ZeroDev's Kernel
3
- * (under EIP-7702) accepts as the EOA being delegated.
4
- *
5
- * Kernel calls:
6
- * - `signMessage({ message: { raw } })` to sign the UserOp hash.
7
- * - `signTypedData({ ... })` to sign the Permit2 witness (and any
8
- * other EIP-712 message routed through the account).
9
- * - `signAuthorization({...})` to sign the 7702 auth tuple on the
10
- * first UserOp from this EOA — installs the delegation on-chain.
11
- *
12
- * `EvmSigner.signTypedData` is required on all callers. `signMessage`
13
- * and `signAuthorization` are optional on `EvmSigner` — this adapter
14
- * throws a clear error if the CCTP path is reached with an
15
- * `EvmSigner` that lacks them.
16
- *
17
- * `signTransaction` is provided as a stub: Kernel never routes txs
18
- * through the owner account (the bundler submits UserOps), so calling
19
- * it would be a programmer error.
20
- */
21
- import { toAccount } from "viem/accounts";
22
- /**
23
- * Wrap an `EvmSigner` in a viem `LocalAccount` so ZeroDev Kernel can
24
- * use it as the EIP-7702 delegated account (`eip7702Account`).
25
- */
26
- export function evmSignerToKernelOwner(signer) {
27
- return toAccount({
28
- address: signer.address,
29
- async signMessage({ message }) {
30
- if (!signer.signMessage) {
31
- throw new Error("CCTP-inbound flow requires `EvmSigner.signMessage`. Extend your signer — e.g. `(m) => walletClient.signMessage({ account, message: m })`.");
32
- }
33
- // viem's `message` is `SignableMessage`: either a string or
34
- // `{ raw: Hex }`. Kernel always passes `{ raw }` — but be
35
- // defensive about the string shape too.
36
- const raw = typeof message === "string"
37
- ? new TextEncoder().encode(message)
38
- : message.raw;
39
- return (await signer.signMessage({ raw }));
40
- },
41
- async signTypedData(typedData) {
42
- // Narrow viem's broad SignTypedDataParameters to the SDK's
43
- // internal EIP712TypedData shape — at runtime they're
44
- // structurally identical, the difference is just generic-heavy
45
- // typing on viem's side.
46
- return (await signer.signTypedData(typedData));
47
- },
48
- async signAuthorization(authorization) {
49
- if (!signer.signAuthorization) {
50
- throw new Error("CCTP-inbound flow under EIP-7702 requires `EvmSigner.signAuthorization`. Extend your signer — e.g. `(a) => walletClient.signAuthorization({ account, ...a })`.");
51
- }
52
- // viem's `AuthorizationRequest` is a `OneOf` — the delegation
53
- // target arrives as EITHER `address` (the canonical field, which
54
- // Kernel/viem actually use) OR the `contractAddress` alias.
55
- // Reading only `contractAddress` yields `undefined` on the
56
- // `address` branch, which then blows up inside viem's
57
- // `hashAuthorization` ("Cannot read properties of undefined").
58
- const contractAddress = (authorization.address ??
59
- authorization.contractAddress);
60
- const result = await signer.signAuthorization({
61
- chainId: authorization.chainId,
62
- contractAddress,
63
- nonce: authorization.nonce,
64
- });
65
- // viem accepts either `v` or `yParity`; the field they actually
66
- // read is `yParity`. Pass both for compatibility.
67
- return {
68
- r: result.r,
69
- s: result.s,
70
- v: result.v !== undefined ? BigInt(result.v) : undefined,
71
- yParity: result.yParity,
72
- chainId: result.chainId,
73
- address: result.address,
74
- nonce: result.nonce,
75
- };
76
- },
77
- async signTransaction() {
78
- throw new Error("signTransaction is not supported on the Kernel owner — UserOps are submitted via the bundler, not from the owner EOA directly.");
79
- },
80
- });
81
- }
82
- //# sourceMappingURL=evmSignerAdapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"evmSignerAdapter.js","sourceRoot":"","sources":["../../src/cctp-inbound/evmSignerAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,SAA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f,KAAK,EAAE,aAAa,CAAC,KAAe;aACrC,CAAC,CAAC;YACH,gEAAgE;YAChE,kDAAkD;YAClD,OAAO;gBACL,CAAC,EAAE,MAAM,CAAC,CAAQ;gBAClB,CAAC,EAAE,MAAM,CAAC,CAAQ;gBAClB,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;gBACxD,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,OAAO,EAAE,MAAM,CAAC,OAAc;gBAC9B,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,eAAe;YACnB,MAAM,IAAI,KAAK,CACb,gIAAgI,CACjI,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -1,95 +0,0 @@
1
- /**
2
- * `cctpFundSwap` — one-shot CCTP-inbound settlement.
3
- *
4
- * Composes the three primitives into a single flow most consumers
5
- * can call directly:
6
- *
7
- * 1. `approveAndBurn` on the source chain.
8
- * 2. `waitForAttestation` against IRIS until the burn is attested.
9
- * 3. `submitUserOp` on the settlement chain via the caller's Kernel
10
- * smart account (paymaster-sponsored).
11
- *
12
- * The caller's single `EvmSigner` serves double duty: source-chain
13
- * signer for step 1 AND Kernel owner for step 3. The smart-account
14
- * address is derived once up-front and pinned as
15
- * `mintRecipient` / `destinationCaller` on the burn.
16
- */
17
- import { arbitrum } from "viem/chains";
18
- import { fetchAttestation } from "../cctp/attestation.js";
19
- import { IRIS_API_MAINNET } from "../cctp/constants.js";
20
- import { approveAndBurn } from "./approveAndBurn.js";
21
- import { cctpMetaForChainId, finalityForChainId } from "./chainMap.js";
22
- import { createSwapSmartAccountClient } from "./smartAccount.js";
23
- import { submitCctpInboundUserOp } from "./submit.js";
24
- /**
25
- * Execute the full CCTP-inbound swap flow end to end. Most consumers
26
- * call this directly — the primitives (`approveAndBurn`,
27
- * `waitForAttestation`, `submitUserOp`) are available separately for
28
- * wizard-style UX that needs per-step control.
29
- */
30
- export async function cctpFundSwap(context, params) {
31
- const { swapId, signer, amount, maxFee, settlementChain = arbitrum, irisApiUrl = IRIS_API_MAINNET, onProgress, signal, } = params;
32
- // Derive CCTP source metadata from the signer's chain id. No need
33
- // for the caller to spell out "Optimism" or the numeric domain —
34
- // the signer already knows which chain it's on.
35
- const source = cctpMetaForChainId(signer.chainId);
36
- const destination = cctpMetaForChainId(settlementChain.id);
37
- // Sources without Fast Transfer (e.g. XDC) must burn at Standard
38
- // finality — requesting fast finality there charges the wrong fee tier
39
- // and the attestation never clears at the fast threshold.
40
- const minFinalityThreshold = finalityForChainId(signer.chainId);
41
- // Derive the Kernel smart-account address up front. Stable across
42
- // all three phases — we mint to it on settlement and gate the
43
- // `receiveMessage` call on it.
44
- const { accountAddress: smartAccountAddress } = await createSwapSmartAccountClient({
45
- signer,
46
- aa: context.aa,
47
- chain: settlementChain,
48
- });
49
- // 1. Source-chain approve + burn.
50
- onProgress?.({ phase: "approving" });
51
- const { approveTxHash, burnTxHash } = await approveAndBurn({
52
- signer,
53
- amount,
54
- usdcAddress: source.usdc,
55
- destinationDomain: destination.domain,
56
- smartAccountAddress,
57
- maxFee,
58
- minFinalityThreshold,
59
- });
60
- onProgress?.({ phase: "burning", burnTxHash });
61
- const burnReceipt = await signer.waitForReceipt(burnTxHash);
62
- if (burnReceipt.status !== "success") {
63
- throw new Error(`CCTP burn tx reverted: ${burnTxHash}`);
64
- }
65
- // 2. Wait for the IRIS attestation to clear.
66
- onProgress?.({ phase: "attestation" });
67
- const { message, attestation } = await fetchAttestation({
68
- sourceChain: source.name,
69
- txHash: burnTxHash,
70
- irisApiUrl,
71
- signal,
72
- });
73
- // 3. Submit the settlement UserOp and wait for the on-chain receipt.
74
- onProgress?.({ phase: "submitting" });
75
- const submit = await submitCctpInboundUserOp(context, {
76
- swapId,
77
- signer,
78
- cctpMessage: message,
79
- cctpAttestation: attestation,
80
- chain: settlementChain,
81
- });
82
- onProgress?.({
83
- phase: "settled",
84
- userOpHash: submit.userOpHash,
85
- transactionHash: submit.transactionHash,
86
- });
87
- return {
88
- approveTxHash,
89
- burnTxHash,
90
- userOpHash: submit.userOpHash,
91
- transactionHash: submit.transactionHash,
92
- smartAccountAddress: smartAccountAddress,
93
- };
94
- }
95
- //# sourceMappingURL=fundSwap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fundSwap.js","sourceRoot":"","sources":["../../src/cctp-inbound/fundSwap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAiEtD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAA4B,EAC5B,MAA0B;IAE1B,MAAM,EACJ,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,eAAe,GAAG,QAAQ,EAC1B,UAAU,GAAG,gBAAgB,EAC7B,UAAU,EACV,MAAM,GACP,GAAG,MAAM,CAAC;IAEX,kEAAkE;IAClE,iEAAiE;IACjE,gDAAgD;IAChD,MAAM,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,WAAW,GAAG,kBAAkB,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;IAE3D,iEAAiE;IACjE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