@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.
Files changed (247) hide show
  1. package/README.md +12 -9
  2. package/dist/api/index.d.ts +21 -8
  3. package/dist/api/index.d.ts.map +1 -1
  4. package/dist/api/index.js +42 -13
  5. package/dist/api/index.js.map +1 -1
  6. package/dist/api/types.d.ts +0 -2
  7. package/dist/api/types.d.ts.map +1 -1
  8. package/dist/aptos/exec.d.ts +2 -2
  9. package/dist/aptos/exec.d.ts.map +1 -1
  10. package/dist/aptos/exec.js.map +1 -1
  11. package/dist/aptos/hasher.d.ts.map +1 -1
  12. package/dist/aptos/hasher.js +1 -1
  13. package/dist/aptos/hasher.js.map +1 -1
  14. package/dist/aptos/index.d.ts +17 -16
  15. package/dist/aptos/index.d.ts.map +1 -1
  16. package/dist/aptos/index.js +42 -73
  17. package/dist/aptos/index.js.map +1 -1
  18. package/dist/aptos/logs.d.ts +2 -2
  19. package/dist/aptos/logs.d.ts.map +1 -1
  20. package/dist/aptos/types.d.ts +2 -19
  21. package/dist/aptos/types.d.ts.map +1 -1
  22. package/dist/aptos/types.js +0 -11
  23. package/dist/aptos/types.js.map +1 -1
  24. package/dist/chain.d.ts +538 -158
  25. package/dist/chain.d.ts.map +1 -1
  26. package/dist/chain.js +132 -19
  27. package/dist/chain.js.map +1 -1
  28. package/dist/commits.d.ts +4 -6
  29. package/dist/commits.d.ts.map +1 -1
  30. package/dist/commits.js +4 -4
  31. package/dist/commits.js.map +1 -1
  32. package/dist/errors/CCIPError.d.ts +33 -4
  33. package/dist/errors/CCIPError.d.ts.map +1 -1
  34. package/dist/errors/CCIPError.js +33 -4
  35. package/dist/errors/CCIPError.js.map +1 -1
  36. package/dist/errors/codes.d.ts +3 -0
  37. package/dist/errors/codes.d.ts.map +1 -1
  38. package/dist/errors/codes.js +3 -1
  39. package/dist/errors/codes.js.map +1 -1
  40. package/dist/errors/index.d.ts +4 -4
  41. package/dist/errors/index.d.ts.map +1 -1
  42. package/dist/errors/index.js +4 -4
  43. package/dist/errors/index.js.map +1 -1
  44. package/dist/errors/recovery.d.ts.map +1 -1
  45. package/dist/errors/recovery.js +4 -1
  46. package/dist/errors/recovery.js.map +1 -1
  47. package/dist/errors/specialized.d.ts +1695 -120
  48. package/dist/errors/specialized.d.ts.map +1 -1
  49. package/dist/errors/specialized.js +1715 -123
  50. package/dist/errors/specialized.js.map +1 -1
  51. package/dist/errors/utils.d.ts.map +1 -1
  52. package/dist/errors/utils.js +0 -1
  53. package/dist/errors/utils.js.map +1 -1
  54. package/dist/evm/abi/OffRamp_2_0.d.ts +764 -0
  55. package/dist/evm/abi/OffRamp_2_0.d.ts.map +1 -0
  56. package/dist/evm/abi/OffRamp_2_0.js +744 -0
  57. package/dist/evm/abi/OffRamp_2_0.js.map +1 -0
  58. package/dist/evm/abi/OnRamp_2_0.d.ts +925 -0
  59. package/dist/evm/abi/OnRamp_2_0.d.ts.map +1 -0
  60. package/dist/evm/abi/OnRamp_2_0.js +992 -0
  61. package/dist/evm/abi/OnRamp_2_0.js.map +1 -0
  62. package/dist/evm/const.d.ts +12 -2
  63. package/dist/evm/const.d.ts.map +1 -1
  64. package/dist/evm/const.js +8 -2
  65. package/dist/evm/const.js.map +1 -1
  66. package/dist/evm/errors.d.ts.map +1 -1
  67. package/dist/evm/errors.js +7 -2
  68. package/dist/evm/errors.js.map +1 -1
  69. package/dist/evm/extra-args.d.ts.map +1 -1
  70. package/dist/evm/extra-args.js +5 -24
  71. package/dist/evm/extra-args.js.map +1 -1
  72. package/dist/evm/hasher.d.ts.map +1 -1
  73. package/dist/evm/hasher.js +23 -13
  74. package/dist/evm/hasher.js.map +1 -1
  75. package/dist/evm/index.d.ts +73 -16
  76. package/dist/evm/index.d.ts.map +1 -1
  77. package/dist/evm/index.js +241 -146
  78. package/dist/evm/index.js.map +1 -1
  79. package/dist/evm/logs.d.ts +1 -1
  80. package/dist/evm/logs.js +1 -1
  81. package/dist/evm/messages.d.ts +59 -5
  82. package/dist/evm/messages.d.ts.map +1 -1
  83. package/dist/evm/messages.js +210 -0
  84. package/dist/evm/messages.js.map +1 -1
  85. package/dist/evm/offchain.d.ts +1 -14
  86. package/dist/evm/offchain.d.ts.map +1 -1
  87. package/dist/evm/offchain.js +1 -133
  88. package/dist/evm/offchain.js.map +1 -1
  89. package/dist/evm/types.d.ts +7 -2
  90. package/dist/evm/types.d.ts.map +1 -1
  91. package/dist/evm/types.js +22 -1
  92. package/dist/evm/types.js.map +1 -1
  93. package/dist/execution.d.ts +62 -22
  94. package/dist/execution.d.ts.map +1 -1
  95. package/dist/execution.js +98 -61
  96. package/dist/execution.js.map +1 -1
  97. package/dist/extra-args.d.ts +13 -3
  98. package/dist/extra-args.d.ts.map +1 -1
  99. package/dist/extra-args.js +13 -3
  100. package/dist/extra-args.js.map +1 -1
  101. package/dist/gas.d.ts +25 -2
  102. package/dist/gas.d.ts.map +1 -1
  103. package/dist/gas.js +30 -4
  104. package/dist/gas.js.map +1 -1
  105. package/dist/index.d.ts +3 -2
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +2 -1
  108. package/dist/index.js.map +1 -1
  109. package/dist/offchain.d.ts +23 -6
  110. package/dist/offchain.d.ts.map +1 -1
  111. package/dist/offchain.js +92 -17
  112. package/dist/offchain.js.map +1 -1
  113. package/dist/requests.d.ts +85 -14
  114. package/dist/requests.d.ts.map +1 -1
  115. package/dist/requests.js +99 -17
  116. package/dist/requests.js.map +1 -1
  117. package/dist/selectors.d.ts.map +1 -1
  118. package/dist/selectors.js +12 -0
  119. package/dist/selectors.js.map +1 -1
  120. package/dist/shared/bcs-codecs.d.ts +61 -0
  121. package/dist/shared/bcs-codecs.d.ts.map +1 -0
  122. package/dist/shared/bcs-codecs.js +102 -0
  123. package/dist/shared/bcs-codecs.js.map +1 -0
  124. package/dist/shared/constants.d.ts +3 -0
  125. package/dist/shared/constants.d.ts.map +1 -0
  126. package/dist/shared/constants.js +3 -0
  127. package/dist/shared/constants.js.map +1 -0
  128. package/dist/solana/exec.d.ts +2 -2
  129. package/dist/solana/exec.d.ts.map +1 -1
  130. package/dist/solana/exec.js.map +1 -1
  131. package/dist/solana/idl/1.6.0/BASE_TOKEN_POOL.d.ts +1 -1
  132. package/dist/solana/idl/1.6.0/BASE_TOKEN_POOL.js +1 -1
  133. package/dist/solana/idl/1.6.0/BURN_MINT_TOKEN_POOL.d.ts +1 -1
  134. package/dist/solana/idl/1.6.0/BURN_MINT_TOKEN_POOL.js +1 -1
  135. package/dist/solana/idl/1.6.0/CCIP_CCTP_TOKEN_POOL.d.ts +1 -1
  136. package/dist/solana/idl/1.6.0/CCIP_CCTP_TOKEN_POOL.js +1 -1
  137. package/dist/solana/idl/1.6.0/CCIP_COMMON.d.ts +16 -1
  138. package/dist/solana/idl/1.6.0/CCIP_COMMON.d.ts.map +1 -1
  139. package/dist/solana/idl/1.6.0/CCIP_COMMON.js +16 -1
  140. package/dist/solana/idl/1.6.0/CCIP_COMMON.js.map +1 -1
  141. package/dist/solana/idl/1.6.0/CCIP_OFFRAMP.d.ts +1 -1
  142. package/dist/solana/idl/1.6.0/CCIP_OFFRAMP.js +1 -1
  143. package/dist/solana/idl/1.6.0/CCIP_ROUTER.d.ts +1 -1
  144. package/dist/solana/idl/1.6.0/CCIP_ROUTER.js +1 -1
  145. package/dist/solana/index.d.ts +85 -24
  146. package/dist/solana/index.d.ts.map +1 -1
  147. package/dist/solana/index.js +69 -37
  148. package/dist/solana/index.js.map +1 -1
  149. package/dist/solana/offchain.d.ts +1 -13
  150. package/dist/solana/offchain.d.ts.map +1 -1
  151. package/dist/solana/offchain.js +1 -66
  152. package/dist/solana/offchain.js.map +1 -1
  153. package/dist/solana/utils.d.ts +4 -4
  154. package/dist/solana/utils.d.ts.map +1 -1
  155. package/dist/solana/utils.js +1 -1
  156. package/dist/solana/utils.js.map +1 -1
  157. package/dist/sui/hasher.d.ts.map +1 -1
  158. package/dist/sui/hasher.js +1 -1
  159. package/dist/sui/hasher.js.map +1 -1
  160. package/dist/sui/index.d.ts +18 -18
  161. package/dist/sui/index.d.ts.map +1 -1
  162. package/dist/sui/index.js +38 -39
  163. package/dist/sui/index.js.map +1 -1
  164. package/dist/sui/manuallyExec/encoder.d.ts +2 -2
  165. package/dist/sui/manuallyExec/encoder.d.ts.map +1 -1
  166. package/dist/sui/manuallyExec/encoder.js.map +1 -1
  167. package/dist/sui/manuallyExec/index.d.ts +2 -2
  168. package/dist/sui/manuallyExec/index.d.ts.map +1 -1
  169. package/dist/ton/exec.d.ts +3 -3
  170. package/dist/ton/exec.d.ts.map +1 -1
  171. package/dist/ton/exec.js +1 -1
  172. package/dist/ton/exec.js.map +1 -1
  173. package/dist/ton/index.d.ts +14 -22
  174. package/dist/ton/index.d.ts.map +1 -1
  175. package/dist/ton/index.js +26 -35
  176. package/dist/ton/index.js.map +1 -1
  177. package/dist/ton/types.d.ts +3 -5
  178. package/dist/ton/types.d.ts.map +1 -1
  179. package/dist/ton/types.js.map +1 -1
  180. package/dist/types.d.ts +55 -20
  181. package/dist/types.d.ts.map +1 -1
  182. package/dist/types.js +6 -1
  183. package/dist/types.js.map +1 -1
  184. package/dist/utils.d.ts +65 -2
  185. package/dist/utils.d.ts.map +1 -1
  186. package/dist/utils.js +74 -2
  187. package/dist/utils.js.map +1 -1
  188. package/package.json +14 -10
  189. package/src/api/index.ts +53 -17
  190. package/src/api/types.ts +0 -2
  191. package/src/aptos/exec.ts +2 -2
  192. package/src/aptos/hasher.ts +1 -1
  193. package/src/aptos/index.ts +55 -100
  194. package/src/aptos/logs.ts +2 -2
  195. package/src/aptos/types.ts +2 -15
  196. package/src/chain.ts +594 -171
  197. package/src/commits.ts +9 -9
  198. package/src/errors/CCIPError.ts +33 -4
  199. package/src/errors/codes.ts +3 -1
  200. package/src/errors/index.ts +4 -0
  201. package/src/errors/recovery.ts +7 -1
  202. package/src/errors/specialized.ts +1726 -130
  203. package/src/errors/utils.ts +0 -1
  204. package/src/evm/abi/OffRamp_2_0.ts +743 -0
  205. package/src/evm/abi/OnRamp_2_0.ts +991 -0
  206. package/src/evm/const.ts +10 -3
  207. package/src/evm/errors.ts +6 -2
  208. package/src/evm/extra-args.ts +4 -21
  209. package/src/evm/hasher.ts +30 -18
  210. package/src/evm/index.ts +314 -176
  211. package/src/evm/logs.ts +1 -1
  212. package/src/evm/messages.ts +323 -11
  213. package/src/evm/offchain.ts +2 -191
  214. package/src/evm/types.ts +20 -2
  215. package/src/execution.ts +125 -86
  216. package/src/extra-args.ts +13 -3
  217. package/src/gas.ts +29 -3
  218. package/src/index.ts +10 -3
  219. package/src/offchain.ts +125 -28
  220. package/src/requests.ts +114 -19
  221. package/src/selectors.ts +12 -0
  222. package/src/shared/bcs-codecs.ts +132 -0
  223. package/src/shared/constants.ts +2 -0
  224. package/src/solana/exec.ts +4 -4
  225. package/src/solana/idl/1.6.0/BASE_TOKEN_POOL.ts +2 -2
  226. package/src/solana/idl/1.6.0/BURN_MINT_TOKEN_POOL.ts +2 -2
  227. package/src/solana/idl/1.6.0/CCIP_CCTP_TOKEN_POOL.ts +2 -2
  228. package/src/solana/idl/1.6.0/CCIP_COMMON.ts +32 -2
  229. package/src/solana/idl/1.6.0/CCIP_OFFRAMP.ts +2 -2
  230. package/src/solana/idl/1.6.0/CCIP_ROUTER.ts +2 -2
  231. package/src/solana/index.ts +110 -85
  232. package/src/solana/offchain.ts +3 -100
  233. package/src/solana/utils.ts +8 -5
  234. package/src/sui/hasher.ts +1 -1
  235. package/src/sui/index.ts +55 -59
  236. package/src/sui/manuallyExec/encoder.ts +2 -2
  237. package/src/sui/manuallyExec/index.ts +2 -2
  238. package/src/ton/exec.ts +4 -7
  239. package/src/ton/index.ts +45 -53
  240. package/src/ton/types.ts +4 -7
  241. package/src/types.ts +81 -37
  242. package/src/utils.ts +73 -2
  243. package/dist/aptos/utils.d.ts +0 -12
  244. package/dist/aptos/utils.d.ts.map +0 -1
  245. package/dist/aptos/utils.js +0 -15
  246. package/dist/aptos/utils.js.map +0 -1
  247. 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 { ExecutionReport } from '../types.ts'
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: ExecutionReport<CCIPMessage_V1_6_EVM>,
21
+ execReport: ExecutionInput<CCIPMessage_V1_6_EVM>,
22
22
  opts?: { gasLimit?: number },
