@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/aptos/exec.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Aptos, AccountAddress } from '@aptos-labs/ts-sdk'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { ExecutionInput } from '../types.ts'
|
|
4
4
|
import { serializeExecutionReport } from './types.ts'
|
|
5
5
|
import type { CCIPMessage_V1_6_EVM } from '../evm/messages.ts'
|
|
6
6
|
|
|
@@ -18,7 +18,7 @@ export async function generateUnsignedExecuteReport(
|
|
|
18
18
|
provider: Aptos,
|
|
19
19
|
payer: string,
|
|
20
20
|
offRamp: string,
|
|
21
|
-
execReport:
|
|
21
|
+
execReport: ExecutionInput<CCIPMessage_V1_6_EVM>,
|
|
22
22
|
opts?: { gasLimit?: number },
|
|
23
23
|
) {
|
|
24
24
|
// Prepare proofs as byte arrays
|
package/src/aptos/hasher.ts
CHANGED
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
} from '../errors/index.ts'
|
|
7
7
|
import { decodeExtraArgs } from '../extra-args.ts'
|
|
8
8
|
import { type LeafHasher, LEAF_DOMAIN_SEPARATOR } from '../hasher/common.ts'
|
|
9
|
+
import { encodeNumber, encodeRawBytes } from '../shared/bcs-codecs.ts'
|
|
9
10
|
import { type CCIPMessage, type CCIPMessage_V1_6, CCIPVersion } from '../types.ts'
|
|
10
11
|
import { getAddressBytes, networkInfo } from '../utils.ts'
|
|
11
|
-
import { encodeNumber, encodeRawBytes } from './utils.ts'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Creates a leaf hasher for Aptos CCIP messages.
|
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,26 +43,26 @@ 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,
|
|
63
57
|
type CCIPMessage,
|
|
64
58
|
type CCIPRequest,
|
|
59
|
+
type ChainLog,
|
|
65
60
|
type ChainTransaction,
|
|
66
61
|
type CommitReport,
|
|
62
|
+
type ExecutionInput,
|
|
67
63
|
type ExecutionReceipt,
|
|
68
|
-
type ExecutionReport,
|
|
69
64
|
type Lane,
|
|
70
|
-
type Log_,
|
|
71
65
|
type NetworkInfo,
|
|
72
|
-
type OffchainTokenData,
|
|
73
66
|
type WithLogger,
|
|
74
67
|
ChainFamily,
|
|
75
68
|
} from '../types.ts'
|
|
@@ -78,14 +71,10 @@ import {
|
|
|
78
71
|
decodeAddress,
|
|
79
72
|
decodeOnRampAddress,
|
|
80
73
|
getAddressBytes,
|
|
81
|
-
getDataBytes,
|
|
82
74
|
networkInfo,
|
|
83
75
|
parseTypeAndVersion,
|
|
84
76
|
util,
|
|
85
77
|
} from '../utils.ts'
|
|
86
|
-
import { generateUnsignedExecuteReport } from './exec.ts'
|
|
87
|
-
import { getAptosLeafHasher } from './hasher.ts'
|
|
88
|
-
import { getUserTxByVersion, getVersionTimestamp, streamAptosLogs } from './logs.ts'
|
|
89
78
|
import { getTokenInfo } from './token.ts'
|
|
90
79
|
import type { CCIPMessage_V1_6_EVM } from '../evm/messages.ts'
|
|
91
80
|
import { buildMessageForDest, decodeMessage, getMessagesInBatch } from '../requests.ts'
|
|
@@ -98,13 +87,18 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
98
87
|
static {
|
|
99
88
|
supportedChains[ChainFamily.Aptos] = AptosChain
|
|
100
89
|
}
|
|
90
|
+
/** Chain family identifier for Aptos networks. */
|
|
101
91
|
static readonly family = ChainFamily.Aptos
|
|
92
|
+
/** Native token decimals (8 for APT). */
|
|
102
93
|
static readonly decimals = 8
|
|
103
94
|
|
|
104
95
|
readonly destroy$: Promise<void>
|
|
96
|
+
/** The Aptos SDK provider for blockchain interactions. */
|
|
105
97
|
provider: Aptos
|
|
106
98
|
|
|
99
|
+
/** Retrieves token information for a given token address. */
|
|
107
100
|
getTokenInfo: (token: string) => Promise<TokenInfo>
|
|
101
|
+
/** @internal */
|
|
108
102
|
_getAccountModulesNames: (address: string) => Promise<string[]>
|
|
109
103
|
|
|
110
104
|
/**
|
|
@@ -241,22 +235,22 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
241
235
|
}
|
|
242
236
|
|
|
243
237
|
/** {@inheritDoc Chain.getLogs} */
|
|
244
|
-
async *getLogs(opts: LogFilter & { versionAsHash?: boolean }): AsyncIterableIterator<
|
|
238
|
+
async *getLogs(opts: LogFilter & { versionAsHash?: boolean }): AsyncIterableIterator<ChainLog> {
|
|
245
239
|
yield* streamAptosLogs(this, opts)
|
|
246
240
|
}
|
|
247
241
|
|
|
248
242
|
/** {@inheritDoc Chain.getMessagesInBatch} */
|
|
249
|
-
async getMessagesInBatch<
|
|
243
|
+
override async getMessagesInBatch<
|
|
250
244
|
R extends PickDeep<
|
|
251
245
|
CCIPRequest,
|
|
252
246
|
'lane' | `log.${'topics' | 'address' | 'blockNumber'}` | 'message.sequenceNumber'
|
|
253
247
|
>,
|
|
254
248
|
>(
|
|
255
249
|
request: R,
|
|
256
|
-
|
|
250
|
+
range: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>,
|
|
257
251
|
opts?: { page?: number },
|
|
258
252
|
): Promise<R['message'][]> {
|
|
259
|
-
return getMessagesInBatch(this, request,
|
|
253
|
+
return getMessagesInBatch(this, request, range, opts)
|
|
260
254
|
}
|
|
261
255
|
|
|
262
256
|
/** {@inheritDoc Chain.typeAndVersion} */
|
|
@@ -296,8 +290,8 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
296
290
|
return Promise.resolve(router.split('::')[0] + '::onramp')
|
|
297
291
|
}
|
|
298
292
|
|
|
299
|
-
/** {@inheritDoc Chain.
|
|
300
|
-
async
|
|
293
|
+
/** {@inheritDoc Chain.getOnRampsForOffRamp} */
|
|
294
|
+
async getOnRampsForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string[]> {
|
|
301
295
|
const [sourceChainConfig] = await this.provider.view<[{ on_ramp: string }]>({
|
|
302
296
|
payload: {
|
|
303
297
|
function:
|
|
@@ -305,12 +299,7 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
305
299
|
functionArguments: [sourceChainSelector],
|
|
306
300
|
},
|
|
307
301
|
})
|
|
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')
|
|
302
|
+
return [decodeAddress(sourceChainConfig.on_ramp, networkInfo(sourceChainSelector).family)]
|
|
314
303
|
}
|
|
315
304
|
|
|
316
305
|
/** {@inheritDoc Chain.getTokenForTokenPool} */
|
|
@@ -393,33 +382,7 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
393
382
|
| (EVMExtraArgsV2 & { _tag: 'EVMExtraArgsV2' })
|
|
394
383
|
| (SVMExtraArgsV1 & { _tag: 'SVMExtraArgsV1' })
|
|
395
384
|
| 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
|
-
}
|
|
385
|
+
return decodeMoveExtraArgs(extraArgs)
|
|
423
386
|
}
|
|
424
387
|
|
|
425
388
|
/**
|
|
@@ -430,11 +393,11 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
430
393
|
*/
|
|
431
394
|
static encodeExtraArgs(extraArgs: ExtraArgs): string {
|
|
432
395
|
if ('gasLimit' in extraArgs && 'allowOutOfOrderExecution' in extraArgs)
|
|
433
|
-
return concat([EVMExtraArgsV2Tag,
|
|
396
|
+
return concat([EVMExtraArgsV2Tag, BcsEVMExtraArgsV2Codec.serialize(extraArgs).toBytes()])
|
|
434
397
|
else if ('computeUnits' in extraArgs)
|
|
435
398
|
return concat([
|
|
436
399
|
SVMExtraArgsV1Tag,
|
|
437
|
-
|
|
400
|
+
BcsSVMExtraArgsV1Codec.serialize({
|
|
438
401
|
...extraArgs,
|
|
439
402
|
computeUnits: Number(extraArgs.computeUnits),
|
|
440
403
|
tokenReceiver: getAddressBytes(extraArgs.tokenReceiver),
|
|
@@ -451,7 +414,7 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
451
414
|
* @returns Array of CommitReport or undefined if not valid.
|
|
452
415
|
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
453
416
|
*/
|
|
454
|
-
static decodeCommits({ data }: Pick<
|
|
417
|
+
static decodeCommits({ data }: Pick<ChainLog, 'data'>, lane?: Lane): CommitReport[] | undefined {
|
|
455
418
|
if (!data || typeof data != 'object') throw new CCIPAptosLogInvalidError(data)
|
|
456
419
|
const data_ = data as {
|
|
457
420
|
blessed_merkle_roots: unknown[] | undefined
|
|
@@ -485,7 +448,7 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
485
448
|
* @returns ExecutionReceipt or undefined if not valid.
|
|
486
449
|
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
487
450
|
*/
|
|
488
|
-
static decodeReceipt({ data }: Pick<
|
|
451
|
+
static decodeReceipt({ data }: Pick<ChainLog, 'data'>): ExecutionReceipt | undefined {
|
|
489
452
|
if (!data || typeof data != 'object') throw new CCIPAptosLogInvalidError(data)
|
|
490
453
|
const data_ = data as { message_id: string; state: number }
|
|
491
454
|
if (!data_.message_id || !data_.state) return
|
|
@@ -498,21 +461,10 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
498
461
|
* Converts bytes to an Aptos address.
|
|
499
462
|
* @param bytes - Bytes to convert.
|
|
500
463
|
* @returns Aptos address (0x-prefixed hex, 32 bytes padded).
|
|
501
|
-
* @throws {@link
|
|
464
|
+
* @throws {@link CCIPDataFormatUnsupportedError} if bytes length exceeds 32
|
|
502
465
|
*/
|
|
503
466
|
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
|
|
467
|
+
return getMoveAddress(bytes)
|
|
516
468
|
}
|
|
517
469
|
|
|
518
470
|
/**
|
|
@@ -600,31 +552,30 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
600
552
|
return (await this.getMessagesInTx(await this.getTransaction(hash)))[0]!
|
|
601
553
|
}
|
|
602
554
|
|
|
603
|
-
/** {@inheritDoc Chain.getOffchainTokenData} */
|
|
604
|
-
getOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]> {
|
|
605
|
-
// default offchain token data
|
|
606
|
-
return Promise.resolve(request.message.tokenAmounts.map(() => undefined))
|
|
607
|
-
}
|
|
608
|
-
|
|
609
555
|
/**
|
|
610
|
-
* {@inheritDoc Chain.
|
|
556
|
+
* {@inheritDoc Chain.generateUnsignedExecute}
|
|
611
557
|
* @throws {@link CCIPAptosExtraArgsV2RequiredError} if message missing EVMExtraArgsV2 fields
|
|
612
558
|
*/
|
|
613
|
-
async
|
|
559
|
+
async generateUnsignedExecute({
|
|
614
560
|
payer,
|
|
615
|
-
offRamp,
|
|
616
|
-
execReport,
|
|
617
561
|
...opts
|
|
618
|
-
}: Parameters<Chain['
|
|
619
|
-
if (
|
|
562
|
+
}: Parameters<Chain['generateUnsignedExecute']>[0]): Promise<UnsignedAptosTx> {
|
|
563
|
+
if (
|
|
564
|
+
!(
|
|
565
|
+
'input' in opts &&
|
|
566
|
+
'message' in opts.input &&
|
|
567
|
+
'allowOutOfOrderExecution' in opts.input.message &&
|
|
568
|
+
'gasLimit' in opts.input.message
|
|
569
|
+
)
|
|
570
|
+
) {
|
|
620
571
|
throw new CCIPAptosExtraArgsV2RequiredError()
|
|
621
572
|
}
|
|
622
573
|
|
|
623
574
|
const tx = await generateUnsignedExecuteReport(
|
|
624
575
|
this.provider,
|
|
625
576
|
payer,
|
|
626
|
-
offRamp,
|
|
627
|
-
|
|
577
|
+
opts.offRamp,
|
|
578
|
+
opts.input as ExecutionInput<CCIPMessage_V1_6_EVM>,
|
|
628
579
|
opts,
|
|
629
580
|
)
|
|
630
581
|
return {
|
|
@@ -634,16 +585,16 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
634
585
|
}
|
|
635
586
|
|
|
636
587
|
/**
|
|
637
|
-
* {@inheritDoc Chain.
|
|
588
|
+
* {@inheritDoc Chain.execute}
|
|
638
589
|
* @throws {@link CCIPAptosWalletInvalidError} if wallet is not a valid Aptos account
|
|
639
590
|
*/
|
|
640
|
-
async
|
|
591
|
+
async execute(opts: Parameters<Chain['execute']>[0]): Promise<CCIPExecution> {
|
|
641
592
|
const account = opts.wallet
|
|
642
593
|
if (!isAptosAccount(account)) {
|
|
643
594
|
throw new CCIPAptosWalletInvalidError(this.constructor.name, util.inspect(opts.wallet))
|
|
644
595
|
}
|
|
645
596
|
|
|
646
|
-
const unsignedTx = await this.
|
|
597
|
+
const unsignedTx = await this.generateUnsignedExecute({
|
|
647
598
|
...opts,
|
|
648
599
|
payer: account.accountAddress.toString(),
|
|
649
600
|
})
|
|
@@ -670,9 +621,13 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
670
621
|
* @returns Parsed data or undefined.
|
|
671
622
|
*/
|
|
672
623
|
static parse(data: unknown) {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
624
|
+
try {
|
|
625
|
+
if (isBytesLike(data)) {
|
|
626
|
+
const parsedExtraArgs = this.decodeExtraArgs(data)
|
|
627
|
+
if (parsedExtraArgs) return parsedExtraArgs
|
|
628
|
+
}
|
|
629
|
+
} catch {
|
|
630
|
+
// ignore
|
|
676
631
|
}
|
|
677
632
|
}
|
|
678
633
|
|
package/src/aptos/logs.ts
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
CCIPLogsWatchRequiresStartError,
|
|
16
16
|
CCIPTopicsInvalidError,
|
|
17
17
|
} from '../errors/index.ts'
|
|
18
|
-
import type {
|
|
18
|
+
import type { ChainLog } from '../types.ts'
|
|
19
19
|
import { sleep } from '../utils.ts'
|
|
20
20
|
|
|
21
21
|
const DEFAULT_POLL_INTERVAL = 5e3
|
|
@@ -241,7 +241,7 @@ async function* fetchEventsBackward(
|
|
|
241
241
|
export async function* streamAptosLogs(
|
|
242
242
|
ctx: { provider: Aptos },
|
|
243
243
|
opts: LogFilter & { versionAsHash?: boolean },
|
|
244
|
-
): AsyncGenerator<
|
|
244
|
+
): AsyncGenerator<ChainLog> {
|
|
245
245
|
const limit = 100
|
|
246
246
|
if (!opts.address || !opts.address.includes('::')) throw new CCIPAptosAddressModuleRequiredError()
|
|
247
247
|
if (opts.topics?.length !== 1 || typeof opts.topics[0] !== 'string')
|
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({
|