@chainlink/ccip-sdk 0.95.0 → 0.96.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 +15 -12
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +20 -16
- package/dist/api/index.js.map +1 -1
- package/dist/api/types.d.ts +25 -29
- package/dist/api/types.d.ts.map +1 -1
- package/dist/aptos/index.d.ts +33 -8
- package/dist/aptos/index.d.ts.map +1 -1
- package/dist/aptos/index.js +74 -41
- package/dist/aptos/index.js.map +1 -1
- package/dist/chain.d.ts +220 -41
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +105 -15
- package/dist/chain.js.map +1 -1
- package/dist/errors/codes.d.ts +2 -0
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/errors/codes.js +2 -0
- package/dist/errors/codes.js.map +1 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/recovery.d.ts.map +1 -1
- package/dist/errors/recovery.js +2 -0
- package/dist/errors/recovery.js.map +1 -1
- package/dist/errors/specialized.d.ts +12 -6
- package/dist/errors/specialized.d.ts.map +1 -1
- package/dist/errors/specialized.js +19 -7
- package/dist/errors/specialized.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 +328 -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/index.d.ts +70 -24
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +72 -91
- package/dist/evm/index.js.map +1 -1
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +16 -2
- package/dist/execution.js.map +1 -1
- package/dist/extra-args.d.ts +103 -4
- package/dist/extra-args.d.ts.map +1 -1
- package/dist/extra-args.js +28 -3
- package/dist/extra-args.js.map +1 -1
- package/dist/gas.d.ts +6 -3
- package/dist/gas.d.ts.map +1 -1
- package/dist/gas.js +14 -6
- package/dist/gas.js.map +1 -1
- package/dist/index.d.ts +10 -9
- 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 +17 -9
- package/dist/requests.d.ts.map +1 -1
- package/dist/requests.js +17 -9
- 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/solana/index.d.ts +70 -15
- package/dist/solana/index.d.ts.map +1 -1
- package/dist/solana/index.js +72 -16
- package/dist/solana/index.js.map +1 -1
- package/dist/sui/index.d.ts +37 -9
- package/dist/sui/index.d.ts.map +1 -1
- package/dist/sui/index.js +40 -11
- package/dist/sui/index.js.map +1 -1
- package/dist/ton/index.d.ts +65 -19
- package/dist/ton/index.d.ts.map +1 -1
- package/dist/ton/index.js +155 -25
- 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/types.d.ts +102 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +15 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +19 -6
- package/dist/utils.js.map +1 -1
- package/package.json +12 -7
- package/src/all-chains.ts +26 -0
- package/src/api/index.ts +26 -25
- package/src/api/types.ts +25 -30
- package/src/aptos/index.ts +79 -43
- package/src/chain.ts +274 -46
- package/src/errors/codes.ts +2 -0
- package/src/errors/index.ts +1 -1
- package/src/errors/recovery.ts +2 -0
- package/src/errors/specialized.ts +24 -7
- package/src/evm/extra-args.ts +377 -0
- package/src/evm/gas.ts +14 -13
- package/src/evm/index.ts +76 -125
- package/src/execution.ts +18 -2
- package/src/extra-args.ts +108 -4
- package/src/gas.ts +16 -9
- package/src/index.ts +12 -9
- package/src/requests.ts +17 -9
- package/src/selectors.ts +12 -0
- package/src/solana/index.ts +72 -16
- package/src/sui/index.ts +40 -11
- package/src/ton/index.ts +192 -27
- package/src/ton/send.ts +222 -0
- package/src/types.ts +103 -1
- package/src/utils.ts +19 -6
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type Cell } from '@ton/core';
|
|
2
|
+
import { type TonClient, Address } from '@ton/ton';
|
|
3
|
+
import type { UnsignedTONTx } from './types.ts';
|
|
4
|
+
import type { AnyMessage, WithLogger } from '../types.ts';
|
|
5
|
+
/** Opcode for Router ccipSend operation */
|
|
6
|
+
export declare const CCIP_SEND_OPCODE = 829853077;
|
|
7
|
+
/** Default gas buffer to add to fee for transaction execution */
|
|
8
|
+
export declare const DEFAULT_GAS_BUFFER: bigint;
|
|
9
|
+
/** Default gas limit for destination chain execution */
|
|
10
|
+
export declare const DEFAULT_GAS_LIMIT = 200000n;
|
|
11
|
+
/**
|
|
12
|
+
* WRAPPED_NATIVE address for TON - sentinel address representing native TON.
|
|
13
|
+
* Used as feeToken for native TON payments in FeeQuoter calls.
|
|
14
|
+
*/
|
|
15
|
+
export declare const WRAPPED_NATIVE: Address;
|
|
16
|
+
/**
|
|
17
|
+
* Builds the Router ccipSend message cell.
|
|
18
|
+
*
|
|
19
|
+
* Relies on TL-B structure (Router_CCIPSend) from chainlink-ton repo.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildCcipSendCell(destChainSelector: bigint, message: AnyMessage, feeTokenAddress?: Address | null, queryId?: bigint): Cell;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the fee for sending a CCIP message by calling FeeQuoter.validatedFee.
|
|
24
|
+
*
|
|
25
|
+
* @param ctx - Context with TonClient provider and logger
|
|
26
|
+
* @param router - Router contract address
|
|
27
|
+
* @param destChainSelector - Destination chain selector
|
|
28
|
+
* @param message - CCIP message to quote
|
|
29
|
+
* @returns Fee amount in nanotons
|
|
30
|
+
*/
|
|
31
|
+
export declare function getFee(ctx: {
|
|
32
|
+
provider: TonClient;
|
|
33
|
+
} & WithLogger, router: string, destChainSelector: bigint, message: AnyMessage): Promise<bigint>;
|
|
34
|
+
/**
|
|
35
|
+
* Generates an unsigned CCIP send transaction for the Router.
|
|
36
|
+
*
|
|
37
|
+
* @param ctx - Context with TonClient provider and logger
|
|
38
|
+
* @param _sender - Sender address (unused, for interface compatibility)
|
|
39
|
+
* @param router - Router contract address
|
|
40
|
+
* @param destChainSelector - Destination chain selector
|
|
41
|
+
* @param message - CCIP message with fee included
|
|
42
|
+
* @param opts - Optional gas buffer override
|
|
43
|
+
* @returns Unsigned transaction ready for signing
|
|
44
|
+
*/
|
|
45
|
+
export declare function generateUnsignedCcipSend(ctx: {
|
|
46
|
+
provider: TonClient;
|
|
47
|
+
} & WithLogger, _sender: string, router: string, destChainSelector: bigint, message: AnyMessage & {
|
|
48
|
+
fee: bigint;
|
|
49
|
+
}, opts?: {
|
|
50
|
+
gasBuffer?: bigint;
|
|
51
|
+
}): Omit<UnsignedTONTx, 'family'>;
|
|
52
|
+
//# sourceMappingURL=send.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/ton/send.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAqB,MAAM,WAAW,CAAA;AACxD,OAAO,EAAE,KAAK,SAAS,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAG/C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGzD,2CAA2C;AAC3C,eAAO,MAAM,gBAAgB,YAAa,CAAA;AAE1C,iEAAiE;AACjE,eAAO,MAAM,kBAAkB,QAAgB,CAAA;AAE/C,wDAAwD;AACxD,eAAO,MAAM,iBAAiB,UAAW,CAAA;AAEzC;;;GAGG;AACH,eAAO,MAAM,cAAc,SAE1B,CAAA;AAoDD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,iBAAiB,EAAE,MAAM,EACzB,OAAO,EAAE,UAAU,EACnB,eAAe,GAAE,OAAO,GAAG,IAAW,EACtC,OAAO,SAAK,GACX,IAAI,CA0BN;AAED;;;;;;;;GAQG;AACH,wBAAsB,MAAM,CAC1B,GAAG,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,GAAG,UAAU,EACzC,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,MAAM,EACzB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,MAAM,CAAC,CAsDjB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,GAAG,UAAU,EACzC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,MAAM,EACzB,OAAO,EAAE,UAAU,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,EACrC,IAAI,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5B,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAkB/B"}
|
package/dist/ton/send.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { beginCell, toNano } from '@ton/core';
|
|
2
|
+
import { Address } from '@ton/ton';
|
|
3
|
+
import { zeroPadValue } from 'ethers';
|
|
4
|
+
import { CCIPError, CCIPErrorCode } from "../errors/index.js";
|
|
5
|
+
import { EVMExtraArgsV2Tag } from "../extra-args.js";
|
|
6
|
+
import { bytesToBuffer, getDataBytes } from "../utils.js";
|
|
7
|
+
/** Opcode for Router ccipSend operation */
|
|
8
|
+
export const CCIP_SEND_OPCODE = 0x31768d95;
|
|
9
|
+
/** Default gas buffer to add to fee for transaction execution */
|
|
10
|
+
export const DEFAULT_GAS_BUFFER = toNano('0.5');
|
|
11
|
+
/** Default gas limit for destination chain execution */
|
|
12
|
+
export const DEFAULT_GAS_LIMIT = 200000n;
|
|
13
|
+
/**
|
|
14
|
+
* WRAPPED_NATIVE address for TON - sentinel address representing native TON.
|
|
15
|
+
* Used as feeToken for native TON payments in FeeQuoter calls.
|
|
16
|
+
*/
|
|
17
|
+
export const WRAPPED_NATIVE = Address.parse('0:0000000000000000000000000000000000000000000000000000000000000001');
|
|
18
|
+
/**
|
|
19
|
+
* Encodes token amounts as a snaked cell.
|
|
20
|
+
* Empty cell for no tokens.
|
|
21
|
+
*/
|
|
22
|
+
function encodeTokenAmounts(tokenAmounts) {
|
|
23
|
+
if (!tokenAmounts || tokenAmounts.length === 0) {
|
|
24
|
+
return beginCell().endCell();
|
|
25
|
+
}
|
|
26
|
+
const builder = beginCell();
|
|
27
|
+
for (const ta of tokenAmounts) {
|
|
28
|
+
builder.storeRef(beginCell().storeAddress(Address.parse(ta.token)).storeUint(ta.amount, 256).endCell());
|
|
29
|
+
}
|
|
30
|
+
return builder.endCell();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Encodes extraArgs as a Cell using the GenericExtraArgsV2 (EVMExtraArgsV2) format.
|
|
34
|
+
*
|
|
35
|
+
* Format per chainlink-ton TL-B:
|
|
36
|
+
* - tag: 32-bit opcode (0x181dcf10)
|
|
37
|
+
* - gasLimit: Maybe<uint256> (1 bit flag + 256 bits if present)
|
|
38
|
+
* - allowOutOfOrderExecution: 1 bit (must be true)
|
|
39
|
+
*/
|
|
40
|
+
function encodeExtraArgsCell(extraArgs) {
|
|
41
|
+
const allowOutOfOrderExecution = true;
|
|
42
|
+
let gasLimit = 0n;
|
|
43
|
+
let hasGasLimit = false;
|
|
44
|
+
if ('gasLimit' in extraArgs && extraArgs.gasLimit > 0n) {
|
|
45
|
+
hasGasLimit = true;
|
|
46
|
+
gasLimit = extraArgs.gasLimit;
|
|
47
|
+
}
|
|
48
|
+
const builder = beginCell()
|
|
49
|
+
.storeUint(Number(EVMExtraArgsV2Tag), 32) // 0x181dcf10
|
|
50
|
+
.storeBit(hasGasLimit);
|
|
51
|
+
if (hasGasLimit) {
|
|
52
|
+
builder.storeUint(gasLimit, 256);
|
|
53
|
+
}
|
|
54
|
+
return builder.storeBit(allowOutOfOrderExecution).endCell();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Builds the Router ccipSend message cell.
|
|
58
|
+
*
|
|
59
|
+
* Relies on TL-B structure (Router_CCIPSend) from chainlink-ton repo.
|
|
60
|
+
*/
|
|
61
|
+
export function buildCcipSendCell(destChainSelector, message, feeTokenAddress = null, queryId = 0n) {
|
|
62
|
+
// Get receiver bytes and pad to 32 bytes for cross-chain encoding
|
|
63
|
+
const paddedReceiver = bytesToBuffer(zeroPadValue(getDataBytes(message.receiver), 32));
|
|
64
|
+
// Data cell (ref 0)
|
|
65
|
+
const dataCell = beginCell()
|
|
66
|
+
.storeBuffer(bytesToBuffer(message.data || '0x'))
|
|
67
|
+
.endCell();
|
|
68
|
+
// Token amounts snaked cell (ref 1)
|
|
69
|
+
const tokenAmountsCell = encodeTokenAmounts(message.tokenAmounts);
|
|
70
|
+
// ExtraArgs cell (ref 2)
|
|
71
|
+
const extraArgsCell = encodeExtraArgsCell(message.extraArgs);
|
|
72
|
+
return beginCell()
|
|
73
|
+
.storeUint(CCIP_SEND_OPCODE, 32) // opcode
|
|
74
|
+
.storeUint(Number(queryId), 64) // queryID
|
|
75
|
+
.storeUint(destChainSelector, 64) // destChainSelector
|
|
76
|
+
.storeUint(paddedReceiver.length, 8) // receiver length in bytes
|
|
77
|
+
.storeBuffer(paddedReceiver) // receiver bytes (32 bytes, left-padded)
|
|
78
|
+
.storeRef(dataCell) // ref 0: data
|
|
79
|
+
.storeRef(tokenAmountsCell) // ref 1: tokenAmounts
|
|
80
|
+
.storeAddress(feeTokenAddress) // null = addr_none for native TON
|
|
81
|
+
.storeRef(extraArgsCell) // ref 2: extraArgs
|
|
82
|
+
.endCell();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Gets the fee for sending a CCIP message by calling FeeQuoter.validatedFee.
|
|
86
|
+
*
|
|
87
|
+
* @param ctx - Context with TonClient provider and logger
|
|
88
|
+
* @param router - Router contract address
|
|
89
|
+
* @param destChainSelector - Destination chain selector
|
|
90
|
+
* @param message - CCIP message to quote
|
|
91
|
+
* @returns Fee amount in nanotons
|
|
92
|
+
*/
|
|
93
|
+
export async function getFee(ctx, router, destChainSelector, message) {
|
|
94
|
+
const { provider, logger = console } = ctx;
|
|
95
|
+
const routerAddress = Address.parse(router);
|
|
96
|
+
// FeeQuoter requires WRAPPED_NATIVE for native TON
|
|
97
|
+
const feeTokenAddress = message.feeToken ? Address.parse(message.feeToken) : WRAPPED_NATIVE;
|
|
98
|
+
// Get FeeQuoter address via OnRamp
|
|
99
|
+
let feeQuoterAddress;
|
|
100
|
+
try {
|
|
101
|
+
const { stack: onRampStack } = await provider.runMethod(routerAddress, 'onRamp', [
|
|
102
|
+
{ type: 'int', value: destChainSelector },
|
|
103
|
+
]);
|
|
104
|
+
const onRampAddress = onRampStack.readAddress();
|
|
105
|
+
logger.debug('OnRamp:', onRampAddress.toString());
|
|
106
|
+
const { stack: feeQuoterStack } = await provider.runMethod(onRampAddress, 'feeQuoter', [
|
|
107
|
+
{ type: 'int', value: destChainSelector },
|
|
108
|
+
]);
|
|
109
|
+
feeQuoterAddress = feeQuoterStack.readAddress();
|
|
110
|
+
logger.debug('FeeQuoter:', feeQuoterAddress.toString());
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
throw new CCIPError(CCIPErrorCode.CONTRACT_TYPE_INVALID, `Could not get FeeQuoter address: ${e instanceof Error ? e.message : String(e)}`);
|
|
114
|
+
}
|
|
115
|
+
// Build stack parameters for validatedFee call
|
|
116
|
+
const paddedReceiver = bytesToBuffer(zeroPadValue(getDataBytes(message.receiver), 32));
|
|
117
|
+
const receiverSlice = beginCell().storeBuffer(paddedReceiver).endCell();
|
|
118
|
+
const dataCell = beginCell()
|
|
119
|
+
.storeBuffer(bytesToBuffer(message.data || '0x'))
|
|
120
|
+
.endCell();
|
|
121
|
+
const tokenAmountsCell = encodeTokenAmounts(message.tokenAmounts);
|
|
122
|
+
const extraArgsCell = encodeExtraArgsCell(message.extraArgs);
|
|
123
|
+
const feeTokenSlice = beginCell().storeAddress(feeTokenAddress).endCell();
|
|
124
|
+
const { stack: feeStack } = await provider.runMethod(feeQuoterAddress, 'validatedFee', [
|
|
125
|
+
{ type: 'int', value: 0n },
|
|
126
|
+
{ type: 'int', value: destChainSelector },
|
|
127
|
+
{ type: 'slice', cell: receiverSlice },
|
|
128
|
+
{ type: 'cell', cell: dataCell },
|
|
129
|
+
{ type: 'cell', cell: tokenAmountsCell },
|
|
130
|
+
{ type: 'slice', cell: feeTokenSlice },
|
|
131
|
+
{ type: 'cell', cell: extraArgsCell },
|
|
132
|
+
]);
|
|
133
|
+
const fee = feeStack.readBigNumber();
|
|
134
|
+
if (fee < 0n) {
|
|
135
|
+
throw new CCIPError(CCIPErrorCode.MESSAGE_INVALID, `Invalid fee: ${fee}`);
|
|
136
|
+
}
|
|
137
|
+
logger.debug('CCIP fee:', fee.toString(), 'nanotons');
|
|
138
|
+
return fee;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Generates an unsigned CCIP send transaction for the Router.
|
|
142
|
+
*
|
|
143
|
+
* @param ctx - Context with TonClient provider and logger
|
|
144
|
+
* @param _sender - Sender address (unused, for interface compatibility)
|
|
145
|
+
* @param router - Router contract address
|
|
146
|
+
* @param destChainSelector - Destination chain selector
|
|
147
|
+
* @param message - CCIP message with fee included
|
|
148
|
+
* @param opts - Optional gas buffer override
|
|
149
|
+
* @returns Unsigned transaction ready for signing
|
|
150
|
+
*/
|
|
151
|
+
export function generateUnsignedCcipSend(ctx, _sender, router, destChainSelector, message, opts) {
|
|
152
|
+
const { logger = console } = ctx;
|
|
153
|
+
const gasBuffer = opts?.gasBuffer ?? DEFAULT_GAS_BUFFER;
|
|
154
|
+
// Router accepts addr_none for native TON (unlike FeeQuoter which needs WRAPPED_NATIVE)
|
|
155
|
+
const feeTokenAddress = message.feeToken ? Address.parse(message.feeToken) : null;
|
|
156
|
+
const ccipSendCell = buildCcipSendCell(destChainSelector, message, feeTokenAddress);
|
|
157
|
+
const totalValue = message.fee + gasBuffer;
|
|
158
|
+
logger.debug('Generating ccipSend tx to router:', router);
|
|
159
|
+
logger.debug('Total value:', totalValue.toString(), 'nanotons');
|
|
160
|
+
return {
|
|
161
|
+
to: router,
|
|
162
|
+
body: ccipSendCell,
|
|
163
|
+
value: totalValue,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=send.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.js","sourceRoot":"","sources":["../../src/ton/send.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACxD,OAAO,EAAkB,OAAO,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAGrC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEzD,2CAA2C;AAC3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAA;AAE1C,iEAAiE;AACjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;AAE/C,wDAAwD;AACxD,MAAM,CAAC,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
|
|
2
2
|
import type { BytesLike, Log } from 'ethers';
|
|
3
|
+
import type { APICCIPRequestMetadata } from './api/types.ts';
|
|
3
4
|
import type OffRamp_1_6_ABI from './evm/abi/OffRamp_1_6.ts';
|
|
4
5
|
import type { CCIPMessage_EVM, CCIPMessage_V1_6_EVM } from './evm/messages.ts';
|
|
5
6
|
import type { ExtraArgs } from './extra-args.ts';
|
|
@@ -77,6 +78,17 @@ type ChainFamilyWithId<F extends ChainFamily> = F extends typeof ChainFamily.EVM
|
|
|
77
78
|
} : never;
|
|
78
79
|
/**
|
|
79
80
|
* Network information including chain selector and metadata.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const info: NetworkInfo = {
|
|
85
|
+
* chainSelector: 16015286601757825753n,
|
|
86
|
+
* name: 'ethereum-testnet-sepolia',
|
|
87
|
+
* networkType: 'TESTNET',
|
|
88
|
+
* family: 'EVM',
|
|
89
|
+
* chainId: 11155111,
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
80
92
|
*/
|
|
81
93
|
export type NetworkInfo<F extends ChainFamily = ChainFamily> = {
|
|
82
94
|
/** Unique chain selector used by CCIP. */
|
|
@@ -88,6 +100,16 @@ export type NetworkInfo<F extends ChainFamily = ChainFamily> = {
|
|
|
88
100
|
} & ChainFamilyWithId<F>;
|
|
89
101
|
/**
|
|
90
102
|
* CCIP lane configuration connecting source and destination chains.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const lane: Lane = {
|
|
107
|
+
* sourceChainSelector: 16015286601757825753n, // Ethereum Sepolia
|
|
108
|
+
* destChainSelector: 12532609583862916517n, // Polygon Mumbai
|
|
109
|
+
* onRamp: '0x1234...abcd',
|
|
110
|
+
* version: '1.6.0',
|
|
111
|
+
* }
|
|
112
|
+
* ```
|
|
91
113
|
*/
|
|
92
114
|
export interface Lane<V extends CCIPVersion = CCIPVersion> {
|
|
93
115
|
/** Source chain selector. */
|
|
@@ -114,6 +136,17 @@ export type Log_ = Pick<Log, 'topics' | 'index' | 'address' | 'blockNumber' | 't
|
|
|
114
136
|
};
|
|
115
137
|
/**
|
|
116
138
|
* Generic transaction structure compatible across chain families.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* const tx: ChainTransaction = {
|
|
143
|
+
* hash: '0xabc123...',
|
|
144
|
+
* logs: [],
|
|
145
|
+
* blockNumber: 12345678,
|
|
146
|
+
* timestamp: 1704067200,
|
|
147
|
+
* from: '0x1234...abcd',
|
|
148
|
+
* }
|
|
149
|
+
* ```
|
|
117
150
|
*/
|
|
118
151
|
export type ChainTransaction = {
|
|
119
152
|
/** Transaction hash. */
|
|
@@ -141,6 +174,28 @@ export interface CCIPRequest<V extends CCIPVersion = CCIPVersion> {
|
|
|
141
174
|
log: Log_;
|
|
142
175
|
/** Transaction that emitted the request. */
|
|
143
176
|
tx: Pick<ChainTransaction, 'hash' | 'logs' | 'blockNumber' | 'timestamp' | 'from' | 'error'>;
|
|
177
|
+
/**
|
|
178
|
+
* API-enriched metadata. Present only when fetched via CCIP API.
|
|
179
|
+
*
|
|
180
|
+
* @remarks
|
|
181
|
+
* When a request is fetched using {@link Chain.getMessageById} or as a fallback
|
|
182
|
+
* in {@link Chain.getMessagesInTx}, this field contains additional information
|
|
183
|
+
* including message status, execution details, and network info.
|
|
184
|
+
*
|
|
185
|
+
* When constructed from on-chain data only, this field is `undefined`.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* const request = await chain.getMessageById(messageId)
|
|
190
|
+
* if (request.metadata) {
|
|
191
|
+
* console.log('Status:', request.metadata.status)
|
|
192
|
+
* console.log('Delivery time:', request.metadata.deliveryTime)
|
|
193
|
+
* }
|
|
194
|
+
* ```
|
|
195
|
+
*
|
|
196
|
+
* @see {@link APICCIPRequestMetadata}
|
|
197
|
+
*/
|
|
198
|
+
metadata?: APICCIPRequestMetadata;
|
|
144
199
|
}
|
|
145
200
|
/**
|
|
146
201
|
* Commit report structure from the OffRamp CommitReportAccepted event.
|
|
@@ -210,6 +265,16 @@ export declare const IntentStatus: {
|
|
|
210
265
|
export type IntentStatus = (typeof IntentStatus)[keyof typeof IntentStatus];
|
|
211
266
|
/**
|
|
212
267
|
* Receipt of a CCIP message execution on the destination chain.
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```typescript
|
|
271
|
+
* const receipt: ExecutionReceipt = {
|
|
272
|
+
* messageId: '0xabc123...',
|
|
273
|
+
* sequenceNumber: 42n,
|
|
274
|
+
* state: ExecutionState.Success,
|
|
275
|
+
* sourceChainSelector: 16015286601757825753n,
|
|
276
|
+
* }
|
|
277
|
+
* ```
|
|
213
278
|
*/
|
|
214
279
|
export type ExecutionReceipt = {
|
|
215
280
|
/** Unique message identifier. */
|
|
@@ -247,6 +312,17 @@ export type OffchainTokenData = {
|
|
|
247
312
|
} | undefined;
|
|
248
313
|
/**
|
|
249
314
|
* Execution report containing message, proofs, and offchain token data.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```typescript
|
|
318
|
+
* const report: ExecutionReport = {
|
|
319
|
+
* message: { messageId: '0x...', ... },
|
|
320
|
+
* proofs: ['0xproof1...', '0xproof2...'],
|
|
321
|
+
* proofFlagBits: 0n,
|
|
322
|
+
* merkleRoot: '0xroot...',
|
|
323
|
+
* offchainTokenData: [],
|
|
324
|
+
* }
|
|
325
|
+
* ```
|
|
250
326
|
*/
|
|
251
327
|
export type ExecutionReport<M extends CCIPMessage = CCIPMessage> = {
|
|
252
328
|
/** The CCIP message to execute. */
|
|
@@ -262,6 +338,16 @@ export type ExecutionReport<M extends CCIPMessage = CCIPMessage> = {
|
|
|
262
338
|
};
|
|
263
339
|
/**
|
|
264
340
|
* A message to be sent to another network.
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```typescript
|
|
344
|
+
* const message: AnyMessage = {
|
|
345
|
+
* receiver: '0x1234...abcd',
|
|
346
|
+
* extraArgs: { gasLimit: 200_000n, allowOutOfOrderExecution: true },
|
|
347
|
+
* data: '0xdeadbeef',
|
|
348
|
+
* tokenAmounts: [{ token: '0xtoken...', amount: 1000000n }],
|
|
349
|
+
* }
|
|
350
|
+
* ```
|
|
265
351
|
*/
|
|
266
352
|
export type AnyMessage = {
|
|
267
353
|
/** Receiver address on the destination chain. */
|
|
@@ -279,7 +365,22 @@ export type AnyMessage = {
|
|
|
279
365
|
feeToken?: string;
|
|
280
366
|
};
|
|
281
367
|
/**
|
|
282
|
-
* Partial
|
|
368
|
+
* Partial {@link AnyMessage}, which populates default fields like `extraArgs` if needed.
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```typescript
|
|
372
|
+
* // Minimal input - only receiver required, defaults applied for extraArgs
|
|
373
|
+
* const input: MessageInput = {
|
|
374
|
+
* receiver: '0x1234...abcd',
|
|
375
|
+
* }
|
|
376
|
+
*
|
|
377
|
+
* // With custom gas limit
|
|
378
|
+
* const inputWithGas: MessageInput = {
|
|
379
|
+
* receiver: '0x1234...abcd',
|
|
380
|
+
* extraArgs: { gasLimit: 500_000n },
|
|
381
|
+
* data: '0xdeadbeef',
|
|
382
|
+
* }
|
|
383
|
+
* ```
|
|
283
384
|
*/
|
|
284
385
|
export type MessageInput = Partial<AnyMessage> & {
|
|
285
386
|
receiver: AnyMessage['receiver'];
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAE5C,OAAO,KAAK,eAAe,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,oB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E,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,CAAA;AAEpF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI;IACjE,mCAAmC;IACnC,OAAO,EAAE,CAAC,CAAA;IACV,qCAAqC;IACrC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAA;IAC5B,wCAAwC;IACxC,aAAa,EAAE,MAAM,CAAA;IACrB,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAA;IAClB,mDAAmD;IACnD,iBAAiB,EAAE,SAAS,iBAAiB,EAAE,CAAA;CAChD,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,iDAAiD;IACjD,QAAQ,EAAE,SAAS,CAAA;IACnB,yDAAyD;IACzD,SAAS,EAAE,SAAS,CAAA;IACpB,8BAA8B;IAC9B,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,gCAAgC;IAChC,YAAY,CAAC,EAAE,SAAS;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC3D,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG;IAC/C,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,CAAA;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types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ist/utils.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ import { type NetworkInfo, type WithLogger, ChainFamily } from './types.ts';
|
|
|
10
10
|
* @param timestamp - target timestamp
|
|
11
11
|
* @param precision - returned blockNumber should be within this many blocks before timestamp
|
|
12
12
|
* @returns blockNumber of a block at provider which is close but before target timestamp
|
|
13
|
-
|
|
13
|
+
* @throws {@link CCIPBlockBeforeTimestampNotFoundError} if no block exists before the given timestamp
|
|
14
|
+
*/
|
|
14
15
|
export declare function getSomeBlockNumberBefore(getBlockTimestamp: (blockNumber: number) => Promise<number>, recentBlockNumber: number, timestamp: number, { precision, logger }?: {
|
|
15
16
|
precision?: number;
|
|
16
17
|
} & WithLogger): Promise<number>;
|
|
@@ -22,6 +23,7 @@ export declare function getSomeBlockNumberBefore(getBlockTimestamp: (blockNumber
|
|
|
22
23
|
* - Chain ID as number, bigint or string (EVM: "1", Aptos: "aptos:1", Solana: genesisHash)
|
|
23
24
|
* - Chain name as string ("ethereum-mainnet")
|
|
24
25
|
* @returns Complete NetworkInfo object
|
|
26
|
+
* @throws {@link CCIPChainNotFoundError} if chain is not found
|
|
25
27
|
*/
|
|
26
28
|
export declare const networkInfo: import("micro-memoize").Memoized<(selectorOrIdOrName: bigint | number | string) => NetworkInfo, {}>;
|
|
27
29
|
/**
|
|
@@ -68,11 +70,19 @@ export declare function bigIntReviver(_key: string, value: unknown): unknown;
|
|
|
68
70
|
export declare function parseJson<T = unknown>(text: string): T;
|
|
69
71
|
/**
|
|
70
72
|
* Decode address from a 32-byte hex string
|
|
71
|
-
|
|
73
|
+
* @param address - Address bytes to decode
|
|
74
|
+
* @param family - Chain family for address format (defaults to EVM)
|
|
75
|
+
* @returns Decoded address string
|
|
76
|
+
* @throws {@link CCIPChainFamilyUnsupportedError} if chain family is not supported
|
|
77
|
+
*/
|
|
72
78
|
export declare function decodeAddress(address: BytesLike, family?: ChainFamily): string;
|
|
73
79
|
/**
|
|
74
80
|
* Validate a value is a txHash string in some supported chain family
|
|
75
|
-
|
|
81
|
+
* @param txHash - Value to check
|
|
82
|
+
* @param family - Optional chain family to validate against
|
|
83
|
+
* @returns true if value is a valid transaction hash
|
|
84
|
+
* @throws {@link CCIPChainFamilyUnsupportedError} if specified chain family is not supported
|
|
85
|
+
*/
|
|
76
86
|
export declare function isSupportedTxHash(txHash: unknown, family?: ChainFamily): txHash is string;
|
|
77
87
|
/**
|
|
78
88
|
* Version of decodeAddress which is aware of custom cross-chain OnRamp formats
|
|
@@ -101,6 +111,7 @@ export declare function isBase64(data: unknown): data is string;
|
|
|
101
111
|
* Converts various data formats to Uint8Array.
|
|
102
112
|
* @param data - Bytes, number array, or Base64 string.
|
|
103
113
|
* @returns Uint8Array representation.
|
|
114
|
+
* @throws {@link CCIPDataFormatUnsupportedError} if data format is not recognized
|
|
104
115
|
*/
|
|
105
116
|
export declare function getDataBytes(data: BytesLike | readonly number[]): Uint8Array;
|
|
106
117
|
/**
|
|
@@ -178,6 +189,7 @@ export declare function withRetry<T>(operation: () => Promise<T>, config: WithRe
|
|
|
178
189
|
* Parses a typeAndVersion string into its components.
|
|
179
190
|
* @param typeAndVersion - String in format "TypeName vX.Y.Z".
|
|
180
191
|
* @returns Tuple of [type, version, original, suffix?].
|
|
192
|
+
* @throws {@link CCIPTypeVersionInvalidError} if string format is invalid
|
|
181
193
|
*/
|
|
182
194
|
export declare function parseTypeAndVersion(typeAndVersion: string): Awaited<ReturnType<Chain['typeAndVersion']>>;
|
|
183
195
|
type RateLimitOpts = {
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAG/B,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,OAAO,EAMb,MAAM,QAAQ,CAAA;AAIf,OAAO,KAAK,EAAE,KAAK,EAAe,MAAM,YAA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CAAC,aAAa,CAAM,EACjC,EAAE,MAAgB,EAAE,GAAE,UAAe,GACpC,OAAO,KAAK,CA0Fd;AAGD,QAAA,MAAM,IAAI;aAKW,CAAC,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC,GAAG;QAClC,MAAM,EAAE,MAAM,CAAA;QACd,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KACxC;CAWN,CAAA;AACP,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
package/dist/utils.js
CHANGED
|
@@ -16,7 +16,8 @@ import { ChainFamily } from "./types.js";
|
|
|
16
16
|
* @param timestamp - target timestamp
|
|
17
17
|
* @param precision - returned blockNumber should be within this many blocks before timestamp
|
|
18
18
|
* @returns blockNumber of a block at provider which is close but before target timestamp
|
|
19
|
-
|
|
19
|
+
* @throws {@link CCIPBlockBeforeTimestampNotFoundError} if no block exists before the given timestamp
|
|
20
|
+
*/
|
|
20
21
|
export async function getSomeBlockNumberBefore(getBlockTimestamp, recentBlockNumber, timestamp, { precision = 10, logger = console } = {}) {
|
|
21
22
|
let beforeBlockNumber = Math.max(1, recentBlockNumber - precision * 1000);
|
|
22
23
|
let beforeTimestamp = await getBlockTimestamp(beforeBlockNumber);
|
|
@@ -69,9 +70,9 @@ export async function getSomeBlockNumberBefore(getBlockTimestamp, recentBlockNum
|
|
|
69
70
|
return beforeBlockNumber;
|
|
70
71
|
}
|
|
71
72
|
/**
|
|
72
|
-
*
|
|
73
|
+
* Converts a chain ID to complete NetworkInfo.
|
|
74
|
+
* Memoized to return the same object reference for a given chainId.
|
|
73
75
|
*/
|
|
74
|
-
// memoized so we always output the same object for a given chainId
|
|
75
76
|
const networkInfoFromChainId = memoize((chainId) => {
|
|
76
77
|
const sel = SELECTORS[chainId];
|
|
77
78
|
if (!sel?.name)
|
|
@@ -92,6 +93,7 @@ const networkInfoFromChainId = memoize((chainId) => {
|
|
|
92
93
|
* - Chain ID as number, bigint or string (EVM: "1", Aptos: "aptos:1", Solana: genesisHash)
|
|
93
94
|
* - Chain name as string ("ethereum-mainnet")
|
|
94
95
|
* @returns Complete NetworkInfo object
|
|
96
|
+
* @throws {@link CCIPChainNotFoundError} if chain is not found
|
|
95
97
|
*/
|
|
96
98
|
export const networkInfo = memoize(function networkInfo_(selectorOrIdOrName) {
|
|
97
99
|
let chainId, match;
|
|
@@ -195,7 +197,11 @@ export function parseJson(text) {
|
|
|
195
197
|
}
|
|
196
198
|
/**
|
|
197
199
|
* Decode address from a 32-byte hex string
|
|
198
|
-
|
|
200
|
+
* @param address - Address bytes to decode
|
|
201
|
+
* @param family - Chain family for address format (defaults to EVM)
|
|
202
|
+
* @returns Decoded address string
|
|
203
|
+
* @throws {@link CCIPChainFamilyUnsupportedError} if chain family is not supported
|
|
204
|
+
*/
|
|
199
205
|
export function decodeAddress(address, family = ChainFamily.EVM) {
|
|
200
206
|
const chain = supportedChains[family];
|
|
201
207
|
if (!chain)
|
|
@@ -204,7 +210,11 @@ export function decodeAddress(address, family = ChainFamily.EVM) {
|
|
|
204
210
|
}
|
|
205
211
|
/**
|
|
206
212
|
* Validate a value is a txHash string in some supported chain family
|
|
207
|
-
|
|
213
|
+
* @param txHash - Value to check
|
|
214
|
+
* @param family - Optional chain family to validate against
|
|
215
|
+
* @returns true if value is a valid transaction hash
|
|
216
|
+
* @throws {@link CCIPChainFamilyUnsupportedError} if specified chain family is not supported
|
|
217
|
+
*/
|
|
208
218
|
export function isSupportedTxHash(txHash, family) {
|
|
209
219
|
let chains;
|
|
210
220
|
if (!family)
|
|
@@ -265,6 +275,7 @@ export function isBase64(data) {
|
|
|
265
275
|
* Converts various data formats to Uint8Array.
|
|
266
276
|
* @param data - Bytes, number array, or Base64 string.
|
|
267
277
|
* @returns Uint8Array representation.
|
|
278
|
+
* @throws {@link CCIPDataFormatUnsupportedError} if data format is not recognized
|
|
268
279
|
*/
|
|
269
280
|
export function getDataBytes(data) {
|
|
270
281
|
if (Array.isArray(data))
|
|
@@ -362,7 +373,8 @@ export function convertKeysToCamelCase(obj, mapValues, key) {
|
|
|
362
373
|
* @param ms - Duration in milliseconds.
|
|
363
374
|
* @returns Promise that resolves after the specified duration.
|
|
364
375
|
*/
|
|
365
|
-
|
|
376
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- unref is Node.js-only; browsers return number
|
|
377
|
+
export const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms).unref?.());
|
|
366
378
|
/**
|
|
367
379
|
* Executes an async operation with retry logic and exponential backoff.
|
|
368
380
|
* Only retries on transient errors (as determined by shouldRetry from errors/utils).
|
|
@@ -428,6 +440,7 @@ export async function withRetry(operation, config) {
|
|
|
428
440
|
* Parses a typeAndVersion string into its components.
|
|
429
441
|
* @param typeAndVersion - String in format "TypeName vX.Y.Z".
|
|
430
442
|
* @returns Tuple of [type, version, original, suffix?].
|
|
443
|
+
* @throws {@link CCIPTypeVersionInvalidError} if string format is invalid
|
|
431
444
|
*/
|
|
432
445
|
export function parseTypeAndVersion(typeAndVersion) {
|
|
433
446
|
const match = typeAndVersion.match(/^(\w.+\S)\s+v?(\d+\.\d+(?:\.\d+)?)([^\d.].*)?$/);
|