@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/aptos/index.ts
CHANGED
|
@@ -7,16 +7,7 @@ import {
|
|
|
7
7
|
SimpleTransaction,
|
|
8
8
|
TransactionResponseType,
|
|
9
9
|
} from '@aptos-labs/ts-sdk'
|
|
10
|
-
import {
|
|
11
|
-
type BytesLike,
|
|
12
|
-
concat,
|
|
13
|
-
dataSlice,
|
|
14
|
-
getBytes,
|
|
15
|
-
hexlify,
|
|
16
|
-
isBytesLike,
|
|
17
|
-
isHexString,
|
|
18
|
-
zeroPadValue,
|
|
19
|
-
} from 'ethers'
|
|
10
|
+
import { type BytesLike, concat, isBytesLike, isHexString } from 'ethers'
|
|
20
11
|
import { memoize } from 'micro-memoize'
|
|
21
12
|
import type { PickDeep } from 'type-fest'
|
|
22
13
|
|
|
@@ -28,9 +19,11 @@ import {
|
|
|
28
19
|
type TokenPoolRemote,
|
|
29
20
|
Chain,
|
|
30
21
|
} from '../chain.ts'
|
|
22
|
+
import { generateUnsignedExecuteReport } from './exec.ts'
|
|
23
|
+
import { getAptosLeafHasher } from './hasher.ts'
|
|
24
|
+
import { getUserTxByVersion, getVersionTimestamp, streamAptosLogs } from './logs.ts'
|
|
31
25
|
import { generateUnsignedCcipSend, getFee } from './send.ts'
|
|
32
26
|
import {
|
|
33
|
-
CCIPAptosAddressInvalidError,
|
|
34
27
|
CCIPAptosExtraArgsEncodingError,
|
|
35
28
|
CCIPAptosExtraArgsV2RequiredError,
|
|
36
29
|
CCIPAptosLogInvalidError,
|
|
@@ -50,13 +43,14 @@ import {
|
|
|
50
43
|
EVMExtraArgsV2Tag,
|
|
51
44
|
SVMExtraArgsV1Tag,
|
|
52
45
|
} from '../extra-args.ts'
|
|
53
|
-
import {
|
|
54
|
-
type UnsignedAptosTx,
|
|
55
|
-
EVMExtraArgsV2Codec,
|
|
56
|
-
SVMExtraArgsV1Codec,
|
|
57
|
-
isAptosAccount,
|
|
58
|
-
} from './types.ts'
|
|
46
|
+
import { type UnsignedAptosTx, isAptosAccount } from './types.ts'
|
|
59
47
|
import type { LeafHasher } from '../hasher/common.ts'
|
|
48
|
+
import {
|
|
49
|
+
BcsEVMExtraArgsV2Codec,
|
|
50
|
+
BcsSVMExtraArgsV1Codec,
|
|
51
|
+
decodeMoveExtraArgs,
|
|
52
|
+
getMoveAddress,
|
|
53
|
+
} from '../shared/bcs-codecs.ts'
|
|
60
54
|
import { supportedChains } from '../supported-chains.ts'
|
|
61
55
|
import {
|
|
62
56
|
type CCIPExecution,
|
|
@@ -64,8 +58,8 @@ import {
|
|
|
64
58
|
type CCIPRequest,
|
|
65
59
|
type ChainTransaction,
|
|
66
60
|
type CommitReport,
|
|
61
|
+
type ExecutionInput,
|
|
67
62
|
type ExecutionReceipt,
|
|
68
|
-
type ExecutionReport,
|
|
69
63
|
type Lane,
|
|
70
64
|
type Log_,
|
|
71
65
|
type NetworkInfo,
|
|
@@ -78,14 +72,10 @@ import {
|
|
|
78
72
|
decodeAddress,
|
|
79
73
|
decodeOnRampAddress,
|
|
80
74
|
getAddressBytes,
|
|
81
|
-
getDataBytes,
|
|
82
75
|
networkInfo,
|
|
83
76
|
parseTypeAndVersion,
|
|
84
77
|
util,
|
|
85
78
|
} from '../utils.ts'
|
|
86
|
-
import { generateUnsignedExecuteReport } from './exec.ts'
|
|
87
|
-
import { getAptosLeafHasher } from './hasher.ts'
|
|
88
|
-
import { getUserTxByVersion, getVersionTimestamp, streamAptosLogs } from './logs.ts'
|
|
89
79
|
import { getTokenInfo } from './token.ts'
|
|
90
80
|
import type { CCIPMessage_V1_6_EVM } from '../evm/messages.ts'
|
|
91
81
|
import { buildMessageForDest, decodeMessage, getMessagesInBatch } from '../requests.ts'
|
|
@@ -98,13 +88,18 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
98
88
|
static {
|
|
99
89
|
supportedChains[ChainFamily.Aptos] = AptosChain
|
|
100
90
|
}
|
|
91
|
+
/** Chain family identifier for Aptos networks. */
|
|
101
92
|
static readonly family = ChainFamily.Aptos
|
|
93
|
+
/** Native token decimals (8 for APT). */
|
|
102
94
|
static readonly decimals = 8
|
|
103
95
|
|
|
104
96
|
readonly destroy$: Promise<void>
|
|
97
|
+
/** The Aptos SDK provider for blockchain interactions. */
|
|
105
98
|
provider: Aptos
|
|
106
99
|
|
|
100
|
+
/** Retrieves token information for a given token address. */
|
|
107
101
|
getTokenInfo: (token: string) => Promise<TokenInfo>
|
|
102
|
+
/** @internal */
|
|
108
103
|
_getAccountModulesNames: (address: string) => Promise<string[]>
|
|
109
104
|
|
|
110
105
|
/**
|
|
@@ -246,17 +241,17 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
246
241
|
}
|
|
247
242
|
|
|
248
243
|
/** {@inheritDoc Chain.getMessagesInBatch} */
|
|
249
|
-
async getMessagesInBatch<
|
|
244
|
+
override async getMessagesInBatch<
|
|
250
245
|
R extends PickDeep<
|
|
251
246
|
CCIPRequest,
|
|
252
247
|
'lane' | `log.${'topics' | 'address' | 'blockNumber'}` | 'message.sequenceNumber'
|
|
253
248
|
>,
|
|
254
249
|
>(
|
|
255
250
|
request: R,
|
|
256
|
-
|
|
251
|
+
range: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>,
|
|
257
252
|
opts?: { page?: number },
|
|
258
253
|
): Promise<R['message'][]> {
|
|
259
|
-
return getMessagesInBatch(this, request,
|
|
254
|
+
return getMessagesInBatch(this, request, range, opts)
|
|
260
255
|
}
|
|
261
256
|
|
|
262
257
|
/** {@inheritDoc Chain.typeAndVersion} */
|
|
@@ -296,8 +291,8 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
296
291
|
return Promise.resolve(router.split('::')[0] + '::onramp')
|
|
297
292
|
}
|
|
298
293
|
|
|
299
|
-
/** {@inheritDoc Chain.
|
|
300
|
-
async
|
|
294
|
+
/** {@inheritDoc Chain.getOnRampsForOffRamp} */
|
|
295
|
+
async getOnRampsForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string[]> {
|
|
301
296
|
const [sourceChainConfig] = await this.provider.view<[{ on_ramp: string }]>({
|
|
302
297
|
payload: {
|
|
303
298
|
function:
|
|
@@ -305,12 +300,7 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
305
300
|
functionArguments: [sourceChainSelector],
|
|
306
301
|
},
|
|
307
302
|
})
|
|
308
|
-
return decodeAddress(sourceChainConfig.on_ramp, networkInfo(sourceChainSelector).family)
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/** {@inheritDoc Chain.getCommitStoreForOffRamp} */
|
|
312
|
-
getCommitStoreForOffRamp(offRamp: string): Promise<string> {
|
|
313
|
-
return Promise.resolve(offRamp.split('::')[0] + '::offramp')
|
|
303
|
+
return [decodeAddress(sourceChainConfig.on_ramp, networkInfo(sourceChainSelector).family)]
|
|
314
304
|
}
|
|
315
305
|
|
|
316
306
|
/** {@inheritDoc Chain.getTokenForTokenPool} */
|
|
@@ -393,33 +383,7 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
393
383
|
| (EVMExtraArgsV2 & { _tag: 'EVMExtraArgsV2' })
|
|
394
384
|
| (SVMExtraArgsV1 & { _tag: 'SVMExtraArgsV1' })
|
|
395
385
|
| undefined {
|
|
396
|
-
|
|
397
|
-
tag = dataSlice(data, 0, 4)
|
|
398
|
-
switch (tag) {
|
|
399
|
-
case EVMExtraArgsV2Tag: {
|
|
400
|
-
const parsed = EVMExtraArgsV2Codec.parse(getBytes(dataSlice(data, 4)))
|
|
401
|
-
// Aptos serialization of EVMExtraArgsV2: 37 bytes total: 4 tag + 32 LE gasLimit + 1 allowOOOE
|
|
402
|
-
return {
|
|
403
|
-
_tag: 'EVMExtraArgsV2',
|
|
404
|
-
...parsed,
|
|
405
|
-
gasLimit: BigInt(parsed.gasLimit),
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
case SVMExtraArgsV1Tag: {
|
|
409
|
-
const parsed = SVMExtraArgsV1Codec.parse(getBytes(dataSlice(data, 4)))
|
|
410
|
-
// Aptos serialization of SVMExtraArgsV1: 13 bytes total: 4 tag + 8 LE computeUnits
|
|
411
|
-
return {
|
|
412
|
-
_tag: 'SVMExtraArgsV1',
|
|
413
|
-
...parsed,
|
|
414
|
-
computeUnits: BigInt(parsed.computeUnits),
|
|
415
|
-
accountIsWritableBitmap: BigInt(parsed.accountIsWritableBitmap),
|
|
416
|
-
tokenReceiver: decodeAddress(new Uint8Array(parsed.tokenReceiver), ChainFamily.Solana),
|
|
417
|
-
accounts: parsed.accounts.map((account) =>
|
|
418
|
-
decodeAddress(new Uint8Array(account), ChainFamily.Solana),
|
|
419
|
-
),
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
386
|
+
return decodeMoveExtraArgs(extraArgs)
|
|
423
387
|
}
|
|
424
388
|
|
|
425
389
|
/**
|
|
@@ -430,11 +394,11 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
430
394
|
*/
|
|
431
395
|
static encodeExtraArgs(extraArgs: ExtraArgs): string {
|
|
432
396
|
if ('gasLimit' in extraArgs && 'allowOutOfOrderExecution' in extraArgs)
|
|
433
|
-
return concat([EVMExtraArgsV2Tag,
|
|
397
|
+
return concat([EVMExtraArgsV2Tag, BcsEVMExtraArgsV2Codec.serialize(extraArgs).toBytes()])
|
|
434
398
|
else if ('computeUnits' in extraArgs)
|
|
435
399
|
return concat([
|
|
436
400
|
SVMExtraArgsV1Tag,
|
|
437
|
-
|
|
401
|
+
BcsSVMExtraArgsV1Codec.serialize({
|
|
438
402
|
...extraArgs,
|
|
439
403
|
computeUnits: Number(extraArgs.computeUnits),
|
|
440
404
|
tokenReceiver: getAddressBytes(extraArgs.tokenReceiver),
|
|
@@ -498,21 +462,10 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
498
462
|
* Converts bytes to an Aptos address.
|
|
499
463
|
* @param bytes - Bytes to convert.
|
|
500
464
|
* @returns Aptos address (0x-prefixed hex, 32 bytes padded).
|
|
501
|
-
* @throws {@link
|
|
465
|
+
* @throws {@link CCIPDataFormatUnsupportedError} if bytes length exceeds 32
|
|
502
466
|
*/
|
|
503
467
|
static getAddress(bytes: BytesLike | readonly number[]): string {
|
|
504
|
-
|
|
505
|
-
if (Array.isArray(bytes)) bytes = new Uint8Array(bytes)
|
|
506
|
-
if (typeof bytes === 'string' && bytes.startsWith('0x')) {
|
|
507
|
-
const idx = bytes.indexOf('::')
|
|
508
|
-
if (idx > 0) {
|
|
509
|
-
suffix = bytes.slice(idx)
|
|
510
|
-
bytes = bytes.slice(0, idx)
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
bytes = getDataBytes(bytes)
|
|
514
|
-
if (bytes.length > 32) throw new CCIPAptosAddressInvalidError(hexlify(bytes))
|
|
515
|
-
return zeroPadValue(bytes, 32) + suffix
|
|
468
|
+
return getMoveAddress(bytes)
|
|
516
469
|
}
|
|
517
470
|
|
|
518
471
|
/**
|
|
@@ -607,24 +560,29 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
607
560
|
}
|
|
608
561
|
|
|
609
562
|
/**
|
|
610
|
-
* {@inheritDoc Chain.
|
|
563
|
+
* {@inheritDoc Chain.generateUnsignedExecute}
|
|
611
564
|
* @throws {@link CCIPAptosExtraArgsV2RequiredError} if message missing EVMExtraArgsV2 fields
|
|
612
565
|
*/
|
|
613
|
-
async
|
|
566
|
+
async generateUnsignedExecute({
|
|
614
567
|
payer,
|
|
615
|
-
offRamp,
|
|
616
|
-
execReport,
|
|
617
568
|
...opts
|
|
618
|
-
}: Parameters<Chain['
|
|
619
|
-
if (
|
|
569
|
+
}: Parameters<Chain['generateUnsignedExecute']>[0]): Promise<UnsignedAptosTx> {
|
|
570
|
+
if (
|
|
571
|
+
!(
|
|
572
|
+
'input' in opts &&
|
|
573
|
+
'message' in opts.input &&
|
|
574
|
+
'allowOutOfOrderExecution' in opts.input.message &&
|
|
575
|
+
'gasLimit' in opts.input.message
|
|
576
|
+
)
|
|
577
|
+
) {
|
|
620
578
|
throw new CCIPAptosExtraArgsV2RequiredError()
|
|
621
579
|
}
|
|
622
580
|
|
|
623
581
|
const tx = await generateUnsignedExecuteReport(
|
|
624
582
|
this.provider,
|
|
625
583
|
payer,
|
|
626
|
-
offRamp,
|
|
627
|
-
|
|
584
|
+
opts.offRamp,
|
|
585
|
+
opts.input as ExecutionInput<CCIPMessage_V1_6_EVM>,
|
|
628
586
|
opts,
|
|
629
587
|
)
|
|
630
588
|
return {
|
|
@@ -634,16 +592,16 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
634
592
|
}
|
|
635
593
|
|
|
636
594
|
/**
|
|
637
|
-
* {@inheritDoc Chain.
|
|
595
|
+
* {@inheritDoc Chain.execute}
|
|
638
596
|
* @throws {@link CCIPAptosWalletInvalidError} if wallet is not a valid Aptos account
|
|
639
597
|
*/
|
|
640
|
-
async
|
|
598
|
+
async execute(opts: Parameters<Chain['execute']>[0]): Promise<CCIPExecution> {
|
|
641
599
|
const account = opts.wallet
|
|
642
600
|
if (!isAptosAccount(account)) {
|
|
643
601
|
throw new CCIPAptosWalletInvalidError(this.constructor.name, util.inspect(opts.wallet))
|
|
644
602
|
}
|
|
645
603
|
|
|
646
|
-
const unsignedTx = await this.
|
|
604
|
+
const unsignedTx = await this.generateUnsignedExecute({
|
|
647
605
|
...opts,
|
|
648
606
|
payer: account.accountAddress.toString(),
|
|
649
607
|
})
|
|
@@ -670,9 +628,13 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
670
628
|
* @returns Parsed data or undefined.
|
|
671
629
|
*/
|
|
672
630
|
static parse(data: unknown) {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
631
|
+
try {
|
|
632
|
+
if (isBytesLike(data)) {
|
|
633
|
+
const parsedExtraArgs = this.decodeExtraArgs(data)
|
|
634
|
+
if (parsedExtraArgs) return parsedExtraArgs
|
|
635
|
+
}
|
|
636
|
+
} catch {
|
|
637
|
+
// ignore
|
|
676
638
|
}
|
|
677
639
|
}
|
|
678
640
|
|
package/src/aptos/types.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { bcs } from '@mysten/bcs'
|
|
|
8
8
|
import { getBytes } from 'ethers'
|
|
9
9
|
|
|
10
10
|
import type { CCIPMessage_V1_6_EVM } from '../evm/messages.ts'
|
|
11
|
-
import type { ChainFamily,
|
|
11
|
+
import type { ChainFamily, ExecutionInput } from '../types.ts'
|
|
12
12
|
import { getAddressBytes } from '../utils.ts'
|
|
13
13
|
|
|
14
14
|
/** Aptos account type with async transaction signing capability. */
|
|
@@ -31,19 +31,6 @@ export function isAptosAccount(account: unknown): account is AptosAsyncAccount {
|
|
|
31
31
|
)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export const EVMExtraArgsV2Codec = bcs.struct('EVMExtraArgsV2', {
|
|
35
|
-
gasLimit: bcs.u256(),
|
|
36
|
-
allowOutOfOrderExecution: bcs.bool(),
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
export const SVMExtraArgsV1Codec = bcs.struct('SVMExtraArgsV1', {
|
|
40
|
-
computeUnits: bcs.u32(),
|
|
41
|
-
accountIsWritableBitmap: bcs.u64(),
|
|
42
|
-
allowOutOfOrderExecution: bcs.bool(),
|
|
43
|
-
tokenReceiver: bcs.vector(bcs.u8()),
|
|
44
|
-
accounts: bcs.vector(bcs.vector(bcs.u8())),
|
|
45
|
-
})
|
|
46
|
-
|
|
47
34
|
export const ExecutionReportCodec = bcs.struct('ExecutionReport', {
|
|
48
35
|
sourceChainSelector: bcs.u64(),
|
|
49
36
|
messageId: bcs.fixedArray(32, bcs.u8()),
|
|
@@ -74,7 +61,7 @@ export const ExecutionReportCodec = bcs.struct('ExecutionReport', {
|
|
|
74
61
|
* @returns BCS-encoded bytes.
|
|
75
62
|
*/
|
|
76
63
|
export function serializeExecutionReport(
|
|
77
|
-
execReport:
|
|
64
|
+
execReport: ExecutionInput<CCIPMessage_V1_6_EVM>,
|
|
78
65
|
): Uint8Array {
|
|
79
66
|
const message = execReport.message
|
|
80
67
|
return ExecutionReportCodec.serialize({
|