@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/src/types.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { AbiParametersToPrimitiveTypes, ExtractAbiEvent } from 'abitype'
|
|
2
|
-
import type { BytesLike, Log } from 'ethers'
|
|
2
|
+
import type { BytesLike, Log as EVMLog } from 'ethers'
|
|
3
|
+
import type { SetOptional } from 'type-fest'
|
|
3
4
|
|
|
4
5
|
import type { APICCIPRequestMetadata } from './api/types.ts'
|
|
5
6
|
import type OffRamp_1_6_ABI from './evm/abi/OffRamp_1_6.ts'
|
|
6
|
-
import type { CCIPMessage_EVM, CCIPMessage_V1_6_EVM } from './evm/messages.ts'
|
|
7
|
+
import type { CCIPMessage_EVM, CCIPMessage_V1_6_EVM, CCIPMessage_V2_0 } from './evm/messages.ts'
|
|
7
8
|
import type { ExtraArgs } from './extra-args.ts'
|
|
8
9
|
import type { CCIPMessage_V1_6_Solana } from './solana/types.ts'
|
|
9
10
|
import type { CCIPMessage_V1_6_Sui } from './sui/types.ts'
|
|
10
|
-
import type { CCIPMessage_V1_6_TON } from './ton/types.ts'
|
|
11
11
|
// v1.6 Base type from EVM contains the intersection of all other CCIPMessage v1.6 types
|
|
12
12
|
export type { CCIPMessage_V1_6 } from './evm/messages.ts'
|
|
13
13
|
|
|
@@ -88,6 +88,7 @@ export const CCIPVersion = {
|
|
|
88
88
|
V1_2: '1.2.0',
|
|
89
89
|
V1_5: '1.5.0',
|
|
90
90
|
V1_6: '1.6.0',
|
|
91
|
+
V2_0: '2.0.0',
|
|
91
92
|
} as const
|
|
92
93
|
/** Type representing one of the supported CCIP versions. */
|
|
93
94
|
export type CCIPVersion = (typeof CCIPVersion)[keyof typeof CCIPVersion]
|
|
@@ -153,20 +154,23 @@ export interface Lane<V extends CCIPVersion = CCIPVersion> {
|
|
|
153
154
|
/**
|
|
154
155
|
* Union type representing a CCIP message across different versions and chain families.
|
|
155
156
|
*/
|
|
156
|
-
export type CCIPMessage<V extends CCIPVersion = CCIPVersion> = V extends
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
export type CCIPMessage<V extends CCIPVersion = CCIPVersion> = V extends typeof CCIPVersion.V2_0
|
|
158
|
+
? CCIPMessage_V2_0
|
|
159
|
+
: V extends typeof CCIPVersion.V1_6
|
|
160
|
+
? CCIPMessage_V1_6_EVM | CCIPMessage_V1_6_Solana | CCIPMessage_V1_6_Sui
|
|
161
|
+
: CCIPMessage_EVM<V>
|
|
161
162
|
|
|
162
163
|
/**
|
|
163
164
|
* Generic log structure compatible across chain families.
|
|
164
165
|
*/
|
|
165
|
-
export type
|
|
166
|
+
export type ChainLog = Pick<
|
|
167
|
+
EVMLog,
|
|
168
|
+
'topics' | 'index' | 'address' | 'blockNumber' | 'transactionHash'
|
|
169
|
+
> & {
|
|
166
170
|
/** Log data as bytes or parsed object. */
|
|
167
171
|
data: BytesLike | Record<string, unknown>
|
|
168
172
|
/** Optional reference to the containing transaction. */
|
|
169
|
-
tx?: ChainTransaction
|
|
173
|
+
tx?: SetOptional<ChainTransaction, 'logs'>
|
|
170
174
|
}
|
|
171
175
|
|
|
172
176
|
/**
|
|
@@ -187,7 +191,7 @@ export type ChainTransaction = {
|
|
|
187
191
|
/** Transaction hash. */
|
|
188
192
|
hash: string
|
|
189
193
|
/** Logs emitted by this transaction. */
|
|
190
|
-
logs: readonly
|
|
194
|
+
logs: readonly ChainLog[]
|
|
191
195
|
/** Block number containing this transaction. */
|
|
192
196
|
blockNumber: number
|
|
193
197
|
/** Unix timestamp of the block. */
|
|
@@ -204,12 +208,10 @@ export type ChainTransaction = {
|
|
|
204
208
|
export interface CCIPRequest<V extends CCIPVersion = CCIPVersion> {
|
|
205
209
|
/** Lane configuration for this request. */
|
|
206
210
|
lane: Lane<V>
|
|
207
|
-
/** The CCIP message being sent. */
|
|
208
211
|
message: CCIPMessage<V>
|
|
209
|
-
|
|
210
|
-
log: Log_
|
|
212
|
+
log: ChainLog
|
|
211
213
|
/** Transaction that emitted the request. */
|
|
212
|
-
tx:
|
|
214
|
+
tx: Omit<ChainTransaction, 'logs'>
|
|
213
215
|
|
|
214
216
|
/**
|
|
215
217
|
* API-enriched metadata. Present only when fetched via CCIP API.
|
|
@@ -236,22 +238,47 @@ export interface CCIPRequest<V extends CCIPVersion = CCIPVersion> {
|
|
|
236
238
|
}
|
|
237
239
|
|
|
238
240
|
/**
|
|
239
|
-
* Commit report structure from the OffRamp CommitReportAccepted event.
|
|
241
|
+
* OnChain Commit report structure from the OffRamp CommitReportAccepted event.
|
|
240
242
|
*/
|
|
241
243
|
export type CommitReport = AbiParametersToPrimitiveTypes<
|
|
242
244
|
ExtractAbiEvent<typeof OffRamp_1_6_ABI, 'CommitReportAccepted'>['inputs']
|
|
243
245
|
>[0][number]
|
|
244
246
|
|
|
245
247
|
/**
|
|
246
|
-
* CCIP
|
|
248
|
+
* OffChain Verification result for a CCIP v2.0 message, returned by the indexer API.
|
|
247
249
|
*/
|
|
248
|
-
export
|
|
249
|
-
/**
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
|
|
250
|
+
export type VerifierResult = {
|
|
251
|
+
/** Verification data required for destination execution (e.g. signatures). */
|
|
252
|
+
ccvData: BytesLike
|
|
253
|
+
/** Source CCV contract address. */
|
|
254
|
+
sourceAddress: string
|
|
255
|
+
/** Destination CCV contract address. */
|
|
256
|
+
destAddress: string
|
|
257
|
+
/** Timestamp of the attestation (Unix seconds). */
|
|
258
|
+
timestamp?: number
|
|
253
259
|
}
|
|
254
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Verification data for a ccip message (onchain CommitReport, or offchain Verifications)
|
|
263
|
+
*/
|
|
264
|
+
export type CCIPVerifications =
|
|
265
|
+
| {
|
|
266
|
+
/** The commit report data. */
|
|
267
|
+
report: CommitReport
|
|
268
|
+
/** Log event from the commit. */
|
|
269
|
+
log: ChainLog
|
|
270
|
+
}
|
|
271
|
+
| {
|
|
272
|
+
/** Policy for this request */
|
|
273
|
+
verificationPolicy: {
|
|
274
|
+
optionalCCVs: readonly string[]
|
|
275
|
+
requiredCCVs: readonly string[]
|
|
276
|
+
optionalThreshold: number
|
|
277
|
+
}
|
|
278
|
+
/** Verifications array; one for each requiredCCV is needed for exec */
|
|
279
|
+
verifications: VerifierResult[]
|
|
280
|
+
}
|
|
281
|
+
|
|
255
282
|
/**
|
|
256
283
|
* Enumeration of possible execution states for a CCIP message.
|
|
257
284
|
*/
|
|
@@ -287,7 +314,11 @@ export const MessageStatus = {
|
|
|
287
314
|
Verifying: 'VERIFYING',
|
|
288
315
|
/** Message has been verified by the CCIP network */
|
|
289
316
|
Verified: 'VERIFIED',
|
|
290
|
-
/**
|
|
317
|
+
/**
|
|
318
|
+
* API returned an unrecognized status value.
|
|
319
|
+
* This typically means the CCIP API has new status values that this SDK version
|
|
320
|
+
* doesn't recognize. Consider updating to the latest SDK version.
|
|
321
|
+
*/
|
|
291
322
|
Unknown: 'UNKNOWN',
|
|
292
323
|
} as const
|
|
293
324
|
/** Type representing a CCIP message lifecycle status. */
|
|
@@ -345,7 +376,7 @@ export interface CCIPExecution {
|
|
|
345
376
|
/** Execution receipt data. */
|
|
346
377
|
receipt: ExecutionReceipt
|
|
347
378
|
/** Log event from the execution. */
|
|
348
|
-
log:
|
|
379
|
+
log: ChainLog
|
|
349
380
|
/** Unix timestamp of the execution. */
|
|
350
381
|
timestamp: number
|
|
351
382
|
}
|
|
@@ -369,18 +400,26 @@ export type OffchainTokenData = { _tag: string; [k: string]: BytesLike } | undef
|
|
|
369
400
|
* }
|
|
370
401
|
* ```
|
|
371
402
|
*/
|
|
372
|
-
export type
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
403
|
+
export type ExecutionInput<M extends CCIPMessage = CCIPMessage> =
|
|
404
|
+
M extends CCIPMessage<typeof CCIPVersion.V2_0>
|
|
405
|
+
? {
|
|
406
|
+
/** encodedMessage as per CCIPv2 codec */
|
|
407
|
+
encodedMessage: M['encodedMessage']
|
|
408
|
+
/** Off-Chain verifications containing verifierResults' ccvData and ccvs addresses */
|
|
409
|
+
verifications: Pick<VerifierResult, 'ccvData' | 'destAddress'>[]
|
|
410
|
+
}
|
|
411
|
+
: {
|
|
412
|
+
/** The CCIP message to execute. */
|
|
413
|
+
message: M
|
|
414
|
+
/** Merkle proofs for the message. */
|
|
415
|
+
proofs: readonly BytesLike[]
|
|
416
|
+
/** Bit flags for proof verification. */
|
|
417
|
+
proofFlagBits: bigint
|
|
418
|
+
/** Merkle root for verification. */
|
|
419
|
+
merkleRoot: string
|
|
420
|
+
/** Offchain token data for each token transfer. */
|
|
421
|
+
offchainTokenData: readonly OffchainTokenData[]
|
|
422
|
+
}
|
|
384
423
|
|
|
385
424
|
/**
|
|
386
425
|
* A message to be sent to another network.
|
|
@@ -396,7 +435,12 @@ export type ExecutionReport<M extends CCIPMessage = CCIPMessage> = {
|
|
|
396
435
|
* ```
|
|
397
436
|
*/
|
|
398
437
|
export type AnyMessage = {
|
|
399
|
-
/**
|
|
438
|
+
/**
|
|
439
|
+
* Receiver address on the destination chain.
|
|
440
|
+
* Must be a valid address for the destination chain family. For instance:
|
|
441
|
+
* - EVM: 20-byte hex (e.g., `0x6d1af98d635d3121286ddda1a0c2d7078b1523ed`)
|
|
442
|
+
* - Solana: Base58 public key (e.g., `7EcDhSYGxXyscszYEp35KHN8vvw3svAuLKTzXwCFLtV`)
|
|
443
|
+
*/
|
|
400
444
|
receiver: BytesLike
|
|
401
445
|
/** Extra arguments for gas limits and other settings. */
|
|
402
446
|
extraArgs: ExtraArgs
|
package/src/utils.ts
CHANGED
|
@@ -131,6 +131,23 @@ const networkInfoFromChainId = memoize((chainId: NetworkInfo['chainId']): Networ
|
|
|
131
131
|
* - Chain name as string ("ethereum-mainnet")
|
|
132
132
|
* @returns Complete NetworkInfo object
|
|
133
133
|
* @throws {@link CCIPChainNotFoundError} if chain is not found
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* import { networkInfo } from '@chainlink/ccip-sdk'
|
|
138
|
+
*
|
|
139
|
+
* // By chain name
|
|
140
|
+
* const sepolia = networkInfo('ethereum-testnet-sepolia')
|
|
141
|
+
* console.log('Selector:', sepolia.chainSelector)
|
|
142
|
+
*
|
|
143
|
+
* // By chain selector
|
|
144
|
+
* const fuji = networkInfo(14767482510784806043n)
|
|
145
|
+
* console.log('Name:', fuji.name) // 'avalanche-testnet-fuji'
|
|
146
|
+
*
|
|
147
|
+
* // By chain ID
|
|
148
|
+
* const mainnet = networkInfo(1)
|
|
149
|
+
* console.log('Family:', mainnet.family) // 'EVM'
|
|
150
|
+
* ```
|
|
134
151
|
*/
|
|
135
152
|
export const networkInfo = memoize(function networkInfo_(
|
|
136
153
|
selectorOrIdOrName: bigint | number | string,
|
|
@@ -206,6 +223,15 @@ export function* blockRangeGenerator(
|
|
|
206
223
|
* @param _key - Property key (unused).
|
|
207
224
|
* @param value - Value to transform.
|
|
208
225
|
* @returns String representation if BigInt, otherwise unchanged value.
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* import { bigIntReplacer } from '@chainlink/ccip-sdk'
|
|
229
|
+
*
|
|
230
|
+
* const data = { amount: 1000000000000000000n }
|
|
231
|
+
* const json = JSON.stringify(data, bigIntReplacer)
|
|
232
|
+
* console.log(json) // '{"amount":"1000000000000000000"}'
|
|
233
|
+
* ```
|
|
234
|
+
* @see {@link bigIntReviver} - Revive BigInt values when parsing
|
|
209
235
|
*/
|
|
210
236
|
export function bigIntReplacer(_key: string, value: unknown): unknown {
|
|
211
237
|
if (typeof value === 'bigint') {
|
|
@@ -219,6 +245,15 @@ export function bigIntReplacer(_key: string, value: unknown): unknown {
|
|
|
219
245
|
* @param _key - Property key (unused).
|
|
220
246
|
* @param value - Value to transform.
|
|
221
247
|
* @returns BigInt if numeric string, otherwise unchanged value.
|
|
248
|
+
* @example
|
|
249
|
+
* ```typescript
|
|
250
|
+
* import { bigIntReviver } from '@chainlink/ccip-sdk'
|
|
251
|
+
*
|
|
252
|
+
* const json = '{"amount":"1000000000000000000"}'
|
|
253
|
+
* const data = JSON.parse(json, bigIntReviver)
|
|
254
|
+
* console.log(typeof data.amount) // 'bigint'
|
|
255
|
+
* ```
|
|
256
|
+
* @see {@link bigIntReplacer} - Stringify BigInt values
|
|
222
257
|
*/
|
|
223
258
|
export function bigIntReviver(_key: string, value: unknown): unknown {
|
|
224
259
|
if (typeof value === 'string' && /^\d+$/.test(value)) {
|
|
@@ -238,11 +273,25 @@ export function parseJson<T = unknown>(text: string): T {
|
|
|
238
273
|
}
|
|
239
274
|
|
|
240
275
|
/**
|
|
241
|
-
* Decode address from a 32-byte hex string
|
|
242
|
-
*
|
|
276
|
+
* Decode address from a 32-byte hex string.
|
|
277
|
+
*
|
|
278
|
+
* @param address - Address bytes to decode (hex string or Uint8Array)
|
|
243
279
|
* @param family - Chain family for address format (defaults to EVM)
|
|
244
280
|
* @returns Decoded address string
|
|
245
281
|
* @throws {@link CCIPChainFamilyUnsupportedError} if chain family is not supported
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```typescript
|
|
285
|
+
* import { decodeAddress, ChainFamily } from '@chainlink/ccip-sdk'
|
|
286
|
+
*
|
|
287
|
+
* // Decode EVM address from 32-byte hex
|
|
288
|
+
* const evmAddr = decodeAddress('0x000000000000000000000000abc123...', ChainFamily.EVM)
|
|
289
|
+
* console.log(evmAddr) // '0xABC123...'
|
|
290
|
+
*
|
|
291
|
+
* // Decode Solana address
|
|
292
|
+
* const solAddr = decodeAddress(bytes, ChainFamily.Solana)
|
|
293
|
+
* console.log(solAddr) // Base58 encoded address
|
|
294
|
+
* ```
|
|
246
295
|
*/
|
|
247
296
|
export function decodeAddress(address: BytesLike, family: ChainFamily = ChainFamily.EVM): string {
|
|
248
297
|
const chain = supportedChains[family]
|
|
@@ -320,6 +369,20 @@ export function isBase64(data: unknown): data is string {
|
|
|
320
369
|
* @param data - Bytes, number array, or Base64 string.
|
|
321
370
|
* @returns Uint8Array representation.
|
|
322
371
|
* @throws {@link CCIPDataFormatUnsupportedError} if data format is not recognized
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
* ```typescript
|
|
375
|
+
* import { getDataBytes } from '@chainlink/ccip-sdk'
|
|
376
|
+
*
|
|
377
|
+
* // From hex string
|
|
378
|
+
* const bytes1 = getDataBytes('0x1234abcd')
|
|
379
|
+
*
|
|
380
|
+
* // From number array
|
|
381
|
+
* const bytes2 = getDataBytes([0x12, 0x34, 0xab, 0xcd])
|
|
382
|
+
*
|
|
383
|
+
* // From Base64
|
|
384
|
+
* const bytes3 = getDataBytes('EjSrzQ==')
|
|
385
|
+
* ```
|
|
323
386
|
*/
|
|
324
387
|
export function getDataBytes(data: BytesLike | readonly number[]): Uint8Array {
|
|
325
388
|
if (Array.isArray(data)) return new Uint8Array(data)
|
|
@@ -369,6 +432,14 @@ export function getAddressBytes(address: BytesLike | readonly number[]): Uint8Ar
|
|
|
369
432
|
? '0x' + address
|
|
370
433
|
: address,
|
|
371
434
|
)
|
|
435
|
+
} else if (typeof address === 'string' && /^-?\d+:[0-9a-f]{64}$/i.test(address)) {
|
|
436
|
+
// TON raw format: "workchain:hash" → 36-byte CCIP format (4-byte BE workchain + 32-byte hash)
|
|
437
|
+
const [workchain, hash] = address.split(':')
|
|
438
|
+
const buf = new Uint8Array(36)
|
|
439
|
+
const view = new DataView(buf.buffer)
|
|
440
|
+
view.setInt32(0, parseInt(workchain!, 10), false) // big-endian
|
|
441
|
+
buf.set(getBytes('0x' + hash), 4)
|
|
442
|
+
bytes = buf
|
|
372
443
|
} else {
|
|
373
444
|
try {
|
|
374
445
|
const bytes_ = bs58.decode(address as string)
|
package/dist/aptos/utils.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type BigNumberish, type BytesLike } from 'ethers';
|
|
2
|
-
/**
|
|
3
|
-
* Encodes a numeric value as a 32-byte hex string.
|
|
4
|
-
* @param value - Numeric value to encode.
|
|
5
|
-
* @returns 32-byte hex string representation of the value.
|
|
6
|
-
*/
|
|
7
|
-
export declare const encodeNumber: (value: BigNumberish) => string;
|
|
8
|
-
/**
|
|
9
|
-
* Encodes dynamic bytes without the struct offset prefix.
|
|
10
|
-
*/
|
|
11
|
-
export declare const encodeRawBytes: (value: BytesLike) => string;
|
|
12
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/aptos/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EAKf,MAAM,QAAQ,CAAA;AAEf;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,YAAY,KAAG,MAA4B,CAAA;AAE/E;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,SAAS,KAAG,MAI9C,CAAA"}
|
package/dist/aptos/utils.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { concat, dataLength, toBeHex, zeroPadBytes, } from 'ethers';
|
|
2
|
-
/**
|
|
3
|
-
* Encodes a numeric value as a 32-byte hex string.
|
|
4
|
-
* @param value - Numeric value to encode.
|
|
5
|
-
* @returns 32-byte hex string representation of the value.
|
|
6
|
-
*/
|
|
7
|
-
export const encodeNumber = (value) => toBeHex(value, 32);
|
|
8
|
-
/**
|
|
9
|
-
* Encodes dynamic bytes without the struct offset prefix.
|
|
10
|
-
*/
|
|
11
|
-
export const encodeRawBytes = (value) => concat([
|
|
12
|
-
encodeNumber(dataLength(value)),
|
|
13
|
-
zeroPadBytes(value, Math.ceil(dataLength(value) / 32) * 32),
|
|
14
|
-
]);
|
|
15
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/aptos/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/aptos/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EACN,UAAU,EACV,OAAO,EACP,YAAY,GACb,MAAM,QAAQ,CAAA;AAEf;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAmB,EAAU,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAgB,EAAU,EAAE,CACzD,MAAM,CAAC;IACL,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC/B,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;CAC5D,CAAC,CAAA"}
|
package/src/aptos/utils.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type BigNumberish,
|
|
3
|
-
type BytesLike,
|
|
4
|
-
concat,
|
|
5
|
-
dataLength,
|
|
6
|
-
toBeHex,
|
|
7
|
-
zeroPadBytes,
|
|
8
|
-
} from 'ethers'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Encodes a numeric value as a 32-byte hex string.
|
|
12
|
-
* @param value - Numeric value to encode.
|
|
13
|
-
* @returns 32-byte hex string representation of the value.
|
|
14
|
-
*/
|
|
15
|
-
export const encodeNumber = (value: BigNumberish): string => toBeHex(value, 32)
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Encodes dynamic bytes without the struct offset prefix.
|
|
19
|
-
*/
|
|
20
|
-
export const encodeRawBytes = (value: BytesLike): string =>
|
|
21
|
-
concat([
|
|
22
|
-
encodeNumber(dataLength(value)),
|
|
23
|
-
zeroPadBytes(value, Math.ceil(dataLength(value) / 32) * 32),
|
|
24
|
-
])
|