@chainlink/ccip-sdk 1.1.0 → 1.1.1

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 (47) hide show
  1. package/dist/api/index.d.ts +1 -1
  2. package/dist/api/index.js +1 -1
  3. package/dist/aptos/index.d.ts.map +1 -1
  4. package/dist/aptos/index.js +5 -5
  5. package/dist/aptos/index.js.map +1 -1
  6. package/dist/chain.d.ts +16 -1
  7. package/dist/chain.d.ts.map +1 -1
  8. package/dist/chain.js +18 -0
  9. package/dist/chain.js.map +1 -1
  10. package/dist/evm/index.d.ts.map +1 -1
  11. package/dist/evm/index.js +2 -11
  12. package/dist/evm/index.js.map +1 -1
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/solana/index.d.ts.map +1 -1
  17. package/dist/solana/index.js +3 -2
  18. package/dist/solana/index.js.map +1 -1
  19. package/dist/sui/exec.d.ts +30 -0
  20. package/dist/sui/exec.d.ts.map +1 -0
  21. package/dist/sui/exec.js +92 -0
  22. package/dist/sui/exec.js.map +1 -0
  23. package/dist/sui/index.d.ts +7 -2
  24. package/dist/sui/index.d.ts.map +1 -1
  25. package/dist/sui/index.js +23 -65
  26. package/dist/sui/index.js.map +1 -1
  27. package/dist/sui/manuallyExec/index.d.ts.map +1 -1
  28. package/dist/sui/manuallyExec/index.js +10 -13
  29. package/dist/sui/manuallyExec/index.js.map +1 -1
  30. package/dist/sui/objects.d.ts.map +1 -1
  31. package/dist/sui/objects.js +4 -2
  32. package/dist/sui/objects.js.map +1 -1
  33. package/dist/sui/types.d.ts +9 -1
  34. package/dist/sui/types.d.ts.map +1 -1
  35. package/dist/sui/types.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/api/index.ts +1 -1
  38. package/src/aptos/index.ts +7 -9
  39. package/src/chain.ts +21 -1
  40. package/src/evm/index.ts +1 -9
  41. package/src/index.ts +1 -0
  42. package/src/solana/index.ts +3 -2
  43. package/src/sui/exec.ts +131 -0
  44. package/src/sui/index.ts +33 -98
  45. package/src/sui/manuallyExec/index.ts +11 -17
  46. package/src/sui/objects.ts +4 -2
  47. package/src/sui/types.ts +10 -1
@@ -560,13 +560,11 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
560
560
  payer,
561
561
  ...opts
