@chainlink/ccip-sdk 0.95.0 → 0.97.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/all-chains.d.ts +23 -0
- package/dist/all-chains.d.ts.map +1 -0
- package/dist/all-chains.js +24 -0
- package/dist/all-chains.js.map +1 -0
- package/dist/api/index.d.ts +31 -19
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +46 -25
- package/dist/api/index.js.map +1 -1
- package/dist/api/types.d.ts +24 -30
- package/dist/api/types.d.ts.map +1 -1
- package/dist/aptos/exec.d.ts +2 -2
- package/dist/aptos/exec.d.ts.map +1 -1
- package/dist/aptos/exec.js.map +1 -1
- package/dist/aptos/hasher.d.ts.map +1 -1
- package/dist/aptos/hasher.js +1 -1
- package/dist/aptos/hasher.js.map +1 -1
- package/dist/aptos/index.d.ts +43 -15
- package/dist/aptos/index.d.ts.map +1 -1
- package/dist/aptos/index.js +112 -105
- package/dist/aptos/index.js.map +1 -1
- package/dist/aptos/types.d.ts +2 -19
- package/dist/aptos/types.d.ts.map +1 -1
- package/dist/aptos/types.js +0 -11
- package/dist/aptos/types.js.map +1 -1
- package/dist/chain.d.ts +734 -174
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +216 -31
- package/dist/chain.js.map +1 -1
- package/dist/commits.d.ts +4 -6
- package/dist/commits.d.ts.map +1 -1
- package/dist/commits.js +4 -4
- package/dist/commits.js.map +1 -1
- package/dist/errors/CCIPError.d.ts +33 -4
- package/dist/errors/CCIPError.d.ts.map +1 -1
- package/dist/errors/CCIPError.js +33 -4
- package/dist/errors/CCIPError.js.map +1 -1
- package/dist/errors/codes.d.ts +5 -0
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/errors/codes.js +5 -1
- package/dist/errors/codes.js.map +1 -1
- package/dist/errors/index.d.ts +2 -2
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +2 -2
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/recovery.d.ts.map +1 -1
- package/dist/errors/recovery.js +6 -1
- package/dist/errors/recovery.js.map +1 -1
- package/dist/errors/specialized.d.ts +1702 -121
- package/dist/errors/specialized.d.ts.map +1 -1
- package/dist/errors/specialized.js +1729 -125
- package/dist/errors/specialized.js.map +1 -1
- package/dist/errors/utils.d.ts.map +1 -1
- package/dist/errors/utils.js +0 -1
- package/dist/errors/utils.js.map +1 -1
- package/dist/evm/abi/OffRamp_2_0.d.ts +764 -0
- package/dist/evm/abi/OffRamp_2_0.d.ts.map +1 -0
- package/dist/evm/abi/OffRamp_2_0.js +744 -0
- package/dist/evm/abi/OffRamp_2_0.js.map +1 -0
- package/dist/evm/abi/OnRamp_2_0.d.ts +925 -0
- package/dist/evm/abi/OnRamp_2_0.d.ts.map +1 -0
- package/dist/evm/abi/OnRamp_2_0.js +992 -0
- package/dist/evm/abi/OnRamp_2_0.js.map +1 -0
- package/dist/evm/const.d.ts +12 -2
- package/dist/evm/const.d.ts.map +1 -1
- package/dist/evm/const.js +8 -2
- package/dist/evm/const.js.map +1 -1
- package/dist/evm/errors.d.ts.map +1 -1
- package/dist/evm/errors.js +7 -2
- package/dist/evm/errors.js.map +1 -1
- package/dist/evm/extra-args.d.ts +25 -0
- package/dist/evm/extra-args.d.ts.map +1 -0
- package/dist/evm/extra-args.js +309 -0
- package/dist/evm/extra-args.js.map +1 -0
- package/dist/evm/gas.d.ts.map +1 -1
- package/dist/evm/gas.js +7 -12
- package/dist/evm/gas.js.map +1 -1
- package/dist/evm/hasher.d.ts.map +1 -1
- package/dist/evm/hasher.js +23 -13
- package/dist/evm/hasher.js.map +1 -1
- package/dist/evm/index.d.ts +140 -35
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +306 -226
- package/dist/evm/index.js.map +1 -1
- package/dist/evm/messages.d.ts +59 -5
- package/dist/evm/messages.d.ts.map +1 -1
- package/dist/evm/messages.js +210 -0
- package/dist/evm/messages.js.map +1 -1
- package/dist/evm/offchain.js.map +1 -1
- package/dist/evm/types.d.ts +7 -2
- package/dist/evm/types.d.ts.map +1 -1
- package/dist/evm/types.js +22 -1
- package/dist/evm/types.js.map +1 -1
- package/dist/execution.d.ts +62 -22
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +102 -51
- package/dist/execution.js.map +1 -1
- package/dist/extra-args.d.ts +113 -4
- package/dist/extra-args.d.ts.map +1 -1
- package/dist/extra-args.js +38 -3
- package/dist/extra-args.js.map +1 -1
- package/dist/gas.d.ts +31 -5
- package/dist/gas.d.ts.map +1 -1
- package/dist/gas.js +43 -9
- package/dist/gas.js.map +1 -1
- package/dist/index.d.ts +11 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/requests.d.ts +101 -22
- package/dist/requests.d.ts.map +1 -1
- package/dist/requests.js +115 -24
- package/dist/requests.js.map +1 -1
- package/dist/selectors.d.ts.map +1 -1
- package/dist/selectors.js +24 -0
- package/dist/selectors.js.map +1 -1
- package/dist/shared/bcs-codecs.d.ts +61 -0
- package/dist/shared/bcs-codecs.d.ts.map +1 -0
- package/dist/shared/bcs-codecs.js +102 -0
- package/dist/shared/bcs-codecs.js.map +1 -0
- package/dist/shared/constants.d.ts +3 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +3 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/solana/exec.d.ts +2 -2
- package/dist/solana/exec.d.ts.map +1 -1
- package/dist/solana/exec.js.map +1 -1
- package/dist/solana/index.d.ts +148 -30
- package/dist/solana/index.d.ts.map +1 -1
- package/dist/solana/index.js +137 -44
- package/dist/solana/index.js.map +1 -1
- package/dist/sui/hasher.d.ts.map +1 -1
- package/dist/sui/hasher.js +1 -1
- package/dist/sui/hasher.js.map +1 -1
- package/dist/sui/index.d.ts +49 -19
- package/dist/sui/index.d.ts.map +1 -1
- package/dist/sui/index.js +76 -43
- package/dist/sui/index.js.map +1 -1
- package/dist/sui/manuallyExec/encoder.d.ts +2 -2
- package/dist/sui/manuallyExec/encoder.d.ts.map +1 -1
- package/dist/sui/manuallyExec/encoder.js.map +1 -1
- package/dist/sui/manuallyExec/index.d.ts +2 -2
- package/dist/sui/manuallyExec/index.d.ts.map +1 -1
- package/dist/ton/exec.d.ts +2 -2
- package/dist/ton/exec.d.ts.map +1 -1
- package/dist/ton/exec.js.map +1 -1
- package/dist/ton/index.d.ts +66 -27
- package/dist/ton/index.d.ts.map +1 -1
- package/dist/ton/index.js +172 -47
- package/dist/ton/index.js.map +1 -1
- package/dist/ton/send.d.ts +52 -0
- package/dist/ton/send.d.ts.map +1 -0
- package/dist/ton/send.js +166 -0
- package/dist/ton/send.js.map +1 -0
- package/dist/ton/types.d.ts +2 -2
- package/dist/ton/types.d.ts.map +1 -1
- package/dist/ton/types.js.map +1 -1
- package/dist/types.d.ts +148 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +79 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +92 -7
- package/dist/utils.js.map +1 -1
- package/package.json +16 -11
- package/src/all-chains.ts +26 -0
- package/src/api/index.ts +58 -34
- package/src/api/types.ts +24 -31
- package/src/aptos/exec.ts +2 -2
- package/src/aptos/hasher.ts +1 -1
- package/src/aptos/index.ts +127 -129
- package/src/aptos/types.ts +2 -15
- package/src/chain.ts +837 -191
- package/src/commits.ts +9 -9
- package/src/errors/CCIPError.ts +33 -4
- package/src/errors/codes.ts +5 -1
- package/src/errors/index.ts +2 -1
- package/src/errors/recovery.ts +9 -1
- package/src/errors/specialized.ts +1745 -132
- package/src/errors/utils.ts +0 -1
- package/src/evm/abi/OffRamp_2_0.ts +743 -0
- package/src/evm/abi/OnRamp_2_0.ts +991 -0
- package/src/evm/const.ts +10 -3
- package/src/evm/errors.ts +6 -2
- package/src/evm/extra-args.ts +360 -0
- package/src/evm/gas.ts +14 -13
- package/src/evm/hasher.ts +30 -18
- package/src/evm/index.ts +376 -281
- package/src/evm/messages.ts +323 -11
- package/src/evm/offchain.ts +2 -2
- package/src/evm/types.ts +20 -2
- package/src/execution.ts +126 -71
- package/src/extra-args.ts +118 -4
- package/src/gas.ts +44 -11
- package/src/index.ts +14 -11
- package/src/requests.ts +128 -24
- package/src/selectors.ts +24 -0
- package/src/shared/bcs-codecs.ts +132 -0
- package/src/shared/constants.ts +2 -0
- package/src/solana/exec.ts +4 -4
- package/src/solana/index.ts +170 -82
- package/src/sui/hasher.ts +1 -1
- package/src/sui/index.ts +88 -56
- package/src/sui/manuallyExec/encoder.ts +2 -2
- package/src/sui/manuallyExec/index.ts +2 -2
- package/src/ton/exec.ts +2 -2
- package/src/ton/index.ts +220 -58
- package/src/ton/send.ts +222 -0
- package/src/ton/types.ts +2 -2
- package/src/types.ts +173 -30
- package/src/utils.ts +91 -7
- package/dist/aptos/utils.d.ts +0 -12
- package/dist/aptos/utils.d.ts.map +0 -1
- package/dist/aptos/utils.js +0 -15
- package/dist/aptos/utils.js.map +0 -1
- package/src/aptos/utils.ts +0 -24
package/dist/execution.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Chain } from './chain.ts';
|
|
2
|
-
import
|
|
2
|
+
import type { CCIPMessage, CCIPVersion, Lane, WithLogger } from './types.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Pure/sync function to calculate/generate OffRamp.executeManually report for messageIds
|
|
5
5
|
*
|
|
@@ -9,29 +9,69 @@ import { type CCIPCommit, type CCIPExecution, type CCIPMessage, type CCIPRequest
|
|
|
9
9
|
* @param merkleRoot - Optional merkleRoot of the CommitReport, for validation
|
|
10
10
|
* @param ctx - Context for logging
|
|
11
11
|
* @returns ManualExec report arguments
|
|
12
|
+
* @throws CCIPMessageNotInBatchError - When the messageId is not found in the provided batch
|
|
13
|
+
* @throws CCIPMerkleRootMismatchError - When calculated merkle root doesn't match the provided one
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* This is a pure/sync function that performs no I/O - all data must be pre-fetched.
|
|
17
|
+
* It builds a merkle tree from the messages, generates a proof for the target messageId,
|
|
18
|
+
* and optionally validates against the provided merkleRoot.
|
|
19
|
+
*
|
|
20
|
+
* The returned proof can be used with `execute` to manually execute a stuck message.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { calculateManualExecProof, EVMChain } from '@chainlink/ccip-sdk'
|
|
25
|
+
*
|
|
26
|
+
* // Fetch the request and all messages in its batch
|
|
27
|
+
* const request = (await source.getMessagesInTx(txHash))[0]
|
|
28
|
+
* const verifications = await dest.getVerifications({ offRamp, request })
|
|
29
|
+
* const messages = await source.getMessagesInBatch(request, commit.report)
|
|
30
|
+
*
|
|
31
|
+
* // Calculate proof for manual execution
|
|
32
|
+
* const proof = calculateManualExecProof(
|
|
33
|
+
* messages,
|
|
34
|
+
* request.lane,
|
|
35
|
+
* request.message.messageId,
|
|
36
|
+
* commit.report.merkleRoot
|
|
37
|
+
* )
|
|
38
|
+
* console.log('Merkle root:', proof.merkleRoot)
|
|
39
|
+
* console.log('Proofs:', proof.proofs)
|
|
40
|
+
* ```
|
|
41
|
+
* @see {@link discoverOffRamp} - Find the OffRamp for manual execution
|
|
42
|
+
* @see {@link execute} - Execute the report on destination chain
|
|
43
|
+
* @see {@link generateUnsignedExecute} - Build unsigned execution tx
|
|
12
44
|
**/
|
|
13
|
-
export declare function calculateManualExecProof<V extends CCIPVersion = CCIPVersion>(messagesInBatch: readonly CCIPMessage<V>[], lane: Lane<V>, messageId: string, merkleRoot?: string, ctx?: WithLogger):
|
|
45
|
+
export declare function calculateManualExecProof<V extends CCIPVersion = CCIPVersion>(messagesInBatch: readonly CCIPMessage<V>[], lane: Lane<V>, messageId: string, merkleRoot?: string, ctx?: WithLogger): {
|
|
46
|
+
proofs: string[];
|
|
47
|
+
proofFlagBits: bigint;
|
|
48
|
+
merkleRoot: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Discover the OffRamp address for a given OnRamp and destination chain.
|
|
52
|
+
* Results are memoized for performance.
|
|
53
|
+
*
|
|
54
|
+
* @param source - Source chain instance.
|
|
55
|
+
* @param dest - Destination chain instance.
|
|
56
|
+
* @param onRamp - OnRamp contract address on source chain.
|
|
57
|
+
* @param ctx - Optional context with logger.
|
|
58
|
+
* @returns OffRamp address on destination chain.
|
|
59
|
+
* @throws CCIPOffRampNotFoundError - When no matching OffRamp is found for the OnRamp
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* import { discoverOffRamp, EVMChain } from '@chainlink/ccip-sdk'
|
|
63
|
+
*
|
|
64
|
+
* const source = await EVMChain.fromUrl('https://rpc.sepolia.org')
|
|
65
|
+
* const dest = await EVMChain.fromUrl('https://rpc.fuji.avax.network')
|
|
66
|
+
*
|
|
67
|
+
* const offRamp = await discoverOffRamp(source, dest, onRampAddress)
|
|
68
|
+
* console.log('OffRamp on destination:', offRamp)
|
|
69
|
+
* ```
|
|
70
|
+
* @see {@link calculateManualExecProof} - Use with OffRamp for manual execution
|
|
71
|
+
* @see {@link execute} - Execute on destination chain
|
|
72
|
+
* @see {@link getExecutionReceipts} - Check execution status
|
|
73
|
+
*/
|
|
14
74
|
export declare const discoverOffRamp: import("micro-memoize").Memoized<(source: Chain, dest: Chain, onRamp: string, { logger }?: WithLogger) => Promise<string>, {
|
|
15
75
|
transformKey: ([source, dest, onRamp]: [source: Chain<import("./types.ts").ChainFamily>, dest: Chain<import("./types.ts").ChainFamily>, onRamp: string, (WithLogger | undefined)?]) => [bigint, bigint, string];
|
|
16
76
|
}>;
|
|
17
|
-
/**
|
|
18
|
-
* Generic implementation for fetching ExecutionReceipts for given requests.
|
|
19
|
-
* If more than one request is given, may yield them interleaved.
|
|
20
|
-
* Completes as soon as there's no more work to be done.
|
|
21
|
-
*
|
|
22
|
-
* Two possible behaviors:
|
|
23
|
-
* - if `startBlock|startTime` is given, pages forward from that block up;
|
|
24
|
-
* completes when success (final) receipt is found for all requests (or reach latest block)
|
|
25
|
-
* - otherwise, pages backwards and returns only the most recent receipt per request;
|
|
26
|
-
* completes when receipts for all requests were seen
|
|
27
|
-
*
|
|
28
|
-
* @param dest - Provider to page through.
|
|
29
|
-
* @param offRamp - OffRamp contract address.
|
|
30
|
-
* @param request - CCIP request to search executions for.
|
|
31
|
-
* @param commit - Optional commit info to narrow down search.
|
|
32
|
-
* @param hints - Optional hints (e.g., `page` for getLogs pagination range).
|
|
33
|
-
*/
|
|
34
|
-
export declare function getExecutionReceipts(dest: Chain, offRamp: string, request: CCIPRequest, commit?: CCIPCommit, hints?: {
|
|
35
|
-
page?: number;
|
|
36
|
-
}): AsyncGenerator<CCIPExecution>;
|
|
37
77
|
//# sourceMappingURL=execution.d.ts.map
|
package/dist/execution.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../src/execution.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../src/execution.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAOvC,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAyCI;AACJ,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAC1E,eAAe,EAAE,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,EAC1C,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EACb,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,MAAM,EACnB,GAAG,CAAC,EAAE,UAAU;;;;EA4BjB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,eAAe,4CAEhB,KAAK,QACP,KAAK,UACH,MAAM,eACQ,UAAU,KAC/B,OAAO,CAAC,MAAM,CAAC;;EAsFnB,CAAA"}
|
package/dist/execution.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { memoize } from 'micro-memoize';
|
|
2
2
|
import { CCIPMerkleRootMismatchError, CCIPMessageNotInBatchError, CCIPOffRampNotFoundError, } from "./errors/index.js";
|
|
3
3
|
import { Tree, getLeafHasher, proofFlagsToBits } from "./hasher/index.js";
|
|
4
|
-
import { ExecutionState, } from "./types.js";
|
|
5
4
|
/**
|
|
6
5
|
* Pure/sync function to calculate/generate OffRamp.executeManually report for messageIds
|
|
7
6
|
*
|
|
@@ -11,6 +10,38 @@ import { ExecutionState, } from "./types.js";
|
|
|
11
10
|
* @param merkleRoot - Optional merkleRoot of the CommitReport, for validation
|
|
12
11
|
* @param ctx - Context for logging
|
|
13
12
|
* @returns ManualExec report arguments
|
|
13
|
+
* @throws CCIPMessageNotInBatchError - When the messageId is not found in the provided batch
|
|
14
|
+
* @throws CCIPMerkleRootMismatchError - When calculated merkle root doesn't match the provided one
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* This is a pure/sync function that performs no I/O - all data must be pre-fetched.
|
|
18
|
+
* It builds a merkle tree from the messages, generates a proof for the target messageId,
|
|
19
|
+
* and optionally validates against the provided merkleRoot.
|
|
20
|
+
*
|
|
21
|
+
* The returned proof can be used with `execute` to manually execute a stuck message.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { calculateManualExecProof, EVMChain } from '@chainlink/ccip-sdk'
|
|
26
|
+
*
|
|
27
|
+
* // Fetch the request and all messages in its batch
|
|
28
|
+
* const request = (await source.getMessagesInTx(txHash))[0]
|
|
29
|
+
* const verifications = await dest.getVerifications({ offRamp, request })
|
|
30
|
+
* const messages = await source.getMessagesInBatch(request, commit.report)
|
|
31
|
+
*
|
|
32
|
+
* // Calculate proof for manual execution
|
|
33
|
+
* const proof = calculateManualExecProof(
|
|
34
|
+
* messages,
|
|
35
|
+
* request.lane,
|
|
36
|
+
* request.message.messageId,
|
|
37
|
+
* commit.report.merkleRoot
|
|
38
|
+
* )
|
|
39
|
+
* console.log('Merkle root:', proof.merkleRoot)
|
|
40
|
+
* console.log('Proofs:', proof.proofs)
|
|
41
|
+
* ```
|
|
42
|
+
* @see {@link discoverOffRamp} - Find the OffRamp for manual execution
|
|
43
|
+
* @see {@link execute} - Execute the report on destination chain
|
|
44
|
+
* @see {@link generateUnsignedExecute} - Build unsigned execution tx
|
|
14
45
|
**/
|
|
15
46
|
export function calculateManualExecProof(messagesInBatch, lane, messageId, merkleRoot, ctx) {
|
|
16
47
|
const hasher = getLeafHasher(lane, ctx);
|
|
@@ -35,25 +66,80 @@ export function calculateManualExecProof(messagesInBatch, lane, messageId, merkl
|
|
|
35
66
|
merkleRoot: tree.root(),
|
|
36
67
|
};
|
|
37
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Discover the OffRamp address for a given OnRamp and destination chain.
|
|
71
|
+
* Results are memoized for performance.
|
|
72
|
+
*
|
|
73
|
+
* @param source - Source chain instance.
|
|
74
|
+
* @param dest - Destination chain instance.
|
|
75
|
+
* @param onRamp - OnRamp contract address on source chain.
|
|
76
|
+
* @param ctx - Optional context with logger.
|
|
77
|
+
* @returns OffRamp address on destination chain.
|
|
78
|
+
* @throws CCIPOffRampNotFoundError - When no matching OffRamp is found for the OnRamp
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* import { discoverOffRamp, EVMChain } from '@chainlink/ccip-sdk'
|
|
82
|
+
*
|
|
83
|
+
* const source = await EVMChain.fromUrl('https://rpc.sepolia.org')
|
|
84
|
+
* const dest = await EVMChain.fromUrl('https://rpc.fuji.avax.network')
|
|
85
|
+
*
|
|
86
|
+
* const offRamp = await discoverOffRamp(source, dest, onRampAddress)
|
|
87
|
+
* console.log('OffRamp on destination:', offRamp)
|
|
88
|
+
* ```
|
|
89
|
+
* @see {@link calculateManualExecProof} - Use with OffRamp for manual execution
|
|
90
|
+
* @see {@link execute} - Execute on destination chain
|
|
91
|
+
* @see {@link getExecutionReceipts} - Check execution status
|
|
92
|
+
*/
|
|
38
93
|
export const discoverOffRamp = memoize(async function discoverOffRamp_(source, dest, onRamp, { logger = console } = {}) {
|
|
39
94
|
const sourceRouter = await source.getRouterForOnRamp(onRamp, dest.network.chainSelector);
|
|
40
95
|
const sourceOffRamps = await source.getOffRampsForRouter(sourceRouter, dest.network.chainSelector);
|
|
41
96
|
for (const offRamp of sourceOffRamps) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
logger.debug('discoverOffRamp:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
97
|
+
let destOnRamps;
|
|
98
|
+
try {
|
|
99
|
+
destOnRamps = await source.getOnRampsForOffRamp(offRamp, dest.network.chainSelector);
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
logger.debug('discoverOffRamp: skipping offRamp', offRamp, '(no valid source chain config)', err);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
for (const destOnRamp of destOnRamps) {
|
|
106
|
+
const destRouter = await dest.getRouterForOnRamp(destOnRamp, source.network.chainSelector);
|
|
107
|
+
const destOffRamps = await dest.getOffRampsForRouter(destRouter, source.network.chainSelector);
|
|
108
|
+
for (const offRamp of destOffRamps) {
|
|
109
|
+
let offRampsOnRamps;
|
|
110
|
+
try {
|
|
111
|
+
offRampsOnRamps = await dest.getOnRampsForOffRamp(offRamp, source.network.chainSelector);
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
logger.debug('discoverOffRamp: skipping dest offRamp', offRamp, '(no valid source chain config)', err);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
for (const offRampsOnRamp of offRampsOnRamps) {
|
|
118
|
+
logger.debug('discoverOffRamp: found, from', {
|
|
119
|
+
sourceOnRamp: onRamp,
|
|
120
|
+
sourceRouter,
|
|
121
|
+
sourceOffRamps,
|
|
122
|
+
destOnRamp,
|
|
123
|
+
destOffRamps,
|
|
124
|
+
offRampsOnRamp,
|
|
125
|
+
}, '=', offRamp);
|
|
126
|
+
for (const offRamp of destOffRamps) {
|
|
127
|
+
const offRampsOnRamps = await dest.getOnRampsForOffRamp(offRamp, source.network.chainSelector);
|
|
128
|
+
for (const offRampsOnRamp of offRampsOnRamps) {
|
|
129
|
+
logger.debug('discoverOffRamp: found, from', {
|
|
130
|
+
sourceOnRamp: onRamp,
|
|
131
|
+
sourceRouter,
|
|
132
|
+
sourceOffRamps,
|
|
133
|
+
destOnRamp,
|
|
134
|
+
destOffRamps,
|
|
135
|
+
offRampsOnRamps,
|
|
136
|
+
}, '=', offRamp);
|
|
137
|
+
if (offRampsOnRamp === onRamp) {
|
|
138
|
+
return offRamp;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
57
143
|
}
|
|
58
144
|
}
|
|
59
145
|
}
|
|
@@ -61,39 +147,4 @@ export const discoverOffRamp = memoize(async function discoverOffRamp_(source, d
|
|
|
61
147
|
}, {
|
|
62
148
|
transformKey: ([source, dest, onRamp]) => [source.network.chainSelector, dest.network.chainSelector, onRamp],
|
|
63
149
|
});
|
|
64
|
-
/**
|
|
65
|
-
* Generic implementation for fetching ExecutionReceipts for given requests.
|
|
66
|
-
* If more than one request is given, may yield them interleaved.
|
|
67
|
-
* Completes as soon as there's no more work to be done.
|
|
68
|
-
*
|
|
69
|
-
* Two possible behaviors:
|
|
70
|
-
* - if `startBlock|startTime` is given, pages forward from that block up;
|
|
71
|
-
* completes when success (final) receipt is found for all requests (or reach latest block)
|
|
72
|
-
* - otherwise, pages backwards and returns only the most recent receipt per request;
|
|
73
|
-
* completes when receipts for all requests were seen
|
|
74
|
-
*
|
|
75
|
-
* @param dest - Provider to page through.
|
|
76
|
-
* @param offRamp - OffRamp contract address.
|
|
77
|
-
* @param request - CCIP request to search executions for.
|
|
78
|
-
* @param commit - Optional commit info to narrow down search.
|
|
79
|
-
* @param hints - Optional hints (e.g., `page` for getLogs pagination range).
|
|
80
|
-
*/
|
|
81
|
-
export async function* getExecutionReceipts(dest, offRamp, request, commit, hints) {
|
|
82
|
-
const onlyLast = !commit?.log.blockNumber && !request.tx.timestamp; // backwards
|
|
83
|
-
for await (const log of dest.getLogs({
|
|
84
|
-
startBlock: commit?.log.blockNumber,
|
|
85
|
-
startTime: request.tx.timestamp,
|
|
86
|
-
address: offRamp,
|
|
87
|
-
topics: ['ExecutionStateChanged'],
|
|
88
|
-
...hints,
|
|
89
|
-
})) {
|
|
90
|
-
const receipt = dest.constructor.decodeReceipt(log);
|
|
91
|
-
if (!receipt || receipt.messageId !== request.message.messageId)
|
|
92
|
-
continue;
|
|
93
|
-
const timestamp = log.tx?.timestamp ?? (await dest.getBlockTimestamp(log.blockNumber));
|
|
94
|
-
yield { receipt, log, timestamp };
|
|
95
|
-
if (onlyLast || receipt.state === ExecutionState.Success)
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
150
|
//# sourceMappingURL=execution.js.map
|
package/dist/execution.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../src/execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../src/execution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MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,CACvC,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAU;CAC9E,CACF,CAAA"}
|
package/dist/extra-args.d.ts
CHANGED
|
@@ -4,12 +4,21 @@ import { ChainFamily } from './types.ts';
|
|
|
4
4
|
export declare const EVMExtraArgsV1Tag: "0x97a657c9";
|
|
5
5
|
/** Tag identifier for EVMExtraArgsV2 encoding. */
|
|
6
6
|
export declare const EVMExtraArgsV2Tag: "0x181dcf10";
|
|
7
|
+
/** Tag identifier for GenericExtraArgsV3 encoding (tightly packed binary format). */
|
|
8
|
+
export declare const GenericExtraArgsV3Tag: "0xa69dd4aa";
|
|
7
9
|
/** Tag identifier for SVMExtraArgsV1 encoding. */
|
|
8
10
|
export declare const SVMExtraArgsV1Tag: "0x1f3b3aba";
|
|
9
11
|
/** Tag identifier for SuiExtraArgsV1 encoding. */
|
|
10
12
|
export declare const SuiExtraArgsV1Tag: "0x21ea4ca9";
|
|
11
13
|
/**
|
|
12
14
|
* EVM extra arguments version 1 with gas limit only.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const args: EVMExtraArgsV1 = {
|
|
19
|
+
* gasLimit: 200_000n,
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
13
22
|
*/
|
|
14
23
|
export type EVMExtraArgsV1 = {
|
|
15
24
|
/** Gas limit for execution on the destination chain. */
|
|
@@ -18,13 +27,68 @@ export type EVMExtraArgsV1 = {
|
|
|
18
27
|
/**
|
|
19
28
|
* EVM extra arguments version 2 with out-of-order execution support.
|
|
20
29
|
* Also known as GenericExtraArgsV2.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const args: EVMExtraArgsV2 = {
|
|
34
|
+
* gasLimit: 200_000n,
|
|
35
|
+
* allowOutOfOrderExecution: true,
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
21
38
|
*/
|
|
22
39
|
export type EVMExtraArgsV2 = EVMExtraArgsV1 & {
|
|
23
40
|
/** Whether to allow out-of-order message execution. */
|
|
24
41
|
allowOutOfOrderExecution: boolean;
|
|
25
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Generic extra arguments version 3 with cross-chain verifiers and executor support.
|
|
45
|
+
* Uses tightly packed binary encoding (NOT ABI-encoded).
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const args: GenericExtraArgsV3 = {
|
|
50
|
+
* gasLimit: 200_000n,
|
|
51
|
+
* blockConfirmations: 5,
|
|
52
|
+
* ccvs: ['0x1234...'],
|
|
53
|
+
* ccvArgs: ['0x010203'],
|
|
54
|
+
* executor: '0x5678...',
|
|
55
|
+
* executorArgs: '0x',
|
|
56
|
+
* tokenReceiver: '0xReceiverAddress...',
|
|
57
|
+
* tokenArgs: '0x',
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export type GenericExtraArgsV3 = {
|
|
62
|
+
/** Gas limit for execution on the destination chain (uint32). */
|
|
63
|
+
gasLimit: bigint;
|
|
64
|
+
/** Number of block confirmations required. */
|
|
65
|
+
blockConfirmations: number;
|
|
66
|
+
/** Cross-chain verifier addresses (EVM addresses). */
|
|
67
|
+
ccvs: string[];
|
|
68
|
+
/** Per-CCV arguments (BytesLike). */
|
|
69
|
+
ccvArgs: BytesLike[];
|
|
70
|
+
/** Executor address (EVM address or empty string for none). */
|
|
71
|
+
executor: string;
|
|
72
|
+
/** Executor-specific arguments (BytesLike). */
|
|
73
|
+
executorArgs: BytesLike;
|
|
74
|
+
/** Token receiver address (checksummed EVM address or hex string). */
|
|
75
|
+
tokenReceiver: string;
|
|
76
|
+
/** Token pool-specific arguments (BytesLike). */
|
|
77
|
+
tokenArgs: BytesLike;
|
|
78
|
+
};
|
|
26
79
|
/**
|
|
27
80
|
* Solana (SVM) extra arguments version 1.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const args: SVMExtraArgsV1 = {
|
|
85
|
+
* computeUnits: 200_000n,
|
|
86
|
+
* accountIsWritableBitmap: 0n,
|
|
87
|
+
* allowOutOfOrderExecution: true,
|
|
88
|
+
* tokenReceiver: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA',
|
|
89
|
+
* accounts: [],
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
28
92
|
*/
|
|
29
93
|
export type SVMExtraArgsV1 = {
|
|
30
94
|
/** Compute units for Solana execution. */
|
|
@@ -40,6 +104,16 @@ export type SVMExtraArgsV1 = {
|
|
|
40
104
|
};
|
|
41
105
|
/**
|
|
42
106
|
* Sui extra arguments version 1.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const args: SuiExtraArgsV1 = {
|
|
111
|
+
* gasLimit: 200_000n,
|
|
112
|
+
* allowOutOfOrderExecution: true,
|
|
113
|
+
* tokenReceiver: '0x1234...abcd',
|
|
114
|
+
* receiverObjectIds: ['0xobject1...', '0xobject2...'],
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
43
117
|
*/
|
|
44
118
|
export type SuiExtraArgsV1 = EVMExtraArgsV2 & {
|
|
45
119
|
/** Token receiver address on Sui. */
|
|
@@ -50,23 +124,58 @@ export type SuiExtraArgsV1 = EVMExtraArgsV2 & {
|
|
|
50
124
|
/**
|
|
51
125
|
* Union type of all supported extra arguments formats.
|
|
52
126
|
*/
|
|
53
|
-
export type ExtraArgs = EVMExtraArgsV1 | EVMExtraArgsV2 | SVMExtraArgsV1 | SuiExtraArgsV1;
|
|
127
|
+
export type ExtraArgs = EVMExtraArgsV1 | EVMExtraArgsV2 | GenericExtraArgsV3 | SVMExtraArgsV1 | SuiExtraArgsV1;
|
|
54
128
|
/**
|
|
55
129
|
* Encodes extra arguments for CCIP messages.
|
|
56
|
-
* The args are *to* a dest network, but are encoded as a message *from* this source chain
|
|
57
|
-
*
|
|
58
|
-
|
|
130
|
+
* The args are *to* a dest network, but are encoded as a message *from* this source chain.
|
|
131
|
+
* E.g. Solana uses Borsh to encode extraArgs in its produced requests, even those targeting EVM.
|
|
132
|
+
*
|
|
133
|
+
* @param args - Extra arguments to encode
|
|
134
|
+
* @param from - Source chain family for encoding format (defaults to EVM)
|
|
135
|
+
* @returns Encoded extra arguments as hex string
|
|
136
|
+
* @throws {@link CCIPChainFamilyUnsupportedError} if chain family not supported
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* import { encodeExtraArgs } from '@chainlink/ccip-sdk'
|
|
141
|
+
*
|
|
142
|
+
* const encoded = encodeExtraArgs({
|
|
143
|
+
* gasLimit: 200_000n,
|
|
144
|
+
* allowOutOfOrderExecution: true,
|
|
145
|
+
* })
|
|
146
|
+
* console.log('Encoded:', encoded) // '0x181dcf10...'
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @see {@link decodeExtraArgs} - Decode extra arguments from bytes
|
|
150
|
+
*/
|
|
59
151
|
export declare function encodeExtraArgs(args: ExtraArgs, from?: ChainFamily): string;
|
|
60
152
|
/**
|
|
61
153
|
* Parses extra arguments from CCIP messages.
|
|
62
154
|
* @param data - Extra arguments bytearray data.
|
|
63
155
|
* @param from - Optional chain family to narrow decoding attempts.
|
|
64
156
|
* @returns Extra arguments object if found, undefined otherwise.
|
|
157
|
+
* @throws {@link CCIPChainFamilyUnsupportedError} if specified chain family not supported
|
|
158
|
+
* @throws {@link CCIPExtraArgsParseError} if data cannot be parsed as valid extra args
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```typescript
|
|
162
|
+
* import { decodeExtraArgs } from '@chainlink/ccip-sdk'
|
|
163
|
+
*
|
|
164
|
+
* const decoded = decodeExtraArgs('0x181dcf10...')
|
|
165
|
+
* if (decoded?._tag === 'EVMExtraArgsV2') {
|
|
166
|
+
* console.log('Gas limit:', decoded.gasLimit)
|
|
167
|
+
* console.log('Out of order:', decoded.allowOutOfOrderExecution)
|
|
168
|
+
* }
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @see {@link encodeExtraArgs} - Encode extra arguments to bytes
|
|
65
172
|
*/
|
|
66
173
|
export declare function decodeExtraArgs(data: BytesLike, from?: ChainFamily): (EVMExtraArgsV1 & {
|
|
67
174
|
_tag: 'EVMExtraArgsV1';
|
|
68
175
|
}) | (EVMExtraArgsV2 & {
|
|
69
176
|
_tag: 'EVMExtraArgsV2';
|
|
177
|
+
}) | (GenericExtraArgsV3 & {
|
|
178
|
+
_tag: 'GenericExtraArgsV3';
|
|
70
179
|
}) | (SVMExtraArgsV1 & {
|
|
71
180
|
_tag: 'SVMExtraArgsV1';
|
|
72
181
|
}) | (SuiExtraArgsV1 & {
|
package/dist/extra-args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extra-args.d.ts","sourceRoot":"","sources":["../src/extra-args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAM,MAAM,QAAQ,CAAA;AAI3C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,kDAAkD;AAClD,eAAO,MAAM,iBAAiB,EAAiD,YAAY,CAAA;AAC3F,kDAAkD;AAClD,eAAO,MAAM,iBAAiB,EAAiD,YAAY,CAAA;AAC3F,kDAAkD;AAClD,eAAO,MAAM,iBAAiB,EAAiD,YAAY,CAAA;AAC3F,kDAAkD;AAClD,eAAO,MAAM,iBAAiB,EAAiD,YAAY,CAAA;AAE3F
|
|
1
|
+
{"version":3,"file":"extra-args.d.ts","sourceRoot":"","sources":["../src/extra-args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAM,MAAM,QAAQ,CAAA;AAI3C,OAAO,EAAE,WAAW,EAAE,MAA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,MAAM,CAAA;IACrB,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG;IAC5C,qCAAqC;IACrC,aAAa,EAAE,MAAM,CAAA;IACrB,4CAA4C;IAC5C,iBAAiB,EAAE,MAAM,EAAE,CAAA;CAC5B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,cAAc,GACd,cAAc,GACd,kBAAkB,GAClB,cAAc,GACd,cAAc,CAAA;AAElB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,GAAE,WAA6B,GAAG,MAAM,CAI5F;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,SAAS,EACf,IAAI,CAAC,EAAE,WAAW,GAEhB,CAAC,cAAc,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,GAC7C,CAAC,cAAc,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,GAC7C,CAAC,kBAAkB,GAAG;IAAE,IAAI,EAAE,oBAAoB,CAAA;CAAE,CAAC,GACrD,CAAC,cAAc,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,GAC7C,CAAC,cAAc,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,GAC7C,SAAS,CAeZ"}
|
package/dist/extra-args.js
CHANGED
|
@@ -6,15 +6,35 @@ import { ChainFamily } from "./types.js";
|
|
|
6
6
|
export const EVMExtraArgsV1Tag = id('CCIP EVMExtraArgsV1').substring(0, 10);
|
|
7
7
|
/** Tag identifier for EVMExtraArgsV2 encoding. */
|
|
8
8
|
export const EVMExtraArgsV2Tag = id('CCIP EVMExtraArgsV2').substring(0, 10);
|
|
9
|
+
/** Tag identifier for GenericExtraArgsV3 encoding (tightly packed binary format). */
|
|
10
|
+
export const GenericExtraArgsV3Tag = id('CCIP GenericExtraArgsV3').substring(0, 10);
|
|
9
11
|
/** Tag identifier for SVMExtraArgsV1 encoding. */
|
|
10
12
|
export const SVMExtraArgsV1Tag = id('CCIP SVMExtraArgsV1').substring(0, 10);
|
|
11
13
|
/** Tag identifier for SuiExtraArgsV1 encoding. */
|
|
12
14
|
export const SuiExtraArgsV1Tag = id('CCIP SuiExtraArgsV1').substring(0, 10);
|
|
13
15
|
/**
|
|
14
16
|
* Encodes extra arguments for CCIP messages.
|
|
15
|
-
* The args are *to* a dest network, but are encoded as a message *from* this source chain
|
|
16
|
-
*
|
|
17
|
-
|
|
17
|
+
* The args are *to* a dest network, but are encoded as a message *from* this source chain.
|
|
18
|
+
* E.g. Solana uses Borsh to encode extraArgs in its produced requests, even those targeting EVM.
|
|
19
|
+
*
|
|
20
|
+
* @param args - Extra arguments to encode
|
|
21
|
+
* @param from - Source chain family for encoding format (defaults to EVM)
|
|
22
|
+
* @returns Encoded extra arguments as hex string
|
|
23
|
+
* @throws {@link CCIPChainFamilyUnsupportedError} if chain family not supported
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { encodeExtraArgs } from '@chainlink/ccip-sdk'
|
|
28
|
+
*
|
|
29
|
+
* const encoded = encodeExtraArgs({
|
|
30
|
+
* gasLimit: 200_000n,
|
|
31
|
+
* allowOutOfOrderExecution: true,
|
|
32
|
+
* })
|
|
33
|
+
* console.log('Encoded:', encoded) // '0x181dcf10...'
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @see {@link decodeExtraArgs} - Decode extra arguments from bytes
|
|
37
|
+
*/
|
|
18
38
|
export function encodeExtraArgs(args, from = ChainFamily.EVM) {
|
|
19
39
|
const chain = supportedChains[from];
|
|
20
40
|
if (!chain)
|
|
@@ -26,6 +46,21 @@ export function encodeExtraArgs(args, from = ChainFamily.EVM) {
|
|
|
26
46
|
* @param data - Extra arguments bytearray data.
|
|
27
47
|
* @param from - Optional chain family to narrow decoding attempts.
|
|
28
48
|
* @returns Extra arguments object if found, undefined otherwise.
|
|
49
|
+
* @throws {@link CCIPChainFamilyUnsupportedError} if specified chain family not supported
|
|
50
|
+
* @throws {@link CCIPExtraArgsParseError} if data cannot be parsed as valid extra args
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* import { decodeExtraArgs } from '@chainlink/ccip-sdk'
|
|
55
|
+
*
|
|
56
|
+
* const decoded = decodeExtraArgs('0x181dcf10...')
|
|
57
|
+
* if (decoded?._tag === 'EVMExtraArgsV2') {
|
|
58
|
+
* console.log('Gas limit:', decoded.gasLimit)
|
|
59
|
+
* console.log('Out of order:', decoded.allowOutOfOrderExecution)
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @see {@link encodeExtraArgs} - Encode extra arguments to bytes
|
|
29
64
|
*/
|
|
30
65
|
export function decodeExtraArgs(data, from) {
|
|
31
66
|
if (!data || data === '')
|
package/dist/extra-args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extra-args.js","sourceRoot":"","sources":["../src/extra-args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE3C,OAAO,EAAE,+BAA+B,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,kDAAkD;AAClD,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC,qBAAqB,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAiB,CAAA;AAC3F,kDAAkD;AAClD,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC,qBAAqB,CAAC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E,EAAE,CAAiB,CAAA;AAgI3F;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,eAAe,CAAC,IAAe,EAAE,OAAoB,WAAW,CAAC,GAAG;IAClF,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;IACnC,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,+BAA+B,CAAC,IAAI,CAAC,CAAA;IAC3D,OAAO,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;AACpC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAe,EACf,IAAkB;IAQlB,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,EAAE;QAAE,OAAM;IAChC,IAAI,MAAM,CAAA;IACV,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;QACnC,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,+BAA+B,CAAC,IAAI,CAAC,CAAA;QAC3D,MAAM,GAAG,CAAC,KAAK,CAAC,CAAA;IAClB,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAA;IACzC,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;QAC3C,IAAI,OAAO;YAAE,OAAO,OAAO,CAAA;IAC7B,CAAC;IACD,MAAM,IAAI,uBAAuB,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAA;AACzD,CAAC"}
|
package/dist/gas.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type BytesLike } from 'ethers';
|
|
2
2
|
import type { Chain } from './chain.ts';
|
|
3
3
|
/**
|
|
4
|
-
* A subset of
|
|
4
|
+
* A subset of {@link MessageInput} for estimating receive execution gas.
|
|
5
5
|
*/
|
|
6
6
|
export type EstimateMessageInput = {
|
|
7
7
|
/** receiver contract address */
|
|
@@ -10,7 +10,7 @@ export type EstimateMessageInput = {
|
|
|
10
10
|
messageId?: string;
|
|
11
11
|
/** optional sender: zero address will be used if omitted */
|
|
12
12
|
sender?: string;
|
|
13
|
-
/** optional data: zero bytes will be used if
|
|
13
|
+
/** optional data: zero bytes will be used if omitted */
|
|
14
14
|
data?: BytesLike;
|
|
15
15
|
/**
|
|
16
16
|
* optional tokenAmounts; `amount` with either source `token` (as in MessageInput) or
|
|
@@ -28,7 +28,7 @@ export type EstimateMessageInput = {
|
|
|
28
28
|
}))[];
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
|
-
* Options for
|
|
31
|
+
* Options for {@link estimateReceiveExecution} function.
|
|
32
32
|
*/
|
|
33
33
|
export type EstimateReceiveExecutionOpts = {
|
|
34
34
|
/** Source chain instance (for token data retrieval) */
|
|
@@ -42,8 +42,34 @@ export type EstimateReceiveExecutionOpts = {
|
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
44
|
* Estimate CCIP gasLimit needed to execute a request on a contract receiver.
|
|
45
|
-
*
|
|
46
|
-
* @
|
|
45
|
+
*
|
|
46
|
+
* @param opts - {@link EstimateReceiveExecutionOpts} for estimation
|
|
47
|
+
* @returns Estimated gasLimit
|
|
48
|
+
*
|
|
49
|
+
* @throws {@link CCIPMethodUnsupportedError} if dest chain doesn't support estimation
|
|
50
|
+
* @throws {@link CCIPContractTypeInvalidError} if routerOrRamp is not a valid contract type
|
|
51
|
+
* @throws {@link CCIPTokenDecimalsInsufficientError} if dest token has insufficient decimals
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* import { estimateReceiveExecution, EVMChain } from '@chainlink/ccip-sdk'
|
|
56
|
+
*
|
|
57
|
+
* const source = await EVMChain.fromUrl('https://rpc.sepolia.org')
|
|
58
|
+
* const dest = await EVMChain.fromUrl('https://rpc.fuji.avax.network')
|
|
59
|
+
*
|
|
60
|
+
* const gasLimit = await estimateReceiveExecution({
|
|
61
|
+
* source,
|
|
62
|
+
* dest,
|
|
63
|
+
* routerOrRamp: '0xRouter...',
|
|
64
|
+
* message: {
|
|
65
|
+
* sender: '0x...',
|
|
66
|
+
* receiver: '0x...',
|
|
67
|
+
* data: '0x...',
|
|
68
|
+
* tokenAmounts: [],
|
|
69
|
+
* },
|
|
70
|
+
* })
|
|
71
|
+
* console.log('Estimated gas:', gasLimit)
|
|
72
|
+
* ```
|
|
47
73
|
*/
|
|
48
74
|
export declare function estimateReceiveExecution({ source, dest, routerOrRamp, message, }: EstimateReceiveExecutionOpts): Promise<number>;
|
|
49
75
|
//# sourceMappingURL=gas.d.ts.map
|
package/dist/gas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gas.d.ts","sourceRoot":"","sources":["../src/gas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAqC,MAAM,QAAQ,CAAA;AAE1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"gas.d.ts","sourceRoot":"","sources":["../src/gas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAqC,MAAM,QAAQ,CAAA;AAE1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAUvC;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,wDAAwD;IACxD,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB;;;;OAIG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;QACvB,MAAM,EAAE,MAAM,CAAA;KACf,GAAG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