@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.
Files changed (217) hide show
  1. package/README.md +2 -2
  2. package/dist/all-chains.d.ts +23 -0
  3. package/dist/all-chains.d.ts.map +1 -0
  4. package/dist/all-chains.js +24 -0
  5. package/dist/all-chains.js.map +1 -0
  6. package/dist/api/index.d.ts +31 -19
  7. package/dist/api/index.d.ts.map +1 -1
  8. package/dist/api/index.js +46 -25
  9. package/dist/api/index.js.map +1 -1
  10. package/dist/api/types.d.ts +24 -30
  11. package/dist/api/types.d.ts.map +1 -1
  12. package/dist/aptos/exec.d.ts +2 -2
  13. package/dist/aptos/exec.d.ts.map +1 -1
  14. package/dist/aptos/exec.js.map +1 -1
  15. package/dist/aptos/hasher.d.ts.map +1 -1
  16. package/dist/aptos/hasher.js +1 -1
  17. package/dist/aptos/hasher.js.map +1 -1
  18. package/dist/aptos/index.d.ts +43 -15
  19. package/dist/aptos/index.d.ts.map +1 -1
  20. package/dist/aptos/index.js +112 -105
  21. package/dist/aptos/index.js.map +1 -1
  22. package/dist/aptos/types.d.ts +2 -19
  23. package/dist/aptos/types.d.ts.map +1 -1
  24. package/dist/aptos/types.js +0 -11
  25. package/dist/aptos/types.js.map +1 -1
  26. package/dist/chain.d.ts +734 -174
  27. package/dist/chain.d.ts.map +1 -1
  28. package/dist/chain.js +216 -31
  29. package/dist/chain.js.map +1 -1
  30. package/dist/commits.d.ts +4 -6
  31. package/dist/commits.d.ts.map +1 -1
  32. package/dist/commits.js +4 -4
  33. package/dist/commits.js.map +1 -1
  34. package/dist/errors/CCIPError.d.ts +33 -4
  35. package/dist/errors/CCIPError.d.ts.map +1 -1
  36. package/dist/errors/CCIPError.js +33 -4
  37. package/dist/errors/CCIPError.js.map +1 -1
  38. package/dist/errors/codes.d.ts +5 -0
  39. package/dist/errors/codes.d.ts.map +1 -1
  40. package/dist/errors/codes.js +5 -1
  41. package/dist/errors/codes.js.map +1 -1
  42. package/dist/errors/index.d.ts +2 -2
  43. package/dist/errors/index.d.ts.map +1 -1
  44. package/dist/errors/index.js +2 -2
  45. package/dist/errors/index.js.map +1 -1
  46. package/dist/errors/recovery.d.ts.map +1 -1
  47. package/dist/errors/recovery.js +6 -1
  48. package/dist/errors/recovery.js.map +1 -1
  49. package/dist/errors/specialized.d.ts +1702 -121
  50. package/dist/errors/specialized.d.ts.map +1 -1
  51. package/dist/errors/specialized.js +1729 -125
  52. package/dist/errors/specialized.js.map +1 -1
  53. package/dist/errors/utils.d.ts.map +1 -1
  54. package/dist/errors/utils.js +0 -1
  55. package/dist/errors/utils.js.map +1 -1
  56. package/dist/evm/abi/OffRamp_2_0.d.ts +764 -0
  57. package/dist/evm/abi/OffRamp_2_0.d.ts.map +1 -0
  58. package/dist/evm/abi/OffRamp_2_0.js +744 -0
  59. package/dist/evm/abi/OffRamp_2_0.js.map +1 -0
  60. package/dist/evm/abi/OnRamp_2_0.d.ts +925 -0
  61. package/dist/evm/abi/OnRamp_2_0.d.ts.map +1 -0
  62. package/dist/evm/abi/OnRamp_2_0.js +992 -0
  63. package/dist/evm/abi/OnRamp_2_0.js.map +1 -0
  64. package/dist/evm/const.d.ts +12 -2
  65. package/dist/evm/const.d.ts.map +1 -1
  66. package/dist/evm/const.js +8 -2
  67. package/dist/evm/const.js.map +1 -1
  68. package/dist/evm/errors.d.ts.map +1 -1
  69. package/dist/evm/errors.js +7 -2
  70. package/dist/evm/errors.js.map +1 -1
  71. package/dist/evm/extra-args.d.ts +25 -0
  72. package/dist/evm/extra-args.d.ts.map +1 -0
  73. package/dist/evm/extra-args.js +309 -0
  74. package/dist/evm/extra-args.js.map +1 -0
  75. package/dist/evm/gas.d.ts.map +1 -1
  76. package/dist/evm/gas.js +7 -12
  77. package/dist/evm/gas.js.map +1 -1
  78. package/dist/evm/hasher.d.ts.map +1 -1
  79. package/dist/evm/hasher.js +23 -13
  80. package/dist/evm/hasher.js.map +1 -1
  81. package/dist/evm/index.d.ts +140 -35
  82. package/dist/evm/index.d.ts.map +1 -1
  83. package/dist/evm/index.js +306 -226
  84. package/dist/evm/index.js.map +1 -1
  85. package/dist/evm/messages.d.ts +59 -5
  86. package/dist/evm/messages.d.ts.map +1 -1
  87. package/dist/evm/messages.js +210 -0
  88. package/dist/evm/messages.js.map +1 -1
  89. package/dist/evm/offchain.js.map +1 -1
  90. package/dist/evm/types.d.ts +7 -2
  91. package/dist/evm/types.d.ts.map +1 -1
  92. package/dist/evm/types.js +22 -1
  93. package/dist/evm/types.js.map +1 -1
  94. package/dist/execution.d.ts +62 -22
  95. package/dist/execution.d.ts.map +1 -1
  96. package/dist/execution.js +102 -51
  97. package/dist/execution.js.map +1 -1
  98. package/dist/extra-args.d.ts +113 -4
  99. package/dist/extra-args.d.ts.map +1 -1
  100. package/dist/extra-args.js +38 -3
  101. package/dist/extra-args.js.map +1 -1
  102. package/dist/gas.d.ts +31 -5
  103. package/dist/gas.d.ts.map +1 -1
  104. package/dist/gas.js +43 -9
  105. package/dist/gas.js.map +1 -1
  106. package/dist/index.d.ts +11 -10
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +8 -8
  109. package/dist/index.js.map +1 -1
  110. package/dist/requests.d.ts +101 -22
  111. package/dist/requests.d.ts.map +1 -1
  112. package/dist/requests.js +115 -24
  113. package/dist/requests.js.map +1 -1
  114. package/dist/selectors.d.ts.map +1 -1
  115. package/dist/selectors.js +24 -0
  116. package/dist/selectors.js.map +1 -1
  117. package/dist/shared/bcs-codecs.d.ts +61 -0
  118. package/dist/shared/bcs-codecs.d.ts.map +1 -0
  119. package/dist/shared/bcs-codecs.js +102 -0
  120. package/dist/shared/bcs-codecs.js.map +1 -0
  121. package/dist/shared/constants.d.ts +3 -0
  122. package/dist/shared/constants.d.ts.map +1 -0
  123. package/dist/shared/constants.js +3 -0
  124. package/dist/shared/constants.js.map +1 -0
  125. package/dist/solana/exec.d.ts +2 -2
  126. package/dist/solana/exec.d.ts.map +1 -1
  127. package/dist/solana/exec.js.map +1 -1
  128. package/dist/solana/index.d.ts +148 -30
  129. package/dist/solana/index.d.ts.map +1 -1
  130. package/dist/solana/index.js +137 -44
  131. package/dist/solana/index.js.map +1 -1
  132. package/dist/sui/hasher.d.ts.map +1 -1
  133. package/dist/sui/hasher.js +1 -1
  134. package/dist/sui/hasher.js.map +1 -1
  135. package/dist/sui/index.d.ts +49 -19
  136. package/dist/sui/index.d.ts.map +1 -1
  137. package/dist/sui/index.js +76 -43
  138. package/dist/sui/index.js.map +1 -1
  139. package/dist/sui/manuallyExec/encoder.d.ts +2 -2
  140. package/dist/sui/manuallyExec/encoder.d.ts.map +1 -1
  141. package/dist/sui/manuallyExec/encoder.js.map +1 -1
  142. package/dist/sui/manuallyExec/index.d.ts +2 -2
  143. package/dist/sui/manuallyExec/index.d.ts.map +1 -1
  144. package/dist/ton/exec.d.ts +2 -2
  145. package/dist/ton/exec.d.ts.map +1 -1
  146. package/dist/ton/exec.js.map +1 -1
  147. package/dist/ton/index.d.ts +66 -27
  148. package/dist/ton/index.d.ts.map +1 -1
  149. package/dist/ton/index.js +172 -47
  150. package/dist/ton/index.js.map +1 -1
  151. package/dist/ton/send.d.ts +52 -0
  152. package/dist/ton/send.d.ts.map +1 -0
  153. package/dist/ton/send.js +166 -0
  154. package/dist/ton/send.js.map +1 -0
  155. package/dist/ton/types.d.ts +2 -2
  156. package/dist/ton/types.d.ts.map +1 -1
  157. package/dist/ton/types.js.map +1 -1
  158. package/dist/types.d.ts +148 -12
  159. package/dist/types.d.ts.map +1 -1
  160. package/dist/types.js +6 -1
  161. package/dist/types.js.map +1 -1
  162. package/dist/utils.d.ts +79 -4
  163. package/dist/utils.d.ts.map +1 -1
  164. package/dist/utils.js +92 -7
  165. package/dist/utils.js.map +1 -1
  166. package/package.json +16 -11
  167. package/src/all-chains.ts +26 -0
  168. package/src/api/index.ts +58 -34
  169. package/src/api/types.ts +24 -31
  170. package/src/aptos/exec.ts +2 -2
  171. package/src/aptos/hasher.ts +1 -1
  172. package/src/aptos/index.ts +127 -129
  173. package/src/aptos/types.ts +2 -15
  174. package/src/chain.ts +837 -191
  175. package/src/commits.ts +9 -9
  176. package/src/errors/CCIPError.ts +33 -4
  177. package/src/errors/codes.ts +5 -1
  178. package/src/errors/index.ts +2 -1
  179. package/src/errors/recovery.ts +9 -1
  180. package/src/errors/specialized.ts +1745 -132
  181. package/src/errors/utils.ts +0 -1
  182. package/src/evm/abi/OffRamp_2_0.ts +743 -0
  183. package/src/evm/abi/OnRamp_2_0.ts +991 -0
  184. package/src/evm/const.ts +10 -3
  185. package/src/evm/errors.ts +6 -2
  186. package/src/evm/extra-args.ts +360 -0
  187. package/src/evm/gas.ts +14 -13
  188. package/src/evm/hasher.ts +30 -18
  189. package/src/evm/index.ts +376 -281
  190. package/src/evm/messages.ts +323 -11
  191. package/src/evm/offchain.ts +2 -2
  192. package/src/evm/types.ts +20 -2
  193. package/src/execution.ts +126 -71
  194. package/src/extra-args.ts +118 -4
  195. package/src/gas.ts +44 -11
  196. package/src/index.ts +14 -11
  197. package/src/requests.ts +128 -24
  198. package/src/selectors.ts +24 -0
  199. package/src/shared/bcs-codecs.ts +132 -0
  200. package/src/shared/constants.ts +2 -0
  201. package/src/solana/exec.ts +4 -4
  202. package/src/solana/index.ts +170 -82
  203. package/src/sui/hasher.ts +1 -1
  204. package/src/sui/index.ts +88 -56
  205. package/src/sui/manuallyExec/encoder.ts +2 -2
  206. package/src/sui/manuallyExec/index.ts +2 -2
  207. package/src/ton/exec.ts +2 -2
  208. package/src/ton/index.ts +220 -58
  209. package/src/ton/send.ts +222 -0
  210. package/src/ton/types.ts +2 -2
  211. package/src/types.ts +173 -30
  212. package/src/utils.ts +91 -7
  213. package/dist/aptos/utils.d.ts +0 -12
  214. package/dist/aptos/utils.d.ts.map +0 -1
  215. package/dist/aptos/utils.js +0 -15
  216. package/dist/aptos/utils.js.map +0 -1
  217. 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
