@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/sui/index.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { isValidSuiAddress, isValidTransactionDigest, normalizeSuiAddress } from
|
|
|
7
7
|
import { type BytesLike, dataLength, hexlify, isBytesLike, isHexString } from 'ethers'
|
|
8
8
|
import type { PickDeep, SetOptional } from 'type-fest'
|
|
9
9
|
|
|
10
|
-
import { AptosChain } from '../aptos/index.ts'
|
|
11
10
|
import {
|
|
12
11
|
type ChainContext,
|
|
13
12
|
type ChainStatic,
|
|
@@ -15,39 +14,47 @@ import {
|
|
|
15
14
|
type LogFilter,
|
|
16
15
|
Chain,
|
|
17
16
|
} from '../chain.ts'
|
|
17
|
+
import { getCcipStateAddress, getOffRampForCcip } from './discovery.ts'
|
|
18
|
+
import { type CommitEvent, streamSuiLogs } from './events.ts'
|
|
19
|
+
import { getSuiLeafHasher } from './hasher.ts'
|
|
20
|
+
import {
|
|
21
|
+
deriveObjectID,
|
|
22
|
+
fetchTokenConfigs,
|
|
23
|
+
getLatestPackageId,
|
|
24
|
+
getObjectRef,
|
|
25
|
+
getReceiverModule,
|
|
26
|
+
} from './objects.ts'
|
|
18
27
|
import {
|
|
19
28
|
CCIPContractNotRouterError,
|
|
20
29
|
CCIPDataFormatUnsupportedError,
|
|
21
30
|
CCIPError,
|
|
22
31
|
CCIPErrorCode,
|
|
23
32
|
CCIPExecTxRevertedError,
|
|
24
|
-
|
|
25
|
-
} from '../errors/index.ts'
|
|
26
|
-
import {
|
|
33
|
+
CCIPExecutionReportChainMismatchError,
|
|
27
34
|
CCIPLogsAddressRequiredError,
|
|
35
|
+
CCIPNotImplementedError,
|
|
28
36
|
CCIPSuiLogInvalidError,
|
|
29
37
|
CCIPTopicsInvalidError,
|
|
30
|
-
} from '../errors/
|
|
38
|
+
} from '../errors/index.ts'
|
|
31
39
|
import type { EVMExtraArgsV2, ExtraArgs, SVMExtraArgsV1, SuiExtraArgsV1 } from '../extra-args.ts'
|
|
32
40
|
import type { LeafHasher } from '../hasher/common.ts'
|
|
33
41
|
import { decodeMessage, getMessagesInBatch } from '../requests.ts'
|
|
42
|
+
import { decodeMoveExtraArgs, getMoveAddress } from '../shared/bcs-codecs.ts'
|
|
34
43
|
import { supportedChains } from '../supported-chains.ts'
|
|
35
|
-
import { getSuiLeafHasher } from './hasher.ts'
|
|
36
44
|
import {
|
|
37
45
|
type AnyMessage,
|
|
38
46
|
type CCIPExecution,
|
|
39
47
|
type CCIPMessage,
|
|
40
48
|
type CCIPRequest,
|
|
41
49
|
type CCIPVersion,
|
|
50
|
+
type ChainLog,
|
|
42
51
|
type ChainTransaction,
|
|
43
52
|
type CommitReport,
|
|
53
|
+
type ExecutionInput,
|
|
44
54
|
type ExecutionReceipt,
|
|
45
|
-
type ExecutionReport,
|
|
46
55
|
type ExecutionState,
|
|
47
56
|
type Lane,
|
|
48
|
-
type Log_,
|
|
49
57
|
type NetworkInfo,
|
|
50
|
-
type OffchainTokenData,
|
|
51
58
|
type WithLogger,
|
|
52
59
|
ChainFamily,
|
|
53
60
|
} from '../types.ts'
|
|
@@ -59,20 +66,11 @@ import {
|
|
|
59
66
|
parseTypeAndVersion,
|
|
60
67
|
util,
|
|
61
68
|
} from '../utils.ts'
|
|
62
|
-
import { getCcipStateAddress, getOffRampForCcip } from './discovery.ts'
|
|
63
|
-
import { type CommitEvent, streamSuiLogs } from './events.ts'
|
|
64
69
|
import {
|
|
65
70
|
type SuiManuallyExecuteInput,
|
|
66
71
|
type TokenConfig,
|
|
67
72
|
buildManualExecutionPTB,
|
|
68
73
|
} from './manuallyExec/index.ts'
|
|
69
|
-
import {
|
|
70
|
-
deriveObjectID,
|
|
71
|
-
fetchTokenConfigs,
|
|
72
|
-
getLatestPackageId,
|
|
73
|
-
getObjectRef,
|
|
74
|
-
getReceiverModule,
|
|
75
|
-
} from './objects.ts'
|
|
76
74
|
import type { CCIPMessage_V1_6_Sui } from './types.ts'
|
|
77
75
|
|
|
78
76
|
const DEFAULT_GAS_LIMIT = 1000000n
|
|
@@ -182,7 +180,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
182
180
|
})
|
|
183
181
|
|
|
184
182
|
// Extract events from the transaction
|
|
185
|
-
const events:
|
|
183
|
+
const events: ChainLog[] = []
|
|
186
184
|
if (txResponse.events?.length) {
|
|
187
185
|
for (const [i, event] of txResponse.events.entries()) {
|
|
188
186
|
const eventType = event.type
|
|
@@ -246,10 +244,10 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
246
244
|
>,
|
|
247
245
|
>(
|
|
248
246
|
request: R,
|
|
249
|
-
|
|
250
|
-
opts?:
|
|
247
|
+
range: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>,
|
|
248
|
+
opts?: Pick<LogFilter, 'page'>,
|
|
251
249
|
): Promise<R['message'][]> {
|
|
252
|
-
return getMessagesInBatch(this, request,
|
|
250
|
+
return getMessagesInBatch(this, request, range, opts)
|
|
253
251
|
}
|
|
254
252
|
|
|
255
253
|
/**
|
|
@@ -318,10 +316,10 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
318
316
|
}
|
|
319
317
|
|
|
320
318
|
/**
|
|
321
|
-
* {@inheritDoc Chain.
|
|
319
|
+
* {@inheritDoc Chain.getOnRampsForOffRamp}
|
|
322
320
|
* @throws {@link CCIPDataFormatUnsupportedError} if view call fails
|
|
323
321
|
*/
|
|
324
|
-
async
|
|
322
|
+
async getOnRampsForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string[]> {
|
|
325
323
|
offRamp = await getLatestPackageId(offRamp, this.client)
|
|
326
324
|
const functionName = 'get_source_chain_config'
|
|
327
325
|
// Preserve module suffix if present, otherwise add it
|
|
@@ -390,12 +388,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
390
388
|
const onRampBytes = configBytes.slice(offset, offset + onRampLength)
|
|
391
389
|
|
|
392
390
|
// Decode the address from the onRamp bytes
|
|
393
|
-
return decodeAddress(onRampBytes, networkInfo(sourceChainSelector).family)
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/** {@inheritDoc Chain.getCommitStoreForOffRamp} */
|
|
397
|
-
getCommitStoreForOffRamp(offRamp: string): Promise<string> {
|
|
398
|
-
return Promise.resolve(offRamp)
|
|
391
|
+
return [decodeAddress(onRampBytes, networkInfo(sourceChainSelector).family)]
|
|
399
392
|
}
|
|
400
393
|
|
|
401
394
|
/**
|
|
@@ -582,7 +575,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
582
575
|
* @returns Decoded CCIPMessage or undefined if not valid.
|
|
583
576
|
* @throws {@link CCIPSuiLogInvalidError} if log data format is invalid
|
|
584
577
|
*/
|
|
585
|
-
static decodeMessage(log:
|
|
578
|
+
static decodeMessage(log: ChainLog): CCIPMessage | undefined {
|
|
586
579
|
const { data } = log
|
|
587
580
|
if (
|
|
588
581
|
(typeof data !== 'string' || !data.startsWith('{')) &&
|
|
@@ -608,7 +601,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
608
601
|
| (EVMExtraArgsV2 & { _tag: 'EVMExtraArgsV2' })
|
|
609
602
|
| (SVMExtraArgsV1 & { _tag: 'SVMExtraArgsV1' })
|
|
610
603
|
| undefined {
|
|
611
|
-
return
|
|
604
|
+
return decodeMoveExtraArgs(extraArgs)
|
|
612
605
|
}
|
|
613
606
|
|
|
614
607
|
/**
|
|
@@ -628,7 +621,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
628
621
|
* @returns Array of decoded commit reports or undefined.
|
|
629
622
|
*/
|
|
630
623
|
static decodeCommits(
|
|
631
|
-
{ data, topics }: SetOptional<Pick<
|
|
624
|
+
{ data, topics }: SetOptional<Pick<ChainLog, 'data' | 'topics'>, 'topics'>,
|
|
632
625
|
lane?: Lane,
|
|
633
626
|
): CommitReport[] | undefined {
|
|
634
627
|
// Check if this is an CommitReportAccepted event
|
|
@@ -664,7 +657,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
664
657
|
static decodeReceipt({
|
|
665
658
|
data,
|
|
666
659
|
topics,
|
|
667
|
-
}: SetOptional<Pick<
|
|
660
|
+
}: SetOptional<Pick<ChainLog, 'data' | 'topics'>, 'topics'>): ExecutionReceipt | undefined {
|
|
668
661
|
// Check if this is an ExecutionStateChanged event
|
|
669
662
|
if (topics?.[0] && topics[0] !== 'ExecutionStateChanged') return
|
|
670
663
|
|
|
@@ -696,7 +689,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
696
689
|
* @returns Sui address.
|
|
697
690
|
*/
|
|
698
691
|
static getAddress(bytes: BytesLike | readonly number[]): string {
|
|
699
|
-
return
|
|
692
|
+
return getMoveAddress(bytes)
|
|
700
693
|
}
|
|
701
694
|
|
|
702
695
|
/**
|
|
@@ -734,30 +727,27 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
734
727
|
return Promise.reject(new CCIPNotImplementedError('SuiChain.sendMessage'))
|
|
735
728
|
}
|
|
736
729
|
|
|
737
|
-
/** {@inheritDoc Chain.
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
return Promise.resolve(request.message.tokenAmounts.map(() => undefined))
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
/** {@inheritDoc Chain.generateUnsignedExecuteReport} */
|
|
744
|
-
override generateUnsignedExecuteReport(
|
|
745
|
-
_opts: Parameters<Chain['generateUnsignedExecuteReport']>[0],
|
|
730
|
+
/** {@inheritDoc Chain.generateUnsignedExecute} */
|
|
731
|
+
override generateUnsignedExecute(
|
|
732
|
+
_opts: Parameters<Chain['generateUnsignedExecute']>[0],
|
|
746
733
|
): Promise<never> {
|
|
747
|
-
return Promise.reject(new CCIPNotImplementedError('SuiChain.
|
|
734
|
+
return Promise.reject(new CCIPNotImplementedError('SuiChain.generateUnsignedExecute'))
|
|
748
735
|
}
|
|
749
736
|
|
|
750
737
|
/**
|
|
751
|
-
* {@inheritDoc Chain.
|
|
738
|
+
* {@inheritDoc Chain.execute}
|
|
752
739
|
* @throws {@link CCIPError} if transaction submission fails
|
|
753
740
|
* @throws {@link CCIPExecTxRevertedError} if transaction reverts
|
|
754
741
|
*/
|
|
755
|
-
async
|
|
756
|
-
opts: Parameters<Chain['
|
|
742
|
+
async execute(
|
|
743
|
+
opts: Parameters<Chain['execute']>[0] & {
|
|
757
744
|
receiverObjectIds?: string[]
|
|
758
745
|
},
|
|
759
746
|
): Promise<CCIPExecution> {
|
|
760
|
-
|
|
747
|
+
if (!('input' in opts && 'message' in opts.input)) {
|
|
748
|
+
throw new CCIPExecutionReportChainMismatchError('Sui')
|
|
749
|
+
}
|
|
750
|
+
const { input, offRamp } = opts
|
|
761
751
|
const wallet = opts.wallet as Keypair
|
|
762
752
|
|
|
763
753
|
// Discover the CCIP package from the offramp
|
|
@@ -769,20 +759,20 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
769
759
|
this.client,
|
|
770
760
|
ccip,
|
|
771
761
|
ccipObjectRef,
|
|
772
|
-
|
|
762
|
+
input.message.receiver,
|
|
773
763
|
)
|
|
774
764
|
let tokenConfigs: TokenConfig[] = []
|
|
775
|
-
if (
|
|
765
|
+
if (input.message.tokenAmounts.length !== 0) {
|
|
776
766
|
tokenConfigs = await fetchTokenConfigs(
|
|
777
767
|
this.client,
|
|
778
768
|
ccip,
|
|
779
769
|
ccipObjectRef,
|
|
780
|
-
|
|
770
|
+
input.message.tokenAmounts as CCIPMessage<typeof CCIPVersion.V1_6>['tokenAmounts'],
|
|
781
771
|
)
|
|
782
772
|
}
|
|
783
773
|
|
|
784
|
-
const
|
|
785
|
-
executionReport:
|
|
774
|
+
const suiInput: SuiManuallyExecuteInput = {
|
|
775
|
+
executionReport: input as ExecutionInput<CCIPMessage_V1_6_Sui>,
|
|
786
776
|
offrampAddress: offRamp,
|
|
787
777
|
ccipAddress: ccip,
|
|
788
778
|
ccipObjectRef,
|
|
@@ -794,16 +784,16 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
794
784
|
this.logger.info(
|
|
795
785
|
`Overriding Sui Manual Execution receiverObjectIds with: ${opts.receiverObjectIds.join(', ')}`,
|
|
796
786
|
)
|
|
797
|
-
|
|
787
|
+
suiInput.overrideReceiverObjectIds = opts.receiverObjectIds
|
|
798
788
|
}
|
|
799
|
-
const tx = buildManualExecutionPTB(
|
|
789
|
+
const tx = buildManualExecutionPTB(suiInput)
|
|
800
790
|
|
|
801
791
|
// Set gas budget if provided
|
|
802
792
|
if (opts.gasLimit) {
|
|
803
793
|
tx.setGasBudget(opts.gasLimit)
|
|
804
794
|
}
|
|
805
795
|
|
|
806
|
-
this.logger.info(`Executing Sui CCIP
|
|
796
|
+
this.logger.info(`Executing Sui CCIP execute transaction...`)
|
|
807
797
|
// Sign and execute the transaction
|
|
808
798
|
let result: SuiTransactionBlockResponse
|
|
809
799
|
try {
|
|
@@ -818,7 +808,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
818
808
|
} catch (e) {
|
|
819
809
|
throw new CCIPError(
|
|
820
810
|
CCIPErrorCode.TRANSACTION_NOT_FINALIZED,
|
|
821
|
-
`Failed to send Sui
|
|
811
|
+
`Failed to send Sui execute transaction: ${(e as Error).message}`,
|
|
822
812
|
)
|
|
823
813
|
}
|
|
824
814
|
|
|
@@ -881,7 +871,13 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
881
871
|
return Promise.reject(new CCIPNotImplementedError('SuiChain.getFeeTokens'))
|
|
882
872
|
}
|
|
883
873
|
|
|
884
|
-
/**
|
|
874
|
+
/**
|
|
875
|
+
* Returns a copy of a message, populating missing fields like `extraArgs` with defaults.
|
|
876
|
+
* It's expected to return a message suitable at least for basic token transfers.
|
|
877
|
+
*
|
|
878
|
+
* @param message - AnyMessage (from source), containing at least `receiver`
|
|
879
|
+
* @returns A message suitable for `sendMessage` to this destination chain family
|
|
880
|
+
*/
|
|
885
881
|
static override buildMessageForDest(
|
|
886
882
|
message: Parameters<ChainStatic['buildMessageForDest']>[0],
|
|
887
883
|
): AnyMessage & { extraArgs: SuiExtraArgsV1 } {
|
|
@@ -5,7 +5,7 @@ import type { BytesLike } from 'ethers'
|
|
|
5
5
|
|
|
6
6
|
import { CCIPMessageInvalidError } from '../../errors/specialized.ts'
|
|
7
7
|
import { decodeExtraArgs } from '../../extra-args.ts'
|
|
8
|
-
import type { CCIPMessage, CCIPVersion,
|
|
8
|
+
import type { CCIPMessage, CCIPVersion, ExecutionInput } from '../../types.ts'
|
|
9
9
|
import { bytesToBuffer, getAddressBytes, getDataBytes, networkInfo } from '../../utils.ts'
|
|
10
10
|
|
|
11
11
|
const Any2SuiTokenTransferBCS = bcs.struct('Any2SuiTokenTransfer', {
|
|
@@ -39,7 +39,7 @@ const ExecutionReportBCS = bcs.struct('ExecutionReport', {
|
|
|
39
39
|
* @returns Serialized execution report as Uint8Array.
|
|
40
40
|
*/
|
|
41
41
|
export function serializeExecutionReport(
|
|
42
|
-
executionReport:
|
|
42
|
+
executionReport: ExecutionInput<CCIPMessage<typeof CCIPVersion.V1_6>>,
|
|
43
43
|
): Uint8Array {
|
|
44
44
|
const { message, offchainTokenData, proofs } = executionReport
|
|
45
45
|
|
|
@@ -5,7 +5,7 @@ import { Transaction } from '@mysten/sui/transactions'
|
|
|
5
5
|
import { serializeExecutionReport } from './encoder.ts'
|
|
6
6
|
import { CCIPMessageInvalidError } from '../../errors/specialized.ts'
|
|
7
7
|
import { decodeExtraArgs } from '../../extra-args.ts'
|
|
8
|
-
import type {
|
|
8
|
+
import type { ExecutionInput } from '../../types.ts'
|
|
9
9
|
import { networkInfo } from '../../utils.ts'
|
|
10
10
|
import type { CCIPMessage_V1_6_Sui } from '../types.ts'
|
|
11
11
|
|
|
@@ -30,7 +30,7 @@ export type TokenConfig = {
|
|
|
30
30
|
/** Input parameters for building a Sui manual execution transaction. */
|
|
31
31
|
export type SuiManuallyExecuteInput = {
|
|
32
32
|
offrampAddress: string
|
|
33
|
-
executionReport:
|
|
33
|
+
executionReport: ExecutionInput<CCIPMessage_V1_6_Sui>
|
|
34
34
|
ccipAddress: string
|
|
35
35
|
ccipObjectRef: string
|
|
36
36
|
offrampStateObject: string
|
package/src/ton/exec.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { type Cell, beginCell } from '@ton/core'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
MANUALLY_EXECUTE_OPCODE,
|
|
7
|
-
serializeExecutionReport,
|
|
8
|
-
} from './types.ts'
|
|
3
|
+
import type { ExecutionInput } from '../types.ts'
|
|
4
|
+
import { MANUALLY_EXECUTE_OPCODE, serializeExecutionReport } from './types.ts'
|
|
5
|
+
import type { CCIPMessage_V1_6_EVM } from '../evm/messages.ts'
|
|
9
6
|
|
|
10
7
|
/**
|
|
11
8
|
* Generates an unsigned execute report payload for the TON OffRamp contract.
|
|
@@ -17,7 +14,7 @@ import {
|
|
|
17
14
|
*/
|
|
18
15
|
export function generateUnsignedExecuteReport(
|
|
19
16
|
offRamp: string,
|
|
20
|
-
execReport:
|
|
17
|
+
execReport: ExecutionInput<CCIPMessage_V1_6_EVM>,
|
|
21
18
|
opts?: { gasLimit?: number },
|
|
22
19
|
): { to: string; body: Cell } {
|
|
23
20
|
// Serialize the execution report
|
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,22 +21,21 @@ 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,
|
|
32
|
+
type ChainLog,
|
|
31
33
|
type ChainTransaction,
|
|
32
34
|
type CommitReport,
|
|
35
|
+
type ExecutionInput,
|
|
33
36
|
type ExecutionReceipt,
|
|
34
|
-
type ExecutionReport,
|
|
35
37
|
type Lane,
|
|
36
|
-
type Log_,
|
|
37
38
|
type NetworkInfo,
|
|
38
|
-
type OffchainTokenData,
|
|
39
39
|
type WithLogger,
|
|
40
40
|
CCIPVersion,
|
|
41
41
|
ChainFamily,
|
|
@@ -49,10 +49,11 @@ import {
|
|
|
49
49
|
parseTypeAndVersion,
|
|
50
50
|
sleep,
|
|
51
51
|
} from '../utils.ts'
|
|
52
|
-
import { generateUnsignedExecuteReport
|
|
52
|
+
import { generateUnsignedExecuteReport } from './exec.ts'
|
|
53
53
|
import { getTONLeafHasher } from './hasher.ts'
|
|
54
|
-
import { type
|
|
54
|
+
import { type UnsignedTONTx, isTONWallet } from './types.ts'
|
|
55
55
|
import { crc32, lookupTxByRawHash, parseJettonContent } from './utils.ts'
|
|
56
|
+
import type { CCIPMessage_V1_6_EVM } from '../evm/messages.ts'
|
|
56
57
|
export type { TONWallet, UnsignedTONTx } from './types.ts'
|
|
57
58
|
|
|
58
59
|
/**
|
|
@@ -307,13 +308,13 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
307
308
|
const compositeHash = `${address.toRawString()}:${tx.lt}:${tx.hash().toString('hex')}`
|
|
308
309
|
const res = {
|
|
309
310
|
hash: compositeHash,
|
|
310
|
-
logs: [] as
|
|
311
|
+
logs: [] as ChainLog[],
|
|
311
312
|
blockNumber: Number(tx.lt), // Note: This is lt (logical time), not block seqno
|
|
312
313
|
timestamp: tx.now,
|
|
313
314
|
from: address.toRawString(),
|
|
314
315
|
tx,
|
|
315
316
|
}
|
|
316
|
-
const logs:
|
|
317
|
+
const logs: ChainLog[] = []
|
|
317
318
|
for (const [index, msg] of tx.outMessages) {
|
|
318
319
|
if (msg.info.type !== 'external-out') continue
|
|
319
320
|
const topics = []
|
|
@@ -349,7 +350,7 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
349
350
|
* @param opts - Log filter options (startBlock/endBlock are interpreted as lt values)
|
|
350
351
|
* @throws {@link CCIPTopicsInvalidError} if topics format is invalid
|
|
351
352
|
*/
|
|
352
|
-
async *getLogs(opts: LogFilter): AsyncIterableIterator<
|
|
353
|
+
async *getLogs(opts: LogFilter): AsyncIterableIterator<ChainLog> {
|
|
353
354
|
let topics
|
|
354
355
|
if (opts.topics?.length) {
|
|
355
356
|
if (!opts.topics.every((topic) => typeof topic === 'string'))
|
|
@@ -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)
|
|
@@ -595,7 +587,7 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
595
587
|
}: {
|
|
596
588
|
data: unknown
|
|
597
589
|
topics?: readonly string[]
|
|
598
|
-
}):
|
|
590
|
+
}): CCIPMessage_V1_6_EVM | undefined {
|
|
599
591
|
if (!data || typeof data !== 'string') return
|
|
600
592
|
if (topics?.length && topics[0] !== crc32('CCIPMessageSent')) return
|
|
601
593
|
|
|
@@ -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,14 +656,11 @@ 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()
|
|
674
|
-
const tokenAmounts:
|
|
663
|
+
const tokenAmounts: CCIPMessage_V1_6_EVM['tokenAmounts'] = [] // TODO: FIXME: parse when implemented
|
|
675
664
|
|
|
676
665
|
// Load feeToken (inline address in body)
|
|
677
666
|
const feeToken = bodySlice.loadMaybeAddress()?.toString() ?? ''
|
|
@@ -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.
|
|
@@ -1110,27 +1099,28 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
1110
1099
|
throw new CCIPTransactionNotFoundError(seqno.toString())
|
|
1111
1100
|
}
|
|
1112
1101
|
|
|
1113
|
-
/** {@inheritDoc Chain.getOffchainTokenData} */
|
|
1114
|
-
getOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]> {
|
|
1115
|
-
return Promise.resolve(request.message.tokenAmounts.map(() => undefined))
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
1102
|
/**
|
|
1119
|
-
* {@inheritDoc Chain.
|
|
1103
|
+
* {@inheritDoc Chain.generateUnsignedExecute}
|
|
1120
1104
|
* @throws {@link CCIPExtraArgsInvalidError} if extra args are not EVMExtraArgsV2 format
|
|
1121
1105
|
*/
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1106
|
+
generateUnsignedExecute(
|
|
1107
|
+
opts: Parameters<Chain['generateUnsignedExecute']>[0],
|
|
1108
|
+
): Promise<UnsignedTONTx> {
|
|
1109
|
+
if (
|
|
1110
|
+
!(
|
|
1111
|
+
'input' in opts &&
|
|
1112
|
+
'message' in opts.input &&
|
|
1113
|
+
'allowOutOfOrderExecution' in opts.input.message &&
|
|
1114
|
+
'gasLimit' in opts.input.message
|
|
1115
|
+
)
|
|
1116
|
+
) {
|
|
1128
1117
|
throw new CCIPExtraArgsInvalidError('TON')
|
|
1129
1118
|
}
|
|
1119
|
+
const { offRamp, input } = opts
|
|
1130
1120
|
|
|
1131
|
-
const unsigned =
|
|
1121
|
+
const unsigned = generateUnsignedExecuteReport(
|
|
1132
1122
|
offRamp,
|
|
1133
|
-
|
|
1123
|
+
input as ExecutionInput<CCIPMessage_V1_6_EVM>,
|
|
1134
1124
|
opts,
|
|
1135
1125
|
)
|
|
1136
1126
|
|
|
@@ -1141,18 +1131,20 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
1141
1131
|
}
|
|
1142
1132
|
|
|
1143
1133
|
/**
|
|
1144
|
-
* {@inheritDoc Chain.
|
|
1134
|
+
* {@inheritDoc Chain.execute}
|
|
1145
1135
|
* @throws {@link CCIPWalletInvalidError} if wallet is not a valid TON wallet
|
|
1146
1136
|
* @throws {@link CCIPReceiptNotFoundError} if execution receipt not found within timeout
|
|
1147
1137
|
*/
|
|
1148
|
-
async
|
|
1138
|
+
async execute(opts: Parameters<Chain['execute']>[0]): Promise<CCIPExecution> {
|
|
1139
|
+
if (!('input' in opts && 'message' in opts.input))
|
|
1140
|
+
throw new CCIPExecutionReportChainMismatchError('TON')
|
|
1149
1141
|
const { offRamp, wallet } = opts
|
|
1150
1142
|
if (!isTONWallet(wallet)) {
|
|
1151
1143
|
throw new CCIPWalletInvalidError(wallet)
|
|
1152
1144
|
}
|
|
1153
1145
|
const payer = await wallet.getAddress()
|
|
1154
1146
|
|
|
1155
|
-
const { family: _, ...unsigned } = await this.
|
|
1147
|
+
const { family: _, ...unsigned } = await this.generateUnsignedExecute({
|
|
1156
1148
|
...opts,
|
|
1157
1149
|
payer,
|
|
1158
1150
|
})
|
|
@@ -1164,7 +1156,7 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
1164
1156
|
...unsigned,
|
|
1165
1157
|
})
|
|
1166
1158
|
|
|
1167
|
-
const message = opts.
|
|
1159
|
+
const message = opts.input.message as CCIPMessage_V1_6_EVM
|
|
1168
1160
|
for await (const exec of this.getExecutionReceipts({
|
|
1169
1161
|
offRamp,
|
|
1170
1162
|
messageId: message.messageId,
|
package/src/ton/types.ts
CHANGED
|
@@ -2,13 +2,10 @@ import { type Builder, Address, Cell, beginCell } from '@ton/core'
|
|
|
2
2
|
import { toBigInt } from 'ethers'
|
|
3
3
|
|
|
4
4
|
import { CCIPDataFormatUnsupportedError } from '../errors/specialized.ts'
|
|
5
|
-
import type {
|
|
6
|
-
import type { CCIPMessage_V1_6, ChainFamily,
|
|
5
|
+
import type { CCIPMessage_V1_6_EVM } from '../evm/messages.ts'
|
|
6
|
+
import type { CCIPMessage_V1_6, ChainFamily, ExecutionInput } from '../types.ts'
|
|
7
7
|
import { bytesToBuffer } from '../utils.ts'
|
|
8
8
|
|
|
9
|
-
/** TON-specific CCIP v1.6 message type with EVMExtraArgsV2 (GenericExtraArgsV2) */
|
|
10
|
-
export type CCIPMessage_V1_6_TON = CCIPMessage_V1_6 & EVMExtraArgsV2
|
|
11
|
-
|
|
12
9
|
/** Opcode for OffRamp_ManuallyExecute message on TON */
|
|
13
10
|
export const MANUALLY_EXECUTE_OPCODE = 0xa00785cf
|
|
14
11
|
|
|
@@ -83,7 +80,7 @@ function asSnakeData<T>(array: T[], builderFn: (item: T) => Builder): Cell {
|
|
|
83
80
|
* @returns BOC-serialized Cell containing the execution report.
|
|
84
81
|
*/
|
|
85
82
|
export function serializeExecutionReport(
|
|
86
|
-
execReport:
|
|
83
|
+
execReport: ExecutionInput<CCIPMessage_V1_6_EVM>,
|
|
87
84
|
): Builder {
|
|
88
85
|
return beginCell()
|
|
89
86
|
.storeUint(execReport.message.sourceChainSelector, 64)
|
|
@@ -97,7 +94,7 @@ export function serializeExecutionReport(
|
|
|
97
94
|
.storeUint(execReport.proofFlagBits, 256)
|
|
98
95
|
}
|
|
99
96
|
|
|
100
|
-
function serializeMessage(message:
|
|
97
|
+
function serializeMessage(message: CCIPMessage_V1_6_EVM): Builder {
|
|
101
98
|
return beginCell()
|
|
102
99
|
.storeUint(BigInt(message.messageId), 256)
|
|
103
100
|
.storeUint(message.sourceChainSelector, 64)
|