@chainlink/ccip-sdk 0.92.1 → 0.93.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 (223) hide show
  1. package/README.md +20 -18
  2. package/dist/api/index.d.ts +103 -0
  3. package/dist/api/index.d.ts.map +1 -0
  4. package/dist/api/index.js +141 -0
  5. package/dist/api/index.js.map +1 -0
  6. package/dist/api/types.d.ts +38 -0
  7. package/dist/api/types.d.ts.map +1 -0
  8. package/dist/api/types.js +2 -0
  9. package/dist/api/types.js.map +1 -0
  10. package/dist/aptos/index.d.ts +20 -33
  11. package/dist/aptos/index.d.ts.map +1 -1
  12. package/dist/aptos/index.js +34 -26
  13. package/dist/aptos/index.js.map +1 -1
  14. package/dist/aptos/logs.js +1 -1
  15. package/dist/aptos/logs.js.map +1 -1
  16. package/dist/aptos/token.js.map +1 -1
  17. package/dist/chain.d.ts +206 -71
  18. package/dist/chain.d.ts.map +1 -1
  19. package/dist/chain.js +89 -20
  20. package/dist/chain.js.map +1 -1
  21. package/dist/commits.d.ts +2 -2
  22. package/dist/commits.d.ts.map +1 -1
  23. package/dist/commits.js +4 -4
  24. package/dist/commits.js.map +1 -1
  25. package/dist/errors/CCIPError.d.ts.map +1 -1
  26. package/dist/errors/CCIPError.js +3 -2
  27. package/dist/errors/CCIPError.js.map +1 -1
  28. package/dist/errors/codes.d.ts +4 -1
  29. package/dist/errors/codes.d.ts.map +1 -1
  30. package/dist/errors/codes.js +6 -1
  31. package/dist/errors/codes.js.map +1 -1
  32. package/dist/errors/index.d.ts +5 -2
  33. package/dist/errors/index.d.ts.map +1 -1
  34. package/dist/errors/index.js +8 -2
  35. package/dist/errors/index.js.map +1 -1
  36. package/dist/errors/recovery.d.ts.map +1 -1
  37. package/dist/errors/recovery.js +4 -1
  38. package/dist/errors/recovery.js.map +1 -1
  39. package/dist/errors/specialized.d.ts +29 -4
  40. package/dist/errors/specialized.d.ts.map +1 -1
  41. package/dist/errors/specialized.js +48 -6
  42. package/dist/errors/specialized.js.map +1 -1
  43. package/dist/evm/errors.js.map +1 -1
  44. package/dist/evm/index.d.ts +24 -48
  45. package/dist/evm/index.d.ts.map +1 -1
  46. package/dist/evm/index.js +71 -59
  47. package/dist/evm/index.js.map +1 -1
  48. package/dist/evm/logs.js.map +1 -1
  49. package/dist/evm/offchain.js +3 -2
  50. package/dist/evm/offchain.js.map +1 -1
  51. package/dist/evm/viem/client-adapter.d.ts +68 -0
  52. package/dist/evm/viem/client-adapter.d.ts.map +1 -0
  53. package/dist/evm/viem/client-adapter.js +104 -0
  54. package/dist/evm/viem/client-adapter.js.map +1 -0
  55. package/dist/evm/viem/index.d.ts +29 -0
  56. package/dist/evm/viem/index.d.ts.map +1 -0
  57. package/dist/evm/viem/index.js +28 -0
  58. package/dist/evm/viem/index.js.map +1 -0
  59. package/dist/evm/viem/types.d.ts +13 -0
  60. package/dist/evm/viem/types.d.ts.map +1 -0
  61. package/dist/evm/viem/types.js +2 -0
  62. package/dist/evm/viem/types.js.map +1 -0
  63. package/dist/evm/viem/wallet-adapter.d.ts +58 -0
  64. package/dist/evm/viem/wallet-adapter.d.ts.map +1 -0
  65. package/dist/evm/viem/wallet-adapter.js +197 -0
  66. package/dist/evm/viem/wallet-adapter.js.map +1 -0
  67. package/dist/execution.d.ts +1 -1
  68. package/dist/execution.d.ts.map +1 -1
  69. package/dist/execution.js +2 -2
  70. package/dist/execution.js.map +1 -1
  71. package/dist/explorer.d.ts +74 -0
  72. package/dist/explorer.d.ts.map +1 -0
  73. package/dist/explorer.js +67 -0
  74. package/dist/explorer.js.map +1 -0
  75. package/dist/gas.js.map +1 -1
  76. package/dist/hasher/merklemulti.js.map +1 -1
  77. package/dist/http-status.d.ts +20 -0
  78. package/dist/http-status.d.ts.map +1 -0
  79. package/dist/http-status.js +25 -0
  80. package/dist/http-status.js.map +1 -0
  81. package/dist/index.d.ts +10 -3
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +4 -2
  84. package/dist/index.js.map +1 -1
  85. package/dist/offchain.js.map +1 -1
  86. package/dist/requests.d.ts +4 -4
  87. package/dist/requests.d.ts.map +1 -1
  88. package/dist/requests.js +6 -6
  89. package/dist/requests.js.map +1 -1
  90. package/dist/solana/cleanup.js +2 -2
  91. package/dist/solana/cleanup.js.map +1 -1
  92. package/dist/solana/exec.js +1 -5
  93. package/dist/solana/exec.js.map +1 -1
  94. package/dist/solana/index.d.ts +28 -57
  95. package/dist/solana/index.d.ts.map +1 -1
  96. package/dist/solana/index.js +66 -70
  97. package/dist/solana/index.js.map +1 -1
  98. package/dist/solana/logs.js +2 -2
  99. package/dist/solana/logs.js.map +1 -1
  100. package/dist/solana/offchain.js +3 -3
  101. package/dist/solana/offchain.js.map +1 -1
  102. package/dist/solana/send.js +1 -1
  103. package/dist/solana/send.js.map +1 -1
  104. package/dist/solana/utils.js +1 -1
  105. package/dist/solana/utils.js.map +1 -1
  106. package/dist/sui/discovery.d.ts.map +1 -1
  107. package/dist/sui/discovery.js +2 -5
  108. package/dist/sui/discovery.js.map +1 -1
  109. package/dist/sui/events.d.ts.map +1 -1
  110. package/dist/sui/events.js +1 -4
  111. package/dist/sui/events.js.map +1 -1
  112. package/dist/sui/index.d.ts +18 -29
  113. package/dist/sui/index.d.ts.map +1 -1
  114. package/dist/sui/index.js +24 -26
  115. package/dist/sui/index.js.map +1 -1
  116. package/dist/sui/manuallyExec/encoder.d.ts.map +1 -1
  117. package/dist/sui/manuallyExec/encoder.js +0 -3
  118. package/dist/sui/manuallyExec/encoder.js.map +1 -1
  119. package/dist/sui/manuallyExec/index.d.ts.map +1 -1
  120. package/dist/sui/manuallyExec/index.js +1 -2
  121. package/dist/sui/manuallyExec/index.js.map +1 -1
  122. package/dist/sui/objects.js +4 -4
  123. package/dist/sui/objects.js.map +1 -1
  124. package/dist/ton/exec.d.ts +2 -2
  125. package/dist/ton/exec.d.ts.map +1 -1
  126. package/dist/ton/exec.js.map +1 -1
  127. package/dist/ton/hasher.js +5 -5
  128. package/dist/ton/hasher.js.map +1 -1
  129. package/dist/ton/index.d.ts +54 -49
  130. package/dist/ton/index.d.ts.map +1 -1
  131. package/dist/ton/index.js +331 -236
  132. package/dist/ton/index.js.map +1 -1
  133. package/dist/ton/logs.d.ts +11 -22
  134. package/dist/ton/logs.d.ts.map +1 -1
  135. package/dist/ton/logs.js +95 -118
  136. package/dist/ton/logs.js.map +1 -1
  137. package/dist/ton/types.d.ts +9 -9
  138. package/dist/ton/types.d.ts.map +1 -1
  139. package/dist/ton/types.js +5 -9
  140. package/dist/ton/types.js.map +1 -1
  141. package/dist/ton/utils.d.ts +8 -27
  142. package/dist/ton/utils.d.ts.map +1 -1
  143. package/dist/ton/utils.js +31 -111
  144. package/dist/ton/utils.js.map +1 -1
  145. package/dist/types.d.ts +34 -0
  146. package/dist/types.d.ts.map +1 -1
  147. package/dist/types.js +30 -0
  148. package/dist/types.js.map +1 -1
  149. package/dist/utils.d.ts +6 -5
  150. package/dist/utils.d.ts.map +1 -1
  151. package/dist/utils.js +76 -52
  152. package/dist/utils.js.map +1 -1
  153. package/dist/viem.d.ts +6 -0
  154. package/dist/viem.d.ts.map +1 -0
  155. package/dist/viem.js +6 -0
  156. package/dist/viem.js.map +1 -0
  157. package/package.json +17 -2
  158. package/src/api/index.ts +167 -0
  159. package/src/api/types.ts +39 -0
  160. package/src/aptos/index.ts +57 -64
  161. package/src/aptos/logs.ts +10 -10
  162. package/src/aptos/token.ts +1 -1
  163. package/src/chain.ts +274 -97
  164. package/src/commits.ts +5 -5
  165. package/src/errors/CCIPError.ts +5 -2
  166. package/src/errors/codes.ts +8 -1
  167. package/src/errors/index.ts +15 -2
  168. package/src/errors/recovery.ts +9 -1
  169. package/src/errors/specialized.ts +61 -6
  170. package/src/evm/errors.ts +2 -2
  171. package/src/evm/index.ts +107 -120
  172. package/src/evm/logs.ts +4 -4
  173. package/src/evm/offchain.ts +5 -4
  174. package/src/evm/viem/client-adapter.ts +124 -0
  175. package/src/evm/viem/index.ts +29 -0
  176. package/src/evm/viem/types.ts +14 -0
  177. package/src/evm/viem/wallet-adapter.ts +233 -0
  178. package/src/execution.ts +9 -9
  179. package/src/explorer.ts +90 -0
  180. package/src/gas.ts +2 -2
  181. package/src/hasher/merklemulti.ts +7 -7
  182. package/src/http-status.ts +31 -0
  183. package/src/index.ts +18 -1
  184. package/src/offchain.ts +1 -1
  185. package/src/requests.ts +9 -12
  186. package/src/solana/cleanup.ts +4 -4
  187. package/src/solana/exec.ts +13 -18
  188. package/src/solana/index.ts +92 -117
  189. package/src/solana/logs.ts +8 -8
  190. package/src/solana/offchain.ts +3 -3
  191. package/src/solana/send.ts +20 -20
  192. package/src/solana/utils.ts +4 -4
  193. package/src/sui/discovery.ts +4 -10
  194. package/src/sui/events.ts +4 -8
  195. package/src/sui/index.ts +36 -48
  196. package/src/sui/manuallyExec/encoder.ts +0 -4
  197. package/src/sui/manuallyExec/index.ts +1 -3
  198. package/src/sui/objects.ts +14 -14
  199. package/src/ton/exec.ts +2 -5
  200. package/src/ton/hasher.ts +5 -5
  201. package/src/ton/index.ts +392 -316
  202. package/src/ton/logs.ts +122 -143
  203. package/src/ton/types.ts +17 -21
  204. package/src/ton/utils.ts +39 -145
  205. package/src/types.ts +36 -0
  206. package/src/utils.ts +96 -66
  207. package/src/viem.ts +5 -0
  208. package/tsconfig.json +3 -2
  209. package/dist/ton/bindings/offramp.d.ts +0 -48
  210. package/dist/ton/bindings/offramp.d.ts.map +0 -1
  211. package/dist/ton/bindings/offramp.js +0 -63
  212. package/dist/ton/bindings/offramp.js.map +0 -1
  213. package/dist/ton/bindings/onramp.d.ts +0 -40
  214. package/dist/ton/bindings/onramp.d.ts.map +0 -1
  215. package/dist/ton/bindings/onramp.js +0 -51
  216. package/dist/ton/bindings/onramp.js.map +0 -1
  217. package/dist/ton/bindings/router.d.ts +0 -47
  218. package/dist/ton/bindings/router.d.ts.map +0 -1
  219. package/dist/ton/bindings/router.js +0 -51
  220. package/dist/ton/bindings/router.js.map +0 -1
  221. package/src/ton/bindings/offramp.ts +0 -96
  222. package/src/ton/bindings/onramp.ts +0 -72
  223. package/src/ton/bindings/router.ts +0 -65
