@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/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AbiParametersToPrimitiveTypes, ExtractAbiEvent } from 'abitype';
|
|
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
|
-
import type { CCIPMessage_EVM, CCIPMessage_V1_6_EVM } from './evm/messages.ts';
|
|
5
|
+
import type { CCIPMessage_EVM, CCIPMessage_V1_6_EVM, CCIPMessage_V2_0 } from './evm/messages.ts';
|
|
5
6
|
import type { ExtraArgs } from './extra-args.ts';
|
|
6
7
|
import type { CCIPMessage_V1_6_Solana } from './solana/types.ts';
|
|
7
8
|
import type { CCIPMessage_V1_6_Sui } from './sui/types.ts';
|
|
@@ -61,6 +62,7 @@ export declare const CCIPVersion: {
|
|
|
61
62
|
readonly V1_2: "1.2.0";
|
|
62
63
|
readonly V1_5: "1.5.0";
|
|
63
64
|
readonly V1_6: "1.6.0";
|
|
65
|
+
readonly V2_0: "2.0.0";
|
|
64
66
|
};
|
|
65
67
|
/** Type representing one of the supported CCIP versions. */
|
|
66
68
|
export type CCIPVersion = (typeof CCIPVersion)[keyof typeof CCIPVersion];
|
|
@@ -77,6 +79,17 @@ type ChainFamilyWithId<F extends ChainFamily> = F extends typeof ChainFamily.EVM
|
|
|
77
79
|
} : never;
|
|
78
80
|
/**
|
|
79
81
|
* Network information including chain selector and metadata.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const info: NetworkInfo = {
|
|
86
|
+
* chainSelector: 16015286601757825753n,
|
|
87
|
+
* name: 'ethereum-testnet-sepolia',
|
|
88
|
+
* networkType: 'TESTNET',
|
|
89
|
+
* family: 'EVM',
|
|
90
|
+
* chainId: 11155111,
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
80
93
|
*/
|
|
81
94
|
export type NetworkInfo<F extends ChainFamily = ChainFamily> = {
|
|
82
95
|
/** Unique chain selector used by CCIP. */
|
|
@@ -88,6 +101,16 @@ export type NetworkInfo<F extends ChainFamily = ChainFamily> = {
|
|
|
88
101
|
} & ChainFamilyWithId<F>;
|
|
89
102
|
/**
|
|
90
103
|
* CCIP lane configuration connecting source and destination chains.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const lane: Lane = {
|
|
108
|
+
* sourceChainSelector: 16015286601757825753n, // Ethereum Sepolia
|
|
109
|
+
* destChainSelector: 12532609583862916517n, // Polygon Mumbai
|
|
110
|
+
* onRamp: '0x1234...abcd',
|
|
111
|
+
* version: '1.6.0',
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
91
114
|
*/
|
|
92
115
|
export interface Lane<V extends CCIPVersion = CCIPVersion> {
|
|
93
116
|
/** Source chain selector. */
|
|
@@ -102,7 +125,7 @@ export interface Lane<V extends CCIPVersion = CCIPVersion> {
|
|
|
102
125
|
/**
|
|
103
126
|
* Union type representing a CCIP message across different versions and chain families.
|
|
104
127
|
*/
|
|
105
|
-
export type CCIPMessage<V extends CCIPVersion = CCIPVersion> = V extends typeof CCIPVersion.
|
|
128
|
+
export type CCIPMessage<V extends CCIPVersion = CCIPVersion> = V extends typeof CCIPVersion.V2_0 ? CCIPMessage_V2_0 : V extends typeof CCIPVersion.V1_6 ? CCIPMessage_V1_6_EVM | CCIPMessage_V1_6_Solana | CCIPMessage_V1_6_Sui | CCIPMessage_V1_6_TON : CCIPMessage_EVM<V>;
|
|
106
129
|
/**
|
|
107
130
|
* Generic log structure compatible across chain families.
|
|
108
131
|
*/
|
|
@@ -114,6 +137,17 @@ export type Log_ = Pick<Log, 'topics' | 'index' | 'address' | 'blockNumber' | 't
|
|
|
114
137
|
};
|
|
115
138
|
/**
|
|
116
139
|
* Generic transaction structure compatible across chain families.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const tx: ChainTransaction = {
|
|
144
|
+
* hash: '0xabc123...',
|
|
145
|
+
* logs: [],
|
|
146
|
+
* blockNumber: 12345678,
|
|
147
|
+
* timestamp: 1704067200,
|
|
148
|
+
* from: '0x1234...abcd',
|
|
149
|
+
* }
|
|
150
|
+
* ```
|
|
117
151
|
*/
|
|
118
152
|
export type ChainTransaction = {
|
|
119
153
|
/** Transaction hash. */
|
|
@@ -135,26 +169,68 @@ export type ChainTransaction = {
|
|
|
135
169
|
export interface CCIPRequest<V extends CCIPVersion = CCIPVersion> {
|
|
136
170
|
/** Lane configuration for this request. */
|
|
137
171
|
lane: Lane<V>;
|
|
138
|
-
/** The CCIP message being sent. */
|
|
139
172
|
message: CCIPMessage<V>;
|
|
140
|
-
/** Log event from the OnRamp. */
|
|
141
173
|
log: Log_;
|
|
142
174
|
/** Transaction that emitted the request. */
|
|
143
175
|
tx: Pick<ChainTransaction, 'hash' | 'logs' | 'blockNumber' | 'timestamp' | 'from' | 'error'>;
|
|
176
|
+
/**
|
|
177
|
+
* API-enriched metadata. Present only when fetched via CCIP API.
|
|
178
|
+
*
|
|
179
|
+
* @remarks
|
|
180
|
+
* When a request is fetched using {@link Chain.getMessageById} or as a fallback
|
|
181
|
+
* in {@link Chain.getMessagesInTx}, this field contains additional information
|
|
182
|
+
* including message status, execution details, and network info.
|
|
183
|
+
*
|
|
184
|
+
* When constructed from on-chain data only, this field is `undefined`.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const request = await chain.getMessageById(messageId)
|
|
189
|
+
* if (request.metadata) {
|
|
190
|
+
* console.log('Status:', request.metadata.status)
|
|
191
|
+
* console.log('Delivery time:', request.metadata.deliveryTime)
|
|
192
|
+
* }
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* @see {@link APICCIPRequestMetadata}
|
|
196
|
+
*/
|
|
197
|
+
metadata?: APICCIPRequestMetadata;
|
|
144
198
|
}
|
|
145
199
|
/**
|
|
146
|
-
* Commit report structure from the OffRamp CommitReportAccepted event.
|
|
200
|
+
* OnChain Commit report structure from the OffRamp CommitReportAccepted event.
|
|
147
201
|
*/
|
|
148
202
|
export type CommitReport = AbiParametersToPrimitiveTypes<ExtractAbiEvent<typeof OffRamp_1_6_ABI, 'CommitReportAccepted'>['inputs']>[0][number];
|
|
149
203
|
/**
|
|
150
|
-
* CCIP
|
|
204
|
+
* OffChain Verification result for a CCIP v2.0 message, returned by the indexer API.
|
|
151
205
|
*/
|
|
152
|
-
export
|
|
206
|
+
export type VerifierResult = {
|
|
207
|
+
/** Verification data required for destination execution (e.g. signatures). */
|
|
208
|
+
ccvData: BytesLike;
|
|
209
|
+
/** Source CCV contract address. */
|
|
210
|
+
sourceAddress: string;
|
|
211
|
+
/** Destination CCV contract address. */
|
|
212
|
+
destAddress: string;
|
|
213
|
+
/** Timestamp of the attestation (Unix seconds). */
|
|
214
|
+
timestamp?: number;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Verification data for a ccip message (onchain CommitReport, or offchain Verifications)
|
|
218
|
+
*/
|
|
219
|
+
export type CCIPVerifications = {
|
|
153
220
|
/** The commit report data. */
|
|
154
221
|
report: CommitReport;
|
|
155
222
|
/** Log event from the commit. */
|
|
156
223
|
log: Log_;
|
|
157
|
-
}
|
|
224
|
+
} | {
|
|
225
|
+
/** Policy for this request */
|
|
226
|
+
verificationPolicy: {
|
|
227
|
+
optionalCCVs: readonly string[];
|
|
228
|
+
requiredCCVs: readonly string[];
|
|
229
|
+
optionalThreshold: number;
|
|
230
|
+
};
|
|
231
|
+
/** Verifications array; one for each requiredCCV is needed for exec */
|
|
232
|
+
verifications: VerifierResult[];
|
|
233
|
+
};
|
|
158
234
|
/**
|
|
159
235
|
* Enumeration of possible execution states for a CCIP message.
|
|
160
236
|
*/
|
|
@@ -189,7 +265,11 @@ export declare const MessageStatus: {
|
|
|
189
265
|
readonly Verifying: "VERIFYING";
|
|
190
266
|
/** Message has been verified by the CCIP network */
|
|
191
267
|
readonly Verified: "VERIFIED";
|
|
192
|
-
/**
|
|
268
|
+
/**
|
|
269
|
+
* API returned an unrecognized status value.
|
|
270
|
+
* This typically means the CCIP API has new status values that this SDK version
|
|
271
|
+
* doesn't recognize. Consider updating to the latest SDK version.
|
|
272
|
+
*/
|
|
193
273
|
readonly Unknown: "UNKNOWN";
|
|
194
274
|
};
|
|
195
275
|
/** Type representing a CCIP message lifecycle status. */
|
|
@@ -210,6 +290,16 @@ export declare const IntentStatus: {
|
|
|
210
290
|
export type IntentStatus = (typeof IntentStatus)[keyof typeof IntentStatus];
|
|
211
291
|
/**
|
|
212
292
|
* Receipt of a CCIP message execution on the destination chain.
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```typescript
|
|
296
|
+
* const receipt: ExecutionReceipt = {
|
|
297
|
+
* messageId: '0xabc123...',
|
|
298
|
+
* sequenceNumber: 42n,
|
|
299
|
+
* state: ExecutionState.Success,
|
|
300
|
+
* sourceChainSelector: 16015286601757825753n,
|
|
301
|
+
* }
|
|
302
|
+
* ```
|
|
213
303
|
*/
|
|
214
304
|
export type ExecutionReceipt = {
|
|
215
305
|
/** Unique message identifier. */
|
|
@@ -247,8 +337,24 @@ export type OffchainTokenData = {
|
|
|
247
337
|
} | undefined;
|
|
248
338
|
/**
|
|
249
339
|
* Execution report containing message, proofs, and offchain token data.
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* const report: ExecutionReport = {
|
|
344
|
+
* message: { messageId: '0x...', ... },
|
|
345
|
+
* proofs: ['0xproof1...', '0xproof2...'],
|
|
346
|
+
* proofFlagBits: 0n,
|
|
347
|
+
* merkleRoot: '0xroot...',
|
|
348
|
+
* offchainTokenData: [],
|
|
349
|
+
* }
|
|
350
|
+
* ```
|
|
250
351
|
*/
|
|
251
|
-
export type
|
|
352
|
+
export type ExecutionInput<M extends CCIPMessage = CCIPMessage> = M extends CCIPMessage<typeof CCIPVersion.V2_0> ? {
|
|
353
|
+
/** encodedMessage as per CCIPv2 codec */
|
|
354
|
+
encodedMessage: M['encodedMessage'];
|
|
355
|
+
/** Off-Chain verifications containing verifierResults' ccvData and ccvs addresses */
|
|
356
|
+
verifications: Pick<VerifierResult, 'ccvData' | 'destAddress'>[];
|
|
357
|
+
} : {
|
|
252
358
|
/** The CCIP message to execute. */
|
|
253
359
|
message: M;
|
|
254
360
|
/** Merkle proofs for the message. */
|
|
@@ -262,9 +368,24 @@ export type ExecutionReport<M extends CCIPMessage = CCIPMessage> = {
|
|
|
262
368
|
};
|
|
263
369
|
/**
|
|
264
370
|
* A message to be sent to another network.
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* ```typescript
|
|
374
|
+
* const message: AnyMessage = {
|
|
375
|
+
* receiver: '0x1234...abcd',
|
|
376
|
+
* extraArgs: { gasLimit: 200_000n, allowOutOfOrderExecution: true },
|
|
377
|
+
* data: '0xdeadbeef',
|
|
378
|
+
* tokenAmounts: [{ token: '0xtoken...', amount: 1000000n }],
|
|
379
|
+
* }
|
|
380
|
+
* ```
|
|
265
381
|
*/
|
|
266
382
|
export type AnyMessage = {
|
|
267
|
-
/**
|
|
383
|
+
/**
|
|
384
|
+
* Receiver address on the destination chain.
|
|
385
|
+
* Must be a valid address for the destination chain family. For instance:
|
|
386
|
+
* - EVM: 20-byte hex (e.g., `0x6d1af98d635d3121286ddda1a0c2d7078b1523ed`)
|
|
387
|
+
* - Solana: Base58 public key (e.g., `7EcDhSYGxXyscszYEp35KHN8vvw3svAuLKTzXwCFLtV`)
|
|
388
|
+
*/
|
|
268
389
|
receiver: BytesLike;
|
|
269
390
|
/** Extra arguments for gas limits and other settings. */
|
|
270
391
|
extraArgs: ExtraArgs;
|
|
@@ -279,7 +400,22 @@ export type AnyMessage = {
|
|
|
279
400
|
feeToken?: string;
|
|
280
401
|
};
|
|
281
402
|
/**
|
|
282
|
-
* Partial
|
|
403
|
+
* Partial {@link AnyMessage}, which populates default fields like `extraArgs` if needed.
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* ```typescript
|
|
407
|
+
* // Minimal input - only receiver required, defaults applied for extraArgs
|
|
408
|
+
* const input: MessageInput = {
|
|
409
|
+
* receiver: '0x1234...abcd',
|
|
410
|
+
* }
|
|
411
|
+
*
|
|
412
|
+
* // With custom gas limit
|
|
413
|
+
* const inputWithGas: MessageInput = {
|
|
414
|
+
* receiver: '0x1234...abcd',
|
|
415
|
+
* extraArgs: { gasLimit: 500_000n },
|
|
416
|
+
* data: '0xdeadbeef',
|
|
417
|
+
* }
|
|
418
|
+
* ```
|
|
283
419
|
*/
|
|
284
420
|
export type MessageInput = Partial<AnyMessage> & {
|
|
285
421
|
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,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;
|
|
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,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAC5D,OAAO,KAAK,eAAe,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAChG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAE1D,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEzD;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;IACnC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;IAClC,IAAI,EAAE,CAAC,GAAG,I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ChC,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
CHANGED
|
@@ -23,6 +23,7 @@ export const CCIPVersion = {
|
|
|
23
23
|
V1_2: '1.2.0',
|
|
24
24
|
V1_5: '1.5.0',
|
|
25
25
|
V1_6: '1.6.0',
|
|
26
|
+
V2_0: '2.0.0',
|
|
26
27
|
};
|
|
27
28
|
/**
|
|
28
29
|
* Enumeration of possible execution states for a CCIP message.
|
|
@@ -56,7 +57,11 @@ export const MessageStatus = {
|
|
|
56
57
|
Verifying: 'VERIFYING',
|
|
57
58
|
/** Message has been verified by the CCIP network */
|
|
58
59
|
Verified: 'VERIFIED',
|
|
59
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* API returned an unrecognized status value.
|
|
62
|
+
* This typically means the CCIP API has new status values that this SDK version
|
|
63
|
+
* doesn't recognize. Consider updating to the latest SDK version.
|
|
64
|
+
*/
|
|
60
65
|
Unknown: 'UNKNOWN',
|
|
61
66
|
};
|
|
62
67
|
/**
|
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.ts"],"names":[],"mappings":"AA2DA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;I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workInfo, 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,24 @@ 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
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { networkInfo } from '@chainlink/ccip-sdk'
|
|
31
|
+
*
|
|
32
|
+
* // By chain name
|
|
33
|
+
* const sepolia = networkInfo('ethereum-testnet-sepolia')
|
|
34
|
+
* console.log('Selector:', sepolia.chainSelector)
|
|
35
|
+
*
|
|
36
|
+
* // By chain selector
|
|
37
|
+
* const fuji = networkInfo(14767482510784806043n)
|
|
38
|
+
* console.log('Name:', fuji.name) // 'avalanche-testnet-fuji'
|
|
39
|
+
*
|
|
40
|
+
* // By chain ID
|
|
41
|
+
* const mainnet = networkInfo(1)
|
|
42
|
+
* console.log('Family:', mainnet.family) // 'EVM'
|
|
43
|
+
* ```
|
|
25
44
|
*/
|
|
26
45
|
export declare const networkInfo: import("micro-memoize").Memoized<(selectorOrIdOrName: bigint | number | string) => NetworkInfo, {}>;
|
|
27
46
|
/**
|
|
@@ -50,6 +69,15 @@ export declare function blockRangeGenerator(params: {
|
|
|
50
69
|
* @param _key - Property key (unused).
|
|
51
70
|
* @param value - Value to transform.
|
|
52
71
|
* @returns String representation if BigInt, otherwise unchanged value.
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* import { bigIntReplacer } from '@chainlink/ccip-sdk'
|
|
75
|
+
*
|
|
76
|
+
* const data = { amount: 1000000000000000000n }
|
|
77
|
+
* const json = JSON.stringify(data, bigIntReplacer)
|
|
78
|
+
* console.log(json) // '{"amount":"1000000000000000000"}'
|
|
79
|
+
* ```
|
|
80
|
+
* @see {@link bigIntReviver} - Revive BigInt values when parsing
|
|
53
81
|
*/
|
|
54
82
|
export declare function bigIntReplacer(_key: string, value: unknown): unknown;
|
|
55
83
|
/**
|
|
@@ -57,6 +85,15 @@ export declare function bigIntReplacer(_key: string, value: unknown): unknown;
|
|
|
57
85
|
* @param _key - Property key (unused).
|
|
58
86
|
* @param value - Value to transform.
|
|
59
87
|
* @returns BigInt if numeric string, otherwise unchanged value.
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* import { bigIntReviver } from '@chainlink/ccip-sdk'
|
|
91
|
+
*
|
|
92
|
+
* const json = '{"amount":"1000000000000000000"}'
|
|
93
|
+
* const data = JSON.parse(json, bigIntReviver)
|
|
94
|
+
* console.log(typeof data.amount) // 'bigint'
|
|
95
|
+
* ```
|
|
96
|
+
* @see {@link bigIntReplacer} - Stringify BigInt values
|
|
60
97
|
*/
|
|
61
98
|
export declare function bigIntReviver(_key: string, value: unknown): unknown;
|
|
62
99
|
/**
|
|
@@ -67,12 +104,34 @@ export declare function bigIntReviver(_key: string, value: unknown): unknown;
|
|
|
67
104
|
*/
|
|
68
105
|
export declare function parseJson<T = unknown>(text: string): T;
|
|
69
106
|
/**
|
|
70
|
-
* Decode address from a 32-byte hex string
|
|
71
|
-
|
|
107
|
+
* Decode address from a 32-byte hex string.
|
|
108
|
+
*
|
|
109
|
+
* @param address - Address bytes to decode (hex string or Uint8Array)
|
|
110
|
+
* @param family - Chain family for address format (defaults to EVM)
|
|
111
|
+
* @returns Decoded address string
|
|
112
|
+
* @throws {@link CCIPChainFamilyUnsupportedError} if chain family is not supported
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* import { decodeAddress, ChainFamily } from '@chainlink/ccip-sdk'
|
|
117
|
+
*
|
|
118
|
+
* // Decode EVM address from 32-byte hex
|
|
119
|
+
* const evmAddr = decodeAddress('0x000000000000000000000000abc123...', ChainFamily.EVM)
|
|
120
|
+
* console.log(evmAddr) // '0xABC123...'
|
|
121
|
+
*
|
|
122
|
+
* // Decode Solana address
|
|
123
|
+
* const solAddr = decodeAddress(bytes, ChainFamily.Solana)
|
|
124
|
+
* console.log(solAddr) // Base58 encoded address
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
72
127
|
export declare function decodeAddress(address: BytesLike, family?: ChainFamily): string;
|
|
73
128
|
/**
|
|
74
129
|
* Validate a value is a txHash string in some supported chain family
|
|
75
|
-
|
|
130
|
+
* @param txHash - Value to check
|
|
131
|
+
* @param family - Optional chain family to validate against
|
|
132
|
+
* @returns true if value is a valid transaction hash
|
|
133
|
+
* @throws {@link CCIPChainFamilyUnsupportedError} if specified chain family is not supported
|
|
134
|
+
*/
|
|
76
135
|
export declare function isSupportedTxHash(txHash: unknown, family?: ChainFamily): txHash is string;
|
|
77
136
|
/**
|
|
78
137
|
* Version of decodeAddress which is aware of custom cross-chain OnRamp formats
|
|
@@ -101,6 +160,21 @@ export declare function isBase64(data: unknown): data is string;
|
|
|
101
160
|
* Converts various data formats to Uint8Array.
|
|
102
161
|
* @param data - Bytes, number array, or Base64 string.
|
|
103
162
|
* @returns Uint8Array representation.
|
|
163
|
+
* @throws {@link CCIPDataFormatUnsupportedError} if data format is not recognized
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* import { getDataBytes } from '@chainlink/ccip-sdk'
|
|
168
|
+
*
|
|
169
|
+
* // From hex string
|
|
170
|
+
* const bytes1 = getDataBytes('0x1234abcd')
|
|
171
|
+
*
|
|
172
|
+
* // From number array
|
|
173
|
+
* const bytes2 = getDataBytes([0x12, 0x34, 0xab, 0xcd])
|
|
174
|
+
*
|
|
175
|
+
* // From Base64
|
|
176
|
+
* const bytes3 = getDataBytes('EjSrzQ==')
|
|
177
|
+
* ```
|
|
104
178
|
*/
|
|
105
179
|
export declare function getDataBytes(data: BytesLike | readonly number[]): Uint8Array;
|
|
106
180
|
/**
|
|
@@ -178,6 +252,7 @@ export declare function withRetry<T>(operation: () => Promise<T>, config: WithRe
|
|
|
178
252
|
* Parses a typeAndVersion string into its components.
|
|
179
253
|
* @param typeAndVersion - String in format "TypeName vX.Y.Z".
|
|
180
254
|
* @returns Tuple of [type, version, original, suffix?].
|
|
255
|
+
* @throws {@link CCIPTypeVersionInvalidError} if string format is invalid
|
|
181
256
|
*/
|
|
182
257
|
export declare function parseTypeAndVersion(typeAndVersion: string): Awaited<ReturnType<Chain['typeAndVersion']>>;
|
|
183
258
|
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,YAAY,CAAA;AAcpD,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE3E
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,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AE,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,24 @@ 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
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* import { networkInfo } from '@chainlink/ccip-sdk'
|
|
101
|
+
*
|
|
102
|
+
* // By chain name
|
|
103
|
+
* const sepolia = networkInfo('ethereum-testnet-sepolia')
|
|
104
|
+
* console.log('Selector:', sepolia.chainSelector)
|
|
105
|
+
*
|
|
106
|
+
* // By chain selector
|
|
107
|
+
* const fuji = networkInfo(14767482510784806043n)
|
|
108
|
+
* console.log('Name:', fuji.name) // 'avalanche-testnet-fuji'
|
|
109
|
+
*
|
|
110
|
+
* // By chain ID
|
|
111
|
+
* const mainnet = networkInfo(1)
|
|
112
|
+
* console.log('Family:', mainnet.family) // 'EVM'
|
|
113
|
+
* ```
|
|
95
114
|
*/
|
|
96
115
|
export const networkInfo = memoize(function networkInfo_(selectorOrIdOrName) {
|
|
97
116
|
let chainId, match;
|
|
@@ -165,6 +184,15 @@ export function* blockRangeGenerator(params) {
|
|
|
165
184
|
* @param _key - Property key (unused).
|
|
166
185
|
* @param value - Value to transform.
|
|
167
186
|
* @returns String representation if BigInt, otherwise unchanged value.
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* import { bigIntReplacer } from '@chainlink/ccip-sdk'
|
|
190
|
+
*
|
|
191
|
+
* const data = { amount: 1000000000000000000n }
|
|
192
|
+
* const json = JSON.stringify(data, bigIntReplacer)
|
|
193
|
+
* console.log(json) // '{"amount":"1000000000000000000"}'
|
|
194
|
+
* ```
|
|
195
|
+
* @see {@link bigIntReviver} - Revive BigInt values when parsing
|
|
168
196
|
*/
|
|
169
197
|
export function bigIntReplacer(_key, value) {
|
|
170
198
|
if (typeof value === 'bigint') {
|
|
@@ -177,6 +205,15 @@ export function bigIntReplacer(_key, value) {
|
|
|
177
205
|
* @param _key - Property key (unused).
|
|
178
206
|
* @param value - Value to transform.
|
|
179
207
|
* @returns BigInt if numeric string, otherwise unchanged value.
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* import { bigIntReviver } from '@chainlink/ccip-sdk'
|
|
211
|
+
*
|
|
212
|
+
* const json = '{"amount":"1000000000000000000"}'
|
|
213
|
+
* const data = JSON.parse(json, bigIntReviver)
|
|
214
|
+
* console.log(typeof data.amount) // 'bigint'
|
|
215
|
+
* ```
|
|
216
|
+
* @see {@link bigIntReplacer} - Stringify BigInt values
|
|
180
217
|
*/
|
|
181
218
|
export function bigIntReviver(_key, value) {
|
|
182
219
|
if (typeof value === 'string' && /^\d+$/.test(value)) {
|
|
@@ -194,8 +231,26 @@ export function parseJson(text) {
|
|
|
194
231
|
return yaml.parse(text, { intAsBigInt: true });
|
|
195
232
|
}
|
|
196
233
|
/**
|
|
197
|
-
* Decode address from a 32-byte hex string
|
|
198
|
-
|
|
234
|
+
* Decode address from a 32-byte hex string.
|
|
235
|
+
*
|
|
236
|
+
* @param address - Address bytes to decode (hex string or Uint8Array)
|
|
237
|
+
* @param family - Chain family for address format (defaults to EVM)
|
|
238
|
+
* @returns Decoded address string
|
|
239
|
+
* @throws {@link CCIPChainFamilyUnsupportedError} if chain family is not supported
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* import { decodeAddress, ChainFamily } from '@chainlink/ccip-sdk'
|
|
244
|
+
*
|
|
245
|
+
* // Decode EVM address from 32-byte hex
|
|
246
|
+
* const evmAddr = decodeAddress('0x000000000000000000000000abc123...', ChainFamily.EVM)
|
|
247
|
+
* console.log(evmAddr) // '0xABC123...'
|
|
248
|
+
*
|
|
249
|
+
* // Decode Solana address
|
|
250
|
+
* const solAddr = decodeAddress(bytes, ChainFamily.Solana)
|
|
251
|
+
* console.log(solAddr) // Base58 encoded address
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
199
254
|
export function decodeAddress(address, family = ChainFamily.EVM) {
|
|
200
255
|
const chain = supportedChains[family];
|
|
201
256
|
if (!chain)
|
|
@@ -204,7 +259,11 @@ export function decodeAddress(address, family = ChainFamily.EVM) {
|
|
|
204
259
|
}
|
|
205
260
|
/**
|
|
206
261
|
* Validate a value is a txHash string in some supported chain family
|
|
207
|
-
|
|
262
|
+
* @param txHash - Value to check
|
|
263
|
+
* @param family - Optional chain family to validate against
|
|
264
|
+
* @returns true if value is a valid transaction hash
|
|
265
|
+
* @throws {@link CCIPChainFamilyUnsupportedError} if specified chain family is not supported
|
|
266
|
+
*/
|
|
208
267
|
export function isSupportedTxHash(txHash, family) {
|
|
209
268
|
let chains;
|
|
210
269
|
if (!family)
|
|
@@ -265,6 +324,21 @@ export function isBase64(data) {
|
|
|
265
324
|
* Converts various data formats to Uint8Array.
|
|
266
325
|
* @param data - Bytes, number array, or Base64 string.
|
|
267
326
|
* @returns Uint8Array representation.
|
|
327
|
+
* @throws {@link CCIPDataFormatUnsupportedError} if data format is not recognized
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```typescript
|
|
331
|
+
* import { getDataBytes } from '@chainlink/ccip-sdk'
|
|
332
|
+
*
|
|
333
|
+
* // From hex string
|
|
334
|
+
* const bytes1 = getDataBytes('0x1234abcd')
|
|
335
|
+
*
|
|
336
|
+
* // From number array
|
|
337
|
+
* const bytes2 = getDataBytes([0x12, 0x34, 0xab, 0xcd])
|
|
338
|
+
*
|
|
339
|
+
* // From Base64
|
|
340
|
+
* const bytes3 = getDataBytes('EjSrzQ==')
|
|
341
|
+
* ```
|
|
268
342
|
*/
|
|
269
343
|
export function getDataBytes(data) {
|
|
270
344
|
if (Array.isArray(data))
|
|
@@ -316,6 +390,15 @@ export function getAddressBytes(address) {
|
|
|
316
390
|
? '0x' + address
|
|
317
391
|
: address);
|
|
318
392
|
}
|
|
393
|
+
else if (typeof address === 'string' && /^-?\d+:[0-9a-f]{64}$/i.test(address)) {
|
|
394
|
+
// TON raw format: "workchain:hash" → 36-byte CCIP format (4-byte BE workchain + 32-byte hash)
|
|
395
|
+
const [workchain, hash] = address.split(':');
|
|
396
|
+
const buf = new Uint8Array(36);
|
|
397
|
+
const view = new DataView(buf.buffer);
|
|
398
|
+
view.setInt32(0, parseInt(workchain, 10), false); // big-endian
|
|
399
|
+
buf.set(getBytes('0x' + hash), 4);
|
|
400
|
+
bytes = buf;
|
|
401
|
+
}
|
|
319
402
|
else {
|
|
320
403
|
try {
|
|
321
404
|
const bytes_ = bs58.decode(address);
|
|
@@ -362,7 +445,8 @@ export function convertKeysToCamelCase(obj, mapValues, key) {
|
|
|
362
445
|
* @param ms - Duration in milliseconds.
|
|
363
446
|
* @returns Promise that resolves after the specified duration.
|
|
364
447
|
*/
|
|
365
|
-
|
|
448
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- unref is Node.js-only; browsers return number
|
|
449
|
+
export const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms).unref?.());
|
|
366
450
|
/**
|
|
367
451
|
* Executes an async operation with retry logic and exponential backoff.
|
|
368
452
|
* Only retries on transient errors (as determined by shouldRetry from errors/utils).
|
|
@@ -428,6 +512,7 @@ export async function withRetry(operation, config) {
|
|
|
428
512
|
* Parses a typeAndVersion string into its components.
|
|
429
513
|
* @param typeAndVersion - String in format "TypeName vX.Y.Z".
|
|
430
514
|
* @returns Tuple of [type, version, original, suffix?].
|
|
515
|
+
* @throws {@link CCIPTypeVersionInvalidError} if string format is invalid
|
|
431
516
|
*/
|
|
432
517
|
export function parseTypeAndVersion(typeAndVersion) {
|
|
433
518
|
const match = typeAndVersion.match(/^(\w.+\S)\s+v?(\d+\.\d+(?:\.\d+)?)([^\d.].*)?$/);
|