@lendasat/lendaswap-sdk-pure 0.2.42 → 0.2.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_esm-7KJOBTZC.js +3660 -0
- package/dist/_esm-7KJOBTZC.js.map +1 -0
- package/dist/_esm-UGRDSVEV.cjs +3662 -0
- package/dist/_esm-UGRDSVEV.cjs.map +1 -0
- package/dist/api/client.d.ts +0 -4
- package/dist/api/client.d.ts.map +1 -1
- package/dist/base-2KYNAFR3.cjs +109 -0
- package/dist/base-2KYNAFR3.cjs.map +1 -0
- package/dist/base-B6OGU65B.js +7 -0
- package/dist/base-B6OGU65B.js.map +1 -0
- package/dist/ccip-MPMAZOUF.js +5 -0
- package/dist/ccip-MPMAZOUF.js.map +1 -0
- package/dist/ccip-PD37NJHA.cjs +26 -0
- package/dist/ccip-PD37NJHA.cjs.map +1 -0
- package/dist/cctp-bridge/index.cjs +67 -0
- package/dist/cctp-bridge/index.cjs.map +1 -0
- package/dist/cctp-bridge/index.js +51 -15
- package/dist/cctp-bridge/index.js.map +1 -1
- package/dist/cctp-inbound/client.d.ts +21 -19
- package/dist/cctp-inbound/client.d.ts.map +1 -1
- package/dist/cctp-inbound/smartAccount.d.ts +21 -19
- package/dist/cctp-inbound/smartAccount.d.ts.map +1 -1
- package/dist/chunk-3JWT4OW2.js +369 -0
- package/dist/chunk-3JWT4OW2.js.map +1 -0
- package/dist/chunk-A4GKKURK.cjs +430 -0
- package/dist/chunk-A4GKKURK.cjs.map +1 -0
- package/dist/chunk-BZU3R5DJ.cjs +554 -0
- package/dist/chunk-BZU3R5DJ.cjs.map +1 -0
- package/dist/chunk-C4YXYD24.js +418 -0
- package/dist/chunk-C4YXYD24.js.map +1 -0
- package/dist/chunk-CZNQYFDP.js +6141 -0
- package/dist/chunk-CZNQYFDP.js.map +1 -0
- package/dist/chunk-DKTFDGIU.js +2207 -0
- package/dist/chunk-DKTFDGIU.js.map +1 -0
- package/dist/chunk-DNSJDKTP.cjs +96 -0
- package/dist/chunk-DNSJDKTP.cjs.map +1 -0
- package/dist/chunk-EPKFLKTM.js +47093 -0
- package/dist/chunk-EPKFLKTM.js.map +1 -0
- package/dist/chunk-JBVKWKD4.cjs +50 -0
- package/dist/chunk-JBVKWKD4.cjs.map +1 -0
- package/dist/chunk-NPFJAXKV.js +551 -0
- package/dist/chunk-NPFJAXKV.js.map +1 -0
- package/dist/chunk-PKDJZJMV.cjs +2214 -0
- package/dist/chunk-PKDJZJMV.cjs.map +1 -0
- package/dist/chunk-PLDDJCW6.js +43 -0
- package/dist/chunk-PLDDJCW6.js.map +1 -0
- package/dist/chunk-RIOT5VOJ.cjs +47240 -0
- package/dist/chunk-RIOT5VOJ.cjs.map +1 -0
- package/dist/chunk-WVZSHRV7.cjs +431 -0
- package/dist/chunk-WVZSHRV7.cjs.map +1 -0
- package/dist/chunk-YEZOPVAH.js +86 -0
- package/dist/chunk-YEZOPVAH.js.map +1 -0
- package/dist/chunk-YLWPBHMV.cjs +6311 -0
- package/dist/chunk-YLWPBHMV.cjs.map +1 -0
- package/dist/client.d.ts +68 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/compose-quote.d.ts +77 -0
- package/dist/compose-quote.d.ts.map +1 -0
- package/dist/delegate.cjs +23 -0
- package/dist/delegate.cjs.map +1 -0
- package/dist/delegate.js +5 -269
- package/dist/delegate.js.map +1 -1
- package/dist/dist-NE2R4YCX.js +5 -0
- package/dist/dist-NE2R4YCX.js.map +1 -0
- package/dist/dist-VEHYC67F.cjs +550 -0
- package/dist/dist-VEHYC67F.cjs.map +1 -0
- package/dist/esplora.d.ts +14 -0
- package/dist/esplora.d.ts.map +1 -1
- package/dist/generated/api.d.ts +235 -38
- package/dist/generated/api.d.ts.map +1 -1
- package/dist/index.cjs +35461 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35309 -32
- package/dist/index.js.map +1 -1
- package/dist/mine.wasm-JJEJEODX.js +9 -0
- package/dist/mine.wasm-JJEJEODX.js.map +1 -0
- package/dist/mine.wasm-Z3ORSBKN.cjs +12 -0
- package/dist/mine.wasm-Z3ORSBKN.cjs.map +1 -0
- package/dist/node.cjs +166 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.js +157 -18
- package/dist/node.js.map +1 -1
- package/dist/secp256k1-PJCSE4N6.cjs +30 -0
- package/dist/secp256k1-PJCSE4N6.cjs.map +1 -0
- package/dist/secp256k1-VZNNVEPN.js +5 -0
- package/dist/secp256k1-VZNNVEPN.js.map +1 -0
- package/dist/tokens.d.ts +2 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/types/chain-config.d.ts +50 -0
- package/dist/types/chain-config.d.ts.map +1 -0
- package/dist/types/chain.d.ts +11 -0
- package/dist/types/chain.d.ts.map +1 -0
- package/dist/types/dex-quote.d.ts +85 -0
- package/dist/types/dex-quote.d.ts.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/network-fees.d.ts +43 -0
- package/dist/types/network-fees.d.ts.map +1 -0
- package/dist/types/quote.d.ts +87 -0
- package/dist/types/quote.d.ts.map +1 -0
- package/dist/types/swap-pairs.d.ts +37 -0
- package/dist/types/swap-pairs.d.ts.map +1 -0
- package/dist/version.d.ts +2 -2
- package/dist/wallet-SCGRX3EN.js +4 -0
- package/dist/wallet-SCGRX3EN.js.map +1 -0
- package/dist/wallet-SZJDXAY7.cjs +45 -0
- package/dist/wallet-SZJDXAY7.cjs.map +1 -0
- package/package.json +23 -10
- package/dist/api/client.js +0 -13
- package/dist/api/client.js.map +0 -1
- package/dist/arkade-network.js +0 -40
- package/dist/arkade-network.js.map +0 -1
- package/dist/arkade.js +0 -61
- package/dist/arkade.js.map +0 -1
- package/dist/cctp/attestation.js +0 -149
- package/dist/cctp/attestation.js.map +0 -1
- package/dist/cctp/constants.js +0 -92
- package/dist/cctp/constants.js.map +0 -1
- package/dist/cctp/fee.js +0 -70
- package/dist/cctp/fee.js.map +0 -1
- package/dist/cctp/index.js +0 -13
- package/dist/cctp/index.js.map +0 -1
- package/dist/cctp/types.js +0 -5
- package/dist/cctp/types.js.map +0 -1
- package/dist/cctp/utils.js +0 -91
- package/dist/cctp/utils.js.map +0 -1
- package/dist/cctp-bridge/bridge.js +0 -74
- package/dist/cctp-bridge/bridge.js.map +0 -1
- package/dist/cctp-inbound/approveAndBurn.js +0 -95
- package/dist/cctp-inbound/approveAndBurn.js.map +0 -1
- package/dist/cctp-inbound/burn.js +0 -66
- package/dist/cctp-inbound/burn.js.map +0 -1
- package/dist/cctp-inbound/chainMap.js +0 -128
- package/dist/cctp-inbound/chainMap.js.map +0 -1
- package/dist/cctp-inbound/client.js +0 -125
- package/dist/cctp-inbound/client.js.map +0 -1
- package/dist/cctp-inbound/eip2612.js +0 -95
- package/dist/cctp-inbound/eip2612.js.map +0 -1
- package/dist/cctp-inbound/evmSignerAdapter.js +0 -82
- package/dist/cctp-inbound/evmSignerAdapter.js.map +0 -1
- package/dist/cctp-inbound/fundSwap.js +0 -95
- package/dist/cctp-inbound/fundSwap.js.map +0 -1
- package/dist/cctp-inbound/index.js +0 -34
- package/dist/cctp-inbound/index.js.map +0 -1
- package/dist/cctp-inbound/permit2.js +0 -32
- package/dist/cctp-inbound/permit2.js.map +0 -1
- package/dist/cctp-inbound/preflight.js +0 -84
- package/dist/cctp-inbound/preflight.js.map +0 -1
- package/dist/cctp-inbound/recover.js +0 -177
- package/dist/cctp-inbound/recover.js.map +0 -1
- package/dist/cctp-inbound/smartAccount.js +0 -117
- package/dist/cctp-inbound/smartAccount.js.map +0 -1
- package/dist/cctp-inbound/submit.js +0 -136
- package/dist/cctp-inbound/submit.js.map +0 -1
- package/dist/cctp-inbound/types.js +0 -5
- package/dist/cctp-inbound/types.js.map +0 -1
- package/dist/cctp-inbound/userOp.js +0 -151
- package/dist/cctp-inbound/userOp.js.map +0 -1
- package/dist/client.js +0 -4126
- package/dist/client.js.map +0 -1
- package/dist/create/arkade-to-lightning.js +0 -76
- package/dist/create/arkade-to-lightning.js.map +0 -1
- package/dist/create/arkade.js +0 -86
- package/dist/create/arkade.js.map +0 -1
- package/dist/create/bitcoin-to-arkade.js +0 -76
- package/dist/create/bitcoin-to-arkade.js.map +0 -1
- package/dist/create/bitcoin.js +0 -77
- package/dist/create/bitcoin.js.map +0 -1
- package/dist/create/evm-to-arkade.js +0 -80
- package/dist/create/evm-to-arkade.js.map +0 -1
- package/dist/create/evm-to-bitcoin.js +0 -82
- package/dist/create/evm-to-bitcoin.js.map +0 -1
- package/dist/create/evm-to-lightning.js +0 -89
- package/dist/create/evm-to-lightning.js.map +0 -1
- package/dist/create/index.js +0 -21
- package/dist/create/index.js.map +0 -1
- package/dist/create/lightning-to-arkade.js +0 -69
- package/dist/create/lightning-to-arkade.js.map +0 -1
- package/dist/create/lightning.js +0 -61
- package/dist/create/lightning.js.map +0 -1
- package/dist/create/retry.js +0 -71
- package/dist/create/retry.js.map +0 -1
- package/dist/create/types.js +0 -5
- package/dist/create/types.js.map +0 -1
- package/dist/escrow/index.js +0 -115
- package/dist/escrow/index.js.map +0 -1
- package/dist/esplora.js +0 -47
- package/dist/esplora.js.map +0 -1
- package/dist/evm/coordinator.js +0 -714
- package/dist/evm/coordinator.js.map +0 -1
- package/dist/evm/htlc.js +0 -278
- package/dist/evm/htlc.js.map +0 -1
- package/dist/evm/index.js +0 -10
- package/dist/evm/index.js.map +0 -1
- package/dist/evm/signing.js +0 -70
- package/dist/evm/signing.js.map +0 -1
- package/dist/evm/wallet.js +0 -133
- package/dist/evm/wallet.js.map +0 -1
- package/dist/generated/api.js +0 -6
- package/dist/generated/api.js.map +0 -1
- package/dist/logging.js +0 -130
- package/dist/logging.js.map +0 -1
- package/dist/price-calculations.js +0 -135
- package/dist/price-calculations.js.map +0 -1
- package/dist/redeem/arkade.js +0 -416
- package/dist/redeem/arkade.js.map +0 -1
- package/dist/redeem/ethereum.js +0 -206
- package/dist/redeem/ethereum.js.map +0 -1
- package/dist/redeem/gasless.js +0 -73
- package/dist/redeem/gasless.js.map +0 -1
- package/dist/redeem/index.js +0 -189
- package/dist/redeem/index.js.map +0 -1
- package/dist/redeem/types.js +0 -36
- package/dist/redeem/types.js.map +0 -1
- package/dist/refund/arkade.js +0 -200
- package/dist/refund/arkade.js.map +0 -1
- package/dist/refund/collab-arkade-evm.js +0 -307
- package/dist/refund/collab-arkade-evm.js.map +0 -1
- package/dist/refund/collab-arkade-lightning.js +0 -245
- package/dist/refund/collab-arkade-lightning.js.map +0 -1
- package/dist/refund/index.js +0 -12
- package/dist/refund/index.js.map +0 -1
- package/dist/refund/onchain.js +0 -366
- package/dist/refund/onchain.js.map +0 -1
- package/dist/signer/index.js +0 -249
- package/dist/signer/index.js.map +0 -1
- package/dist/storage/idb.js +0 -236
- package/dist/storage/idb.js.map +0 -1
- package/dist/storage/index.js +0 -98
- package/dist/storage/index.js.map +0 -1
- package/dist/storage/sqlite.js +0 -206
- package/dist/storage/sqlite.js.map +0 -1
- package/dist/storage/types.js +0 -9
- package/dist/storage/types.js.map +0 -1
- package/dist/tokens.js +0 -322
- package/dist/tokens.js.map +0 -1
- package/dist/usd-price.js +0 -96
- package/dist/usd-price.js.map +0 -1
- package/dist/usdt0-bridge/constants.js +0 -71
- package/dist/usdt0-bridge/constants.js.map +0 -1
- package/dist/usdt0-bridge/index.js +0 -11
- package/dist/usdt0-bridge/index.js.map +0 -1
- package/dist/usdt0-bridge/tracking.js +0 -123
- package/dist/usdt0-bridge/tracking.js.map +0 -1
- package/dist/usdt0-bridge/utils.js +0 -51
- package/dist/usdt0-bridge/utils.js.map +0 -1
- package/dist/version.js +0 -6
- package/dist/version.js.map +0 -1
- package/dist/ws.js +0 -145
- package/dist/ws.js.map +0 -1
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CCTP-inbound flow — "any CCTPv2 chain → Arbitrum USDC → BTC" swaps.
|
|
3
|
-
*
|
|
4
|
-
* The SDK orchestrates:
|
|
5
|
-
* 1. Source-chain USDC burn via `TokenMessenger.depositForBurn`
|
|
6
|
-
* (`destinationCaller` pinned to the user's Kernel smart account).
|
|
7
|
-
* 2. IRIS attestation polling.
|
|
8
|
-
* 3. Settlement-chain UserOp via the user's Kernel smart account
|
|
9
|
-
* (atomic `receiveMessage` + `USDC.approve(Permit2)` +
|
|
10
|
-
* `executeAndCreateWithPermit2`), paymaster-sponsored so the user
|
|
11
|
-
* needs no ETH on Arbitrum.
|
|
12
|
-
*
|
|
13
|
-
* The Kernel smart account is owned by the user's connected wallet
|
|
14
|
-
* (viem `Account` / Privy / wagmi / raw key) — no SDK-derived key
|
|
15
|
-
* material. Consumer-side wallet prompts cover Permit2 typed data and
|
|
16
|
-
* the UserOp signature.
|
|
17
|
-
*
|
|
18
|
-
* Public API:
|
|
19
|
-
* - `client.cctpInbound.*` — step-by-step primitives (for custom UX)
|
|
20
|
-
* - `client.fundSwap(swapId, signer)` — one-shot wrapper built on top
|
|
21
|
-
*/
|
|
22
|
-
export { approveAndBurn, } from "./approveAndBurn.js";
|
|
23
|
-
export { encodeDepositForBurn, } from "./burn.js";
|
|
24
|
-
export { CCTP_STANDARD_ONLY_CHAIN_IDS, CCTP_VIEM_CHAINS, CHAIN_ID_TO_CCTP_NAME, cctpMetaForChainId, DIRECT_SOURCE_CHAIN_IDS, finalityForChainId, getCctpViemChain, getCctpViemChainByName, isCctpOnlySource, } from "./chainMap.js";
|
|
25
|
-
export { CctpInboundClient } from "./client.js";
|
|
26
|
-
export { buildDomainSeparator, MAX_UINT256, signEip2612Permit, USDC_DOMAIN_FIELDS, } from "./eip2612.js";
|
|
27
|
-
export { cctpFundSwap, } from "./fundSwap.js";
|
|
28
|
-
export { signPermit2Witness, } from "./permit2.js";
|
|
29
|
-
export { extractRevertData, simulateBatchCalls, } from "./preflight.js";
|
|
30
|
-
export { recoverCctpInbound, } from "./recover.js";
|
|
31
|
-
export { createSwapSmartAccountClient, } from "./smartAccount.js";
|
|
32
|
-
export { submitCctpInboundUserOp, } from "./submit.js";
|
|
33
|
-
export { addressToBytes32Hex, buildCctpInboundBatch, } from "./userOp.js";
|
|
34
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cctp-inbound/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAGL,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,oBAAoB,GACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,4BAA4B,EAC5B,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,oBAAoB,EACpB,WAAW,EAGX,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAKL,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,iBAAiB,EAEjB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAKL,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,mBAAmB,EAInB,qBAAqB,GAGtB,MAAM,aAAa,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Permit2 signing for `executeAndCreateWithPermit2` using the SDK's
|
|
3
|
-
* HD-derived EVM key.
|
|
4
|
-
*
|
|
5
|
-
* Wraps the existing `buildPermit2FundingDigest` + `signEvmDigest` and
|
|
6
|
-
* returns the compact 65-byte signature format (`r ‖ s ‖ v`) that
|
|
7
|
-
* `HTLCCoordinator.executeAndCreateWithPermit2` expects, ready to POST
|
|
8
|
-
* to the backend's gasless-funding endpoint.
|
|
9
|
-
*/
|
|
10
|
-
import { buildPermit2FundingDigest, } from "../evm/coordinator.js";
|
|
11
|
-
import { signEvmDigest } from "../evm/signing.js";
|
|
12
|
-
/**
|
|
13
|
-
* Signs the Permit2 EIP-712 digest using the SDK's derived key and packs
|
|
14
|
-
* the signature in the compact `r ‖ s ‖ v` form the backend submitter
|
|
15
|
-
* forwards to Permit2 on-chain.
|
|
16
|
-
*/
|
|
17
|
-
export function signPermit2Witness(params) {
|
|
18
|
-
const digest = buildPermit2FundingDigest(params.funding);
|
|
19
|
-
const sig = signEvmDigest(params.secretKey, digest);
|
|
20
|
-
const r = sig.r.replace(/^0x/, "");
|
|
21
|
-
const s = sig.s.replace(/^0x/, "");
|
|
22
|
-
const v = sig.v.toString(16).padStart(2, "0");
|
|
23
|
-
if (r.length !== 64 || s.length !== 64) {
|
|
24
|
-
throw new Error(`Malformed signature scalars: r=${r.length}, s=${s.length}`);
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
nonce: params.funding.nonce.toString(),
|
|
28
|
-
deadline: Number(params.funding.deadline),
|
|
29
|
-
signature: `0x${r}${s}${v}`,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=permit2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permit2.js","sourceRoot":"","sources":["../../src/cctp-inbound/permit2.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,yBAAyB,GAE1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAoBlD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAAyB;IAEzB,MAAM,MAAM,GAAG,yBAAyB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzD,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAEpD,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACnC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACnC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC9C,IAAI,CAAC,CAAC,MAAM,KAAK,EAAE,IAAI,CAAC,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CACb,kCAAkC,CAAC,CAAC,MAAM,OAAO,CAAC,CAAC,MAAM,EAAE,CAC5D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE;QACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;QACzC,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;KAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Optional per-call pre-flight for the CCTP-inbound UserOp batch.
|
|
3
|
-
*
|
|
4
|
-
* The bundler simulates the whole UserOp and returns a single
|
|
5
|
-
* "execution reverted" if any inner call fails — useless for
|
|
6
|
-
* iterating. This helper runs each call individually via `eth_call`
|
|
7
|
-
* with the smart account as `from`, surfacing the per-call revert
|
|
8
|
-
* data before we even talk to the bundler.
|
|
9
|
-
*
|
|
10
|
-
* Limitation: any call that re-enters the smart account (e.g. Permit2
|
|
11
|
-
* invoking `IERC1271.isValidSignature`) reverts here because the
|
|
12
|
-
* account isn't deployed at simulation time but WILL be in the real
|
|
13
|
-
* UserOp via factoryData. Treat these reverts as informational — the
|
|
14
|
-
* bundler's full-simulation is the authoritative check.
|
|
15
|
-
*/
|
|
16
|
-
import { createSdkLogger } from "../logging.js";
|
|
17
|
-
/**
|
|
18
|
-
* Walk a viem error chain and surface any RPC-level revert data
|
|
19
|
-
* (selector + encoded args). viem buries these under `cause` /
|
|
20
|
-
* `data` / nested `data.data`.
|
|
21
|
-
*/
|
|
22
|
-
export function extractRevertData(err) {
|
|
23
|
-
let cur = err;
|
|
24
|
-
for (let depth = 0; depth < 10 && cur; depth++) {
|
|
25
|
-
const node = cur;
|
|
26
|
-
if (typeof node.data === "string" && node.data.startsWith("0x")) {
|
|
27
|
-
return node.data;
|
|
28
|
-
}
|
|
29
|
-
if (typeof node.data === "object" && node.data !== null) {
|
|
30
|
-
const nested = node.data.data;
|
|
31
|
-
if (typeof nested === "string" && nested.startsWith("0x")) {
|
|
32
|
-
return nested;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
cur = node.cause;
|
|
36
|
-
}
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Run `eth_call` once per batch call with the smart account as
|
|
41
|
-
* `from`. Logs per-call status via `console.log` / `console.warn` so
|
|
42
|
-
* failures are visible in devtools. Never throws — pre-flight reverts
|
|
43
|
-
* for calls that re-enter the smart account are expected.
|
|
44
|
-
*/
|
|
45
|
-
export async function simulateBatchCalls(args) {
|
|
46
|
-
const { calls, smartAccount, publicClient } = args;
|
|
47
|
-
const logger = createSdkLogger(args).child({
|
|
48
|
-
module: "cctp-inbound/preflight",
|
|
49
|
-
operation: "cctp.preflight",
|
|
50
|
-
data: { smartAccount },
|
|
51
|
-
});
|
|
52
|
-
for (let i = 0; i < calls.length; i++) {
|
|
53
|
-
const call = calls[i];
|
|
54
|
-
const label = `[cctp-inbound/preflight] call ${i + 1}/${calls.length} to ${call.to}`;
|
|
55
|
-
try {
|
|
56
|
-
await publicClient.call({
|
|
57
|
-
account: smartAccount,
|
|
58
|
-
to: call.to,
|
|
59
|
-
data: call.data,
|
|
60
|
-
value: call.value,
|
|
61
|
-
});
|
|
62
|
-
logger.debug({
|
|
63
|
-
event: "cctp.preflight.call_ok",
|
|
64
|
-
message: "CCTP preflight call succeeded",
|
|
65
|
-
data: { label, index: i, to: call.to },
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
const revertData = extractRevertData(err);
|
|
70
|
-
logger.warn({
|
|
71
|
-
event: "cctp.preflight.call_reverted",
|
|
72
|
-
message: "CCTP preflight call reverted; this may be OK at send time",
|
|
73
|
-
data: {
|
|
74
|
-
label,
|
|
75
|
-
index: i,
|
|
76
|
-
to: call.to,
|
|
77
|
-
revertData: revertData ?? "(none)",
|
|
78
|
-
},
|
|
79
|
-
error: err,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=preflight.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/cctp-inbound/preflight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,eAAe,EAA8B,MAAM,eAAe,CAAC;AAG5E;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC5C,IAAI,GAAG,GAAY,GAAG,CAAC;IACvB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,EAAE,IAAI,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,GAA0C,CAAC;QACxD,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAChE,O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AAK,CAAC;gBACX,KAAK,EAAE,wBAAwB;gBAC/B,OAAO,EAAE,+BAA+B;gBACxC,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE;aACvC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,UAAU,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;YAC1C,MAAM,CAAC,IAAI,CAAC;gBACV,KAAK,EAAE,8BAA8B;gBACrC,OAAO,EAAE,2DAA2D;gBACpE,IAAI,EAAE;oBACJ,KAAK;oBACL,KAAK,EAAE,CAAC;oBACR,EAAE,EAAE,IAAI,CAAC,EAAE;oBACX,UAAU,EAAE,UAAU,IAAI,QAAQ;iBACnC;gBACD,KAAK,EAAE,GAAG;aACX,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `recoverCctpInbound` — sweep USDC stranded in the user's smart account
|
|
3
|
-
* after a CCTP burn whose HTLC settlement never completed.
|
|
4
|
-
*
|
|
5
|
-
* Two failure modes are handled:
|
|
6
|
-
* - User burned on the source chain but never called `receiveMessage`
|
|
7
|
-
* on Arbitrum (smart account holds 0 USDC; the message is unconsumed).
|
|
8
|
-
* - User called `receiveMessage` but the HTLC fund step reverted
|
|
9
|
-
* (smart account already holds the minted USDC).
|
|
10
|
-
*
|
|
11
|
-
* Strategy: at most two paymaster-sponsored UserOps.
|
|
12
|
-
* 1. If `MessageTransmitter.usedNonces(nonce) == 0`: send a UserOp that
|
|
13
|
-
* calls `receiveMessage(message, attestation)`. The smart account
|
|
14
|
-
* remains the `destinationCaller`, so only it can submit.
|
|
15
|
-
* 2. Read the smart account's USDC balance, then send a UserOp that
|
|
16
|
-
* calls `USDC.transfer(recipient, balance)`.
|
|
17
|
-
*
|
|
18
|
-
* The two-UserOp split avoids decoding the CCTP message body to predict
|
|
19
|
-
* the post-mint balance — `balanceOf` between the calls is authoritative.
|
|
20
|
-
*/
|
|
21
|
-
import { createPublicClient, encodeFunctionData, erc20Abi, http, parseAbi, } from "viem";
|
|
22
|
-
import { arbitrum } from "viem/chains";
|
|
23
|
-
import { fetchAttestation } from "../cctp/attestation.js";
|
|
24
|
-
import { IRIS_API_MAINNET, MESSAGE_TRANSMITTER_V2, USDC_ADDRESSES, } from "../cctp/constants.js";
|
|
25
|
-
import { createSwapSmartAccountClient } from "./smartAccount.js";
|
|
26
|
-
const MESSAGE_TRANSMITTER_ABI = parseAbi([
|
|
27
|
-
"function receiveMessage(bytes message, bytes attestation) external returns (bool)",
|
|
28
|
-
]);
|
|
29
|
-
const USED_NONCES_ABI = [
|
|
30
|
-
{
|
|
31
|
-
type: "function",
|
|
32
|
-
name: "usedNonces",
|
|
33
|
-
stateMutability: "view",
|
|
34
|
-
inputs: [{ name: "nonce", type: "bytes32" }],
|
|
35
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
36
|
-
},
|
|
37
|
-
];
|
|
38
|
-
/**
|
|
39
|
-
* CCTPv2 message header layout: the per-burn nonce sits at bytes 12..44.
|
|
40
|
-
* As a 0x-prefixed hex string, that's chars [26, 90).
|
|
41
|
-
*/
|
|
42
|
-
function extractNonce(cctpMessage) {
|
|
43
|
-
return `0x${cctpMessage.slice(26, 26 + 64)}`;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* CCTPv2 message header: the `destinationCaller` is a bytes32 field at
|
|
47
|
-
* offset 108..140. The address occupies the trailing 20 bytes (left-
|
|
48
|
-
* padded with zeros). In hex-string coordinates that's chars [242, 282).
|
|
49
|
-
*
|
|
50
|
-
* `receiveMessage` reverts with `Invalid caller for message` when
|
|
51
|
-
* `msg.sender` doesn't match this field, so we check it client-side
|
|
52
|
-
* before burning a UserOp + paymaster gas on a guaranteed failure.
|
|
53
|
-
*/
|
|
54
|
-
function extractDestinationCaller(cctpMessage) {
|
|
55
|
-
return `0x${cctpMessage.slice(242, 282)}`;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Recover USDC from a stalled CCTP-inbound flow by sweeping the smart
|
|
59
|
-
* account's balance to a user-provided address. Paymaster-sponsored,
|
|
60
|
-
* so the smart account needs no ETH.
|
|
61
|
-
*/
|
|
62
|
-
export async function recoverCctpInbound(context, params) {
|
|
63
|
-
const { signer, burnTxHash, sourceChain, recipient, chain = arbitrum, irisApiUrl = IRIS_API_MAINNET, onProgress, signal, } = params;
|
|
64
|
-
const { client: aaClient, accountAddress } = await createSwapSmartAccountClient({ signer, aa: context.aa, chain });
|
|
65
|
-
const publicClient = createPublicClient({
|
|
66
|
-
chain,
|
|
67
|
-
transport: http(context.aa.bundlerUrl),
|
|
68
|
-
});
|
|
69
|
-
// 1. Make sure we have the attestation. If the receiveMessage call was
|
|
70
|
-
// already made by someone (incl. the user themselves), we can skip
|
|
71
|
-
// the IRIS poll entirely.
|
|
72
|
-
let cctpMessage = params.attestation?.message;
|
|
73
|
-
let cctpAttestation = params.attestation?.attestation;
|
|
74
|
-
let receiveUserOpHash;
|
|
75
|
-
// Only Arbitrum is a supported settlement chain today.
|
|
76
|
-
const usdcAddress = USDC_ADDRESSES.Arbitrum;
|
|
77
|
-
if (!cctpMessage || !cctpAttestation) {
|
|
78
|
-
onProgress?.({ phase: "attestation" });
|
|
79
|
-
const fetched = await fetchAttestation({
|
|
80
|
-
sourceChain,
|
|
81
|
-
txHash: burnTxHash,
|
|
82
|
-
irisApiUrl,
|
|
83
|
-
signal,
|
|
84
|
-
});
|
|
85
|
-
cctpMessage = fetched.message;
|
|
86
|
-
cctpAttestation = fetched.attestation;
|
|
87
|
-
}
|
|
88
|
-
// 2. Decide whether to include receiveMessage. Use `usedNonces` — the
|
|
89
|
-
// authoritative signal (matches the logic in submit.ts).
|
|
90
|
-
const nonce = extractNonce(cctpMessage);
|
|
91
|
-
const usedNonce = (await publicClient.readContract({
|
|
92
|
-
address: MESSAGE_TRANSMITTER_V2,
|
|
93
|
-
abi: USED_NONCES_ABI,
|
|
94
|
-
functionName: "usedNonces",
|
|
95
|
-
args: [nonce],
|
|
96
|
-
}));
|
|
97
|
-
const skipReceiveMessage = usedNonce !== 0n;
|
|
98
|
-
// 3. Submit receiveMessage UserOp if the burn hasn't been claimed yet.
|
|
99
|
-
if (!skipReceiveMessage) {
|
|
100
|
-
// Guard: only `destinationCaller` can call receiveMessage. If the
|
|
101
|
-
// current owner key derives a different account, the on-chain
|
|
102
|
-
// revert ("Invalid caller for message") is opaque — surface the
|
|
103
|
-
// mismatch with an actionable message instead.
|
|
104
|
-
const destinationCaller = extractDestinationCaller(cctpMessage);
|
|
105
|
-
if (destinationCaller.toLowerCase() !==
|
|
106
|
-
accountAddress.toLowerCase()) {
|
|
107
|
-
throw new Error(`Recovery wallet mismatch: this CCTP burn was sent to ${destinationCaller}, ` +
|
|
108
|
-
`but your current wallet's smart-account address is ${accountAddress}. ` +
|
|
109
|
-
`You must recover with the same mnemonic that created the original swap.`);
|
|
110
|
-
}
|
|
111
|
-
const receiveData = encodeFunctionData({
|
|
112
|
-
abi: MESSAGE_TRANSMITTER_ABI,
|
|
113
|
-
functionName: "receiveMessage",
|
|
114
|
-
args: [cctpMessage, cctpAttestation],
|
|
115
|
-
});
|
|
116
|
-
receiveUserOpHash = await aaClient.sendUserOperation({
|
|
117
|
-
calls: [
|
|
118
|
-
{
|
|
119
|
-
to: MESSAGE_TRANSMITTER_V2,
|
|
120
|
-
data: receiveData,
|
|
121
|
-
value: 0n,
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
});
|
|
125
|
-
onProgress?.({ phase: "receiving", userOpHash: receiveUserOpHash });
|
|
126
|
-
await aaClient.waitForUserOperationReceipt({ hash: receiveUserOpHash });
|
|
127
|
-
}
|
|
128
|
-
// 4. Read the smart account's USDC balance — this is the recoverable amount.
|
|
129
|
-
const balance = (await publicClient.readContract({
|
|
130
|
-
address: usdcAddress,
|
|
131
|
-
abi: erc20Abi,
|
|
132
|
-
functionName: "balanceOf",
|
|
133
|
-
args: [accountAddress],
|
|
134
|
-
}));
|
|
135
|
-
if (balance === 0n) {
|
|
136
|
-
throw new Error(`No USDC at smart account ${accountAddress} after receiveMessage. Nothing to recover.`);
|
|
137
|
-
}
|
|
138
|
-
// 5. Sweep the balance to `recipient`.
|
|
139
|
-
const transferData = encodeFunctionData({
|
|
140
|
-
abi: erc20Abi,
|
|
141
|
-
functionName: "transfer",
|
|
142
|
-
args: [recipient, balance],
|
|
143
|
-
});
|
|
144
|
-
const sweepUserOpHash = await aaClient.sendUserOperation({
|
|
145
|
-
calls: [
|
|
146
|
-
{
|
|
147
|
-
to: usdcAddress,
|
|
148
|
-
data: transferData,
|
|
149
|
-
value: 0n,
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
});
|
|
153
|
-
onProgress?.({
|
|
154
|
-
phase: "sweeping",
|
|
155
|
-
userOpHash: sweepUserOpHash,
|
|
156
|
-
amount: balance,
|
|
157
|
-
});
|
|
158
|
-
const sweepReceipt = await aaClient.waitForUserOperationReceipt({
|
|
159
|
-
hash: sweepUserOpHash,
|
|
160
|
-
});
|
|
161
|
-
const sweepTxHash = sweepReceipt.receipt?.transactionHash;
|
|
162
|
-
onProgress?.({
|
|
163
|
-
phase: "done",
|
|
164
|
-
receiveUserOpHash,
|
|
165
|
-
sweepUserOpHash,
|
|
166
|
-
sweepTxHash,
|
|
167
|
-
recoveredAmount: balance,
|
|
168
|
-
});
|
|
169
|
-
return {
|
|
170
|
-
receiveUserOpHash,
|
|
171
|
-
sweepUserOpHash,
|
|
172
|
-
sweepTxHash,
|
|
173
|
-
smartAccountAddress: accountAddress,
|
|
174
|
-
recoveredAmount: balance,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
//# sourceMappingURL=recover.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recover.js","sourceRoot":"","sources":["../../src/cctp-inbound/recover.ts"],"names":[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F,CAAC;IACJ,CAAC;IAED,uCAAuC;IACvC,MAAM,YAAY,GAAG,kBAAkB,CAAC;QACtC,GAAG,EAAE,QAAQ;QACb,YAAY,EAAE,UAAU;QACxB,IAAI,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC;KAC3B,CAAC,CAAC;IACH,MAAM,eAAe,GAAG,MAAM,QAAQ,CAAC,iBAAiB,CAAC;QACvD,KAAK,EAAE;YACL;gBACE,EAAE,EAAE,WAAsB;gBAC1B,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,EAAE;aACV;SACF;KACF,CAAC,CAAC;IACH,UAAU,EAAE,CAAC;QACX,KAAK,EAAE,UAAU;QACjB,UAAU,EAAE,eAAe;QAC3B,MAAM,EAAE,OAAO;KAChB,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,2BAA2B,CAAC;QAC9D,IAAI,EAAE,eAAe;KACtB,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,EAAE,eAAkC,CAAC;IAE7E,UAAU,EAAE,CAAC;QACX,KAAK,EAAE,MAAM;QACb,iBAAiB;QACjB,eAAe;QACf,WAAW;QACX,eAAe,EAAE,OAAO;KACzB,CAAC,CAAC;IAEH,OAAO;QACL,iBAAiB;QACjB,eAAe;QACf,WAAW;QACX,mBAAmB,EAAE,cAAyB;QAC9C,eAAe,EAAE,OAAO;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build a ZeroDev Kernel smart-account client on Arbitrum from a viem
|
|
3
|
-
* `Account` supplied by the consumer (Privy, wagmi, raw private key —
|
|
4
|
-
* any viem-compatible signer).
|
|
5
|
-
*
|
|
6
|
-
* Under EIP-7702 the consumer's EOA *is* the smart account — its code
|
|
7
|
-
* is delegated to a Kernel implementation on the first UserOp. So the
|
|
8
|
-
* smart-account address and the EOA address are the same, which makes
|
|
9
|
-
* the EOA address usable directly as both:
|
|
10
|
-
* - `mintRecipient` on the source-chain CCTP burn (USDC arrives here)
|
|
11
|
-
* - `destinationCaller` (bytes32-padded) — only this account can
|
|
12
|
-
* call `receiveMessage` on Arbitrum
|
|
13
|
-
*
|
|
14
|
-
* No CREATE2, no factory, no counterfactual address: the first
|
|
15
|
-
* UserOperation carries the 7702 authorization tuple and installs the
|
|
16
|
-
* delegation on-chain; subsequent ones reuse it.
|
|
17
|
-
*
|
|
18
|
-
* Bundler + paymaster both live at the same Alchemy app URL; the
|
|
19
|
-
* policy id is passed via the ERC-7677 `paymasterContext`.
|
|
20
|
-
*/
|
|
21
|
-
import { createKernelAccount, createKernelAccountClient } from "@zerodev/sdk";
|
|
22
|
-
import { getEntryPoint, KERNEL_V3_3 } from "@zerodev/sdk/constants";
|
|
23
|
-
import { createPublicClient, http } from "viem";
|
|
24
|
-
import { createPaymasterClient } from "viem/account-abstraction";
|
|
25
|
-
import { arbitrum } from "viem/chains";
|
|
26
|
-
import { evmSignerToKernelOwner } from "./evmSignerAdapter.js";
|
|
27
|
-
/**
|
|
28
|
-
* Creates a Kernel smart-account client ready to send UserOperations.
|
|
29
|
-
* Async — resolves once the account is derived.
|
|
30
|
-
*
|
|
31
|
-
* @returns `{ client, account, accountAddress }` where `accountAddress`
|
|
32
|
-
* equals the consumer's EOA address (7702: EOA *is* the account).
|
|
33
|
-
*/
|
|
34
|
-
export async function createSwapSmartAccountClient(params) {
|
|
35
|
-
const { signer, aa, chain = arbitrum } = params;
|
|
36
|
-
const { bundlerUrl, paymasterPolicyId } = aa;
|
|
37
|
-
if (!bundlerUrl) {
|
|
38
|
-
throw new Error("aa.bundlerUrl is required");
|
|
39
|
-
}
|
|
40
|
-
if (!paymasterPolicyId) {
|
|
41
|
-
throw new Error("aa.paymasterPolicyId is required");
|
|
42
|
-
}
|
|
43
|
-
const entryPoint = getEntryPoint("0.7");
|
|
44
|
-
const publicClient = createPublicClient({
|
|
45
|
-
chain,
|
|
46
|
-
transport: http(bundlerUrl),
|
|
47
|
-
});
|
|
48
|
-
// Adapt the EvmSigner to a viem LocalAccount. Under 7702 this is the
|
|
49
|
-
// EOA whose code gets delegated to Kernel — the adapter throws a
|
|
50
|
-
// clear error if `signMessage` (UserOp hash) or `signAuthorization`
|
|
51
|
-
// (7702 auth tuple) is missing on the EvmSigner.
|
|
52
|
-
const kernelOwner = evmSignerToKernelOwner(signer);
|
|
53
|
-
// EIP-7702 mode: pass the EOA as `eip7702Account`. Kernel signs the
|
|
54
|
-
// authorization tuple on the first UserOp via the account's
|
|
55
|
-
// `signAuthorization`, installing the delegation on-chain. No
|
|
56
|
-
// separate ECDSA validator plugin or CREATE2 factory needed — the
|
|
57
|
-
// delegated EOA's own key gates the account.
|
|
58
|
-
const account = await createKernelAccount(publicClient, {
|
|
59
|
-
eip7702Account: kernelOwner,
|
|
60
|
-
entryPoint,
|
|
61
|
-
kernelVersion: KERNEL_V3_3,
|
|
62
|
-
});
|
|
63
|
-
// Alchemy serves standard ERC-7677 paymaster methods
|
|
64
|
-
// (`pm_getPaymasterStubData` / `pm_getPaymasterData`) on the same app
|
|
65
|
-
// URL as the bundler. Passing the policy id via `paymasterContext`
|
|
66
|
-
// lets viem call both methods at the right points in the UserOp
|
|
67
|
-
// preparation flow (stub → gas estimate → final paymaster data).
|
|
68
|
-
const paymasterClient = createPaymasterClient({
|
|
69
|
-
transport: http(bundlerUrl),
|
|
70
|
-
});
|
|
71
|
-
const client = createKernelAccountClient({
|
|
72
|
-
account,
|
|
73
|
-
chain,
|
|
74
|
-
bundlerTransport: http(bundlerUrl),
|
|
75
|
-
paymaster: paymasterClient,
|
|
76
|
-
paymasterContext: { policyId: paymasterPolicyId },
|
|
77
|
-
userOperation: {
|
|
78
|
-
// ZeroDev's default fetcher calls `zd_getUserOperationGasPrice`,
|
|
79
|
-
// which Alchemy's bundler rejects. Use Alchemy's
|
|
80
|
-
// `rundler_maxPriorityFeePerGas` instead and combine with viem's
|
|
81
|
-
// base-fee estimate for maxFeePerGas. Falls back to a static
|
|
82
|
-
// floor (0.001 gwei) if the rundler method isn't available.
|
|
83
|
-
estimateFeesPerGas: async () => {
|
|
84
|
-
const STATIC_MIN_PRIORITY = 1000000n;
|
|
85
|
-
let maxPriorityFeePerGas = STATIC_MIN_PRIORITY;
|
|
86
|
-
try {
|
|
87
|
-
const resp = await fetch(bundlerUrl, {
|
|
88
|
-
method: "POST",
|
|
89
|
-
headers: { "Content-Type": "application/json" },
|
|
90
|
-
body: JSON.stringify({
|
|
91
|
-
jsonrpc: "2.0",
|
|
92
|
-
id: 1,
|
|
93
|
-
method: "rundler_maxPriorityFeePerGas",
|
|
94
|
-
params: [],
|
|
95
|
-
}),
|
|
96
|
-
});
|
|
97
|
-
const json = await resp.json();
|
|
98
|
-
if (typeof json.result === "string") {
|
|
99
|
-
const rundlerFee = BigInt(json.result);
|
|
100
|
-
maxPriorityFeePerGas =
|
|
101
|
-
rundlerFee > STATIC_MIN_PRIORITY
|
|
102
|
-
? rundlerFee
|
|
103
|
-
: STATIC_MIN_PRIORITY;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
catch {
|
|
107
|
-
/* fall through to static floor */
|
|
108
|
-
}
|
|
109
|
-
const baseFees = await publicClient.estimateFeesPerGas();
|
|
110
|
-
const maxFeePerGas = baseFees.maxFeePerGas + maxPriorityFeePerGas;
|
|
111
|
-
return { maxFeePerGas, maxPriorityFeePerGas };
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
return { client, account, accountAddress: account.address };
|
|
116
|
-
}
|
|
117
|
-
//# sourceMappingURL=smartAccount.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"smartAccount.js","sourceRoot":"","sources":["../../src/cctp-inbound/smartAccount.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,aAAa,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M,YAAY,CAAC,kBAAkB,EAAE,CAAC;gBACzD,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,GAAG,oBAAoB,CAAC;gBAClE,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,CAAC;YAChD,CAAC;SACF;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;AAC9D,CAAC"}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `submitUserOp` — end-to-end UserOp submission for the CCTP-inbound
|
|
3
|
-
* settlement step. Composes:
|
|
4
|
-
*
|
|
5
|
-
* 1. Fetch HTLC/DEX calldata from the backend.
|
|
6
|
-
* 2. Build a Kernel smart-account client owned by the caller's signer.
|
|
7
|
-
* 3. Check the smart-account USDC balance; skip `receiveMessage` if
|
|
8
|
-
* funds already landed (retry-safe).
|
|
9
|
-
* 4. Compose the 3-call UserOp batch.
|
|
10
|
-
* 5. Send the UserOp via the bundler; optionally wait for the
|
|
11
|
-
* on-chain tx hash.
|
|
12
|
-
*
|
|
13
|
-
* The authoritative high-level primitive for a settlement — most
|
|
14
|
-
* consumers call this (or the even-higher-level `Client.fundSwap`).
|
|
15
|
-
*/
|
|
16
|
-
import { createPublicClient, http } from "viem";
|
|
17
|
-
import { arbitrum } from "viem/chains";
|
|
18
|
-
import { MESSAGE_TRANSMITTER_V2 } from "../cctp/constants.js";
|
|
19
|
-
import { simulateBatchCalls } from "./preflight.js";
|
|
20
|
-
import { createSwapSmartAccountClient } from "./smartAccount.js";
|
|
21
|
-
import { buildCctpInboundBatch, } from "./userOp.js";
|
|
22
|
-
/**
|
|
23
|
-
* CCTPv2 burn/mint message layout (see Circle's `MessageTransmitterV2`):
|
|
24
|
-
*
|
|
25
|
-
* offset size field
|
|
26
|
-
* 0 4 version
|
|
27
|
-
* 4 4 sourceDomain
|
|
28
|
-
* 8 4 destinationDomain
|
|
29
|
-
* 12 32 nonce <-- what we extract
|
|
30
|
-
* 44 32 sender
|
|
31
|
-
* ...
|
|
32
|
-
*
|
|
33
|
-
* Hex-string offsets include the "0x" prefix and 2 chars per byte, so the
|
|
34
|
-
* nonce sits at chars [26, 90).
|
|
35
|
-
*/
|
|
36
|
-
function extractNonce(cctpMessage) {
|
|
37
|
-
return `0x${cctpMessage.slice(26, 26 + 64)}`;
|
|
38
|
-
}
|
|
39
|
-
/** `MessageTransmitterV2.usedNonces(bytes32)` — returns 0 if unused. */
|
|
40
|
-
const USED_NONCES_ABI = [
|
|
41
|
-
{
|
|
42
|
-
type: "function",
|
|
43
|
-
name: "usedNonces",
|
|
44
|
-
stateMutability: "view",
|
|
45
|
-
inputs: [{ name: "nonce", type: "bytes32" }],
|
|
46
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
47
|
-
},
|
|
48
|
-
];
|
|
49
|
-
/**
|
|
50
|
-
* Execute the full CCTP-inbound settlement UserOp for a swap.
|
|
51
|
-
*
|
|
52
|
-
* This is intentionally a free function rather than a
|
|
53
|
-
* `CctpInboundClient` method — the client exposes a thin wrapper that
|
|
54
|
-
* injects its own state; tests and advanced consumers can call the
|
|
55
|
-
* free function directly with a custom `SubmitUserOpContext`.
|
|
56
|
-
*/
|
|
57
|
-
export async function submitCctpInboundUserOp(context, params) {
|
|
58
|
-
const { apiClient, aa } = context;
|
|
59
|
-
const { swapId, signer, cctpMessage, cctpAttestation, chain = arbitrum, noWait, preflightSimulate, } = params;
|
|
60
|
-
// 1. Fetch the HTLC/DEX calldata the backend built for this swap.
|
|
61
|
-
const { data, error } = await apiClient.GET("/swap/{id}/swap-and-lock-calldata-userop", { params: { path: { id: swapId } } });
|
|
62
|
-
if (error || !data) {
|
|
63
|
-
throw new Error(`Failed to fetch CCTP-inbound calldata for swap ${swapId}: ${JSON.stringify(error)}`);
|
|
64
|
-
}
|
|
65
|
-
const server = data;
|
|
66
|
-
// 2. Derive the Kernel client + the smart-account address.
|
|
67
|
-
const { client: aaClient, account: smartAccount, accountAddress, } = await createSwapSmartAccountClient({ signer, aa, chain });
|
|
68
|
-
// 3. Decide whether to include `receiveMessage` in the batch, based on
|
|
69
|
-
// whether *this specific burn's nonce* has already been consumed by
|
|
70
|
-
// MessageTransmitter. A prior balance-based heuristic here was
|
|
71
|
-
// unsafe: any USDC that happened to be at the smart-account address
|
|
72
|
-
// (residual from a partial prior attempt, a direct transfer, …) made
|
|
73
|
-
// it skip `receiveMessage` even if the current burn was still
|
|
74
|
-
// unminted, stranding the fresh funds. Nonce consumption is the
|
|
75
|
-
// authoritative signal — `MessageTransmitter.usedNonces(nonce)`
|
|
76
|
-
// returns non-zero iff the mint for *this* message has landed.
|
|
77
|
-
// Reuses the bundler URL as the node RPC (Alchemy serves both).
|
|
78
|
-
const publicClient = createPublicClient({
|
|
79
|
-
chain,
|
|
80
|
-
transport: http(aa.bundlerUrl),
|
|
81
|
-
});
|
|
82
|
-
const nonce = extractNonce(cctpMessage);
|
|
83
|
-
const usedNonce = (await publicClient.readContract({
|
|
84
|
-
address: MESSAGE_TRANSMITTER_V2,
|
|
85
|
-
abi: USED_NONCES_ABI,
|
|
86
|
-
functionName: "usedNonces",
|
|
87
|
-
args: [nonce],
|
|
88
|
-
}));
|
|
89
|
-
const skipReceiveMessage = usedNonce !== 0n;
|
|
90
|
-
// 4. Compose the 3-call batch (receiveMessage + approve + HTLC create).
|
|
91
|
-
const { calls } = await buildCctpInboundBatch({
|
|
92
|
-
server,
|
|
93
|
-
smartAccountAddress: accountAddress,
|
|
94
|
-
signTypedData: (args) => smartAccount.signTypedData(args),
|
|
95
|
-
cctpMessage,
|
|
96
|
-
cctpAttestation,
|
|
97
|
-
chainId: chain.id,
|
|
98
|
-
skipReceiveMessage,
|
|
99
|
-
});
|
|
100
|
-
// 5. Optional debug pre-flight: per-call `eth_call` with the smart
|
|
101
|
-
// account as `from`, logging per-call status. The bundler's
|
|
102
|
-
// full simulation at `sendUserOperation` is the authoritative
|
|
103
|
-
// check — this is purely for observability while iterating.
|
|
104
|
-
if (preflightSimulate) {
|
|
105
|
-
await simulateBatchCalls({
|
|
106
|
-
calls,
|
|
107
|
-
smartAccount: accountAddress,
|
|
108
|
-
publicClient,
|
|
109
|
-
logger: params.logger,
|
|
110
|
-
logLevel: params.logLevel,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
// 6. Send the UserOp via the bundler. Paymaster sponsorship is wired
|
|
114
|
-
// into the Kernel client already, so no gas is owed by the caller.
|
|
115
|
-
const userOpHash = await aaClient.sendUserOperation({ calls });
|
|
116
|
-
if (noWait) {
|
|
117
|
-
return { userOpHash, smartAccountAddress: accountAddress };
|
|
118
|
-
}
|
|
119
|
-
const receipt = await aaClient.waitForUserOperationReceipt({
|
|
120
|
-
hash: userOpHash,
|
|
121
|
-
});
|
|
122
|
-
// A UserOp can be included on-chain yet revert during execution;
|
|
123
|
-
// waitForUserOperationReceipt resolves with success=false rather than
|
|
124
|
-
// throwing. Surface that as an error so callers retry instead of treating a
|
|
125
|
-
// reverted settlement as done. The batch is atomic, so a reverted attempt
|
|
126
|
-
// applied nothing and re-submission is safe (receiveMessage is nonce-gated).
|
|
127
|
-
if (!receipt.success) {
|
|
128
|
-
throw new Error(`CCTP-inbound settlement UserOp ${userOpHash} reverted on-chain${receipt.reason ? `: ${receipt.reason}` : ""}`);
|
|
129
|
-
}
|
|
130
|
-
return {
|
|
131
|
-
userOpHash,
|
|
132
|
-
smartAccountAddress: accountAddress,
|
|
133
|
-
transactionHash: receipt.receipt?.transactionHash,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
//# sourceMappingURL=submit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"submit.js","sourceRoot":"","sources":["../../src/cctp-inbound/submit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,QAAQ,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