@chainlink/ccip-sdk 0.95.0 → 0.97.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/all-chains.d.ts +23 -0
- package/dist/all-chains.d.ts.map +1 -0
- package/dist/all-chains.js +24 -0
- package/dist/all-chains.js.map +1 -0
- package/dist/api/index.d.ts +31 -19
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +46 -25
- package/dist/api/index.js.map +1 -1
- package/dist/api/types.d.ts +24 -30
- package/dist/api/types.d.ts.map +1 -1
- package/dist/aptos/exec.d.ts +2 -2
- package/dist/aptos/exec.d.ts.map +1 -1
- package/dist/aptos/exec.js.map +1 -1
- package/dist/aptos/hasher.d.ts.map +1 -1
- package/dist/aptos/hasher.js +1 -1
- package/dist/aptos/hasher.js.map +1 -1
- package/dist/aptos/index.d.ts +43 -15
- package/dist/aptos/index.d.ts.map +1 -1
- package/dist/aptos/index.js +112 -105
- package/dist/aptos/index.js.map +1 -1
- package/dist/aptos/types.d.ts +2 -19
- package/dist/aptos/types.d.ts.map +1 -1
- package/dist/aptos/types.js +0 -11
- package/dist/aptos/types.js.map +1 -1
- package/dist/chain.d.ts +734 -174
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +216 -31
- package/dist/chain.js.map +1 -1
- package/dist/commits.d.ts +4 -6
- package/dist/commits.d.ts.map +1 -1
- package/dist/commits.js +4 -4
- package/dist/commits.js.map +1 -1
- package/dist/errors/CCIPError.d.ts +33 -4
- package/dist/errors/CCIPError.d.ts.map +1 -1
- package/dist/errors/CCIPError.js +33 -4
- package/dist/errors/CCIPError.js.map +1 -1
- package/dist/errors/codes.d.ts +5 -0
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/errors/codes.js +5 -1
- package/dist/errors/codes.js.map +1 -1
- package/dist/errors/index.d.ts +2 -2
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +2 -2
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/recovery.d.ts.map +1 -1
- package/dist/errors/recovery.js +6 -1
- package/dist/errors/recovery.js.map +1 -1
- package/dist/errors/specialized.d.ts +1702 -121
- package/dist/errors/specialized.d.ts.map +1 -1
- package/dist/errors/specialized.js +1729 -125
- package/dist/errors/specialized.js.map +1 -1
- package/dist/errors/utils.d.ts.map +1 -1
- package/dist/errors/utils.js +0 -1
- package/dist/errors/utils.js.map +1 -1
- package/dist/evm/abi/OffRamp_2_0.d.ts +764 -0
- package/dist/evm/abi/OffRamp_2_0.d.ts.map +1 -0
- package/dist/evm/abi/OffRamp_2_0.js +744 -0
- package/dist/evm/abi/OffRamp_2_0.js.map +1 -0
- package/dist/evm/abi/OnRamp_2_0.d.ts +925 -0
- package/dist/evm/abi/OnRamp_2_0.d.ts.map +1 -0
- package/dist/evm/abi/OnRamp_2_0.js +992 -0
- package/dist/evm/abi/OnRamp_2_0.js.map +1 -0
- package/dist/evm/const.d.ts +12 -2
- package/dist/evm/const.d.ts.map +1 -1
- package/dist/evm/const.js +8 -2
- package/dist/evm/const.js.map +1 -1
- package/dist/evm/errors.d.ts.map +1 -1
- package/dist/evm/errors.js +7 -2
- package/dist/evm/errors.js.map +1 -1
- package/dist/evm/extra-args.d.ts +25 -0
- package/dist/evm/extra-args.d.ts.map +1 -0
- package/dist/evm/extra-args.js +309 -0
- package/dist/evm/extra-args.js.map +1 -0
- package/dist/evm/gas.d.ts.map +1 -1
- package/dist/evm/gas.js +7 -12
- package/dist/evm/gas.js.map +1 -1
- package/dist/evm/hasher.d.ts.map +1 -1
- package/dist/evm/hasher.js +23 -13
- package/dist/evm/hasher.js.map +1 -1
- package/dist/evm/index.d.ts +140 -35
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +306 -226
- package/dist/evm/index.js.map +1 -1
- package/dist/evm/messages.d.ts +59 -5
- package/dist/evm/messages.d.ts.map +1 -1
- package/dist/evm/messages.js +210 -0
- package/dist/evm/messages.js.map +1 -1
- package/dist/evm/offchain.js.map +1 -1
- package/dist/evm/types.d.ts +7 -2
- package/dist/evm/types.d.ts.map +1 -1
- package/dist/evm/types.js +22 -1
- package/dist/evm/types.js.map +1 -1
- package/dist/execution.d.ts +62 -22
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +102 -51
- package/dist/execution.js.map +1 -1
- package/dist/extra-args.d.ts +113 -4
- package/dist/extra-args.d.ts.map +1 -1
- package/dist/extra-args.js +38 -3
- package/dist/extra-args.js.map +1 -1
- package/dist/gas.d.ts +31 -5
- package/dist/gas.d.ts.map +1 -1
- package/dist/gas.js +43 -9
- package/dist/gas.js.map +1 -1
- package/dist/index.d.ts +11 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/requests.d.ts +101 -22
- package/dist/requests.d.ts.map +1 -1
- package/dist/requests.js +115 -24
- package/dist/requests.js.map +1 -1
- package/dist/selectors.d.ts.map +1 -1
- package/dist/selectors.js +24 -0
- package/dist/selectors.js.map +1 -1
- package/dist/shared/bcs-codecs.d.ts +61 -0
- package/dist/shared/bcs-codecs.d.ts.map +1 -0
- package/dist/shared/bcs-codecs.js +102 -0
- package/dist/shared/bcs-codecs.js.map +1 -0
- package/dist/shared/constants.d.ts +3 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +3 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/solana/exec.d.ts +2 -2
- package/dist/solana/exec.d.ts.map +1 -1
- package/dist/solana/exec.js.map +1 -1
- package/dist/solana/index.d.ts +148 -30
- package/dist/solana/index.d.ts.map +1 -1
- package/dist/solana/index.js +137 -44
- package/dist/solana/index.js.map +1 -1
- package/dist/sui/hasher.d.ts.map +1 -1
- package/dist/sui/hasher.js +1 -1
- package/dist/sui/hasher.js.map +1 -1
- package/dist/sui/index.d.ts +49 -19
- package/dist/sui/index.d.ts.map +1 -1
- package/dist/sui/index.js +76 -43
- package/dist/sui/index.js.map +1 -1
- package/dist/sui/manuallyExec/encoder.d.ts +2 -2
- package/dist/sui/manuallyExec/encoder.d.ts.map +1 -1
- package/dist/sui/manuallyExec/encoder.js.map +1 -1
- package/dist/sui/manuallyExec/index.d.ts +2 -2
- package/dist/sui/manuallyExec/index.d.ts.map +1 -1
- package/dist/ton/exec.d.ts +2 -2
- package/dist/ton/exec.d.ts.map +1 -1
- package/dist/ton/exec.js.map +1 -1
- package/dist/ton/index.d.ts +66 -27
- package/dist/ton/index.d.ts.map +1 -1
- package/dist/ton/index.js +172 -47
- package/dist/ton/index.js.map +1 -1
- package/dist/ton/send.d.ts +52 -0
- package/dist/ton/send.d.ts.map +1 -0
- package/dist/ton/send.js +166 -0
- package/dist/ton/send.js.map +1 -0
- package/dist/ton/types.d.ts +2 -2
- package/dist/ton/types.d.ts.map +1 -1
- package/dist/ton/types.js.map +1 -1
- package/dist/types.d.ts +148 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +79 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +92 -7
- package/dist/utils.js.map +1 -1
- package/package.json +16 -11
- package/src/all-chains.ts +26 -0
- package/src/api/index.ts +58 -34
- package/src/api/types.ts +24 -31
- package/src/aptos/exec.ts +2 -2
- package/src/aptos/hasher.ts +1 -1
- package/src/aptos/index.ts +127 -129
- package/src/aptos/types.ts +2 -15
- package/src/chain.ts +837 -191
- package/src/commits.ts +9 -9
- package/src/errors/CCIPError.ts +33 -4
- package/src/errors/codes.ts +5 -1
- package/src/errors/index.ts +2 -1
- package/src/errors/recovery.ts +9 -1
- package/src/errors/specialized.ts +1745 -132
- package/src/errors/utils.ts +0 -1
- package/src/evm/abi/OffRamp_2_0.ts +743 -0
- package/src/evm/abi/OnRamp_2_0.ts +991 -0
- package/src/evm/const.ts +10 -3
- package/src/evm/errors.ts +6 -2
- package/src/evm/extra-args.ts +360 -0
- package/src/evm/gas.ts +14 -13
- package/src/evm/hasher.ts +30 -18
- package/src/evm/index.ts +376 -281
- package/src/evm/messages.ts +323 -11
- package/src/evm/offchain.ts +2 -2
- package/src/evm/types.ts +20 -2
- package/src/execution.ts +126 -71
- package/src/extra-args.ts +118 -4
- package/src/gas.ts +44 -11
- package/src/index.ts +14 -11
- package/src/requests.ts +128 -24
- package/src/selectors.ts +24 -0
- package/src/shared/bcs-codecs.ts +132 -0
- package/src/shared/constants.ts +2 -0
- package/src/solana/exec.ts +4 -4
- package/src/solana/index.ts +170 -82
- package/src/sui/hasher.ts +1 -1
- package/src/sui/index.ts +88 -56
- package/src/sui/manuallyExec/encoder.ts +2 -2
- package/src/sui/manuallyExec/index.ts +2 -2
- package/src/ton/exec.ts +2 -2
- package/src/ton/index.ts +220 -58
- package/src/ton/send.ts +222 -0
- package/src/ton/types.ts +2 -2
- package/src/types.ts +173 -30
- package/src/utils.ts +91 -7
- package/dist/aptos/utils.d.ts +0 -12
- package/dist/aptos/utils.d.ts.map +0 -1
- package/dist/aptos/utils.js +0 -15
- package/dist/aptos/utils.js.map +0 -1
- package/src/aptos/utils.ts +0 -24
package/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,24 +14,33 @@ 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,
|
|
@@ -41,8 +49,8 @@ import {
|
|
|
41
49
|
type CCIPVersion,
|
|
42
50
|
type ChainTransaction,
|
|
43
51
|
type CommitReport,
|
|
52
|
+
type ExecutionInput,
|
|
44
53
|
type ExecutionReceipt,
|
|
45
|
-
type ExecutionReport,
|
|
46
54
|
type ExecutionState,
|
|
47
55
|
type Lane,
|
|
48
56
|
type Log_,
|
|
@@ -59,20 +67,11 @@ import {
|
|
|
59
67
|
parseTypeAndVersion,
|
|
60
68
|
util,
|
|
61
69
|
} from '../utils.ts'
|
|
62
|
-
import { getCcipStateAddress, getOffRampForCcip } from './discovery.ts'
|
|
63
|
-
import { type CommitEvent, streamSuiLogs } from './events.ts'
|
|
64
70
|
import {
|
|
65
71
|
type SuiManuallyExecuteInput,
|
|
66
72
|
type TokenConfig,
|
|
67
73
|
buildManualExecutionPTB,
|
|
68
74
|
} from './manuallyExec/index.ts'
|
|
69
|
-
import {
|
|
70
|
-
deriveObjectID,
|
|
71
|
-
fetchTokenConfigs,
|
|
72
|
-
getLatestPackageId,
|
|
73
|
-
getObjectRef,
|
|
74
|
-
getReceiverModule,
|
|
75
|
-
} from './objects.ts'
|
|
76
75
|
import type { CCIPMessage_V1_6_Sui } from './types.ts'
|
|
77
76
|
|
|
78
77
|
const DEFAULT_GAS_LIMIT = 1000000n
|
|
@@ -125,6 +124,8 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
125
124
|
* Creates a SuiChain instance from an RPC URL.
|
|
126
125
|
* @param url - HTTP or WebSocket endpoint URL for the Sui network.
|
|
127
126
|
* @returns A new SuiChain instance.
|
|
127
|
+
* @throws {@link CCIPDataFormatUnsupportedError} if unable to fetch chain identifier
|
|
128
|
+
* @throws {@link CCIPError} if chain identifier is not supported
|
|
128
129
|
*/
|
|
129
130
|
static async fromUrl(url: string, ctx?: ChainContext): Promise<SuiChain> {
|
|
130
131
|
const client = new SuiClient({ url })
|
|
@@ -208,7 +209,11 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
208
209
|
}
|
|
209
210
|
}
|
|
210
211
|
|
|
211
|
-
/**
|
|
212
|
+
/**
|
|
213
|
+
* {@inheritDoc Chain.getLogs}
|
|
214
|
+
* @throws {@link CCIPLogsAddressRequiredError} if address is not provided
|
|
215
|
+
* @throws {@link CCIPTopicsInvalidError} if topics format is invalid
|
|
216
|
+
*/
|
|
212
217
|
async *getLogs(opts: LogFilter & { versionAsHash?: boolean }) {
|
|
213
218
|
if (!opts.address) throw new CCIPLogsAddressRequiredError()
|
|
214
219
|
|
|
@@ -240,13 +245,16 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
240
245
|
>,
|
|
241
246
|
>(
|
|
242
247
|
request: R,
|
|
243
|
-
|
|
244
|
-
opts?:
|
|
248
|
+
range: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>,
|
|
249
|
+
opts?: Pick<LogFilter, 'page'>,
|
|
245
250
|
): Promise<R['message'][]> {
|
|
246
|
-
return getMessagesInBatch(this, request,
|
|
251
|
+
return getMessagesInBatch(this, request, range, opts)
|
|
247
252
|
}
|
|
248
253
|
|
|
249
|
-
/**
|
|
254
|
+
/**
|
|
255
|
+
* {@inheritDoc Chain.typeAndVersion}
|
|
256
|
+
* @throws {@link CCIPDataFormatUnsupportedError} if view call fails
|
|
257
|
+
*/
|
|
250
258
|
async typeAndVersion(address: string) {
|
|
251
259
|
// requires address to have `::<module>` suffix
|
|
252
260
|
address = await getLatestPackageId(address, this.client)
|
|
@@ -280,7 +288,10 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
280
288
|
return Promise.resolve(onRamp)
|
|
281
289
|
}
|
|
282
290
|
|
|
283
|
-
/**
|
|
291
|
+
/**
|
|
292
|
+
* {@inheritDoc Chain.getRouterForOffRamp}
|
|
293
|
+
* @throws {@link CCIPContractNotRouterError} always (Sui architecture doesn't have separate router)
|
|
294
|
+
*/
|
|
284
295
|
getRouterForOffRamp(offRamp: string, _sourceChainSelector: bigint): Promise<string> {
|
|
285
296
|
throw new CCIPContractNotRouterError(offRamp, 'unknown')
|
|
286
297
|
}
|
|
@@ -305,8 +316,11 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
305
316
|
return Promise.resolve(router)
|
|
306
317
|
}
|
|
307
318
|
|
|
308
|
-
/**
|
|
309
|
-
|
|
319
|
+
/**
|
|
320
|
+
* {@inheritDoc Chain.getOnRampsForOffRamp}
|
|
321
|
+
* @throws {@link CCIPDataFormatUnsupportedError} if view call fails
|
|
322
|
+
*/
|
|
323
|
+
async getOnRampsForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string[]> {
|
|
310
324
|
offRamp = await getLatestPackageId(offRamp, this.client)
|
|
311
325
|
const functionName = 'get_source_chain_config'
|
|
312
326
|
// Preserve module suffix if present, otherwise add it
|
|
@@ -375,15 +389,14 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
375
389
|
const onRampBytes = configBytes.slice(offset, offset + onRampLength)
|
|
376
390
|
|
|
377
391
|
// Decode the address from the onRamp bytes
|
|
378
|
-
return decodeAddress(onRampBytes, networkInfo(sourceChainSelector).family)
|
|
392
|
+
return [decodeAddress(onRampBytes, networkInfo(sourceChainSelector).family)]
|
|
379
393
|
}
|
|
380
394
|
|
|
381
|
-
/**
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
/** {@inheritDoc Chain.getTokenForTokenPool} */
|
|
395
|
+
/**
|
|
396
|
+
* {@inheritDoc Chain.getTokenForTokenPool}
|
|
397
|
+
* @throws {@link CCIPError} if token pool type is invalid or state not found
|
|
398
|
+
* @throws {@link CCIPDataFormatUnsupportedError} if view call fails
|
|
399
|
+
*/
|
|
387
400
|
async getTokenForTokenPool(tokenPool: string): Promise<string> {
|
|
388
401
|
const normalizedTokenPool = normalizeSuiAddress(tokenPool)
|
|
389
402
|
|
|
@@ -481,7 +494,10 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
481
494
|
return coinMetadataAddress
|
|
482
495
|
}
|
|
483
496
|
|
|
484
|
-
/**
|
|
497
|
+
/**
|
|
498
|
+
* {@inheritDoc Chain.getTokenInfo}
|
|
499
|
+
* @throws {@link CCIPError} if token address is invalid or metadata cannot be loaded
|
|
500
|
+
*/
|
|
485
501
|
async getTokenInfo(token: string): Promise<{ symbol: string; decimals: number }> {
|
|
486
502
|
const normalizedTokenAddress = normalizeSuiAddress(token)
|
|
487
503
|
if (!isValidSuiAddress(normalizedTokenAddress)) {
|
|
@@ -558,6 +574,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
558
574
|
* Decodes a CCIP message from a Sui log event.
|
|
559
575
|
* @param log - Log event data.
|
|
560
576
|
* @returns Decoded CCIPMessage or undefined if not valid.
|
|
577
|
+
* @throws {@link CCIPSuiLogInvalidError} if log data format is invalid
|
|
561
578
|
*/
|
|
562
579
|
static decodeMessage(log: Log_): CCIPMessage | undefined {
|
|
563
580
|
const { data } = log
|
|
@@ -585,13 +602,14 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
585
602
|
| (EVMExtraArgsV2 & { _tag: 'EVMExtraArgsV2' })
|
|
586
603
|
| (SVMExtraArgsV1 & { _tag: 'SVMExtraArgsV1' })
|
|
587
604
|
| undefined {
|
|
588
|
-
return
|
|
605
|
+
return decodeMoveExtraArgs(extraArgs)
|
|
589
606
|
}
|
|
590
607
|
|
|
591
608
|
/**
|
|
592
609
|
* Encodes extra arguments for CCIP messages.
|
|
593
610
|
* @param _extraArgs - Extra arguments to encode.
|
|
594
611
|
* @returns Encoded extra arguments as a hex string.
|
|
612
|
+
* @throws {@link CCIPNotImplementedError} always (not yet implemented)
|
|
595
613
|
*/
|
|
596
614
|
static encodeExtraArgs(_extraArgs: ExtraArgs): string {
|
|
597
615
|
throw new CCIPNotImplementedError()
|
|
@@ -672,7 +690,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
672
690
|
* @returns Sui address.
|
|
673
691
|
*/
|
|
674
692
|
static getAddress(bytes: BytesLike | readonly number[]): string {
|
|
675
|
-
return
|
|
693
|
+
return getMoveAddress(bytes)
|
|
676
694
|
}
|
|
677
695
|
|
|
678
696
|
/**
|
|
@@ -716,20 +734,27 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
716
734
|
return Promise.resolve(request.message.tokenAmounts.map(() => undefined))
|
|
717
735
|
}
|
|
718
736
|
|
|
719
|
-
/** {@inheritDoc Chain.
|
|
720
|
-
override
|
|
721
|
-
_opts: Parameters<Chain['
|
|
737
|
+
/** {@inheritDoc Chain.generateUnsignedExecute} */
|
|
738
|
+
override generateUnsignedExecute(
|
|
739
|
+
_opts: Parameters<Chain['generateUnsignedExecute']>[0],
|
|
722
740
|
): Promise<never> {
|
|
723
|
-
return Promise.reject(new CCIPNotImplementedError('SuiChain.
|
|
741
|
+
return Promise.reject(new CCIPNotImplementedError('SuiChain.generateUnsignedExecute'))
|
|
724
742
|
}
|
|
725
743
|
|
|
726
|
-
/**
|
|
727
|
-
|
|
728
|
-
|
|
744
|
+
/**
|
|
745
|
+
* {@inheritDoc Chain.execute}
|
|
746
|
+
* @throws {@link CCIPError} if transaction submission fails
|
|
747
|
+
* @throws {@link CCIPExecTxRevertedError} if transaction reverts
|
|
748
|
+
*/
|
|
749
|
+
async execute(
|
|
750
|
+
opts: Parameters<Chain['execute']>[0] & {
|
|
729
751
|
receiverObjectIds?: string[]
|
|
730
752
|
},
|
|
731
753
|
): Promise<CCIPExecution> {
|
|
732
|
-
|
|
754
|
+
if (!('input' in opts && 'message' in opts.input)) {
|
|
755
|
+
throw new CCIPExecutionReportChainMismatchError('Sui')
|
|
756
|
+
}
|
|
757
|
+
const { input, offRamp } = opts
|
|
733
758
|
const wallet = opts.wallet as Keypair
|
|
734
759
|
|
|
735
760
|
// Discover the CCIP package from the offramp
|
|
@@ -741,20 +766,20 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
741
766
|
this.client,
|
|
742
767
|
ccip,
|
|
743
768
|
ccipObjectRef,
|
|
744
|
-
|
|
769
|
+
input.message.receiver,
|
|
745
770
|
)
|
|
746
771
|
let tokenConfigs: TokenConfig[] = []
|
|
747
|
-
if (
|
|
772
|
+
if (input.message.tokenAmounts.length !== 0) {
|
|
748
773
|
tokenConfigs = await fetchTokenConfigs(
|
|
749
774
|
this.client,
|
|
750
775
|
ccip,
|
|
751
776
|
ccipObjectRef,
|
|
752
|
-
|
|
777
|
+
input.message.tokenAmounts as CCIPMessage<typeof CCIPVersion.V1_6>['tokenAmounts'],
|
|
753
778
|
)
|
|
754
779
|
}
|
|
755
780
|
|
|
756
|
-
const
|
|
757
|
-
executionReport:
|
|
781
|
+
const suiInput: SuiManuallyExecuteInput = {
|
|
782
|
+
executionReport: input as ExecutionInput<CCIPMessage_V1_6_Sui>,
|
|
758
783
|
offrampAddress: offRamp,
|
|
759
784
|
ccipAddress: ccip,
|
|
760
785
|
ccipObjectRef,
|
|
@@ -766,16 +791,16 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
766
791
|
this.logger.info(
|
|
767
792
|
`Overriding Sui Manual Execution receiverObjectIds with: ${opts.receiverObjectIds.join(', ')}`,
|
|
768
793
|
)
|
|
769
|
-
|
|
794
|
+
suiInput.overrideReceiverObjectIds = opts.receiverObjectIds
|
|
770
795
|
}
|
|
771
|
-
const tx = buildManualExecutionPTB(
|
|
796
|
+
const tx = buildManualExecutionPTB(suiInput)
|
|
772
797
|
|
|
773
798
|
// Set gas budget if provided
|
|
774
799
|
if (opts.gasLimit) {
|
|
775
800
|
tx.setGasBudget(opts.gasLimit)
|
|
776
801
|
}
|
|
777
802
|
|
|
778
|
-
this.logger.info(`Executing Sui CCIP
|
|
803
|
+
this.logger.info(`Executing Sui CCIP execute transaction...`)
|
|
779
804
|
// Sign and execute the transaction
|
|
780
805
|
let result: SuiTransactionBlockResponse
|
|
781
806
|
try {
|
|
@@ -790,7 +815,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
790
815
|
} catch (e) {
|
|
791
816
|
throw new CCIPError(
|
|
792
817
|
CCIPErrorCode.TRANSACTION_NOT_FINALIZED,
|
|
793
|
-
`Failed to send Sui
|
|
818
|
+
`Failed to send Sui execute transaction: ${(e as Error).message}`,
|
|
794
819
|
)
|
|
795
820
|
}
|
|
796
821
|
|
|
@@ -838,9 +863,9 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
838
863
|
return Promise.reject(new CCIPNotImplementedError('SuiChain.getRegistryTokenConfig'))
|
|
839
864
|
}
|
|
840
865
|
|
|
841
|
-
/** {@inheritDoc Chain.
|
|
842
|
-
async
|
|
843
|
-
return Promise.reject(new CCIPNotImplementedError('SuiChain.
|
|
866
|
+
/** {@inheritDoc Chain.getTokenPoolConfig} */
|
|
867
|
+
async getTokenPoolConfig(_tokenPool: string): Promise<never> {
|
|
868
|
+
return Promise.reject(new CCIPNotImplementedError('SuiChain.getTokenPoolConfig'))
|
|
844
869
|
}
|
|
845
870
|
|
|
846
871
|
/** {@inheritDoc Chain.getTokenPoolRemotes} */
|
|
@@ -853,7 +878,13 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
853
878
|
return Promise.reject(new CCIPNotImplementedError('SuiChain.getFeeTokens'))
|
|
854
879
|
}
|
|
855
880
|
|
|
856
|
-
/**
|
|
881
|
+
/**
|
|
882
|
+
* Returns a copy of a message, populating missing fields like `extraArgs` with defaults.
|
|
883
|
+
* It's expected to return a message suitable at least for basic token transfers.
|
|
884
|
+
*
|
|
885
|
+
* @param message - AnyMessage (from source), containing at least `receiver`
|
|
886
|
+
* @returns A message suitable for `sendMessage` to this destination chain family
|
|
887
|
+
*/
|
|
857
888
|
static override buildMessageForDest(
|
|
858
889
|
message: Parameters<ChainStatic['buildMessageForDest']>[0],
|
|
859
890
|
): AnyMessage & { extraArgs: SuiExtraArgsV1 } {
|
|
@@ -872,7 +903,8 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
|
|
|
872
903
|
const tokenReceiver =
|
|
873
904
|
message.extraArgs &&
|
|
874
905
|
'tokenReceiver' in message.extraArgs &&
|
|
875
|
-
message.extraArgs.tokenReceiver != null
|
|
906
|
+
message.extraArgs.tokenReceiver != null &&
|
|
907
|
+
typeof message.extraArgs.tokenReceiver === 'string'
|
|
876
908
|
? message.extraArgs.tokenReceiver
|
|
877
909
|
: message.tokenAmounts?.length
|
|
878
910
|
? this.getAddress(message.receiver)
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
import { type Cell, beginCell } from '@ton/core'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { ExecutionInput } from '../types.ts'
|
|
4
4
|
import {
|
|
5
5
|
type CCIPMessage_V1_6_TON,
|
|
6
6
|
MANUALLY_EXECUTE_OPCODE,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
*/
|
|
18
18
|
export function generateUnsignedExecuteReport(
|
|
19
19
|
offRamp: string,
|
|
20
|
-
execReport:
|
|
20
|
+
execReport: ExecutionInput<CCIPMessage_V1_6_TON>,
|
|
21
21
|
opts?: { gasLimit?: number },
|
|
22
22
|
): { to: string; body: Cell } {
|
|
23
23
|
// Serialize the execution report
|