- CCIPNotImplementedError,
25
- } from '../errors/index.ts'
26
- import {
33
+ CCIPExecutionReportChainMismatchError,
27
34
  CCIPLogsAddressRequiredError,
35
+ CCIPNotImplementedError,
28
36
  CCIPSuiLogInvalidError,
29
37
  CCIPTopicsInvalidError,
30
- } from '../errors/specialized.ts'
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
- /** {@inheritDoc Chain.getLogs} */
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
- commit: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>,
244
- opts?: { page?: number },
248
+ range: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>,
249
+ opts?: Pick<LogFilter, 'page'>,
245
250
  ): Promise<R['message'][]> {
246
- return getMessagesInBatch(this, request, commit, opts)
251
+ return getMessagesInBatch(this, request, range, opts)
247
252
  }
248
253
 
249
- /** {@inheritDoc Chain.typeAndVersion} */
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
- /** {@inheritDoc Chain.getRouterForOffRamp} */
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
- /** {@inheritDoc Chain.getOnRampForOffRamp} */
309
- async getOnRampForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string> {
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
- /** {@inheritDoc Chain.getCommitStoreForOffRamp} */
382
- getCommitStoreForOffRamp(offRamp: string): Promise<string> {
383
- return Promise.resolve(offRamp)
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
- /** {@inheritDoc Chain.getTokenInfo} */
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 AptosChain.decodeExtraArgs(extraArgs)
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 AptosChain.getAddress(bytes)
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.generateUnsignedExecuteReport} */
720
- override generateUnsignedExecuteReport(
721
- _opts: Parameters<Chain['generateUnsignedExecuteReport']>[0],
737
+ /** {@inheritDoc Chain.generateUnsignedExecute} */
738
+ override generateUnsignedExecute(
739
+ _opts: Parameters<Chain['generateUnsignedExecute']>[0],
722
740
  ): Promise<never> {
723
- return Promise.reject(new CCIPNotImplementedError('SuiChain.generateUnsignedExecuteReport'))
741
+ return Promise.reject(new CCIPNotImplementedError('SuiChain.generateUnsignedExecute'))
724
742
  }
725
743
 
726
- /** {@inheritDoc Chain.executeReport} */
727
- async executeReport(
728
- opts: Parameters<Chain['executeReport']>[0] & {
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
- const { execReport, offRamp } = opts
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
- execReport.message.receiver,
769
+ input.message.receiver,
745
770
  )
746
771
  let tokenConfigs: TokenConfig[] = []
747
- if (execReport.message.tokenAmounts.length !== 0) {
772
+ if (input.message.tokenAmounts.length !== 0) {
748
773
  tokenConfigs = await fetchTokenConfigs(
749
774
  this.client,
750
775
  ccip,
751
776
  ccipObjectRef,
752
- execReport.message.tokenAmounts as CCIPMessage<typeof CCIPVersion.V1_6>['tokenAmounts'],
777
+ input.message.tokenAmounts as CCIPMessage<typeof CCIPVersion.V1_6>['tokenAmounts'],
753
778
  )
754
779
  }
755
780
 
756
- const input: SuiManuallyExecuteInput = {
757
- executionReport: execReport as ExecutionReport<CCIPMessage_V1_6_Sui>,
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
- input.overrideReceiverObjectIds = opts.receiverObjectIds
794
+ suiInput.overrideReceiverObjectIds = opts.receiverObjectIds
770
795
  }
771
- const tx = buildManualExecutionPTB(input)
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 executeReport transaction...`)
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 executeReport transaction: ${(e as Error).message}`,
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.getTokenPoolConfigs} */
842
- async getTokenPoolConfigs(_tokenPool: string): Promise<never> {
843
- return Promise.reject(new CCIPNotImplementedError('SuiChain.getTokenPoolConfigs'))
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
- /** {@inheritDoc ChainStatic.buildMessageForDest} */
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, ExecutionReport } from '../../types.ts'
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: ExecutionReport<CCIPMessage<typeof CCIPVersion.V1_6>>,
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 { ExecutionReport } from '../../types.ts'
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: ExecutionReport<CCIPMessage_V1_6_Sui>
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 { ExecutionReport } from '../types.ts'
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: ExecutionReport<CCIPMessage_V1_6_TON>,
20
+ execReport: ExecutionInput<CCIPMessage_V1_6_TON>,
21
21
  opts?: { gasLimit?: number },
22
22
  ): { to: string; body: Cell } {
23
23
  // Serialize the execution report