562
562
  }: Parameters<Chain['generateUnsignedExecute']>[0]): Promise<UnsignedAptosTx> {
563
+ const resolved = await this.resolveExecuteOpts(opts)
563
564
  if (
564
- !(
565
- 'input' in opts &&
566
- 'message' in opts.input &&
567
- 'allowOutOfOrderExecution' in opts.input.message &&
568
- 'gasLimit' in opts.input.message
569
- )
565
+ !('message' in resolved.input) ||
566
+ !('allowOutOfOrderExecution' in resolved.input.message) ||
567
+ !('gasLimit' in resolved.input.message)
570
568
  ) {
571
569
  throw new CCIPAptosExtraArgsV2RequiredError()
572
570
  }
@@ -574,9 +572,9 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
574
572
  const tx = await generateUnsignedExecuteReport(
575
573
  this.provider,
576
574
  payer,
577
- opts.offRamp,
578
- opts.input as ExecutionInput<CCIPMessage_V1_6_EVM>,
579
- opts,
575
+ resolved.offRamp,
576
+ resolved.input as ExecutionInput<CCIPMessage_V1_6_EVM>,
577
+ resolved,
580
578
  )
581
579
  return {
582
580
  family: ChainFamily.Aptos,
package/src/chain.ts CHANGED
@@ -28,6 +28,7 @@ import { getOffchainTokenData } from './offchain.ts'
28
28
  import { getMessagesInTx } from './requests.ts'
29
29
  import { DEFAULT_GAS_LIMIT } from './shared/constants.ts'
30
30
  import type { UnsignedSolanaTx } from './solana/types.ts'
31
+ import type { UnsignedSuiTx } from './sui/types.ts'
31
32
  import type { UnsignedTONTx } from './ton/types.ts'
32
33
  import {
33
34
  type AnyMessage,
@@ -364,7 +365,7 @@ export type UnsignedTx = {
364
365
  [ChainFamily.Solana]: UnsignedSolanaTx
365
366
  [ChainFamily.Aptos]: UnsignedAptosTx
366
367
  [ChainFamily.TON]: UnsignedTONTx
367
- [ChainFamily.Sui]: never // TODO
368
+ [ChainFamily.Sui]: UnsignedSuiTx
368
369
  [ChainFamily.Unknown]: never
369
370
  }
370
371
 
@@ -1011,6 +1012,25 @@ export abstract class Chain<F extends ChainFamily = ChainFamily> {
1011
1012
  return getOffchainTokenData(request, this)
1012
1013
  }
1013
1014
 
1015
+ /**
1016
+ * Resolves {@link ExecuteOpts} that may contain a `messageId` (API shorthand) into the
1017
+ * canonical `{ offRamp, input }` form required by {@link generateUnsignedExecute}.
1018
+ *
1019
+ * When `opts` already contains `input` the method is a no-op and returns it unchanged.
1020
+ * When `opts` contains only a `messageId` it calls `apiClient.getExecutionInput` and merges
1021
+ * the result back with any extra opts fields (e.g. `gasLimit`).
1022
+ *
1023
+ * @throws {@link CCIPApiClientNotAvailableError} if `messageId` is provided but no apiClient
1024
+ */
1025
+ protected async resolveExecuteOpts(
1026
+ opts: ExecuteOpts,
1027
+ ): Promise<Omit<ExecuteOpts, 'messageId'> & { offRamp: string; input: ExecutionInput }> {
1028
+ if ('input' in opts) return opts
1029
+ if (!this.apiClient) throw new CCIPApiClientNotAvailableError()
1030
+ const { offRamp, ...input } = await this.apiClient.getExecutionInput(opts.messageId)
1031
+ return { ...opts, offRamp, input }
1032
+ }
1033
+
1014
1034
  /**
1015
1035
  * Generate unsigned tx to manuallyExecute a message.
1016
1036
  *
package/src/evm/index.ts CHANGED
@@ -37,7 +37,6 @@ import {
37
37
  } from '../chain.ts'
38
38
  import {
39
39
  CCIPAddressInvalidEvmError,
40
- CCIPApiClientNotAvailableError,
41
40
  CCIPBlockNotFoundError,
42
41
  CCIPContractNotRouterError,
43
42
  CCIPContractTypeInvalidError,
@@ -67,7 +66,6 @@ import {
67
66
  type ChainLog,
68
67
  type ChainTransaction,
69
68
  type CommitReport,
70
- type ExecutionInput,
71
69
  type ExecutionReceipt,
72
70
  type ExecutionState,
73
71
  type Lane,
@@ -1140,13 +1138,7 @@ export class EVMChain extends Chain<typeof ChainFamily.EVM> {
1140
1138
  async generateUnsignedExecute(
1141
1139
  opts: Parameters<Chain['generateUnsignedExecute']>[0],
1142
1140
  ): Promise<UnsignedEVMTx> {
1143
- let input: ExecutionInput, offRamp: string
1144
- if (!('input' in opts)) {
1145
- if (!this.apiClient) throw new CCIPApiClientNotAvailableError()
1146
- ;({ offRamp, ...input } = await this.apiClient.getExecutionInput(opts.messageId))
1147
- } else {
1148
- ;({ offRamp, input } = opts)
1149
- }
1141
+ const { offRamp, input } = await this.resolveExecuteOpts(opts)
1150
1142
  if ('verifications' in input) {
1151
1143
  const contract = new Contract(
1152
1144
  offRamp,
package/src/index.ts CHANGED
@@ -100,6 +100,7 @@ export type { UnsignedEVMTx } from './evm/index.ts'
100
100
  import { SolanaChain } from './solana/index.ts'
101
101
  export type { UnsignedSolanaTx } from './solana/index.ts'
102
102
  import { SuiChain } from './sui/index.ts'
103
+ export type { UnsignedSuiTx } from './sui/index.ts'
103
104
  import { TONChain } from './ton/index.ts'
104
105
  export type { UnsignedTONTx } from './ton/index.ts'
105
106
  import { ChainFamily, NetworkType } from './types.ts'
@@ -1118,9 +1118,10 @@ export class SolanaChain extends Chain<typeof ChainFamily.Solana> {
1118
1118
  payer,
1119
1119
  ...opts
1120
1120
  }: Parameters<Chain['generateUnsignedExecute']>[0]): Promise<UnsignedSolanaTx> {
1121
- if (!('input' in opts) || !('message' in opts.input) || !('computeUnits' in opts.input.message))
1121
+ const resolved = await this.resolveExecuteOpts(opts)
1122
+ if (!('message' in resolved.input) || !('computeUnits' in resolved.input.message))
1122
1123
  throw new CCIPExecutionReportChainMismatchError('Solana')
1123
- const { offRamp, input } = opts
1124
+ const { offRamp, input } = resolved
1124
1125
  const execReport_ = input as ExecutionInput<CCIPMessage_V1_6_Solana>
1125
1126
  return generateUnsignedExecuteReport(
1126
1127
  this,
@@ -0,0 +1,131 @@
1
+ import type { SuiClient } from '@mysten/sui/client'
2
+ import type { Keypair } from '@mysten/sui/cryptography'
3
+ import { Transaction } from '@mysten/sui/transactions'
4
+
5
+ import {
6
+ CCIPError,
7
+ CCIPErrorCode,
8
+ CCIPExecTxRevertedError,
9
+ CCIPExecutionReportChainMismatchError,
10
+ } from '../errors/index.ts'
11
+ import { type ExecutionInput, ChainFamily } from '../types.ts'
12
+ import { getCcipStateAddress } from './discovery.ts'
13
+ import {
14
+ type SuiManuallyExecuteInput,
15
+ type TokenConfig,
16
+ buildManualExecutionPTB,
17
+ } from './manuallyExec/index.ts'
18
+ import { fetchTokenConfigs, getObjectRef, getReceiverModule } from './objects.ts'
19
+ import type { CCIPMessage_V1_6_Sui, UnsignedSuiTx } from './types.ts'
20
+
21
+ /**
22
+ * Builds a Sui manual-execution PTB and returns it as an {@link UnsignedSuiTx}.
23
+ *
24
+ * @param client - Sui RPC client.
25
+ * @param offRamp - OffRamp object ID / address.
26
+ * @param input - Execution input (message + proofs).
27
+ * @param opts - Optional overrides such as `gasLimit` and `receiverObjectIds`.
28
+ * @returns Serialized unsigned transaction ready to sign and submit.
29
+ */
30
+ export async function generateUnsignedExecutePTB(
31
+ client: SuiClient,
32
+ offRamp: string,
33
+ input: ExecutionInput<CCIPMessage_V1_6_Sui>,
34
+ opts?: { gasLimit?: number | bigint; receiverObjectIds?: string[] },
35
+ ): Promise<UnsignedSuiTx> {
36
+ if (!('message' in input)) {
37
+ throw new CCIPExecutionReportChainMismatchError('Sui')
38
+ }
39
+
40
+ const ccip = await getCcipStateAddress(offRamp, client)
41
+
42
+ const ccipObjectRef = await getObjectRef(ccip, client)
43
+ const [offrampStateObject, receiverConfig] = await Promise.all([
44
+ getObjectRef(offRamp, client),
45
+ getReceiverModule(client, ccip, ccipObjectRef, input.message.receiver),
46
+ ])
47
+
48
+ let tokenConfigs: TokenConfig[] = []
49
+ if (input.message.tokenAmounts.length !== 0) {
50
+ tokenConfigs = await fetchTokenConfigs(client, ccip, ccipObjectRef, input.message.tokenAmounts)
51
+ }
52
+
53
+ const suiInput: SuiManuallyExecuteInput = {
54
+ executionReport: input,
55
+ offrampAddress: offRamp,
56
+ ccipAddress: ccip,
57
+ ccipObjectRef,
58
+ offrampStateObject,
59
+ receiverConfig,
60
+ tokenConfigs,
61
+ ...(opts?.receiverObjectIds ? { overrideReceiverObjectIds: opts.receiverObjectIds } : {}),
62
+ }
63
+
64
+ const tx = buildManualExecutionPTB(suiInput)
65
+
66
+ if (opts?.gasLimit) {
67
+ tx.setGasBudget(opts.gasLimit)
68
+ }
69
+
70
+ return {
71
+ family: ChainFamily.Sui,
72
+ transactions: [tx.serialize()],
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Signs and executes a pre-built {@link UnsignedSuiTx} using the provided keypair.
78
+ *
79
+ * @param client - Sui RPC client.
80
+ * @param wallet - Keypair used to sign the transaction.
81
+ * @param unsignedTx - The unsigned Sui transaction to execute.
82
+ * @param logger - Optional logger.
83
+ * @returns The finalized transaction digest string.
84
+ */
85
+ export async function signAndExecuteSuiTx(
86
+ client: SuiClient,
87
+ wallet: Keypair,
88
+ unsignedTx: UnsignedSuiTx,
89
+ logger?: { info: (...args: unknown[]) => void },
90
+ ): Promise<string> {
91
+ const tx = Transaction.from(unsignedTx.transactions[0])
92
+
93
+ logger?.info('Executing Sui CCIP execute transaction...')
94
+
95
+ let digest: string
96
+ try {
97
+ const result = await client.signAndExecuteTransaction({
98
+ signer: wallet,
99
+ transaction: tx,
100
+ options: {
101
+ showEffects: true,
102
+ showEvents: true,
103
+ },
104
+ })
105
+
106
+ if (result.effects?.status.status !== 'success') {
107
+ const errorMsg = result.effects?.status.error ?? 'Unknown error'
108
+ throw new CCIPExecTxRevertedError(result.digest, { context: { error: errorMsg } })
109
+ }
110
+
111
+ digest = result.digest
112
+ } catch (e) {
113
+ if (e instanceof CCIPExecTxRevertedError) throw e
114
+ throw new CCIPError(
115
+ CCIPErrorCode.TRANSACTION_NOT_FINALIZED,
116
+ `Failed to send Sui execute transaction: ${(e as Error).message}`,
117
+ )
118
+ }
119
+
120
+ logger?.info(`Waiting for Sui transaction ${digest} to be finalized...`)
121
+
122
+ await client.waitForTransaction({
123
+ digest,
124
+ options: {
125
+ showEffects: true,
126
+ showEvents: true,
127
+ },
128
+ })
129
+
130
+ return digest
131
+ }
package/src/sui/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { bcs } from '@mysten/sui/bcs'
2
- import { type SuiTransactionBlockResponse, SuiClient } from '@mysten/sui/client'
2
+ import { SuiClient } from '@mysten/sui/client'
3
3
  import type { Keypair } from '@mysten/sui/cryptography'
4
4
  import { SuiGraphQLClient } from '@mysten/sui/graphql'
5
5
  import { Transaction } from '@mysten/sui/transactions'
@@ -17,20 +17,13 @@ import {
17
17
  import { getCcipStateAddress, getOffRampForCcip } from './discovery.ts'
18
18
  import { type CommitEvent, streamSuiLogs } from './events.ts'
19
19
  import { getSuiLeafHasher } from './hasher.ts'
20
- import {
21
- deriveObjectID,
22
- fetchTokenConfigs,
23
- getLatestPackageId,
24
- getObjectRef,
25
- getReceiverModule,
26
- } from './objects.ts'
20
+ import { deriveObjectID, getLatestPackageId, getObjectRef } from './objects.ts'
27
21
  import {
28
22
  CCIPArgumentInvalidError,
29
23
  CCIPContractNotRouterError,
30
24
  CCIPDataFormatUnsupportedError,
31
25
  CCIPError,
32
26
  CCIPErrorCode,
33
- CCIPExecTxRevertedError,
34
27
  CCIPExecutionReportChainMismatchError,
35
28
  CCIPLogsAddressRequiredError,
36
29
  CCIPNotImplementedError,
@@ -47,7 +40,6 @@ import {
47
40
  type CCIPExecution,
48
41
  type CCIPMessage,
49
42
  type CCIPRequest,
50
- type CCIPVersion,
51
43
  type ChainLog,
52
44
  type ChainTransaction,
53
45
  type CommitReport,
@@ -67,12 +59,9 @@ import {
67
59
  parseTypeAndVersion,
68
60
  util,
69
61
  } from '../utils.ts'
70
- import {
71
- type SuiManuallyExecuteInput,
72
- type TokenConfig,
73
- buildManualExecutionPTB,
74
- } from './manuallyExec/index.ts'
75
- import type { CCIPMessage_V1_6_Sui } from './types.ts'
62
+ import { generateUnsignedExecutePTB, signAndExecuteSuiTx } from './exec.ts'
63
+ import type { CCIPMessage_V1_6_Sui, UnsignedSuiTx } from './types.ts'
64
+ export type { UnsignedSuiTx }
76
65
 
77
66
  const DEFAULT_GAS_LIMIT = 1000000n
78
67
 
@@ -728,11 +717,28 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
728
717
  return Promise.reject(new CCIPNotImplementedError('SuiChain.sendMessage'))
729
718
  }
730
719
 
731
- /** {@inheritDoc Chain.generateUnsignedExecute} */
732
- override generateUnsignedExecute(
733
- _opts: Parameters<Chain['generateUnsignedExecute']>[0],
734
- ): Promise<never> {
735
- return Promise.reject(new CCIPNotImplementedError('SuiChain.generateUnsignedExecute'))
720
+ /**
721
+ * {@inheritDoc Chain.generateUnsignedExecute}
722
+ * @throws {@link CCIPExecutionReportChainMismatchError} if input is not a Sui v1.6 execution report
723
+ */
724
+ override async generateUnsignedExecute(
725
+ opts: Parameters<Chain['generateUnsignedExecute']>[0],
726
+ ): Promise<UnsignedSuiTx> {
727
+ const resolved = await this.resolveExecuteOpts(opts)
728
+ if (!resolved.offRamp.includes('::')) resolved.offRamp += '::offramp'
729
+ if (!('message' in resolved.input)) {
730
+ throw new CCIPExecutionReportChainMismatchError('Sui')
731
+ }
732
+
733
+ return generateUnsignedExecutePTB(
734
+ this.client,
735
+ resolved.offRamp,
736
+ resolved.input as ExecutionInput<CCIPMessage_V1_6_Sui>,
737
+ {
738
+ gasLimit: resolved.gasLimit,
739
+ receiverObjectIds: (resolved as { receiverObjectIds?: string[] }).receiverObjectIds,
740
+ },
741
+ )
736
742
  }
737
743
 
738
744
  /**
@@ -745,94 +751,23 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
745
751
  receiverObjectIds?: string[]
746
752
  },
747
753
  ): Promise<CCIPExecution> {
748
- if (!('input' in opts && 'message' in opts.input)) {
749
- throw new CCIPExecutionReportChainMismatchError('Sui')
750
- }
751
- const { input, offRamp } = opts
752
754
  const wallet = opts.wallet as Keypair
753
755
 
754
- // Discover the CCIP package from the offramp
755
- const ccip = await getCcipStateAddress(offRamp, this.client)
756
-
757
- const ccipObjectRef = await getObjectRef(ccip, this.client)
758
- const offrampStateObject = await getObjectRef(offRamp, this.client)
759
- const receiverConfig = await getReceiverModule(
760
- this.client,
761
- ccip,
762
- ccipObjectRef,
763
- input.message.receiver,
764
- )
765
- let tokenConfigs: TokenConfig[] = []
766
- if (input.message.tokenAmounts.length !== 0) {
767
- tokenConfigs = await fetchTokenConfigs(
768
- this.client,
769
- ccip,
770
- ccipObjectRef,
771
- input.message.tokenAmounts as CCIPMessage<typeof CCIPVersion.V1_6>['tokenAmounts'],
772
- )
773
- }
774
-
775
- const suiInput: SuiManuallyExecuteInput = {
776
- executionReport: input as ExecutionInput<CCIPMessage_V1_6_Sui>,
777
- offrampAddress: offRamp,
778
- ccipAddress: ccip,
779
- ccipObjectRef,
780
- offrampStateObject,
781
- receiverConfig,
782
- tokenConfigs,
783
- }
784
756
  if (opts.receiverObjectIds) {
785
757
  this.logger.info(
786
758
  `Overriding Sui Manual Execution receiverObjectIds with: ${opts.receiverObjectIds.join(', ')}`,
787
759
  )
788
- suiInput.overrideReceiverObjectIds = opts.receiverObjectIds
789
760
  }
790
- const tx = buildManualExecutionPTB(suiInput)
791
761
 
792
- // Set gas budget if provided
793
- if (opts.gasLimit) {
794
- tx.setGasBudget(opts.gasLimit)
795
- }
796
-
797
- this.logger.info(`Executing Sui CCIP execute transaction...`)
798
- // Sign and execute the transaction
799
- let result: SuiTransactionBlockResponse
800
- try {
801
- result = await this.client.signAndExecuteTransaction({
802
- signer: wallet,
803
- transaction: tx,
804
- options: {
805
- showEffects: true,
806
- showEvents: true,
807
- },
808
- })
809
- } catch (e) {
810
- throw new CCIPError(
811
- CCIPErrorCode.TRANSACTION_NOT_FINALIZED,
812
- `Failed to send Sui execute transaction: ${(e as Error).message}`,
813
- )
814
- }
815
-
816
- // Check if transaction inmediately reverted
817
- if (result.effects?.status.status !== 'success') {
818
- const errorMsg = result.effects?.status.error || 'Unknown error'
819
- throw new CCIPExecTxRevertedError(result.digest, {
820
- context: { error: errorMsg },
821
- })
822
- }
823
-
824
- this.logger.info(`Waiting for Sui transaction ${result.digest} to be finalized...`)
825
-
826
- await this.client.waitForTransaction({
827
- digest: result.digest,
828
- options: {
829
- showEffects: true,
830
- showEvents: true,
831
- },
762
+ const unsignedTx = await this.generateUnsignedExecute({
763
+ ...opts,
764
+ payer: '',
832
765
  })
833
766
 
767
+ const digest = await signAndExecuteSuiTx(this.client, wallet, unsignedTx, this.logger)
768
+
834
769
  // Return the transaction as a ChainTransaction
835
- return this.getExecutionReceiptInTx(await this.getTransaction(result.digest))
770
+ return this.getExecutionReceiptInTx(await this.getTransaction(digest))
836
771
  }
837
772
 
838
773
  /**
@@ -4,9 +4,7 @@ import { Transaction } from '@mysten/sui/transactions'
4
4
 
5
5
  import { serializeExecutionReport } from './encoder.ts'
6
6
  import { CCIPMessageInvalidError } from '../../errors/specialized.ts'
7
- import { decodeExtraArgs } from '../../extra-args.ts'
8
7
  import type { ExecutionInput } from '../../types.ts'
9
- import { networkInfo } from '../../utils.ts'
10
8
  import type { CCIPMessage_V1_6_Sui } from '../types.ts'
11
9
 
12
10
  /** Configuration for manually executing a Sui receiver module. */
@@ -56,12 +54,16 @@ export function buildManualExecutionPTB({
56
54
  }: SuiManuallyExecuteInput): Transaction {
57
55
  const reportBytes = serializeExecutionReport(executionReport)
58
56
 
57
+ // Strip any ::module suffixes to get bare package IDs for move call targets
58
+ const offrampPackageId = offrampAddress.split('::')[0]!
59
+ const ccipPackageId = ccipAddress.split('::')[0]!
60
+
59
61
  // Create transaction
60
62
  const tx = new Transaction()
61
63
 
62
64
  // Step 1: Call manually_init_execute to prepare the execution
63
65
  const receiverParamsArg = tx.moveCall({
64
- target: `${offrampAddress}::offramp::manually_init_execute`,
66
+ target: `${offrampPackageId}::offramp::manually_init_execute`,
65
67
  arguments: [
66
68
  tx.object(ccipObjectRef),
67
69
  tx.object(offrampStateObject),
@@ -72,7 +74,7 @@ export function buildManualExecutionPTB({
72
74
 
73
75
  // Get the message from the from the report using the offramp helper
74
76
  const messageArg = tx.moveCall({
75
- target: `${ccipAddress}::offramp_state_helper::extract_any2sui_message`,
77
+ target: `${ccipPackageId}::offramp_state_helper::extract_any2sui_message`,
76
78
  arguments: [receiverParamsArg],
77
79
  })
78
80
 
@@ -96,17 +98,9 @@ export function buildManualExecutionPTB({
96
98
  }
97
99
  }
98
100
 
99
- // Decode extraArgs to get receiverObjectIds
100
- const decodedExtraArgs = decodeExtraArgs(
101
- executionReport.message.extraArgs,
102
- networkInfo(executionReport.message.destChainSelector).family,
103
- )
104
-
105
- if (!decodedExtraArgs || decodedExtraArgs._tag !== 'SuiExtraArgsV1') {
106
- throw new CCIPMessageInvalidError('Expected Sui extra args')
107
- }
101
+ const { receiverObjectIds } = executionReport.message
108
102
 
109
- if (decodedExtraArgs.receiverObjectIds.length === 0) {
103
+ if (receiverObjectIds.length === 0) {
110
104
  throw new CCIPMessageInvalidError('No receiverObjectIds provided in SUIExtraArgsV1')
111
105
  }
112
106
  // Call the receiver contract
@@ -116,16 +110,16 @@ export function buildManualExecutionPTB({
116
110
  tx.pure.vector('u8', Buffer.from(executionReport.message.messageId.slice(2), 'hex')),
117
111
  tx.object(ccipObjectRef),
118
112
  messageArg,
119
- // if overrideReceiverObjectIds is provided, use them; otherwise, use the ones from decodedExtraArgs (original message)
113
+ // if overrideReceiverObjectIds is provided, use them; otherwise, use the ones from the message
120
114
  ...(overrideReceiverObjectIds && overrideReceiverObjectIds.length > 0
121
115
  ? overrideReceiverObjectIds.map(tx.object)
122
- : decodedExtraArgs.receiverObjectIds.map(tx.object)),
116
+ : receiverObjectIds.map(tx.object)),
123
117
  ],
124
118
  })
125
119
 
126
120
  // Step 2: Call finish_execute to complete the execution
127
121
  tx.moveCall({
128
- target: `${offrampAddress}::offramp::finish_execute`,
122
+ target: `${offrampPackageId}::offramp::finish_execute`,
129
123
  arguments: [
130
124
  tx.object(ccipObjectRef),
131
125
  tx.object(offrampStateObject),
@@ -135,11 +135,12 @@ export async function getReceiverModule(
135
135
  ccipObjectRef: string,
136
136
  receiverPackageId: string,
137
137
  ) {
138
+ const ccipBarePackageId = ccipPackageId.split('::')[0]!
138
139
  // Call get_receiver_config from receiver_registry contract
139
140
  const tx = new Transaction()
140
141
 
141
142
  tx.moveCall({
142
- target: `${ccipPackageId}::receiver_registry::get_receiver_config`,
143
+ target: `${ccipBarePackageId}::receiver_registry::get_receiver_config`,
143
144
  arguments: [tx.object(ccipObjectRef), tx.pure.address(receiverPackageId)],
144
145
  })
145
146
 
@@ -207,12 +208,13 @@ export async function fetchTokenConfigs(
207
208
  ]
208
209
 
209
210
  // Fetch token config for each unique token address
211
+ const ccipBarePackageId = ccipPackageId.split('::')[0]!
210
212
  for (const tokenAddress of tokenAddresses) {
211
213
  const tx = new Transaction()
212
214
 
213
215
  // Call get_token_config_struct from token_admin_registry
214
216
  tx.moveCall({
215
- target: `${ccipPackageId}::token_admin_registry::get_token_config_struct`,
217
+ target: `${ccipBarePackageId}::token_admin_registry::get_token_config_struct`,
216
218
  arguments: [tx.object(ccipObjectRef), tx.pure.address(tokenAddress)],
217
219
  })
218
220
 
package/src/sui/types.ts CHANGED
@@ -2,12 +2,21 @@ import { bcs } from '@mysten/sui/bcs'
2
2
  import { concat } from 'ethers'
3
3
 
4
4
  import { type SuiExtraArgsV1, SuiExtraArgsV1Tag } from '../extra-args.ts'
5
- import type { CCIPMessage_V1_6 } from '../types.ts'
5
+ import type { CCIPMessage_V1_6, ChainFamily } from '../types.ts'
6
6
  import { getAddressBytes, getDataBytes } from '../utils.ts'
7
7
 
8
8
  /** Sui-specific CCIP v1.6 message type with Sui extra args. */
9
9
  export type CCIPMessage_V1_6_Sui = CCIPMessage_V1_6 & SuiExtraArgsV1
10
10
 
11
+ /**
12
+ * Unsigned Sui transaction, serialized via Transaction#serialize().
13
+ * Reconstruct with Transaction.from(transactions[0]).
14
+ */
15
+ export type UnsignedSuiTx = {
16
+ family: typeof ChainFamily.Sui
17
+ transactions: [string]
18
+ }
19
+
11
20
  export const SuiExtraArgsV1Codec = bcs.struct('SuiExtraArgsV1', {
12
21
  gasLimit: bcs.u64(),
13
22
  allowOutOfOrderExecution: bcs.bool(),