@chainlink/ccip-sdk 0.96.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/dist/api/index.d.ts +17 -8
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +27 -10
- 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 +13 -10
- package/dist/aptos/index.d.ts.map +1 -1
- package/dist/aptos/index.js +42 -68
- 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 +532 -151
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +113 -18
- 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 +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 +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 -14
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +240 -141
- 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 +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 +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/requests.d.ts +85 -14
- package/dist/requests.d.ts.map +1 -1
- package/dist/requests.js +99 -16
- 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/index.d.ts +80 -17
- package/dist/solana/index.d.ts.map +1 -1
- package/dist/solana/index.js +67 -30
- 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 +14 -12
- package/dist/sui/index.d.ts.map +1 -1
- package/dist/sui/index.js +38 -34
- 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 +9 -16
- package/dist/ton/index.d.ts.map +1 -1
- package/dist/ton/index.js +26 -31
- package/dist/ton/index.js.map +1 -1
- 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 +46 -11
- 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 +9 -9
- package/src/api/index.ts +33 -10
- 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 +51 -89
- package/src/aptos/types.ts +2 -15
- package/src/chain.ts +581 -163
- 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 +1 -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 +310 -166
- 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 +125 -86
- package/src/extra-args.ts +13 -3
- package/src/gas.ts +29 -3
- package/src/index.ts +2 -2
- package/src/requests.ts +112 -16
- 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/index.ts +100 -68
- package/src/sui/hasher.ts +1 -1
- package/src/sui/index.ts +50 -47
- 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 +37 -40
- package/src/ton/types.ts +2 -2
- package/src/types.ts +70 -29
- 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/ton/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { generateUnsignedCcipSend, getFee as getFeeImpl } from './send.ts'
|
|
|
12
12
|
import { type ChainContext, type GetBalanceOpts, type LogFilter, Chain } from '../chain.ts'
|
|
13
13
|
import {
|
|
14
14
|
CCIPArgumentInvalidError,
|
|
15
|
+
CCIPExecutionReportChainMismatchError,
|
|
15
16
|
CCIPExtraArgsInvalidError,
|
|
16
17
|
CCIPHttpError,
|
|
17
18
|
CCIPNotImplementedError,
|
|
@@ -20,18 +21,18 @@ import {
|
|
|
20
21
|
CCIPTopicsInvalidError,
|
|
21
22
|
CCIPTransactionNotFoundError,
|
|
22
23
|
CCIPWalletInvalidError,
|
|
23
|
-
} from '../errors/
|
|
24
|
+
} from '../errors/index.ts'
|
|
24
25
|
import { type EVMExtraArgsV2, type ExtraArgs, EVMExtraArgsV2Tag } from '../extra-args.ts'
|
|
25
26
|
import type { LeafHasher } from '../hasher/common.ts'
|
|
26
|
-
import { buildMessageForDest } from '../requests.ts'
|
|
27
|
+
import { buildMessageForDest, getMessagesInBatch } from '../requests.ts'
|
|
27
28
|
import { supportedChains } from '../supported-chains.ts'
|
|
28
29
|
import {
|
|
29
30
|
type CCIPExecution,
|
|
30
31
|
type CCIPRequest,
|
|
31
32
|
type ChainTransaction,
|
|
32
33
|
type CommitReport,
|
|
34
|
+
type ExecutionInput,
|
|
33
35
|
type ExecutionReceipt,
|
|
34
|
-
type ExecutionReport,
|
|
35
36
|
type Lane,
|
|
36
37
|
type Log_,
|
|
37
38
|
type NetworkInfo,
|
|
@@ -49,7 +50,7 @@ import {
|
|
|
49
50
|
parseTypeAndVersion,
|
|
50
51
|
sleep,
|
|
51
52
|
} from '../utils.ts'
|
|
52
|
-
import { generateUnsignedExecuteReport
|
|
53
|
+
import { generateUnsignedExecuteReport } from './exec.ts'
|
|
53
54
|
import { getTONLeafHasher } from './hasher.ts'
|
|
54
55
|
import { type CCIPMessage_V1_6_TON, type UnsignedTONTx, isTONWallet } from './types.ts'
|
|
55
56
|
import { crc32, lookupTxByRawHash, parseJettonContent } from './utils.ts'
|
|
@@ -370,21 +371,18 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
370
371
|
}
|
|
371
372
|
}
|
|
372
373
|
|
|
373
|
-
/**
|
|
374
|
-
* {@inheritDoc Chain.getMessagesInBatch}
|
|
375
|
-
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
376
|
-
*/
|
|
374
|
+
/** {@inheritDoc Chain.getMessagesInBatch} */
|
|
377
375
|
override async getMessagesInBatch<
|
|
378
376
|
R extends PickDeep<
|
|
379
377
|
CCIPRequest,
|
|
380
378
|
'lane' | `log.${'topics' | 'address' | 'blockNumber'}` | 'message.sequenceNumber'
|
|
381
379
|
>,
|
|
382
380
|
>(
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
381
|
+
request: R,
|
|
382
|
+
range: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>,
|
|
383
|
+
opts?: Pick<LogFilter, 'page'>,
|
|
386
384
|
): Promise<R['message'][]> {
|
|
387
|
-
return
|
|
385
|
+
return getMessagesInBatch(this, request, range, opts)
|
|
388
386
|
}
|
|
389
387
|
|
|
390
388
|
/** {@inheritDoc Chain.typeAndVersion} */
|
|
@@ -462,10 +460,10 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
462
460
|
}
|
|
463
461
|
|
|
464
462
|
/**
|
|
465
|
-
* {@inheritDoc Chain.
|
|
463
|
+
* {@inheritDoc Chain.getOnRampsForOffRamp}
|
|
466
464
|
* @throws {@link CCIPSourceChainUnsupportedError} if source chain is not configured
|
|
467
465
|
*/
|
|
468
|
-
async
|
|
466
|
+
async getOnRampsForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string[]> {
|
|
469
467
|
try {
|
|
470
468
|
const offRampContract = this.provider.provider(Address.parse(offRamp))
|
|
471
469
|
|
|
@@ -493,7 +491,7 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
493
491
|
const onRampLength = onRampSlice.loadUint(8)
|
|
494
492
|
onRamp = onRampSlice.loadBuffer(onRampLength)
|
|
495
493
|
}
|
|
496
|
-
return decodeAddress(onRamp, networkInfo(sourceChainSelector).family)
|
|
494
|
+
return [decodeAddress(onRamp, networkInfo(sourceChainSelector).family)]
|
|
497
495
|
} catch (error) {
|
|
498
496
|
if (isTvmError(error) && error.exitCode === 266) {
|
|
499
497
|
throw new CCIPSourceChainUnsupportedError(sourceChainSelector, {
|
|
@@ -504,12 +502,6 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
504
502
|
}
|
|
505
503
|
}
|
|
506
504
|
|
|
507
|
-
/** {@inheritDoc Chain.getCommitStoreForOffRamp} */
|
|
508
|
-
async getCommitStoreForOffRamp(offRamp: string): Promise<string> {
|
|
509
|
-
// TODO: FIXME: check assumption
|
|
510
|
-
return Promise.resolve(offRamp)
|
|
511
|
-
}
|
|
512
|
-
|
|
513
505
|
/**
|
|
514
506
|
* {@inheritDoc Chain.getTokenForTokenPool}
|
|
515
507
|
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
@@ -617,7 +609,7 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
617
609
|
}
|
|
618
610
|
|
|
619
611
|
// Load sender address
|
|
620
|
-
const sender = slice.loadAddress().
|
|
612
|
+
const sender = slice.loadAddress().toRawString()
|
|
621
613
|
|
|
622
614
|
// Load body cell ref
|
|
623
615
|
const bodyCell = slice.loadRef()
|
|
@@ -664,10 +656,7 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
664
656
|
const allowOutOfOrderExecution = extraArgsSlice.loadBit()
|
|
665
657
|
|
|
666
658
|
// Build extraArgs as raw hex matching reference format
|
|
667
|
-
const
|
|
668
|
-
const gasLimitHex = (hasGasLimit ? '8' : '0') + gasLimit.toString(16).padStart(63, '0')
|
|
669
|
-
const oooByte = allowOutOfOrderExecution ? '40' : '00'
|
|
670
|
-
const extraArgs = '0x' + tagHex + gasLimitHex + oooByte
|
|
659
|
+
const extraArgs = '0x' + extraArgsCell.toBoc().toString('hex')
|
|
671
660
|
|
|
672
661
|
// Load tokenAmounts from ref 3
|
|
673
662
|
const _tokenAmountsCell = bodySlice.loadRef()
|
|
@@ -832,7 +821,7 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
832
821
|
* - sourceChainSelector: uint64 (8 bytes)
|
|
833
822
|
* - sequenceNumber: uint64 (8 bytes)
|
|
834
823
|
* - messageId: uint256 (32 bytes)
|
|
835
|
-
* - state: uint8 (1 byte) -
|
|
824
|
+
* - state: uint8 (1 byte) - InProgress=1, Success=2, Failed=3
|
|
836
825
|
*
|
|
837
826
|
* @param log - Log with data field (base64-encoded BOC).
|
|
838
827
|
* @returns ExecutionReceipt or undefined if not valid.
|
|
@@ -1116,21 +1105,27 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
1116
1105
|
}
|
|
1117
1106
|
|
|
1118
1107
|
/**
|
|
1119
|
-
* {@inheritDoc Chain.
|
|
1108
|
+
* {@inheritDoc Chain.generateUnsignedExecute}
|
|
1120
1109
|
* @throws {@link CCIPExtraArgsInvalidError} if extra args are not EVMExtraArgsV2 format
|
|
1121
1110
|
*/
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1111
|
+
generateUnsignedExecute(
|
|
1112
|
+
opts: Parameters<Chain['generateUnsignedExecute']>[0],
|
|
1113
|
+
): Promise<UnsignedTONTx> {
|
|
1114
|
+
if (
|
|
1115
|
+
!(
|
|
1116
|
+
'input' in opts &&
|
|
1117
|
+
'message' in opts.input &&
|
|
1118
|
+
'allowOutOfOrderExecution' in opts.input.message &&
|
|
1119
|
+
'gasLimit' in opts.input.message
|
|
1120
|
+
)
|
|
1121
|
+
) {
|
|
1128
1122
|
throw new CCIPExtraArgsInvalidError('TON')
|
|
1129
1123
|
}
|
|
1124
|
+
const { offRamp, input } = opts
|
|
1130
1125
|
|
|
1131
|
-
const unsigned =
|
|
1126
|
+
const unsigned = generateUnsignedExecuteReport(
|
|
1132
1127
|
offRamp,
|
|
1133
|
-
|
|
1128
|
+
input as ExecutionInput<CCIPMessage_V1_6_TON>,
|
|
1134
1129
|
opts,
|
|
1135
1130
|
)
|
|
1136
1131
|
|
|
@@ -1141,18 +1136,20 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
1141
1136
|
}
|
|
1142
1137
|
|
|
1143
1138
|
/**
|
|
1144
|
-
* {@inheritDoc Chain.
|
|
1139
|
+
* {@inheritDoc Chain.execute}
|
|
1145
1140
|
* @throws {@link CCIPWalletInvalidError} if wallet is not a valid TON wallet
|
|
1146
1141
|
* @throws {@link CCIPReceiptNotFoundError} if execution receipt not found within timeout
|
|
1147
1142
|
*/
|
|
1148
|
-
async
|
|
1143
|
+
async execute(opts: Parameters<Chain['execute']>[0]): Promise<CCIPExecution> {
|
|
1144
|
+
if (!('input' in opts && 'message' in opts.input))
|
|
1145
|
+
throw new CCIPExecutionReportChainMismatchError('TON')
|
|
1149
1146
|
const { offRamp, wallet } = opts
|
|
1150
1147
|
if (!isTONWallet(wallet)) {
|
|
1151
1148
|
throw new CCIPWalletInvalidError(wallet)
|
|
1152
1149
|
}
|
|
1153
1150
|
const payer = await wallet.getAddress()
|
|
1154
1151
|
|
|
1155
|
-
const { family: _, ...unsigned } = await this.
|
|
1152
|
+
const { family: _, ...unsigned } = await this.generateUnsignedExecute({
|
|
1156
1153
|
...opts,
|
|
1157
1154
|
payer,
|
|
1158
1155
|
})
|
|
@@ -1164,7 +1161,7 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
1164
1161
|
...unsigned,
|
|
1165
1162
|
})
|
|
1166
1163
|
|
|
1167
|
-
const message = opts.
|
|
1164
|
+
const message = opts.input.message as CCIPMessage_V1_6_TON
|
|
1168
1165
|
for await (const exec of this.getExecutionReceipts({
|
|
1169
1166
|
offRamp,
|
|
1170
1167
|
messageId: message.messageId,
|
package/src/ton/types.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { toBigInt } from 'ethers'
|
|
|
3
3
|
|
|
4
4
|
import { CCIPDataFormatUnsupportedError } from '../errors/specialized.ts'
|
|
5
5
|
import type { EVMExtraArgsV2 } from '../extra-args.ts'
|
|
6
|
-
import type { CCIPMessage_V1_6, ChainFamily,
|
|
6
|
+
import type { CCIPMessage_V1_6, ChainFamily, ExecutionInput } from '../types.ts'
|
|
7
7
|
import { bytesToBuffer } from '../utils.ts'
|
|
8
8
|
|
|
9
9
|
/** TON-specific CCIP v1.6 message type with EVMExtraArgsV2 (GenericExtraArgsV2) */
|
|
@@ -83,7 +83,7 @@ function asSnakeData<T>(array: T[], builderFn: (item: T) => Builder): Cell {
|
|
|
83
83
|
* @returns BOC-serialized Cell containing the execution report.
|
|
84
84
|
*/
|
|
85
85
|
export function serializeExecutionReport(
|
|
86
|
-
execReport:
|
|
86
|
+
execReport: ExecutionInput<CCIPMessage_V1_6_TON>,
|
|
87
87
|
): Builder {
|
|
88
88
|
return beginCell()
|
|
89
89
|
.storeUint(execReport.message.sourceChainSelector, 64)
|
package/src/types.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { BytesLike, Log } from 'ethers'
|
|
|
3
3
|
|
|
4
4
|
import type { APICCIPRequestMetadata } from './api/types.ts'
|
|
5
5
|
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'
|
|
6
|
+
import type { CCIPMessage_EVM, CCIPMessage_V1_6_EVM, CCIPMessage_V2_0 } from './evm/messages.ts'
|
|
7
7
|
import type { ExtraArgs } from './extra-args.ts'
|
|
8
8
|
import type { CCIPMessage_V1_6_Solana } from './solana/types.ts'
|
|
9
9
|
import type { CCIPMessage_V1_6_Sui } from './sui/types.ts'
|
|
@@ -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,11 +154,11 @@ 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 | CCIPMessage_V1_6_TON
|
|
161
|
+
: CCIPMessage_EVM<V>
|
|
161
162
|
|
|
162
163
|
/**
|
|
163
164
|
* Generic log structure compatible across chain families.
|
|
@@ -204,9 +205,7 @@ export type ChainTransaction = {
|
|
|
204
205
|
export interface CCIPRequest<V extends CCIPVersion = CCIPVersion> {
|
|
205
206
|
/** Lane configuration for this request. */
|
|
206
207
|
lane: Lane<V>
|
|
207
|
-
/** The CCIP message being sent. */
|
|
208
208
|
message: CCIPMessage<V>
|
|
209
|
-
/** Log event from the OnRamp. */
|
|
210
209
|
log: Log_
|
|
211
210
|
/** Transaction that emitted the request. */
|
|
212
211
|
tx: Pick<ChainTransaction, 'hash' | 'logs' | 'blockNumber' | 'timestamp' | 'from' | 'error'>
|
|
@@ -236,22 +235,47 @@ export interface CCIPRequest<V extends CCIPVersion = CCIPVersion> {
|
|
|
236
235
|
}
|
|
237
236
|
|
|
238
237
|
/**
|
|
239
|
-
* Commit report structure from the OffRamp CommitReportAccepted event.
|
|
238
|
+
* OnChain Commit report structure from the OffRamp CommitReportAccepted event.
|
|
240
239
|
*/
|
|
241
240
|
export type CommitReport = AbiParametersToPrimitiveTypes<
|
|
242
241
|
ExtractAbiEvent<typeof OffRamp_1_6_ABI, 'CommitReportAccepted'>['inputs']
|
|
243
242
|
>[0][number]
|
|
244
243
|
|
|
245
244
|
/**
|
|
246
|
-
* CCIP
|
|
245
|
+
* OffChain Verification result for a CCIP v2.0 message, returned by the indexer API.
|
|
247
246
|
*/
|
|
248
|
-
export
|
|
249
|
-
/**
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
|
|
247
|
+
export type VerifierResult = {
|
|
248
|
+
/** Verification data required for destination execution (e.g. signatures). */
|
|
249
|
+
ccvData: BytesLike
|
|
250
|
+
/** Source CCV contract address. */
|
|
251
|
+
sourceAddress: string
|
|
252
|
+
/** Destination CCV contract address. */
|
|
253
|
+
destAddress: string
|
|
254
|
+
/** Timestamp of the attestation (Unix seconds). */
|
|
255
|
+
timestamp?: number
|
|
253
256
|
}
|
|
254
257
|
|
|
258
|
+
/**
|
|
259
|
+
* Verification data for a ccip message (onchain CommitReport, or offchain Verifications)
|
|
260
|
+
*/
|
|
261
|
+
export type CCIPVerifications =
|
|
262
|
+
| {
|
|
263
|
+
/** The commit report data. */
|
|
264
|
+
report: CommitReport
|
|
265
|
+
/** Log event from the commit. */
|
|
266
|
+
log: Log_
|
|
267
|
+
}
|
|
268
|
+
| {
|
|
269
|
+
/** Policy for this request */
|
|
270
|
+
verificationPolicy: {
|
|
271
|
+
optionalCCVs: readonly string[]
|
|
272
|
+
requiredCCVs: readonly string[]
|
|
273
|
+
optionalThreshold: number
|
|
274
|
+
}
|
|
275
|
+
/** Verifications array; one for each requiredCCV is needed for exec */
|
|
276
|
+
verifications: VerifierResult[]
|
|
277
|
+
}
|
|
278
|
+
|
|
255
279
|
/**
|
|
256
280
|
* Enumeration of possible execution states for a CCIP message.
|
|
257
281
|
*/
|
|
@@ -287,7 +311,11 @@ export const MessageStatus = {
|
|
|
287
311
|
Verifying: 'VERIFYING',
|
|
288
312
|
/** Message has been verified by the CCIP network */
|
|
289
313
|
Verified: 'VERIFIED',
|
|
290
|
-
/**
|
|
314
|
+
/**
|
|
315
|
+
* API returned an unrecognized status value.
|
|
316
|
+
* This typically means the CCIP API has new status values that this SDK version
|
|
317
|
+
* doesn't recognize. Consider updating to the latest SDK version.
|
|
318
|
+
*/
|
|
291
319
|
Unknown: 'UNKNOWN',
|
|
292
320
|
} as const
|
|
293
321
|
/** Type representing a CCIP message lifecycle status. */
|
|
@@ -369,18 +397,26 @@ export type OffchainTokenData = { _tag: string; [k: string]: BytesLike } | undef
|
|
|
369
397
|
* }
|
|
370
398
|
* ```
|
|
371
399
|
*/
|
|
372
|
-
export type
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
400
|
+
export type ExecutionInput<M extends CCIPMessage = CCIPMessage> =
|
|
401
|
+
M extends CCIPMessage<typeof CCIPVersion.V2_0>
|
|
402
|
+
? {
|
|
403
|
+
/** encodedMessage as per CCIPv2 codec */
|
|
404
|
+
encodedMessage: M['encodedMessage']
|
|
405
|
+
/** Off-Chain verifications containing verifierResults' ccvData and ccvs addresses */
|
|
406
|
+
verifications: Pick<VerifierResult, 'ccvData' | 'destAddress'>[]
|
|
407
|
+
}
|
|
408
|
+
: {
|
|
409
|
+
/** The CCIP message to execute. */
|
|
410
|
+
message: M
|
|
411
|
+
/** Merkle proofs for the message. */
|
|
412
|
+
proofs: readonly BytesLike[]
|
|
413
|
+
/** Bit flags for proof verification. */
|
|
414
|
+
proofFlagBits: bigint
|
|
415
|
+
/** Merkle root for verification. */
|
|
416
|
+
merkleRoot: string
|
|
417
|
+
/** Offchain token data for each token transfer. */
|
|
418
|
+
offchainTokenData: readonly OffchainTokenData[]
|
|
419
|
+
}
|
|
384
420
|
|
|
385
421
|
/**
|
|
386
422
|
* A message to be sent to another network.
|
|
@@ -396,7 +432,12 @@ export type ExecutionReport<M extends CCIPMessage = CCIPMessage> = {
|
|
|
396
432
|
* ```
|
|
397
433
|
*/
|
|
398
434
|
export type AnyMessage = {
|
|
399
|
-
/**
|
|
435
|
+
/**
|
|
436
|
+
* Receiver address on the destination chain.
|
|
437
|
+
* Must be a valid address for the destination chain family. For instance:
|
|
438
|
+
* - EVM: 20-byte hex (e.g., `0x6d1af98d635d3121286ddda1a0c2d7078b1523ed`)
|
|
439
|
+
* - Solana: Base58 public key (e.g., `7EcDhSYGxXyscszYEp35KHN8vvw3svAuLKTzXwCFLtV`)
|
|
440
|
+
*/
|
|
400
441
|
receiver: BytesLike
|
|
401
442
|
/** Extra arguments for gas limits and other settings. */
|
|
402
443
|
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
|
-
])
|