@lendasat/lendaswap-sdk-pure 0.2.24 → 0.2.26
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/arkade-network.d.ts +8 -0
- package/dist/arkade-network.d.ts.map +1 -0
- package/dist/arkade-network.js +40 -0
- package/dist/arkade-network.js.map +1 -0
- package/dist/arkade.d.ts.map +1 -1
- package/dist/arkade.js +2 -9
- package/dist/arkade.js.map +1 -1
- package/dist/cctp/constants.d.ts.map +1 -1
- package/dist/cctp/constants.js +4 -0
- package/dist/cctp/constants.js.map +1 -1
- package/dist/cctp/fee.d.ts +49 -0
- package/dist/cctp/fee.d.ts.map +1 -0
- package/dist/cctp/fee.js +70 -0
- package/dist/cctp/fee.js.map +1 -0
- package/dist/cctp/index.d.ts +2 -1
- package/dist/cctp/index.d.ts.map +1 -1
- package/dist/cctp/index.js +2 -1
- package/dist/cctp/index.js.map +1 -1
- package/dist/cctp/utils.d.ts +15 -0
- package/dist/cctp/utils.d.ts.map +1 -1
- package/dist/cctp/utils.js +41 -0
- package/dist/cctp/utils.js.map +1 -1
- package/dist/cctp-bridge/bridge.d.ts +62 -0
- package/dist/cctp-bridge/bridge.d.ts.map +1 -0
- package/dist/cctp-bridge/bridge.js +74 -0
- package/dist/cctp-bridge/bridge.js.map +1 -0
- package/dist/cctp-bridge/index.d.ts +17 -0
- package/dist/cctp-bridge/index.d.ts.map +1 -0
- package/dist/cctp-bridge/index.js +16 -0
- package/dist/cctp-bridge/index.js.map +1 -0
- package/dist/cctp-inbound/approveAndBurn.d.ts +68 -0
- package/dist/cctp-inbound/approveAndBurn.d.ts.map +1 -0
- package/dist/cctp-inbound/approveAndBurn.js +95 -0
- package/dist/cctp-inbound/approveAndBurn.js.map +1 -0
- package/dist/cctp-inbound/burn.d.ts +51 -0
- package/dist/cctp-inbound/burn.d.ts.map +1 -0
- package/dist/cctp-inbound/burn.js +66 -0
- package/dist/cctp-inbound/burn.js.map +1 -0
- package/dist/cctp-inbound/chainMap.d.ts +48 -0
- package/dist/cctp-inbound/chainMap.d.ts.map +1 -0
- package/dist/cctp-inbound/chainMap.js +103 -0
- package/dist/cctp-inbound/chainMap.js.map +1 -0
- package/dist/cctp-inbound/client.d.ts +1573 -0
- package/dist/cctp-inbound/client.d.ts.map +1 -0
- package/dist/cctp-inbound/client.js +117 -0
- package/dist/cctp-inbound/client.js.map +1 -0
- package/dist/cctp-inbound/eip2612.d.ts +77 -0
- package/dist/cctp-inbound/eip2612.d.ts.map +1 -0
- package/dist/cctp-inbound/eip2612.js +95 -0
- package/dist/cctp-inbound/eip2612.js.map +1 -0
- package/dist/cctp-inbound/evmSignerAdapter.d.ts +25 -0
- package/dist/cctp-inbound/evmSignerAdapter.d.ts.map +1 -0
- package/dist/cctp-inbound/evmSignerAdapter.js +50 -0
- package/dist/cctp-inbound/evmSignerAdapter.js.map +1 -0
- package/dist/cctp-inbound/fundSwap.d.ts +94 -0
- package/dist/cctp-inbound/fundSwap.d.ts.map +1 -0
- package/dist/cctp-inbound/fundSwap.js +90 -0
- package/dist/cctp-inbound/fundSwap.js.map +1 -0
- package/dist/cctp-inbound/index.d.ts +35 -0
- package/dist/cctp-inbound/index.d.ts.map +1 -0
- package/dist/cctp-inbound/index.js +33 -0
- package/dist/cctp-inbound/index.js.map +1 -0
- package/dist/cctp-inbound/permit2.d.ts +33 -0
- package/dist/cctp-inbound/permit2.d.ts.map +1 -0
- package/dist/cctp-inbound/permit2.js +32 -0
- package/dist/cctp-inbound/permit2.js.map +1 -0
- package/dist/cctp-inbound/preflight.d.ts +36 -0
- package/dist/cctp-inbound/preflight.d.ts.map +1 -0
- package/dist/cctp-inbound/preflight.js +67 -0
- package/dist/cctp-inbound/preflight.js.map +1 -0
- package/dist/cctp-inbound/smartAccount.d.ts +1518 -0
- package/dist/cctp-inbound/smartAccount.d.ts.map +1 -0
- package/dist/cctp-inbound/smartAccount.js +117 -0
- package/dist/cctp-inbound/smartAccount.js.map +1 -0
- package/dist/cctp-inbound/submit.d.ts +75 -0
- package/dist/cctp-inbound/submit.d.ts.map +1 -0
- package/dist/cctp-inbound/submit.js +126 -0
- package/dist/cctp-inbound/submit.js.map +1 -0
- package/dist/cctp-inbound/types.d.ts +30 -0
- package/dist/cctp-inbound/types.d.ts.map +1 -0
- package/dist/cctp-inbound/types.js +5 -0
- package/dist/cctp-inbound/types.js.map +1 -0
- package/dist/cctp-inbound/userOp.d.ts +93 -0
- package/dist/cctp-inbound/userOp.d.ts.map +1 -0
- package/dist/cctp-inbound/userOp.js +151 -0
- package/dist/cctp-inbound/userOp.js.map +1 -0
- package/dist/client.d.ts +166 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +565 -32
- package/dist/client.js.map +1 -1
- package/dist/create/arkade.d.ts.map +1 -1
- package/dist/create/arkade.js +21 -19
- package/dist/create/arkade.js.map +1 -1
- package/dist/create/bitcoin.d.ts.map +1 -1
- package/dist/create/bitcoin.js +17 -15
- package/dist/create/bitcoin.js.map +1 -1
- package/dist/create/evm-to-arkade.d.ts.map +1 -1
- package/dist/create/evm-to-arkade.js +2 -0
- package/dist/create/evm-to-arkade.js.map +1 -1
- package/dist/create/evm-to-bitcoin.d.ts.map +1 -1
- package/dist/create/evm-to-bitcoin.js +2 -0
- package/dist/create/evm-to-bitcoin.js.map +1 -1
- package/dist/create/evm-to-lightning.d.ts.map +1 -1
- package/dist/create/evm-to-lightning.js +6 -3
- package/dist/create/evm-to-lightning.js.map +1 -1
- package/dist/create/lightning.d.ts.map +1 -1
- package/dist/create/lightning.js +17 -15
- package/dist/create/lightning.js.map +1 -1
- package/dist/create/types.d.ts +40 -0
- package/dist/create/types.d.ts.map +1 -1
- package/dist/delegate.d.ts.map +1 -1
- package/dist/delegate.js +2 -31
- package/dist/delegate.js.map +1 -1
- package/dist/evm/wallet.d.ts +16 -0
- package/dist/evm/wallet.d.ts.map +1 -1
- package/dist/evm/wallet.js.map +1 -1
- package/dist/generated/api.d.ts +408 -2
- package/dist/generated/api.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/redeem/arkade.d.ts.map +1 -1
- package/dist/redeem/arkade.js +4 -43
- package/dist/redeem/arkade.js.map +1 -1
- package/dist/redeem/gasless.d.ts +16 -0
- package/dist/redeem/gasless.d.ts.map +1 -1
- package/dist/redeem/gasless.js +3 -1
- package/dist/redeem/gasless.js.map +1 -1
- package/dist/refund/arkade.d.ts.map +1 -1
- package/dist/refund/arkade.js +3 -39
- package/dist/refund/arkade.js.map +1 -1
- package/dist/refund/{collab.d.ts → collab-arkade-evm.d.ts} +6 -6
- package/dist/refund/collab-arkade-evm.d.ts.map +1 -0
- package/dist/refund/{collab.js → collab-arkade-evm.js} +6 -38
- package/dist/refund/collab-arkade-evm.js.map +1 -0
- package/dist/refund/collab-arkade-lightning.d.ts +59 -0
- package/dist/refund/collab-arkade-lightning.d.ts.map +1 -0
- package/dist/refund/collab-arkade-lightning.js +208 -0
- package/dist/refund/collab-arkade-lightning.js.map +1 -0
- package/dist/refund/index.d.ts +3 -2
- package/dist/refund/index.d.ts.map +1 -1
- package/dist/refund/index.js +3 -2
- package/dist/refund/index.js.map +1 -1
- package/dist/tokens.d.ts +18 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +43 -7
- package/dist/tokens.js.map +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +1 -1
- package/package.json +27 -2
- package/dist/refund/collab.d.ts.map +0 -1
- package/dist/refund/collab.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/cctp-inbound/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACl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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAwDa,CAAC;2BAEM,CAAC;;mCAKH,CAAC;mBAAe,CAAC;;yCAUb,CAAC;;;;;;;;;;;uBAwCc,CAAC;;;2BAAkN,CAAC;;;;;;;;;;;;;;;;;;;;;;;IAzEpQ;;;;;;;;OAQG;IACH,gBAAgB,CAAC,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,UAAU,CAAC;IAI1E;;;;;;;;;OASG;IACH,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAOrE;;;;;;;;;OASG;IACH,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAI3E;;;;;;;;OAQG;IACH,kBAAkB,CAChB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC;IAI7B;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAGlE"}
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
constructor(config) {
|
|
27
|
+
this.#apiClient = config.apiClient;
|
|
28
|
+
this.#aa = config.aa;
|
|
29
|
+
}
|
|
30
|
+
/** The AA config this client was built with. */
|
|
31
|
+
get aa() {
|
|
32
|
+
return this.#aa;
|
|
33
|
+
}
|
|
34
|
+
/** The underlying typed API client. */
|
|
35
|
+
get api() {
|
|
36
|
+
return this.#apiClient;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Build a Kernel smart-account client owned by `owner`.
|
|
40
|
+
*
|
|
41
|
+
* Low-level primitive — most consumers will use `submitUserOp` or
|
|
42
|
+
* the one-shot `client.fundSwap` instead of constructing the AA
|
|
43
|
+
* client themselves.
|
|
44
|
+
*/
|
|
45
|
+
createSmartAccountClient(args) {
|
|
46
|
+
const params = {
|
|
47
|
+
signer: args.signer,
|
|
48
|
+
aa: this.#aa,
|
|
49
|
+
chain: args.chain,
|
|
50
|
+
};
|
|
51
|
+
return createSwapSmartAccountClient(params);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Compose the 3-call UserOp batch (receiveMessage + USDC.approve +
|
|
55
|
+
* executeAndCreateWithPermit2) that the smart account will execute
|
|
56
|
+
* atomically. Produces the Permit2 signature via the caller-supplied
|
|
57
|
+
* `signTypedData` — typically `kernelAccount.signTypedData`.
|
|
58
|
+
*
|
|
59
|
+
* Low-level primitive — most consumers call `submitUserOp` instead,
|
|
60
|
+
* which composes batch + send + wait-for-receipt.
|
|
61
|
+
*/
|
|
62
|
+
buildUserOpBatch(params) {
|
|
63
|
+
return buildCctpInboundBatch(params);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* End-to-end settlement UserOp: fetch calldata, build Kernel client,
|
|
67
|
+
* compose the batch, submit via the bundler, and (by default) wait
|
|
68
|
+
* for the on-chain receipt.
|
|
69
|
+
*
|
|
70
|
+
* This is the main high-level entry point for the CCTP-inbound
|
|
71
|
+
* settlement step. Pass the IRIS message + attestation (from
|
|
72
|
+
* `waitForAttestation`, landing in a follow-up step) and the
|
|
73
|
+
* caller's signer.
|
|
74
|
+
*/
|
|
75
|
+
submitUserOp(params) {
|
|
76
|
+
return submitCctpInboundUserOp({ apiClient: this.#apiClient, aa: this.#aa }, params);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Source-chain USDC approve (if needed) + `depositForBurn`. The
|
|
80
|
+
* minted USDC on the destination chain is pinned to
|
|
81
|
+
* `smartAccountAddress`, and `destinationCaller` is pinned to the
|
|
82
|
+
* same address — only that account can settle the message.
|
|
83
|
+
*
|
|
84
|
+
* Does not wait for CCTP attestation; returns as soon as both txs
|
|
85
|
+
* are broadcast. The caller pairs this with `waitForAttestation`
|
|
86
|
+
* (landing in the next step) and `submitUserOp`.
|
|
87
|
+
*/
|
|
88
|
+
approveAndBurn(params) {
|
|
89
|
+
return approveAndBurn(params);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Poll Circle's IRIS V2 API until the CCTP attestation for a burn
|
|
93
|
+
* tx is `complete`, then return the `message` + `attestation` bytes
|
|
94
|
+
* ready to feed into `submitUserOp`.
|
|
95
|
+
*
|
|
96
|
+
* Typical wait: ~15 seconds for fast transfers, a few minutes for
|
|
97
|
+
* standard. Defaults to a 15-minute timeout; callers can pass
|
|
98
|
+
* `signal` (AbortSignal) to cancel early.
|
|
99
|
+
*/
|
|
100
|
+
waitForAttestation(options) {
|
|
101
|
+
return fetchAttestation(options);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* One-shot CCTP-inbound swap: approve + burn on the source chain,
|
|
105
|
+
* poll IRIS for the attestation, then submit the settlement UserOp
|
|
106
|
+
* via the Kernel smart account. Paymaster sponsors the settlement
|
|
107
|
+
* so the user needs no ETH on the destination chain.
|
|
108
|
+
*
|
|
109
|
+
* The `walletClient.account` signs both the source-chain txs and
|
|
110
|
+
* the destination-chain UserOp (as Kernel owner), and its address
|
|
111
|
+
* anchors the deterministic smart-account address.
|
|
112
|
+
*/
|
|
113
|
+
fundSwap(params) {
|
|
114
|
+
return cctpFundSwap({ apiClient: this.#apiClient, aa: this.#aa }, params);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AAEhC,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;AAOrB,MAAM,OAAO,iBAAiB;IACnB,UAAU,CAAY;IACtB,GAAG,CAAW;IAEvB,YAAY,MAA+B;QACzC,IAAI,CAAC,UAAU,GAAG,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-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
|
+
/** Parameters for signing an EIP-2612 permit against a specific token. */
|
|
12
|
+
export interface SignEip2612Params {
|
|
13
|
+
/** Signer's secp256k1 private key (from the SDK HD signer). */
|
|
14
|
+
secretKey: Uint8Array | string;
|
|
15
|
+
/** The token's EIP-712 DOMAIN_SEPARATOR (0x-prefixed, from `token.DOMAIN_SEPARATOR()`). */
|
|
16
|
+
domainSeparator: string;
|
|
17
|
+
/** Token owner address (= `deriveEvmAddress(secretKey)`). */
|
|
18
|
+
owner: string;
|
|
19
|
+
/**
|
|
20
|
+
* Spender. Defaults to Permit2 (the usual target — this is what enables
|
|
21
|
+
* `executeAndCreateWithPermit2` to pull via Permit2 in the same multicall).
|
|
22
|
+
*/
|
|
23
|
+
spender?: string;
|
|
24
|
+
/** Approval amount. Pass `MAX_UINT256` to remove the need for future permits. */
|
|
25
|
+
value: bigint;
|
|
26
|
+
/** Current EIP-2612 nonce for `owner` on the token (from `token.nonces(owner)`). */
|
|
27
|
+
nonce: number;
|
|
28
|
+
/** Signature deadline (unix seconds). */
|
|
29
|
+
deadline: bigint;
|
|
30
|
+
}
|
|
31
|
+
/** Signed EIP-2612 permit ready to submit on-chain. */
|
|
32
|
+
export interface SignedEip2612Permit {
|
|
33
|
+
/** v, r, s components — v is 27 or 28. */
|
|
34
|
+
v: number;
|
|
35
|
+
r: string;
|
|
36
|
+
s: string;
|
|
37
|
+
/** Approval amount (as stringified decimal for API transport). */
|
|
38
|
+
value: string;
|
|
39
|
+
/** Signature deadline (unix seconds). */
|
|
40
|
+
deadline: number;
|
|
41
|
+
}
|
|
42
|
+
/** uint256 max — sign once, never need another permit. */
|
|
43
|
+
export declare const MAX_UINT256: bigint;
|
|
44
|
+
/**
|
|
45
|
+
* Signs an EIP-2612 permit using the SDK's derived key, returning the
|
|
46
|
+
* split signature + value/deadline in a shape the backend's gasless
|
|
47
|
+
* endpoint accepts directly.
|
|
48
|
+
*/
|
|
49
|
+
export declare function signEip2612Permit(params: SignEip2612Params): SignedEip2612Permit;
|
|
50
|
+
/**
|
|
51
|
+
* Builds an EIP-712 domain separator from the standard 4-field domain.
|
|
52
|
+
*
|
|
53
|
+
* Use when you know the token's on-chain `name` and `version` and want to
|
|
54
|
+
* avoid an RPC call to `token.DOMAIN_SEPARATOR()`. For USDC deployments,
|
|
55
|
+
* both vary slightly — see {@link USDC_DOMAIN_FIELDS}.
|
|
56
|
+
*/
|
|
57
|
+
export declare function buildDomainSeparator(params: {
|
|
58
|
+
name: string;
|
|
59
|
+
version: string;
|
|
60
|
+
chainId: number;
|
|
61
|
+
verifyingContract: string;
|
|
62
|
+
}): string;
|
|
63
|
+
/**
|
|
64
|
+
* Known EIP-712 domain fields for native USDC on each CCTPv2-supported EVM
|
|
65
|
+
* chain. Populate as needed — verify on-chain via `DOMAIN_SEPARATOR()` before
|
|
66
|
+
* relying on these in production.
|
|
67
|
+
*
|
|
68
|
+
* Arbitrum native USDC (`0xaf88d065e77c8cC2239327C5EDb3A432268e5831`) reports
|
|
69
|
+
* `name = "USD Coin"`, `version = "2"`. Most Circle-issued native USDC uses
|
|
70
|
+
* the same; bridged USDC.e variants differ.
|
|
71
|
+
*/
|
|
72
|
+
export declare const USDC_DOMAIN_FIELDS: Record<number, {
|
|
73
|
+
name: string;
|
|
74
|
+
version: string;
|
|
75
|
+
address: string;
|
|
76
|
+
}>;
|
|
77
|
+
//# sourceMappingURL=eip2612.d.ts.map
|
|
@@ -0,0 +1 @@
|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AAA;CAAE,CAOnD,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eip2612.js","sourceRoot":"","sources":["../../src/cctp-inbound/eip2612.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EACL,wBAAwB,EAExB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAmClD,0DAA0D;AAC1D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AAE7C;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAyB;IAEzB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,eAAe,CAAC;IAElD,MAAM,YAAY,GAAwB;QACxC,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
* Kernel's validator 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 smart account).
|
|
9
|
+
*
|
|
10
|
+
* `EvmSigner.signTypedData` is required on all callers. `signMessage`
|
|
11
|
+
* is optional on `EvmSigner` — this adapter throws a clear error if
|
|
12
|
+
* the CCTP path is reached with an `EvmSigner` that lacks it.
|
|
13
|
+
*
|
|
14
|
+
* `signTransaction` is provided as a stub: Kernel never routes txs
|
|
15
|
+
* through the owner account (the bundler submits UserOps), so calling
|
|
16
|
+
* it would be a programmer error.
|
|
17
|
+
*/
|
|
18
|
+
import type { LocalAccount } from "viem";
|
|
19
|
+
import type { EvmSigner } from "../evm/wallet.js";
|
|
20
|
+
/**
|
|
21
|
+
* Wrap an `EvmSigner` in a viem `LocalAccount` so ZeroDev Kernel's
|
|
22
|
+
* `signerToEcdsaValidator` can use it as the account owner.
|
|
23
|
+
*/
|
|
24
|
+
export declare function evmSignerToKernelOwner(signer: EvmSigner): LocalAccount;
|
|
25
|
+
//# sourceMappingURL=evmSignerAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evmSignerAdapter.d.ts","sourceRoot":"","sources":["../../src/cctp-inbound/evmSignerAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAO,YAAY,EAAE,MAAM,MAAM,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,YAAY,CAiCtE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge `EvmSigner` → a viem `LocalAccount` that ZeroDev's Kernel
|
|
3
|
+
* ECDSA validator accepts as an `owner`.
|
|
4
|
+
*
|
|
5
|
+
* Kernel's validator 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 smart account).
|
|
9
|
+
*
|
|
10
|
+
* `EvmSigner.signTypedData` is required on all callers. `signMessage`
|
|
11
|
+
* is optional on `EvmSigner` — this adapter throws a clear error if
|
|
12
|
+
* the CCTP path is reached with an `EvmSigner` that lacks it.
|
|
13
|
+
*
|
|
14
|
+
* `signTransaction` is provided as a stub: Kernel never routes txs
|
|
15
|
+
* through the owner account (the bundler submits UserOps), so calling
|
|
16
|
+
* it would be a programmer error.
|
|
17
|
+
*/
|
|
18
|
+
import { toAccount } from "viem/accounts";
|
|
19
|
+
/**
|
|
20
|
+
* Wrap an `EvmSigner` in a viem `LocalAccount` so ZeroDev Kernel's
|
|
21
|
+
* `signerToEcdsaValidator` can use it as the account owner.
|
|
22
|
+
*/
|
|
23
|
+
export function evmSignerToKernelOwner(signer) {
|
|
24
|
+
return toAccount({
|
|
25
|
+
address: signer.address,
|
|
26
|
+
async signMessage({ message }) {
|
|
27
|
+
if (!signer.signMessage) {
|
|
28
|
+
throw new Error("CCTP-inbound flow requires `EvmSigner.signMessage`. Extend your signer — e.g. `(m) => walletClient.signMessage({ account, message: m })`.");
|
|
29
|
+
}
|
|
30
|
+
// viem's `message` is `SignableMessage`: either a string or
|
|
31
|
+
// `{ raw: Hex }`. Kernel always passes `{ raw }` — but be
|
|
32
|
+
// defensive about the string shape too.
|
|
33
|
+
const raw = typeof message === "string"
|
|
34
|
+
? new TextEncoder().encode(message)
|
|
35
|
+
: message.raw;
|
|
36
|
+
return (await signer.signMessage({ raw }));
|
|
37
|
+
},
|
|
38
|
+
async signTypedData(typedData) {
|
|
39
|
+
// Narrow viem's broad SignTypedDataParameters to the SDK's
|
|
40
|
+
// internal EIP712TypedData shape — at runtime they're
|
|
41
|
+
// structurally identical, the difference is just generic-heavy
|
|
42
|
+
// typing on viem's side.
|
|
43
|
+
return (await signer.signTypedData(typedData));
|
|
44
|
+
},
|
|
45
|
+
async signTransaction() {
|
|
46
|
+
throw new Error("signTransaction is not supported on the Kernel owner — UserOps are submitted via the bundler, not from the owner EOA directly.");
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=evmSignerAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evmSignerAdapter.js","sourceRoot":"","sources":["../../src/cctp-inbound/evmSignerAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAiB;IACtD,OAAO,SAAS,CAAC;QACf,OAAO,EAAE,MAAM,CAAC,OAAc;QAC9B,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE;YAC3B,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CACb,2IAA2I,CAC5I,CAAC;YACJ,CAAC;YACD,4DAA4D;YAC5D,0DAA0D;YAC1D,wCAAwC;YACxC,MAAM,GAAG,GACP,OAAO,OAAO,KAAK,QAAQ;gBACzB,CAAC,CAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAuB;gBAC1D,CAAC,CAAE,OAAO,CAAC,GAAc,CAAC;YAC9B,OAAO,CAAC,MAAM,MAAM,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE,CAAC,CAAQ,CAAC;QACpD,CAAC;QACD,KAAK,CAAC,aAAa,CAAC,SAAS;YAC3B,2DAA2D;YAC3D,sDAAsD;YACtD,+DAA+D;YAC/D,yBAAyB;YACzB,OAAO,CAAC,MAAM,MAAM,CAAC,aAAa,CAChC,SAAiE,CAClE,CAAQ,CAAC;QACZ,CAAC;QACD,KAAK,CAAC,eAAe;YACnB,MAAM,IAAI,KAAK,CACb,gIAAgI,CACjI,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
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 type { Chain, Hex } from "viem";
|
|
18
|
+
import type { ApiClient } from "../api/client.js";
|
|
19
|
+
import type { EvmSigner } from "../evm/wallet.js";
|
|
20
|
+
import type { AaConfig } from "./types.js";
|
|
21
|
+
/**
|
|
22
|
+
* High-level progress events emitted during a CCTP-inbound swap.
|
|
23
|
+
* Consumers wire a single `onProgress` callback to drive UI updates
|
|
24
|
+
* without coupling to the primitive-level mechanics.
|
|
25
|
+
*/
|
|
26
|
+
export type CctpProgressStep = {
|
|
27
|
+
phase: "approving";
|
|
28
|
+
} | {
|
|
29
|
+
phase: "burning";
|
|
30
|
+
burnTxHash: Hex;
|
|
31
|
+
} | {
|
|
32
|
+
phase: "attestation";
|
|
33
|
+
} | {
|
|
34
|
+
phase: "submitting";
|
|
35
|
+
} | {
|
|
36
|
+
phase: "settled";
|
|
37
|
+
userOpHash: Hex;
|
|
38
|
+
transactionHash?: Hex;
|
|
39
|
+
};
|
|
40
|
+
export interface CctpFundSwapParams {
|
|
41
|
+
/** Swap ID from `client.createSwap(...)`. */
|
|
42
|
+
swapId: string;
|
|
43
|
+
/**
|
|
44
|
+
* SDK signer bound to the **source chain**. Its `address` is the
|
|
45
|
+
* source-chain sender AND the Kernel-account owner on the settlement
|
|
46
|
+
* chain. Requires `signer.signMessage` for the CCTP path.
|
|
47
|
+
*/
|
|
48
|
+
signer: EvmSigner;
|
|
49
|
+
/** USDC amount in smallest units (6 decimals). */
|
|
50
|
+
amount: bigint;
|
|
51
|
+
/**
|
|
52
|
+
* Max fast-transfer fee in USDC units (from IRIS's
|
|
53
|
+
* `/v2/burn/USDC/fees` endpoint). Typical: ~1/10000 of `amount`.
|
|
54
|
+
*/
|
|
55
|
+
maxFee: bigint;
|
|
56
|
+
/**
|
|
57
|
+
* Settlement chain. Defaults to Arbitrum mainnet — the only
|
|
58
|
+
* supported settlement chain today.
|
|
59
|
+
*/
|
|
60
|
+
settlementChain?: Chain;
|
|
61
|
+
/**
|
|
62
|
+
* IRIS API base URL. Defaults to mainnet; override for testnet.
|
|
63
|
+
*/
|
|
64
|
+
irisApiUrl?: string;
|
|
65
|
+
/** Invoked as the flow advances through its phases. */
|
|
66
|
+
onProgress?: (step: CctpProgressStep) => void;
|
|
67
|
+
/** Abort signal for cancelling the attestation wait. */
|
|
68
|
+
signal?: AbortSignal;
|
|
69
|
+
}
|
|
70
|
+
export interface CctpFundSwapResult {
|
|
71
|
+
/** Source-chain burn tx. */
|
|
72
|
+
burnTxHash: Hex;
|
|
73
|
+
/** Source-chain approve tx (omitted if allowance was already sufficient). */
|
|
74
|
+
approveTxHash?: Hex;
|
|
75
|
+
/** Settlement-chain UserOp hash. */
|
|
76
|
+
userOpHash: Hex;
|
|
77
|
+
/** Settlement-chain bundled tx hash (populated once the UserOp is mined). */
|
|
78
|
+
transactionHash?: Hex;
|
|
79
|
+
/** Deterministic Kernel smart-account address owning the HTLC deposit. */
|
|
80
|
+
smartAccountAddress: Hex;
|
|
81
|
+
}
|
|
82
|
+
/** Context passed by `CctpInboundClient` when delegating to this function. */
|
|
83
|
+
export interface CctpFundSwapContext {
|
|
84
|
+
apiClient: ApiClient;
|
|
85
|
+
aa: AaConfig;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Execute the full CCTP-inbound swap flow end to end. Most consumers
|
|
89
|
+
* call this directly — the primitives (`approveAndBurn`,
|
|
90
|
+
* `waitForAttestation`, `submitUserOp`) are available separately for
|
|
91
|
+
* wizard-style UX that needs per-step control.
|
|
92
|
+
*/
|
|
93
|
+
export declare function cctpFundSwap(context: CctpFundSwapContext, params: CctpFundSwapParams): Promise<CctpFundSwapResult>;
|
|
94
|
+
//# sourceMappingURL=fundSwap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fundSwap.d.ts","sourceRoot":"","sources":["../../src/cctp-inbound/fundSwap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAKlD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,GACtB;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,GAAG,CAAA;CAAE,GACrC;IAAE,KAAK,EAAE,aAAa,CAAA;CAAE,GACxB;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE,GACvB;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,GAAG,CAAC;IAAC,eAAe,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC;AAEjE,MAAM,WAAW,kBAAkB;IACjC,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,MAAM,EAAE,SAAS,CAAC;IAClB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC9C,wDAAwD;IACxD,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,4BAA4B;IAC5B,UAAU,EAAE,GAAG,CAAC;IAChB,6EAA6E;IAC7E,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,oCAAoC;IACpC,UAAU,EAAE,GAAG,CAAC;IAChB,6EAA6E;IAC7E,eAAe,CAAC,EAAE,GAAG,CAAC;IACtB,0EAA0E;IAC1E,mBAAmB,EAAE,GAAG,CAAC;CAC1B;AAED,8EAA8E;AAC9E,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,SAAS,CAAC;IACrB,EAAE,EAAE,QAAQ,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC,CA2E7B"}
|
|
@@ -0,0 +1,90 @@
|
|
|
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 } 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
|
+
// Derive the Kernel smart-account address up front. Stable across
|
|
38
|
+
// all three phases — we mint to it on settlement and gate the
|
|
39
|
+
// `receiveMessage` call on it.
|
|
40
|
+
const { accountAddress: smartAccountAddress } = await createSwapSmartAccountClient({
|
|
41
|
+
signer,
|
|
42
|
+
aa: context.aa,
|
|
43
|
+
chain: settlementChain,
|
|
44
|
+
});
|
|
45
|
+
// 1. Source-chain approve + burn.
|
|
46
|
+
onProgress?.({ phase: "approving" });
|
|
47
|
+
const { approveTxHash, burnTxHash } = await approveAndBurn({
|
|
48
|
+
signer,
|
|
49
|
+
amount,
|
|
50
|
+
usdcAddress: source.usdc,
|
|
51
|
+
destinationDomain: destination.domain,
|
|
52
|
+
smartAccountAddress,
|
|
53
|
+
maxFee,
|
|
54
|
+
});
|
|
55
|
+
onProgress?.({ phase: "burning", burnTxHash });
|
|
56
|
+
const burnReceipt = await signer.waitForReceipt(burnTxHash);
|
|
57
|
+
if (burnReceipt.status !== "success") {
|
|
58
|
+
throw new Error(`CCTP burn tx reverted: ${burnTxHash}`);
|
|
59
|
+
}
|
|
60
|
+
// 2. Wait for the IRIS attestation to clear.
|
|
61
|
+
onProgress?.({ phase: "attestation" });
|
|
62
|
+
const { message, attestation } = await fetchAttestation({
|
|
63
|
+
sourceChain: source.name,
|
|
64
|
+
txHash: burnTxHash,
|
|
65
|
+
irisApiUrl,
|
|
66
|
+
signal,
|
|
67
|
+
});
|
|
68
|
+
// 3. Submit the settlement UserOp and wait for the on-chain receipt.
|
|
69
|
+
onProgress?.({ phase: "submitting" });
|
|
70
|
+
const submit = await submitCctpInboundUserOp(context, {
|
|
71
|
+
swapId,
|
|
72
|
+
signer,
|
|
73
|
+
cctpMessage: message,
|
|
74
|
+
cctpAttestation: attestation,
|
|
75
|
+
chain: settlementChain,
|
|
76
|
+
});
|
|
77
|
+
onProgress?.({
|
|
78
|
+
phase: "settled",
|
|
79
|
+
userOpHash: submit.userOpHash,
|
|
80
|
+
transactionHash: submit.transactionHash,
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
approveTxHash,
|
|
84
|
+
burnTxHash,
|
|
85
|
+
userOpHash: submit.userOpHash,
|
|
86
|
+
transactionHash: submit.transactionHash,
|
|
87
|
+
smartAccountAddress: smartAccountAddress,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=fundSwap.js.map
|
|
@@ -0,0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AAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { type ApproveAndBurnParams, type ApproveAndBurnResult, approveAndBurn, } from "./approveAndBurn.js";
|
|
23
|
+
export { type DepositForBurnParams, encodeDepositForBurn, } from "./burn.js";
|
|
24
|
+
export { CCTP_VIEM_CHAINS, CHAIN_ID_TO_CCTP_NAME, cctpMetaForChainId, DIRECT_SOURCE_CHAIN_IDS, getCctpViemChain, getCctpViemChainByName, isCctpOnlySource, } from "./chainMap.js";
|
|
25
|
+
export type { CctpInboundClientConfig } from "./client.js";
|
|
26
|
+
export { CctpInboundClient } from "./client.js";
|
|
27
|
+
export { buildDomainSeparator, MAX_UINT256, type SignEip2612Params, type SignedEip2612Permit, signEip2612Permit, USDC_DOMAIN_FIELDS, } from "./eip2612.js";
|
|
28
|
+
export { type CctpFundSwapContext, type CctpFundSwapParams, type CctpFundSwapResult, type CctpProgressStep, cctpFundSwap, } from "./fundSwap.js";
|
|
29
|
+
export { type SignedPermit2Witness, type SignPermit2Params, signPermit2Witness, } from "./permit2.js";
|
|
30
|
+
export { extractRevertData, type SimulateBatchCallsArgs, simulateBatchCalls, } from "./preflight.js";
|
|
31
|
+
export { type CreateSwapSmartAccountClientParams, createSwapSmartAccountClient, } from "./smartAccount.js";
|
|
32
|
+
export { type SubmitUserOpContext, type SubmitUserOpParams, type SubmitUserOpResult, submitCctpInboundUserOp, } from "./submit.js";
|
|
33
|
+
export type { AaConfig } from "./types.js";
|
|
34
|
+
export { addressToBytes32Hex, type BatchCall, type BuildCctpInboundBatchParams, type BuiltBatch, buildCctpInboundBatch, type SignTypedDataFn, type UseropCalldataResponse, } from "./userOp.js";
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cctp-inbound/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,oBAAoB,EACzB,oBAAoB,GACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,iBAAiB,EACjB,kBAAkB,GACn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