@chainlink/ccip-sdk 0.96.0 → 1.0.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 +12 -9
- package/dist/api/index.d.ts +21 -8
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +42 -13
- package/dist/api/index.js.map +1 -1
- package/dist/api/types.d.ts +0 -2
- 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 +17 -16
- package/dist/aptos/index.d.ts.map +1 -1
- package/dist/aptos/index.js +42 -73
- package/dist/aptos/index.js.map +1 -1
- package/dist/aptos/logs.d.ts +2 -2
- package/dist/aptos/logs.d.ts.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 +538 -158
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +132 -19
- 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 +3 -0
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/errors/codes.js +3 -1
- package/dist/errors/codes.js.map +1 -1
- package/dist/errors/index.d.ts +4 -4
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +4 -4
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/recovery.d.ts.map +1 -1
- package/dist/errors/recovery.js +4 -1
- package/dist/errors/recovery.js.map +1 -1
- package/dist/errors/specialized.d.ts +1695 -120
- package/dist/errors/specialized.d.ts.map +1 -1
- package/dist/errors/specialized.js +1715 -123
- 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.map +1 -1
- package/dist/evm/extra-args.js +5 -24
- package/dist/evm/extra-args.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 +73 -16
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +241 -146
- package/dist/evm/index.js.map +1 -1
- package/dist/evm/logs.d.ts +1 -1
- package/dist/evm/logs.js +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.d.ts +1 -14
- package/dist/evm/offchain.d.ts.map +1 -1
- package/dist/evm/offchain.js +1 -133
- 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 +98 -61
- package/dist/execution.js.map +1 -1
- package/dist/extra-args.d.ts +13 -3
- package/dist/extra-args.d.ts.map +1 -1
- package/dist/extra-args.js +13 -3
- package/dist/extra-args.js.map +1 -1
- package/dist/gas.d.ts +25 -2
- package/dist/gas.d.ts.map +1 -1
- package/dist/gas.js +30 -4
- package/dist/gas.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/offchain.d.ts +23 -6
- package/dist/offchain.d.ts.map +1 -1
- package/dist/offchain.js +92 -17
- package/dist/offchain.js.map +1 -1
- package/dist/requests.d.ts +85 -14
- package/dist/requests.d.ts.map +1 -1
- package/dist/requests.js +99 -17
- package/dist/requests.js.map +1 -1
- package/dist/selectors.d.ts.map +1 -1
- package/dist/selectors.js +12 -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/idl/1.6.0/BASE_TOKEN_POOL.d.ts +1 -1
- package/dist/solana/idl/1.6.0/BASE_TOKEN_POOL.js +1 -1
- package/dist/solana/idl/1.6.0/BURN_MINT_TOKEN_POOL.d.ts +1 -1
- package/dist/solana/idl/1.6.0/BURN_MINT_TOKEN_POOL.js +1 -1
- package/dist/solana/idl/1.6.0/CCIP_CCTP_TOKEN_POOL.d.ts +1 -1
- package/dist/solana/idl/1.6.0/CCIP_CCTP_TOKEN_POOL.js +1 -1
- package/dist/solana/idl/1.6.0/CCIP_COMMON.d.ts +16 -1
- package/dist/solana/idl/1.6.0/CCIP_COMMON.d.ts.map +1 -1
- package/dist/solana/idl/1.6.0/CCIP_COMMON.js +16 -1
- package/dist/solana/idl/1.6.0/CCIP_COMMON.js.map +1 -1
- package/dist/solana/idl/1.6.0/CCIP_OFFRAMP.d.ts +1 -1
- package/dist/solana/idl/1.6.0/CCIP_OFFRAMP.js +1 -1
- package/dist/solana/idl/1.6.0/CCIP_ROUTER.d.ts +1 -1
- package/dist/solana/idl/1.6.0/CCIP_ROUTER.js +1 -1
- package/dist/solana/index.d.ts +85 -24
- package/dist/solana/index.d.ts.map +1 -1
- package/dist/solana/index.js +69 -37
- package/dist/solana/index.js.map +1 -1
- package/dist/solana/offchain.d.ts +1 -13
- package/dist/solana/offchain.d.ts.map +1 -1
- package/dist/solana/offchain.js +1 -66
- package/dist/solana/offchain.js.map +1 -1
- package/dist/solana/utils.d.ts +4 -4
- package/dist/solana/utils.d.ts.map +1 -1
- package/dist/solana/utils.js +1 -1
- package/dist/solana/utils.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 +18 -18
- package/dist/sui/index.d.ts.map +1 -1
- package/dist/sui/index.js +38 -39
- 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 +3 -3
- package/dist/ton/exec.d.ts.map +1 -1
- package/dist/ton/exec.js +1 -1
- package/dist/ton/exec.js.map +1 -1
- package/dist/ton/index.d.ts +14 -22
- package/dist/ton/index.d.ts.map +1 -1
- package/dist/ton/index.js +26 -35
- package/dist/ton/index.js.map +1 -1
- package/dist/ton/types.d.ts +3 -5
- package/dist/ton/types.d.ts.map +1 -1
- package/dist/ton/types.js.map +1 -1
- package/dist/types.d.ts +55 -20
- 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 +65 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +74 -2
- package/dist/utils.js.map +1 -1
- package/package.json +14 -10
- package/src/api/index.ts +53 -17
- package/src/api/types.ts +0 -2
- package/src/aptos/exec.ts +2 -2
- package/src/aptos/hasher.ts +1 -1
- package/src/aptos/index.ts +55 -100
- package/src/aptos/logs.ts +2 -2
- package/src/aptos/types.ts +2 -15
- package/src/chain.ts +594 -171
- package/src/commits.ts +9 -9
- package/src/errors/CCIPError.ts +33 -4
- package/src/errors/codes.ts +3 -1
- package/src/errors/index.ts +4 -0
- package/src/errors/recovery.ts +7 -1
- package/src/errors/specialized.ts +1726 -130
- 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 +4 -21
- package/src/evm/hasher.ts +30 -18
- package/src/evm/index.ts +314 -176
- package/src/evm/logs.ts +1 -1
- package/src/evm/messages.ts +323 -11
- package/src/evm/offchain.ts +2 -191
- package/src/evm/types.ts +20 -2
- package/src/execution.ts +125 -86
- package/src/extra-args.ts +13 -3
- package/src/gas.ts +29 -3
- package/src/index.ts +10 -3
- package/src/offchain.ts +125 -28
- package/src/requests.ts +114 -19
- package/src/selectors.ts +12 -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/idl/1.6.0/BASE_TOKEN_POOL.ts +2 -2
- package/src/solana/idl/1.6.0/BURN_MINT_TOKEN_POOL.ts +2 -2
- package/src/solana/idl/1.6.0/CCIP_CCTP_TOKEN_POOL.ts +2 -2
- package/src/solana/idl/1.6.0/CCIP_COMMON.ts +32 -2
- package/src/solana/idl/1.6.0/CCIP_OFFRAMP.ts +2 -2
- package/src/solana/idl/1.6.0/CCIP_ROUTER.ts +2 -2
- package/src/solana/index.ts +110 -85
- package/src/solana/offchain.ts +3 -100
- package/src/solana/utils.ts +8 -5
- package/src/sui/hasher.ts +1 -1
- package/src/sui/index.ts +55 -59
- package/src/sui/manuallyExec/encoder.ts +2 -2
- package/src/sui/manuallyExec/index.ts +2 -2
- package/src/ton/exec.ts +4 -7
- package/src/ton/index.ts +45 -53
- package/src/ton/types.ts +4 -7
- package/src/types.ts +81 -37
- package/src/utils.ts +73 -2
- 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/evm/offchain.js
CHANGED
|
@@ -1,56 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getLbtcAttestation, getUsdcAttestation } from "../offchain.js";
|
|
3
|
-
import { networkInfo } from "../utils.js";
|
|
4
|
-
import { defaultAbiCoder, interfaces, requestsFragments } from "./const.js";
|
|
5
|
-
import { parseSourceTokenData } from "./messages.js";
|
|
6
|
-
const BURNED_EVENT_1_5 = interfaces.TokenPool_v1_5.getEvent('Burned');
|
|
7
|
-
const BURNED_EVENT_1_6 = interfaces.TokenPool_v1_6.getEvent('LockedOrBurned');
|
|
8
|
-
const BURNED_EVENT_TOPIC_HASHES = new Set([BURNED_EVENT_1_5.topicHash, BURNED_EVENT_1_6.topicHash]);
|
|
9
|
-
const USDC_EVENT = EventFragment.from('MessageSent(bytes message)');
|
|
10
|
-
const TRANSFER_EVENT = EventFragment.from('Transfer(address from, address to, uint256 value)');
|
|
11
|
-
export const LBTC_EVENT = EventFragment.from('DepositToBridge(address fromAddress, bytes32 toAddress, bytes32 payloadHash, bytes payload)');
|
|
12
|
-
export const LBTC_EVENT_V2 = EventFragment.from('DepositToBridge(address fromAddress, bytes32 toAddress, bytes32 payloadHash)');
|
|
13
|
-
const LBTC_EVENTS_HASHES = new Set([LBTC_EVENT.topicHash, LBTC_EVENT_V2.topicHash]);
|
|
14
|
-
/**
|
|
15
|
-
* Fetch offchain token data for all transfers in request
|
|
16
|
-
*
|
|
17
|
-
* @param request - Request (or subset of) to fetch offchainTokenData for
|
|
18
|
-
* @returns Array of byte arrays, one per transfer in request
|
|
19
|
-
*/
|
|
20
|
-
export async function fetchEVMOffchainTokenData(request, ctx) {
|
|
21
|
-
const { networkType } = networkInfo(request.message.sourceChainSelector);
|
|
22
|
-
// there's a chance there are other CCIPSendRequested in same tx,
|
|
23
|
-
// and they may contain USDC transfers as well, so we select
|
|
24
|
-
// any USDC logs after that and before our CCIPSendRequested
|
|
25
|
-
const prevCcipRequestIdx = request.tx.logs.find(({ topics, index }) => topics[0] in requestsFragments && index < request.log.index)?.index ?? -1;
|
|
26
|
-
const usdcRequestLogs = request.tx.logs.filter(({ index }) => prevCcipRequestIdx < index && index < request.log.index);
|
|
27
|
-
const offchainTokenData = request.message.tokenAmounts.map(() => undefined);
|
|
28
|
-
const usdcTokenData = await getUsdcTokenData(request.message.tokenAmounts, usdcRequestLogs, networkType, ctx);
|
|
29
|
-
let lbtcTokenData = [];
|
|
30
|
-
try {
|
|
31
|
-
let tokenAmounts;
|
|
32
|
-
if ('sourceTokenData' in request.message) {
|
|
33
|
-
tokenAmounts = request.message.sourceTokenData.map(parseSourceTokenData);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
tokenAmounts = request.message.tokenAmounts;
|
|
37
|
-
}
|
|
38
|
-
//for lbtc we distinguish logs by hash in event, so we can pass all of them
|
|
39
|
-
lbtcTokenData = await getLbtcTokenData(tokenAmounts, request.tx.logs, networkType, ctx);
|
|
40
|
-
}
|
|
41
|
-
catch (_) {
|
|
42
|
-
// pass
|
|
43
|
-
}
|
|
44
|
-
for (let i = 0; i < offchainTokenData.length; i++) {
|
|
45
|
-
if (usdcTokenData[i]) {
|
|
46
|
-
offchainTokenData[i] = usdcTokenData[i];
|
|
47
|
-
}
|
|
48
|
-
else if (lbtcTokenData[i]) {
|
|
49
|
-
offchainTokenData[i] = lbtcTokenData[i];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return offchainTokenData;
|
|
53
|
-
}
|
|
1
|
+
import { defaultAbiCoder } from "./const.js";
|
|
54
2
|
/**
|
|
55
3
|
* Encodes offchain token data for EVM execution.
|
|
56
4
|
* @param data - Offchain token data to encode.
|
|
@@ -65,84 +13,4 @@ export function encodeEVMOffchainTokenData(data) {
|
|
|
65
13
|
}
|
|
66
14
|
return '0x';
|
|
67
15
|
}
|
|
68
|
-
/**
|
|
69
|
-
* Try to fetch USDC attestations for transfers, return undefined in position if can't
|
|
70
|
-
*
|
|
71
|
-
* @param tokenAmounts - all tokenAmounts to try
|
|
72
|
-
* @param allLogsInRequest - all other logs in same tx as CCIPSendRequested
|
|
73
|
-
* @param networkType - network type (mainnet or testnet)
|
|
74
|
-
* @returns array where each position is either the attestation for that transfer or undefined
|
|
75
|
-
**/
|
|
76
|
-
async function getUsdcTokenData(tokenAmounts, allLogsInRequest, networkType, { logger = console } = {}) {
|
|
77
|
-
const attestations = [];
|
|
78
|
-
const messageSentPerTokenAndPool = allLogsInRequest.reduce((acc, log, i, arr) => {
|
|
79
|
-
// for our MessageSent of interest (USDC-like), the token is the contract
|
|
80
|
-
// which emitted a (burn) Transfer immediately before this event, and the pool emitted a Burned
|
|
81
|
-
// event 2 events after
|
|
82
|
-
const transferLog = arr[i - 1];
|
|
83
|
-
const poolLog = arr[i + 2];
|
|
84
|
-
if (log.topics[0] !== USDC_EVENT.topicHash ||
|
|
85
|
-
transferLog?.topics[0] !== TRANSFER_EVENT.topicHash ||
|
|
86
|
-
!poolLog?.topics.length ||
|
|
87
|
-
!BURNED_EVENT_TOPIC_HASHES.has(poolLog.topics[0])) {
|
|
88
|
-
return acc;
|
|
89
|
-
}
|
|
90
|
-
const token = transferLog.address;
|
|
91
|
-
const pool = poolLog.address;
|
|
92
|
-
acc.set(token, [...(acc.get(token) ?? []), log]);
|
|
93
|
-
acc.set(pool, [...(acc.get(pool) ?? []), log]);
|
|
94
|
-
return acc;
|
|
95
|
-
}, new Map());
|
|
96
|
-
for (const [i, tokenAmount] of tokenAmounts.entries()) {
|
|
97
|
-
const tokenOrPool = 'token' in tokenAmount ? tokenAmount.token : tokenAmount.sourcePoolAddress;
|
|
98
|
-
// what if there are more USDC transfers of this same token after this one?
|
|
99
|
-
const tokenTransfersCountAfter = tokenAmounts.filter((ta, j) => ('token' in ta ? ta.token : ta.sourcePoolAddress) === tokenOrPool && j > i).length;
|
|
100
|
-
let messageSentLog;
|
|
101
|
-
const messageSents = messageSentPerTokenAndPool.get(tokenOrPool);
|
|
102
|
-
if (messageSents) {
|
|
103
|
-
// look from the end (near our request), but skip MessageSents for further transfers
|
|
104
|
-
messageSentLog = messageSents[messageSents.length - 1 - tokenTransfersCountAfter];
|
|
105
|
-
}
|
|
106
|
-
let tokenData;
|
|
107
|
-
if (messageSentLog) {
|
|
108
|
-
let message;
|
|
109
|
-
try {
|
|
110
|
-
message = defaultAbiCoder.decode(USDC_EVENT.inputs, messageSentLog.data)[0];
|
|
111
|
-
const attestation = await getUsdcAttestation(message, networkType);
|
|
112
|
-
tokenData = {
|
|
113
|
-
_tag: 'usdc',
|
|
114
|
-
message,
|
|
115
|
-
attestation,
|
|
116
|
-
};
|
|
117
|
-
// encoding of OffchainTokenData to be done as part of Chain.executeReceipt
|
|
118
|
-
}
|
|
119
|
-
catch (err) {
|
|
120
|
-
// maybe not a USDC transfer, or not ready
|
|
121
|
-
logger.warn(`❌ EVM CCTP: Failed to fetch attestation for message:`, message, err);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
attestations.push(tokenData);
|
|
125
|
-
}
|
|
126
|
-
return attestations;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Try to fetch LBTC attestations for transfers, return undefined in position if can't or not required
|
|
130
|
-
**/
|
|
131
|
-
async function getLbtcTokenData(tokenAmounts, allLogsInRequest, networkType, { logger = console } = {}) {
|
|
132
|
-
const lbtcDepositHashes = new Set(allLogsInRequest
|
|
133
|
-
.filter(({ topics }) => LBTC_EVENTS_HASHES.has(topics[0]))
|
|
134
|
-
.map(({ topics }) => topics[3]));
|
|
135
|
-
return Promise.all(tokenAmounts.map(async ({ extraData }) => {
|
|
136
|
-
// Attestation is required when SourceTokenData.extraData is 32 bytes long ('0x' + 64 hex chars)
|
|
137
|
-
// otherwise attestation is not required
|
|
138
|
-
if (lbtcDepositHashes.has(extraData)) {
|
|
139
|
-
try {
|
|
140
|
-
return { _tag: 'lbtc', extraData, ...(await getLbtcAttestation(extraData, networkType)) };
|
|
141
|
-
}
|
|
142
|
-
catch (err) {
|
|
143
|
-
logger.warn(`❌ EVM LBTC: Failed to fetch attestation for message:`, extraData, err);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}));
|
|
147
|
-
}
|
|
148
16
|
//# sourceMappingURL=offchain.js.map
|
package/dist/evm/offchain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"offchain.js","sourceRoot":"","sources":["../../src/evm/offchain.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"offchain.js","sourceRoot":"","sources":["../../src/evm/offchain.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,IAAuB;IAChE,IAAI,IAAI,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;QAC1B,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,yCAAyC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IACpF,CAAC;SAAM,IAAI,IAAI,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,WAAqB,CAAA;IACnC,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/dist/evm/types.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type TransactionRequest } from 'ethers';
|
|
2
2
|
import type { ChainFamily } from '../types.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Type representing a set of unsigned EVM transactions
|
|
5
5
|
*/
|
|
6
6
|
export type UnsignedEVMTx = {
|
|
7
7
|
family: typeof ChainFamily.EVM;
|
|
8
|
-
transactions: Pick<TransactionRequest, 'from' | 'to' | 'data'>[];
|
|
8
|
+
transactions: Pick<TransactionRequest, 'from' | 'to' | 'data' | 'gasLimit'>[];
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Convert a Result or Promise to an object
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare function resultToObject<T>(o: T): T;
|
|
10
15
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/evm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/evm/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/evm/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAU,MAAM,QAAQ,CAAA;AAExD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,OAAO,WAAW,CAAC,GAAG,CAAA;IAC9B,YAAY,EAAE,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,UAAU,CAAC,EAAE,CAAA;CAC9E,CAAA;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAYzC"}
|
package/dist/evm/types.js
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import { Result } from 'ethers';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a Result or Promise to an object
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export function resultToObject(o) {
|
|
7
|
+
if (o instanceof Promise)
|
|
8
|
+
return o.then(resultToObject);
|
|
9
|
+
if (!(o instanceof Result))
|
|
10
|
+
return o;
|
|
11
|
+
if (o.length === 0)
|
|
12
|
+
return o.toArray();
|
|
13
|
+
try {
|
|
14
|
+
const obj = o.toObject();
|
|
15
|
+
if (!Object.keys(obj).every((k) => /^_+\d*$/.test(k)))
|
|
16
|
+
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, resultToObject(v)]));
|
|
17
|
+
}
|
|
18
|
+
catch (_) {
|
|
19
|
+
// fallthrough
|
|
20
|
+
}
|
|
21
|
+
return o.toArray().map(resultToObject);
|
|
22
|
+
}
|
|
2
23
|
//# sourceMappingURL=types.js.map
|
package/dist/evm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/evm/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/evm/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,MAAM,EAAE,MAAM,QAAQ,CAAA;AAYxD;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAI,CAAI;IACpC,IAAI,CAAC,YAAY,OAAO;QAAE,OAAO,CAAC,CAAC,IAAI,CAAC,cAAc,CAAM,CAAA;IAC5D,IAAI,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC;QAAE,OAAO,CAAC,CAAA;IACpC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC,OAAO,EAAO,CAAA;IAC3C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAA;QACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACnD,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAM,CAAA;IAC/F,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,cAAc;IAChB,CAAC;IACD,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,cAAc,CAAM,CAAA;AAC7C,CAAC"}
|
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,39 +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
|
-
let
|
|
97
|
+
let destOnRamps;
|
|
43
98
|
try {
|
|
44
|
-
|
|
99
|
+
destOnRamps = await source.getOnRampsForOffRamp(offRamp, dest.network.chainSelector);
|
|
45
100
|
}
|
|
46
|
-
catch {
|
|
47
|
-
logger.debug('discoverOffRamp: skipping offRamp', offRamp, '(no valid source chain config)');
|
|
101
|
+
catch (err) {
|
|
102
|
+
logger.debug('discoverOffRamp: skipping offRamp', offRamp, '(no valid source chain config)', err);
|
|
48
103
|
continue;
|
|
49
104
|
}
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
+
}
|
|
71
143
|
}
|
|
72
144
|
}
|
|
73
145
|
}
|
|
@@ -75,39 +147,4 @@ export const discoverOffRamp = memoize(async function discoverOffRamp_(source, d
|
|
|
75
147
|
}, {
|
|
76
148
|
transformKey: ([source, dest, onRamp]) => [source.network.chainSelector, dest.network.chainSelector, onRamp],
|
|
77
149
|
});
|
|
78
|
-
/**
|
|
79
|
-
* Generic implementation for fetching ExecutionReceipts for given requests.
|
|
80
|
-
* If more than one request is given, may yield them interleaved.
|
|
81
|
-
* Completes as soon as there's no more work to be done.
|
|
82
|
-
*
|
|
83
|
-
* Two possible behaviors:
|
|
84
|
-
* - if `startBlock|startTime` is given, pages forward from that block up;
|
|
85
|
-
* completes when success (final) receipt is found for all requests (or reach latest block)
|
|
86
|
-
* - otherwise, pages backwards and returns only the most recent receipt per request;
|
|
87
|
-
* completes when receipts for all requests were seen
|
|
88
|
-
*
|
|
89
|
-
* @param dest - Provider to page through.
|
|
90
|
-
* @param offRamp - OffRamp contract address.
|
|
91
|
-
* @param request - CCIP request to search executions for.
|
|
92
|
-
* @param commit - Optional commit info to narrow down search.
|
|
93
|
-
* @param hints - Optional hints (e.g., `page` for getLogs pagination range).
|
|
94
|
-
*/
|
|
95
|
-
export async function* getExecutionReceipts(dest, offRamp, request, commit, hints) {
|
|
96
|
-
const onlyLast = !commit?.log.blockNumber && !request.tx.timestamp; // backwards
|
|
97
|
-
for await (const log of dest.getLogs({
|
|
98
|
-
startBlock: commit?.log.blockNumber,
|
|
99
|
-
startTime: request.tx.timestamp,
|
|
100
|
-
address: offRamp,
|
|
101
|
-
topics: ['ExecutionStateChanged'],
|
|
102
|
-
...hints,
|
|
103
|
-
})) {
|
|
104
|
-
const receipt = dest.constructor.decodeReceipt(log);
|
|
105
|
-
if (!receipt || receipt.messageId !== request.message.messageId)
|
|
106
|
-
continue;
|
|
107
|
-
const timestamp = log.tx?.timestamp ?? (await dest.getBlockTimestamp(log.blockNumber));
|
|
108
|
-
yield { receipt, log, timestamp };
|
|
109
|
-
if (onlyLast || receipt.state === ExecutionState.Success)
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
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,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H,CAAC;IACH,CAAC;IACD,MAAM,IAAI,wBAAwB,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AAC/D,CAAC,EACD;IACE,YAAY,EAAE,CAAC,CAAC,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
|
@@ -5,7 +5,7 @@ export declare const EVMExtraArgsV1Tag: "0x97a657c9";
|
|
|
5
5
|
/** Tag identifier for EVMExtraArgsV2 encoding. */
|
|
6
6
|
export declare const EVMExtraArgsV2Tag: "0x181dcf10";
|
|
7
7
|
/** Tag identifier for GenericExtraArgsV3 encoding (tightly packed binary format). */
|
|
8
|
-
export declare const GenericExtraArgsV3Tag: "
|
|
8
|
+
export declare const GenericExtraArgsV3Tag: "0xa69dd4aa";
|
|
9
9
|
/** Tag identifier for SVMExtraArgsV1 encoding. */
|
|
10
10
|
export declare const SVMExtraArgsV1Tag: "0x1f3b3aba";
|
|
11
11
|
/** Tag identifier for SuiExtraArgsV1 encoding. */
|
|
@@ -129,6 +129,7 @@ export type ExtraArgs = EVMExtraArgsV1 | EVMExtraArgsV2 | GenericExtraArgsV3 | S
|
|
|
129
129
|
* Encodes extra arguments for CCIP messages.
|
|
130
130
|
* The args are *to* a dest network, but are encoded as a message *from* this source chain.
|
|
131
131
|
* E.g. Solana uses Borsh to encode extraArgs in its produced requests, even those targeting EVM.
|
|
132
|
+
*
|
|
132
133
|
* @param args - Extra arguments to encode
|
|
133
134
|
* @param from - Source chain family for encoding format (defaults to EVM)
|
|
134
135
|
* @returns Encoded extra arguments as hex string
|
|
@@ -136,12 +137,16 @@ export type ExtraArgs = EVMExtraArgsV1 | EVMExtraArgsV2 | GenericExtraArgsV3 | S
|
|
|
136
137
|
*
|
|
137
138
|
* @example
|
|
138
139
|
* ```typescript
|
|
140
|
+
* import { encodeExtraArgs } from '@chainlink/ccip-sdk'
|
|
141
|
+
*
|
|
139
142
|
* const encoded = encodeExtraArgs({
|
|
140
143
|
* gasLimit: 200_000n,
|
|
141
144
|
* allowOutOfOrderExecution: true,
|
|
142
145
|
* })
|
|
143
|
-
* //
|
|
146
|
+
* console.log('Encoded:', encoded) // '0x181dcf10...'
|
|
144
147
|
* ```
|
|
148
|
+
*
|
|
149
|
+
* @see {@link decodeExtraArgs} - Decode extra arguments from bytes
|
|
145
150
|
*/
|
|
146
151
|
export declare function encodeExtraArgs(args: ExtraArgs, from?: ChainFamily): string;
|
|
147
152
|
/**
|
|
@@ -154,11 +159,16 @@ export declare function encodeExtraArgs(args: ExtraArgs, from?: ChainFamily): st
|
|
|
154
159
|
*
|
|
155
160
|
* @example
|
|
156
161
|
* ```typescript
|
|
162
|
+
* import { decodeExtraArgs } from '@chainlink/ccip-sdk'
|
|
163
|
+
*
|
|
157
164
|
* const decoded = decodeExtraArgs('0x181dcf10...')
|
|
158
165
|
* if (decoded?._tag === 'EVMExtraArgsV2') {
|
|
159
|
-
* console.log(
|
|
166
|
+
* console.log('Gas limit:', decoded.gasLimit)
|
|
167
|
+
* console.log('Out of order:', decoded.allowOutOfOrderExecution)
|
|
160
168
|
* }
|
|
161
169
|
* ```
|
|
170
|
+
*
|
|
171
|
+
* @see {@link encodeExtraArgs} - Encode extra arguments to bytes
|
|
162
172
|
*/
|
|
163
173
|
export declare function decodeExtraArgs(data: BytesLike, from?: ChainFamily): (EVMExtraArgsV1 & {
|
|
164
174
|
_tag: 'EVMExtraArgsV1';
|
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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