@@ -25,16 +25,10 @@ export const discoverCCIP = async (client: SuiClient, onramp: string): Promise<s
25
25
  transactionBlock: tx,
26
26
  })
27
27
  const returnValues = inspectResult.results?.[0]?.returnValues
28
- if (!returnValues || returnValues.length === 0) {
28
+ if (!returnValues?.length) {
29
29
  throw new CCIPError(CCIPErrorCode.UNKNOWN, 'No return values from dev inspect')
30
30
  }
31
- const [valueBytes] = returnValues[0]
32
- if (!valueBytes) {
33
- throw new CCIPError(
34
- CCIPErrorCode.UNKNOWN,
35
- 'Unable to decode CCIP package id from return values',
36
- )
37
- }
31
+ const [valueBytes] = returnValues[0]!
38
32
 
39
33
  return normalizeSuiAddress(hexlify(bytesToBuffer(valueBytes)))
40
34
  }
@@ -145,7 +139,7 @@ export const discoverOfframp = async (client: SuiClient, ccip: string) => {
145
139
  .flatMap((pkg) => Object.values(pkg))
146
140
  .filter((module) => module.name === 'offramp')
147
141
 
148
- if (offrampPkgs.length === 0) {
142
+ if (!offrampPkgs.length) {
149
143
  throw new CCIPError(
150
144
  CCIPErrorCode.UNKNOWN,
151
145
  'Could not find OffRamp package among OwnerCap packages',
@@ -159,5 +153,5 @@ export const discoverOfframp = async (client: SuiClient, ccip: string) => {
159
153
  )
160
154
  }
161
155
 
162
- return normalizeSuiAddress(offrampPkgs[0].address)
156
+ return normalizeSuiAddress(offrampPkgs[0]!.address)
163
157
  }
package/src/sui/events.ts CHANGED
@@ -35,11 +35,11 @@ async function getTransactionDigestsInTimeRange(
35
35
  order: 'ascending',
36
36
  })
37
37
 
38
- if (!firstEvents.data || firstEvents.data.length === 0) {
38
+ if (!firstEvents.data.length) {
39
39
  return null
40
40
  }
41
41
 
42
- const firstDigest = firstEvents.data[0].id.txDigest
42
+ const firstDigest = firstEvents.data[0]!.id.txDigest
43
43
 
44
44
  // Get last event (descending order)
45
45
  const lastEvents = await client.queryEvents({
@@ -48,7 +48,7 @@ async function getTransactionDigestsInTimeRange(
48
48
  order: 'descending',
49
49
  })
50
50
 
51
- const lastDigest = lastEvents.data[0].id.txDigest
51
+ const lastDigest = lastEvents.data[0]!.id.txDigest
52
52
 
53
53
  return { firstDigest, lastDigest }
54
54
  }
@@ -145,7 +145,7 @@ async function getCheckpointsFromTransactions(
145
145
  if (!latestResult.data) {
146
146
  throw new CCIPDataFormatUnsupportedError('Failed to fetch latest checkpoint')
147
147
  }
148
- endCheckpoint = parseInt(latestResult.data.checkpoints.nodes[0].sequenceNumber)
148
+ endCheckpoint = parseInt(latestResult.data.checkpoints.nodes[0]!.sequenceNumber)
149
149
  } else {
150
150
  endCheckpoint = parseInt(result.data.last.effects.checkpoint.sequenceNumber)
151
151
  }
@@ -282,10 +282,6 @@ async function fetchEventsWithCheckpointRange<T>(
282
282
 
283
283
  hasNextPage = pageInfo.hasNextPage
284
284
  cursor = pageInfo.endCursor ?? undefined
285
-
286
- if (!hasNextPage) {
287
- break
288
- }
289
285
  }
290
286
 
291
287
  return allEvents
package/src/sui/index.ts CHANGED
@@ -7,7 +7,7 @@ import { type BytesLike, AbiCoder, hexlify, isBytesLike } from 'ethers'
7
7
  import type { PickDeep } from 'type-fest'
8
8
 
9
9
  import { AptosChain } from '../aptos/index.ts'
10
- import { type LogFilter, Chain } from '../chain.ts'
10
+ import { type ChainContext, type LogFilter, Chain } from '../chain.ts'
11
11
  import {
12
12
  CCIPContractNotRouterError,
13
13
  CCIPDataFormatUnsupportedError,
@@ -24,7 +24,7 @@ import { getSuiLeafHasher } from './hasher.ts'
24
24
  import type { LeafHasher } from '../hasher/common.ts'
25
25
  import { supportedChains } from '../supported-chains.ts'
26
26
  import {
27
- type AnyMessage,
27
+ type CCIPExecution,
28
28
  type CCIPMessage,
29
29
  type CCIPRequest,
30
30
  type CCIPVersion,
@@ -40,6 +40,7 @@ import {
40
40
  type WithLogger,
41
41
  ChainFamily,
42
42
  } from '../types.ts'
43
+ import { discoverCCIP, discoverOfframp } from './discovery.ts'
43
44
  import type { CCIPMessage_V1_6_Sui } from './types.ts'
44
45
  import { bytesToBuffer, decodeAddress, getDataBytes, networkInfo } from '../utils.ts'
45
46
  import { type CommitEvent, getSuiEventsInTimeRange } from './events.ts'
@@ -54,8 +55,6 @@ import {
54
55
  getOffRampStateObject,
55
56
  getReceiverModule,
56
57
  } from './objects.ts'
57
- import selectors from '../selectors.ts'
58
- import { discoverCCIP, discoverOfframp } from './discovery.ts'
59
58
 
60
59
  export const SUI_EXTRA_ARGS_V1_TAG = '21ea4ca9' as const
61
60
 
@@ -89,7 +88,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
89
88
  * @param client - Sui client for interacting with the Sui network.
90
89
  * @param network - Network information for this chain.
91
90
  */
92
- constructor(client: SuiClient, network: NetworkInfo<typeof ChainFamily.Sui>, ctx?: WithLogger) {
91
+ constructor(client: SuiClient, network: NetworkInfo<typeof ChainFamily.Sui>, ctx?: ChainContext) {
93
92
  super(network, ctx)
94
93
 
95
94
  this.client = client
@@ -98,11 +97,10 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
98
97
 
99
98
  // TODO: Graphql client should come from config
100
99
  let graphqlUrl: string
101
- const selector = network.chainSelector
102
- if (selector === selectors['sui:1'].selector) {
100
+ if (this.network.name === 'sui-mainnet') {
103
101
  // Sui mainnet (sui:1)
104
102
  graphqlUrl = 'https://graphql.mainnet.sui.io/graphql'
105
- } else if (selector === selectors['sui:2'].selector) {
103
+ } else if (this.network.name === 'sui-testnet') {
106
104
  // Sui testnet (sui:2)
107
105
  graphqlUrl = 'https://graphql.testnet.sui.io/graphql'
108
106
  } else {
@@ -120,7 +118,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
120
118
  * @param url - HTTP or WebSocket endpoint URL for the Sui network.
121
119
  * @returns A new SuiChain instance.
122
120
  */
123
- static async fromUrl(url: string, ctx?: WithLogger): Promise<SuiChain> {
121
+ static async fromUrl(url: string, ctx?: ChainContext): Promise<SuiChain> {
124
122
  const client = new SuiClient({ url })
125
123
 
126
124
  // Get chain identifier from the client and map to network info format
@@ -173,13 +171,12 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
173
171
 
174
172
  // Extract events from the transaction
175
173
  const events: Log_[] = []
176
- if (txResponse.events) {
177
- for (let i = 0; i < txResponse.events.length; i++) {
178
- const event = txResponse.events[i]
174
+ if (txResponse.events?.length) {
175
+ for (const [i, event] of txResponse.events.entries()) {
179
176
  const eventType = event.type
180
177
  const packageId = eventType.split('::')[0]
181
178
  const moduleName = eventType.split('::')[1]
182
- const eventName = eventType.split('::')[2]
179
+ const eventName = eventType.split('::')[2]!
183
180
 
184
181
  events.push({
185
182
  address: `${packageId}::${moduleName}`,
@@ -197,7 +194,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
197
194
  logs: events,
198
195
  blockNumber: Number(txResponse.checkpoint || 0),
199
196
  timestamp: Number(txResponse.timestampMs || 0) / 1000,
200
- from: txResponse.transaction?.data?.sender || '',
197
+ from: txResponse.transaction?.data.sender || '',
201
198
  }
202
199
  }
203
200
 
@@ -245,13 +242,13 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
245
242
  }
246
243
  }
247
244
 
248
- /** {@inheritDoc Chain.fetchRequestsInTx} */
249
- override async fetchRequestsInTx(_tx: string | ChainTransaction): Promise<CCIPRequest[]> {
250
- return Promise.reject(new CCIPNotImplementedError('SuiChain.fetchRequestsInTx'))
245
+ /** {@inheritDoc Chain.getMessagesInTx} */
246
+ override async getMessagesInTx(_tx: string | ChainTransaction): Promise<CCIPRequest[]> {
247
+ return Promise.reject(new CCIPNotImplementedError('SuiChain.getMessagesInTx'))
251
248
  }
252
249
 
253
- /** {@inheritDoc Chain.fetchAllMessagesInBatch} */
254
- override async fetchAllMessagesInBatch<
250
+ /** {@inheritDoc Chain.getMessagesInBatch} */
251
+ override async getMessagesInBatch<
255
252
  R extends PickDeep<
256
253
  CCIPRequest,
257
254
  'lane' | `log.${'topics' | 'address' | 'blockNumber'}` | 'message.sequenceNumber'
@@ -261,7 +258,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
261
258
  _commit: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>,
262
259
  _opts?: { page?: number },
263
260
  ): Promise<R['message'][]> {
264
- return Promise.reject(new CCIPNotImplementedError('SuiChain.fetchAllMessagesInBatch'))
261
+ return Promise.reject(new CCIPNotImplementedError('SuiChain.getMessagesInBatch'))
265
262
  }
266
263
 
267
264
  /** {@inheritDoc Chain.typeAndVersion} */
@@ -368,7 +365,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
368
365
  offset += 1
369
366
 
370
367
  // OnRamp (vector<u8>)
371
- const onRampLength = configBytes[offset]
368
+ const onRampLength = configBytes[offset]!
372
369
  offset += 1
373
370
  const onRampBytes = configBytes.slice(offset, offset + onRampLength)
374
371
 
@@ -439,7 +436,9 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
439
436
  * @param extraArgs - Encoded extra arguments bytes.
440
437
  * @returns Decoded extra arguments or undefined if unknown format.
441
438
  */
442
- static decodeExtraArgs(extraArgs: BytesLike): SuiExtraArgsV1 & { _tag: 'SuiExtraArgsV1' } {
439
+ static decodeExtraArgs(
440
+ extraArgs: BytesLike,
441
+ ): (SuiExtraArgsV1 & { _tag: 'SuiExtraArgsV1' }) | undefined {
443
442
  const data = getDataBytes(extraArgs)
444
443
  const hexBytes = toHex(data)
445
444
  if (!hexBytes.startsWith(SUI_EXTRA_ARGS_V1_TAG)) {
@@ -581,33 +580,24 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
581
580
  }
582
581
 
583
582
  /** {@inheritDoc Chain.getFee} */
584
- async getFee(_router: string, _destChainSelector: bigint, _message: AnyMessage): Promise<bigint> {
583
+ async getFee(_opts: Parameters<Chain['getFee']>[0]): Promise<bigint> {
585
584
  return Promise.reject(new CCIPNotImplementedError('SuiChain.getFee'))
586
585
  }
587
586
 
588
587
  /** {@inheritDoc Chain.generateUnsignedSendMessage} */
589
588
  override generateUnsignedSendMessage(
590
- _sender: string,
591
- _router: string,
592
- _destChainSelector: bigint,
593
- _message: AnyMessage & { fee?: bigint },
594
- _opts?: { approveMax?: boolean },
589
+ _opts: Parameters<Chain['generateUnsignedSendMessage']>[0],
595
590
  ): Promise<never> {
596
591
  return Promise.reject(new CCIPNotImplementedError('SuiChain.generateUnsignedSendMessage'))
597
592
  }
598
593
 
599
594
  /** {@inheritDoc Chain.sendMessage} */
600
- async sendMessage(
601
- _router: string,
602
- _destChainSelector: bigint,
603
- _message: AnyMessage & { fee: bigint },
604
- _opts?: { wallet?: unknown; approveMax?: boolean },
605
- ): Promise<CCIPRequest> {
595
+ async sendMessage(_opts: Parameters<Chain['sendMessage']>[0]): Promise<CCIPRequest> {
606
596
  return Promise.reject(new CCIPNotImplementedError('SuiChain.sendMessage'))
607
597
  }
608
598
 
609
- /** {@inheritDoc Chain.fetchOffchainTokenData} */
610
- fetchOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]> {
599
+ /** {@inheritDoc Chain.getOffchainTokenData} */
600
+ getOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]> {
611
601
  if (!('receiverObjectIds' in request.message)) {
612
602
  throw new CCIPSuiMessageVersionInvalidError()
613
603
  }
@@ -617,20 +607,18 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
617
607
 
618
608
  /** {@inheritDoc Chain.generateUnsignedExecuteReport} */
619
609
  override generateUnsignedExecuteReport(
620
- _payer: string,
621
- _offRamp: string,
622
- _execReport: ExecutionReport,
623
- _opts: object,
610
+ _opts: Parameters<Chain['generateUnsignedExecuteReport']>[0],
624
611
  ): Promise<never> {
625
612
  return Promise.reject(new CCIPNotImplementedError('SuiChain.generateUnsignedExecuteReport'))
626
613
  }
627
614
 
628
615
  /** {@inheritDoc Chain.executeReport} */
629
616
  async executeReport(
630
- _offRamp: string,
631
- execReport: ExecutionReport,
632
- opts: { wallet: unknown; gasLimit?: number; receiverObjectIds?: string[] },
633
- ): Promise<ChainTransaction> {
617
+ opts: Parameters<Chain['executeReport']>[0] & {
618
+ receiverObjectIds?: string[]
619
+ },
620
+ ): Promise<CCIPExecution> {
621
+ const { execReport } = opts
634
622
  if (!this.contractsDir.offRamp || !this.contractsDir.ccip) {
635
623
  throw new CCIPContractNotRouterError(
636
624
  'OffRamp or CCIP address not set in contracts directory',
@@ -674,7 +662,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
674
662
  const tx = buildManualExecutionPTB(input)
675
663
 
676
664
  // Set gas budget if provided
677
- if (opts?.gasLimit) {
665
+ if (opts.gasLimit) {
678
666
  tx.setGasBudget(opts.gasLimit)
679
667
  }
680
668
 
@@ -698,8 +686,8 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
698
686
  }
699
687
 
700
688
  // Check if transaction inmediately reverted
701
- if (result.effects?.status?.status !== 'success') {
702
- const errorMsg = result.effects?.status?.error || 'Unknown error'
689
+ if (result.effects?.status.status !== 'success') {
690
+ const errorMsg = result.effects?.status.error || 'Unknown error'
703
691
  throw new CCIPExecTxRevertedError(result.digest, {
704
692
  context: { error: errorMsg },
705
693
  })
@@ -716,7 +704,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
716
704
  })
717
705
 
718
706
  // Return the transaction as a ChainTransaction
719
- return this.getTransaction(result.digest)
707
+ return this.getExecutionReceiptInTx(await this.getTransaction(result.digest))
720
708
  }
721
709
 
722
710
  /**
@@ -41,10 +41,6 @@ export function serializeExecutionReport(
41
41
  ): Uint8Array {
42
42
  const { message, offchainTokenData, proofs } = executionReport
43
43
 
44
- if (!message) {
45
- throw new CCIPMessageInvalidError('Message is undefined in execution report')
46
- }
47
-
48
44
  let gasLimit, tokenReceiver
49
45
  if ('receiverObjectIds' in message) {
50
46
  ;({ gasLimit, tokenReceiver } = message)
@@ -81,9 +81,7 @@ export function buildManualExecutionPTB({
81
81
  }
82
82
 
83
83
  // Process each token transfer
84
- for (let i = 0; i < tokenConfigs.length; i++) {
85
- const tokenConfig = tokenConfigs[i]
86
-
84
+ for (const tokenConfig of tokenConfigs) {
87
85
  tx.moveCall({
88
86
  target: `${tokenConfig.tokenPoolPackageId}::${tokenConfig.tokenPoolModule}::release_or_mint`,
89
87
  typeArguments: [tokenConfig.tokenType],
@@ -63,14 +63,14 @@ export async function getCcipObjectRef(client: SuiClient, ccipPackageId: string)
63
63
  },
64
64
  })
65
65
 
66
- if (pointerResponse.data.length === 0) {
66
+ if (!pointerResponse.data.length) {
67
67
  throw new CCIPDataFormatUnsupportedError(
68
68
  'No CCIPObjectRefPointer found for the given packageId',
69
69
  )
70
70
  }
71
71
 
72
72
  // Get the pointer object to extract ccip_object_id
73
- const pointerId = pointerResponse.data[0].data?.objectId
73
+ const pointerId = pointerResponse.data[0]!.data?.objectId
74
74
  if (!pointerId) {
75
75
  throw new CCIPDataFormatUnsupportedError('Pointer does not have objectId')
76
76
  }
@@ -110,13 +110,13 @@ export async function getOffRampStateObject(
110
110
  },
111
111
  })
112
112
 
113
- if (offrampPointerResponse.data.length === 0) {
113
+ if (!offrampPointerResponse.data.length) {
114
114
  throw new CCIPDataFormatUnsupportedError(
115
115
  'No OffRampStatePointer found for the given offramp package',
116
116
  )
117
117
  }
118
118
 
119
- const offrampPointerId = offrampPointerResponse.data[0].data?.objectId
119
+ const offrampPointerId = offrampPointerResponse.data[0]!.data?.objectId
120
120
 
121
121
  if (!offrampPointerId) {
122
122
  throw new CCIPDataFormatUnsupportedError('OffRampStatePointer does not have a valid objectId')
@@ -180,19 +180,19 @@ export async function getReceiverModule(
180
180
 
181
181
  const returnValues = result.results[0]?.returnValues
182
182
 
183
- if (!returnValues || returnValues.length === 0) {
183
+ if (!returnValues?.length) {
184
184
  throw new CCIPDataFormatUnsupportedError('No return values from get_receiver_config')
185
185
  }
186
186
 
187
187
  // Decode the ReceiverConfig struct
188
188
  // ReceiverConfig has two fields: module_name (String) and proof_typename (ascii::String)
189
189
  // The struct is returned as a BCS-encoded byte array
190
- const receiverConfigBytes = returnValues[0][0]
190
+ const receiverConfigBytes = returnValues[0]![0]
191
191
 
192
192
  // Parse the struct:
193
193
  // First field is module_name (String = vector<u8> with length prefix)
194
194
  let offset = 0
195
- const moduleNameLength = receiverConfigBytes[offset]
195
+ const moduleNameLength = receiverConfigBytes[offset]!
196
196
  offset += 1
197
197
  const moduleName = new TextDecoder().decode(
198
198
  new Uint8Array(receiverConfigBytes.slice(offset, offset + moduleNameLength)),
@@ -257,14 +257,14 @@ export async function fetchTokenConfigs(
257
257
 
258
258
  const returnValues = result.results[0]?.returnValues
259
259
 
260
- if (!returnValues || returnValues.length === 0) {
260
+ if (!returnValues?.length) {
261
261
  throw new CCIPDataFormatUnsupportedError(
262
262
  `No return values from get_token_config_struct for ${tokenAddress}`,
263
263
  )
264
264
  }
265
265
 
266
266
  // Parse the TokenConfig struct from BCS-encoded bytes
267
- const configBytes = returnValues[0][0]
267
+ const configBytes = returnValues[0]![0]
268
268
 
269
269
  // TokenConfig structure (from token_admin_registry.go):
270
270
  // - TokenPoolPackageId (address = 32 bytes)
@@ -286,7 +286,7 @@ export async function fetchTokenConfigs(
286
286
  offset += 32
287
287
 
288
288
  // TokenPoolModule (String)
289
- const moduleNameLength = configBytes[offset]
289
+ const moduleNameLength = configBytes[offset]!
290
290
  offset += 1
291
291
  const tokenPoolModule = new TextDecoder().decode(
292
292
  new Uint8Array(configBytes.slice(offset, offset + moduleNameLength)),
@@ -294,7 +294,7 @@ export async function fetchTokenConfigs(
294
294
  offset += moduleNameLength
295
295
 
296
296
  // TokenType (ascii::String)
297
- const tokenTypeLength = configBytes[offset]
297
+ const tokenTypeLength = configBytes[offset]!
298
298
  offset += 1
299
299
  const tokenType = new TextDecoder().decode(
300
300
  new Uint8Array(configBytes.slice(offset, offset + tokenTypeLength)),
@@ -316,7 +316,7 @@ export async function fetchTokenConfigs(
316
316
  offset += 32
317
317
 
318
318
  // TokenPoolTypeProof (ascii::String)
319
- const proofLength = configBytes[offset]
319
+ const proofLength = configBytes[offset]!
320
320
  offset += 1
321
321
  const tokenPoolTypeProof = new TextDecoder().decode(
322
322
  new Uint8Array(configBytes.slice(offset, offset + proofLength)),
@@ -324,7 +324,7 @@ export async function fetchTokenConfigs(
324
324
  offset += proofLength
325
325
 
326
326
  // LockOrBurnParams (vector<address>)
327
- const lockOrBurnCount = configBytes[offset]
327
+ const lockOrBurnCount = configBytes[offset]!
328
328
  offset += 1
329
329
  const lockOrBurnParams: string[] = []
330
330
  for (let i = 0; i < lockOrBurnCount; i++) {
@@ -334,7 +334,7 @@ export async function fetchTokenConfigs(
334
334
  }
335
335
 
336
336
  // ReleaseOrMintParams (vector<address>)
337
- const releaseOrMintCount = configBytes[offset]
337
+ const releaseOrMintCount = configBytes[offset]!
338
338
  offset += 1
339
339
  const releaseOrMintParams: string[] = []
340
340
  for (let i = 0; i < releaseOrMintCount; i++) {
package/src/ton/exec.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { beginCell } from '@ton/core'
1
+ import { type Cell, beginCell } from '@ton/core'
2
2
 
3
3
  import type { ExecutionReport } from '../types.ts'
4
4
  import {
@@ -19,10 +19,7 @@ export function generateUnsignedExecuteReport(
19
19
  offRamp: string,
20
20
  execReport: ExecutionReport<CCIPMessage_V1_6_TON>,
21
21
  opts?: { gasLimit?: number },
22
- ): {
23
- to: string
24
- body: ReturnType<typeof beginCell>['endCell'] extends () => infer R ? R : never
25
- } {
22
+ ): { to: string; body: Cell } {
26
23
  // Serialize the execution report
27
24
  const serializedReport = serializeExecutionReport(execReport)
28
25
 
package/src/ton/hasher.ts CHANGED
@@ -8,8 +8,8 @@ import {
8
8
  import { decodeExtraArgs } from '../extra-args.ts'
9
9
  import type { LeafHasher } from '../hasher/common.ts'
10
10
  import { type CCIPMessage, type CCIPMessage_V1_6, CCIPVersion } from '../types.ts'
11
- import { networkInfo } from '../utils.ts'
12
- import { hexToBuffer, tryParseCell } from './utils.ts'
11
+ import { bytesToBuffer, networkInfo } from '../utils.ts'
12
+ import { tryParseCell } from './utils.ts'
13
13
 
14
14
  // TON uses 256 bits (32 bytes) of zeros as leaf domain separator
15
15
  const TON_LEAF_DOMAIN_SEPARATOR = 0n
@@ -62,7 +62,7 @@ export const hashTONMetadata = (
62
62
  ): string => {
63
63
  // Domain separator for TON messages
64
64
  const versionHash = BigInt(sha256(Buffer.from('Any2TVMMessageHashV1')))
65
- const onRampBytes = hexToBuffer(onRamp)
65
+ const onRampBytes = bytesToBuffer(onRamp)
66
66
 
67
67
  // Build metadata cell
68
68
  const metadataCell = beginCell()
@@ -114,7 +114,7 @@ function hashV16TONMessage(message: CCIPMessage_V1_6, metadataHash: string): str
114
114
  .endCell()
115
115
 
116
116
  // Build sender cell with address bytes
117
- const senderBytes = hexToBuffer(message.sender)
117
+ const senderBytes = bytesToBuffer(message.sender)
118
118
  const senderCell = beginCell()
119
119
  .storeUint(BigInt(senderBytes.length), 8)
120
120
  .storeBuffer(senderBytes)
@@ -155,7 +155,7 @@ function buildTokenAmountsCell(tokenAmounts: readonly TokenAmount[]): Cell {
155
155
 
156
156
  // Process each token transfer
157
157
  for (const ta of tokenAmounts) {
158
- const sourcePoolBytes = hexToBuffer(ta.sourcePoolAddress)
158
+ const sourcePoolBytes = bytesToBuffer(ta.sourcePoolAddress)
159
159
 
160
160
  // Extract amount
161
161
  const amountSource =