23
23
  ) {
24
24
  // Prepare proofs as byte arrays
@@ -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.
@@ -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<Log_> {
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
- commit: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>,
250
+ range: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>,
257
251
  opts?: { page?: number },
258
252
  ): Promise<R['message'][]> {
259
- return getMessagesInBatch(this, request, commit, opts)
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.getOnRampForOffRamp} */
300
- async getOnRampForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string> {
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
- const data = getDataBytes(extraArgs),
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, EVMExtraArgsV2Codec.serialize(extraArgs).toBytes()])
396
+ return concat([EVMExtraArgsV2Tag, BcsEVMExtraArgsV2Codec.serialize(extraArgs).toBytes()])
434
397
  else if ('computeUnits' in extraArgs)
435
398
  return concat([
436
399
  SVMExtraArgsV1Tag,
437
- SVMExtraArgsV1Codec.serialize({
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<Log_, 'data'>, lane?: Lane): CommitReport[] | undefined {
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<Log_, 'data'>): ExecutionReceipt | undefined {
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 CCIPAptosAddressInvalidError} if bytes length exceeds 32
464
+ * @throws {@link CCIPDataFormatUnsupportedError} if bytes length exceeds 32
502
465
  */
503
466
  static getAddress(bytes: BytesLike | readonly number[]): string {
504
- let suffix = ''
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.generateUnsignedExecuteReport}
556
+ * {@inheritDoc Chain.generateUnsignedExecute}
611
557
  * @throws {@link CCIPAptosExtraArgsV2RequiredError} if message missing EVMExtraArgsV2 fields
612
558
  */
613
- async generateUnsignedExecuteReport({
559
+ async generateUnsignedExecute({
614
560
  payer,
615
- offRamp,
616
- execReport,
617
561
  ...opts
618
- }: Parameters<Chain['generateUnsignedExecuteReport']>[0]): Promise<UnsignedAptosTx> {
619
- if (!('allowOutOfOrderExecution' in execReport.message && 'gasLimit' in execReport.message)) {
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
- execReport as ExecutionReport<CCIPMessage_V1_6_EVM>,
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.executeReport}
588
+ * {@inheritDoc Chain.execute}
638
589
  * @throws {@link CCIPAptosWalletInvalidError} if wallet is not a valid Aptos account
639
590
  */
640
- async executeReport(opts: Parameters<Chain['executeReport']>[0]): Promise<CCIPExecution> {
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.generateUnsignedExecuteReport({
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
- if (isBytesLike(data)) {
674
- const parsedExtraArgs = this.decodeExtraArgs(data)
675
- if (parsedExtraArgs) return parsedExtraArgs
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 { Log_ } from '../types.ts'
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<Log_> {
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')
@@ -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, ExecutionReport } from '../types.ts'
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: ExecutionReport<CCIPMessage_V1_6_EVM>,
64
+ execReport: ExecutionInput<CCIPMessage_V1_6_EVM>,
78
65
  ): Uint8Array {
79
66
  const message = execReport.message
80
67
  return ExecutionReportCodec.serialize({