@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/dist/chain.d.ts CHANGED
@@ -7,7 +7,7 @@ import type { EVMExtraArgsV1, EVMExtraArgsV2, ExtraArgs, GenericExtraArgsV3, SVM
7
7
  import type { LeafHasher } from './hasher/common.ts';
8
8
  import type { UnsignedSolanaTx } from './solana/types.ts';
9
9
  import type { UnsignedTONTx } from './ton/types.ts';
10
- import { type AnyMessage, type CCIPCommit, type CCIPExecution, type CCIPMessage, type CCIPRequest, type ChainFamily, type ChainTransaction, type CommitReport, type ExecutionReceipt, type ExecutionReport, type Lane, type Log_, type Logger, type MessageInput, type NetworkInfo, type OffchainTokenData, type WithLogger } from './types.ts';
10
+ import { type AnyMessage, type CCIPExecution, type CCIPMessage, type CCIPRequest, type CCIPVerifications, type ChainFamily, type ChainLog, type ChainTransaction, type CommitReport, type ExecutionInput, type ExecutionReceipt, type Lane, type Logger, type MessageInput, type NetworkInfo, type OffchainTokenData, type WithLogger } from './types.ts';
11
11
  import { util } from './utils.ts';
12
12
  /**
13
13
  * Context for Chain class initialization.
@@ -21,7 +21,7 @@ import { util } from './utils.ts';
21
21
  *
22
22
  * @example Custom API endpoint
23
23
  * ```typescript
24
- * const api = new CCIPAPIClient('https://staging-api.example.com', { logger })
24
+ * const api = CCIPAPIClient.fromUrl('https://staging-api.example.com', { logger })
25
25
  * const chain = await EVMChain.fromUrl(rpcUrl, { apiClient: api, logger })
26
26
  * ```
27
27
  *
@@ -220,13 +220,20 @@ export type SendMessageOpts = {
220
220
  approveMax?: boolean;
221
221
  };
222
222
  /**
223
- * Common options for {@link Chain.generateUnsignedExecuteReport} and {@link Chain.executeReport} methods.
223
+ * Common options for {@link Chain.generateUnsignedExecute} and {@link Chain.execute} methods.
224
224
  */
225
- export type ExecuteReportOpts = {
225
+ export type ExecuteOpts = ({
226
226
  /** address of the OffRamp contract */
227
227
  offRamp: string;
228
- /** execution report */
229
- execReport: ExecutionReport;
228
+ /** input payload to execute message; contains proofs for v1 and verifications for v2 */
229
+ input: ExecutionInput;
230
+ } | {
231
+ /**
232
+ * messageId of message to execute; requires `apiClient`.
233
+ * @remarks Currently throws CCIPNotImplementedError - API endpoint pending.
234
+ */
235
+ messageId: string;
236
+ }) & {
230
237
  /** gasLimit or computeUnits limit override for the ccipReceive call */
231
238
  gasLimit?: number;
232
239
  /** For EVM, overrides gasLimit on tokenPool call */
@@ -259,24 +266,63 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
259
266
  /** Cleanup method to release resources (e.g., close connections). */
260
267
  destroy?(): void | Promise<void>;
261
268
  /**
262
- * Fetch the timestamp of a given block
263
- * @param block - positive block number, negative finality depth or 'finalized' tag
264
- * @returns timestamp of the block, in seconds
269
+ * Fetch the timestamp of a given block.
270
+ *
271
+ * @param block - Positive block number, negative finality depth, or 'finalized' tag
272
+ * @returns Promise resolving to timestamp of the block, in seconds
273
+ *
265
274
  * @throws {@link CCIPBlockNotFoundError} if block does not exist
275
+ *
276
+ * @example Get finalized block timestamp
277
+ * ```typescript
278
+ * const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
279
+ * const timestamp = await chain.getBlockTimestamp('finalized')
280
+ * console.log(`Finalized at: ${new Date(timestamp * 1000).toISOString()}`)
281
+ * ```
266
282
  */
267
283
  abstract getBlockTimestamp(block: number | 'finalized'): Promise<number>;
268
284
  /**
269
- * Fetch a transaction by its hash
270
- * @param hash - transaction hash
271
- * @returns generic transaction details
272
- * @throws {@link CCIPTransactionNotFoundError} if transaction not found
285
+ * Fetch a transaction by its hash.
286
+ *
287
+ * @param hash - Transaction hash
288
+ * @returns Promise resolving to generic transaction details
289
+ *
290
+ * @throws {@link CCIPTransactionNotFoundError} if transaction does not exist (transient)
291
+ *
292
+ * @example Fetch transaction details
293
+ * ```typescript
294
+ * const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
295
+ * try {
296
+ * const tx = await chain.getTransaction('0xabc123...')
297
+ * console.log(`Block: ${tx.blockNumber}, Timestamp: ${tx.timestamp}`)
298
+ * } catch (err) {
299
+ * if (err instanceof CCIPTransactionNotFoundError && err.isTransient) {
300
+ * // Transaction may be pending
301
+ * }
302
+ * }
303
+ * ```
273
304
  */
274
305
  abstract getTransaction(hash: string): Promise<ChainTransaction>;
275
306
  /**
276
307
  * Confirm a log tx is finalized or wait for it to be finalized.
308
+ *
277
309
  * @param opts - Options containing the request, finality level, and optional cancel promise
278
310
  * @returns true when the transaction is finalized
311
+ *
279
312
  * @throws {@link CCIPTransactionNotFinalizedError} if the transaction is not included (e.g., due to a reorg)
313
+ *
314
+ * @example Wait for message finality
315
+ * ```typescript
316
+ * const request = await source.getMessagesInTx(txHash)
317
+ * try {
318
+ * await source.waitFinalized({ request: request[0] })
319
+ * console.log('Transaction finalized')
320
+ * } catch (err) {
321
+ * if (err instanceof CCIPTransactionNotFinalizedError) {
322
+ * console.log('Transaction not yet finalized')
323
+ * }
324
+ * }
325
+ * ```
280
326
  */
281
327
  waitFinalized({ request: { log, tx }, finality, cancel$, }: {
282
328
  request: SetOptional<PickDeep<CCIPRequest, `log.${'address' | 'blockNumber' | 'transactionHash' | 'topics' | 'tx.timestamp'}` | 'tx.timestamp'>, 'tx'>;
@@ -307,12 +353,24 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
307
353
  * @throws {@link CCIPLogsWatchRequiresStartError} if watch mode is used without startBlock or startTime
308
354
  * @throws {@link CCIPLogsAddressRequiredError} if address is required but not provided (chain-specific)
309
355
  */
310
- abstract getLogs(opts: LogFilter): AsyncIterableIterator<Log_>;
356
+ abstract getLogs(opts: LogFilter): AsyncIterableIterator<ChainLog>;
311
357
  /**
312
- * Fetch all CCIP requests in a transaction
358
+ * Fetch all CCIP requests in a transaction.
359
+ *
313
360
  * @param tx - ChainTransaction or txHash to fetch requests from
314
- * @returns CCIP messages in the transaction (at least one)
315
- * @throws {@link CCIPMessageNotFoundInTxError} if no CCIP messages found in transaction
361
+ * @returns Promise resolving to CCIP messages in the transaction (at least one)
362
+ *
363
+ * @throws {@link CCIPTransactionNotFoundError} if transaction does not exist
364
+ * @throws {@link CCIPMessageNotFoundInTxError} if no CCIPSendRequested events in tx
365
+ *
366
+ * @example Get messages from transaction
367
+ * ```typescript
368
+ * const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
369
+ * const requests = await chain.getMessagesInTx('0xabc123...')
370
+ * for (const req of requests) {
371
+ * console.log(`Message ID: ${req.message.messageId}`)
372
+ * }
373
+ * ```
316
374
  */
317
375
  getMessagesInTx(tx: string | ChainTransaction): Promise<CCIPRequest[]>;
318
376
  /**
@@ -340,94 +398,183 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
340
398
  * @returns CCIPRequest with `metadata` populated from API
341
399
  * @throws {@link CCIPApiClientNotAvailableError} if API disabled
342
400
  * @throws {@link CCIPMessageIdNotFoundError} if message not found
401
+ * @throws {@link CCIPOnRampRequiredError} if onRamp is required but not provided
343
402
  * @throws {@link CCIPHttpError} if API request fails
344
- **/
403
+ */
345
404
  getMessageById(messageId: string, _opts?: {
346
405
  page?: number;
347
406
  onRamp?: string;
348
407
  }): Promise<CCIPRequest>;
349
408
  /**
350
409
  * Fetches all CCIP messages contained in a given commit batch.
351
- * @param request - CCIPRequest to fetch batch for.
352
- * @param commit - CommitReport range (min, max).
353
- * @param opts - Optional parameters (e.g., `page` for pagination width).
354
- * @returns Array of messages in the batch.
410
+ * To be implemented for chains supporting CCIPVersion &lt;= v1.6.0
411
+ *
412
+ * @param request - CCIPRequest to fetch batch for
413
+ * @param range - batch range \{ minSeqnr, maxSeqNr \}, e.g. from [[CommitReport]]
414
+ * @param opts - Optional parameters (e.g., `page` for pagination width)
415
+ * @returns Array of messages in the batch
416
+ *
355
417
  * @throws {@link CCIPMessageBatchIncompleteError} if not all messages in range could be fetched
418
+ *
419
+ * @example Get all messages in a batch
420
+ * ```typescript
421
+ * const verifications = await dest.getVerifications({ offRamp, request })
422
+ * const messages = await source.getMessagesInBatch(request, verifications.report)
423
+ * console.log(`Found ${messages.length} messages in batch`)
424
+ * ```
356
425
  */
357
- abstract getMessagesInBatch<R extends PickDeep<CCIPRequest, 'lane' | `log.${'topics' | 'address' | 'blockNumber'}` | 'message.sequenceNumber'>>(request: R, commit: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>, opts?: {
426
+ getMessagesInBatch?<R extends PickDeep<CCIPRequest, 'lane' | `log.${'topics' | 'address' | 'blockNumber'}` | 'message.sequenceNumber'>>(request: R, range: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>, opts?: {
358
427
  page?: number;
359
428
  }): Promise<R['message'][]>;
360
429
  /**
361
- * Fetch typeAndVersion for a given CCIP contract address
430
+ * Fetch input data needed for executing messages
431
+ * Should be called on the *source* instance
432
+ * @param opts - getExecutionInput options containing request and verifications
433
+ * @returns `input` payload to be passed to [[execute]]
434
+ * @see {@link execute} - method to execute a message
435
+ */
436
+ getExecutionInput({ request, verifications, ...opts }: {
437
+ request: CCIPRequest;
438
+ verifications: CCIPVerifications;
439
+ } & Pick<LogFilter, 'page'>): Promise<ExecutionInput>;
440
+ /**
441
+ * Fetch typeAndVersion for a given CCIP contract address.
442
+ *
362
443
  * @param address - CCIP contract address
363
- * @returns type - parsed type of the contract, e.g. `OnRamp`
364
- * @returns version - parsed version of the contract, e.g. `1.6.0`
365
- * @returns typeAndVersion - original (unparsed) typeAndVersion() string
366
- * @returns suffix - suffix of the version, if any (e.g. `-dev`)
367
- * @throws {@link CCIPTypeVersionInvalidError} if contract doesn't have valid typeAndVersion
444
+ * @returns Promise resolving to tuple:
445
+ * - `type` - Parsed type of the contract, e.g. `OnRamp`
446
+ * - `version` - Parsed version of the contract, e.g. `1.6.0`
447
+ * - `typeAndVersion` - Original (unparsed) typeAndVersion() string
448
+ * - `suffix` - Suffix of the version, if any (e.g. `-dev`)
449
+ *
450
+ * @throws {@link CCIPTypeVersionInvalidError} if typeAndVersion string cannot be parsed
451
+ *
452
+ * @example Check contract version
453
+ * ```typescript
454
+ * const [type, version] = await chain.typeAndVersion(contractAddress)
455
+ * console.log(`Contract: ${type} v${version}`)
456
+ * if (version < '1.6.0') {
457
+ * console.log('Legacy contract detected')
458
+ * }
459
+ * ```
368
460
  */
369
461
  abstract typeAndVersion(address: string): Promise<[type: string, version: string, typeAndVersion: string, suffix?: string]>;
370
462
  /**
371
- * Fetch the Router address set in OnRamp config
372
- * Used to discover OffRamp connected to OnRamp
463
+ * Fetch the Router address set in OnRamp config.
464
+ * Used to discover OffRamp connected to OnRamp.
465
+ *
373
466
  * @param onRamp - OnRamp contract address
374
- * @param destChainSelector - destination chain selector
375
- * @returns Router address
467
+ * @param destChainSelector - Destination chain selector
468
+ * @returns Promise resolving to Router address
469
+ *
470
+ * @throws {@link CCIPContractTypeInvalidError} if address is not an OnRamp
471
+ *
472
+ * @example Get router from onRamp
473
+ * ```typescript
474
+ * const router = await chain.getRouterForOnRamp(onRampAddress, destSelector)
475
+ * console.log(`Router: ${router}`)
476
+ * ```
376
477
  */
377
478
  abstract getRouterForOnRamp(onRamp: string, destChainSelector: bigint): Promise<string>;
378
479
  /**
379
- * Fetch the Router address set in OffRamp config
480
+ * Fetch the Router address set in OffRamp config.
481
+ *
380
482
  * @param offRamp - OffRamp contract address
381
- * @param sourceChainSelector - source chain selector
382
- * @returns Router address
483
+ * @param sourceChainSelector - Source chain selector
484
+ * @returns Promise resolving to Router address
485
+ *
486
+ * @throws {@link CCIPContractTypeInvalidError} if address is not an OffRamp
487
+ *
488
+ * @example Get router from offRamp
489
+ * ```typescript
490
+ * const router = await chain.getRouterForOffRamp(offRampAddress, sourceSelector)
491
+ * console.log(`Router: ${router}`)
492
+ * ```
383
493
  */
384
494
  abstract getRouterForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string>;
385
495
  /**
386
- * Get the native token address for a Router
387
- * @param router - router contract address
388
- * @returns native token address (usually wrapped)
496
+ * Get the native token address for a Router.
497
+ *
498
+ * @param router - Router contract address
499
+ * @returns Promise resolving to native token address (usually wrapped)
500
+ *
501
+ * @example Get wrapped native token
502
+ * ```typescript
503
+ * const weth = await chain.getNativeTokenForRouter(routerAddress)
504
+ * console.log(`Wrapped native: ${weth}`)
505
+ * ```
389
506
  */
390
507
  abstract getNativeTokenForRouter(router: string): Promise<string>;
391
508
  /**
392
- * Fetch the OffRamps allowlisted in a Router
393
- * Used to discover OffRamp connected to an OnRamp
509
+ * Fetch the OffRamps allowlisted in a Router.
510
+ * Used to discover OffRamp connected to an OnRamp.
511
+ *
394
512
  * @param router - Router contract address
395
- * @param sourceChainSelector - source chain selector
396
- * @returns array of OffRamp addresses
513
+ * @param sourceChainSelector - Source chain selector
514
+ * @returns Promise resolving to array of OffRamp addresses
515
+ *
516
+ * @example Get offRamps for a source chain
517
+ * ```typescript
518
+ * const offRamps = await dest.getOffRampsForRouter(routerAddress, sourceSelector)
519
+ * console.log(`Found ${offRamps.length} offRamp(s)`)
520
+ * ```
397
521
  */
398
522
  abstract getOffRampsForRouter(router: string, sourceChainSelector: bigint): Promise<string[]>;
399
523
  /**
400
- * Fetch the OnRamp registered in a Router for a destination chain
524
+ * Fetch the OnRamp registered in a Router for a destination chain.
525
+ *
401
526
  * @param router - Router contract address
402
- * @param destChainSelector - destination chain selector
403
- * @returns OnRamp addresses
527
+ * @param destChainSelector - Destination chain selector
528
+ * @returns Promise resolving to OnRamp address
529
+ *
530
+ * @throws {@link CCIPLaneNotFoundError} if no lane exists to destination
531
+ *
532
+ * @example Get onRamp for destination
533
+ * ```typescript
534
+ * const onRamp = await source.getOnRampForRouter(routerAddress, destSelector)
535
+ * console.log(`OnRamp: ${onRamp}`)
536
+ * ```
404
537
  */
405
538
  abstract getOnRampForRouter(router: string, destChainSelector: bigint): Promise<string>;
406
539
  /**
407
- * Fetch the OnRamp address set in OffRamp config
408
- * Used to discover OffRamp connected to an OnRamp
540
+ * Fetch the OnRamps addresses set in OffRamp config.
541
+ * Used to discover OffRamp connected to an OnRamp.
542
+ *
409
543
  * @param offRamp - OffRamp contract address
410
- * @param sourceChainSelector - source chain selector
411
- * @returns OnRamp address
412
- */
413
- abstract getOnRampForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string>;
414
- /**
415
- * Fetch the CommitStore set in OffRamp config (CCIP v1.5 and earlier).
416
- * For CCIP v1.6 and later, it should return the offRamp address.
417
- * @param offRamp - OffRamp contract address.
418
- * @returns CommitStore address.
544
+ * @param sourceChainSelector - Source chain selector
545
+ * @returns Promise resolving to OnRamps addresses
546
+ *
547
+ * @example Get onRamp from offRamp config
548
+ * ```typescript
549
+ * const [onRamp] = await dest.getOnRampsForOffRamp(offRampAddress, sourceSelector)
550
+ * console.log(`OnRamp: ${onRamp}`)
551
+ * ```
419
552
  */
420
- abstract getCommitStoreForOffRamp(offRamp: string): Promise<string>;
553
+ abstract getOnRampsForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string[]>;
421
554
  /**
422
- * Fetch the TokenPool's token/mint
555
+ * Fetch the TokenPool's token/mint.
556
+ *
423
557
  * @param tokenPool - TokenPool address
424
- * @returns Token or mint address
558
+ * @returns Promise resolving to token or mint address
559
+ *
560
+ * @example Get token for pool
561
+ * ```typescript
562
+ * const token = await chain.getTokenForTokenPool(tokenPoolAddress)
563
+ * console.log(`Token: ${token}`)
564
+ * ```
425
565
  */
426
566
  abstract getTokenForTokenPool(tokenPool: string): Promise<string>;
427
567
  /**
428
- * Fetch token metadata
568
+ * Fetch token metadata.
569
+ *
429
570
  * @param token - Token address
430
- * @returns Token symbol and decimals, and optionally name
571
+ * @returns Promise resolving to token symbol, decimals, and optionally name
572
+ *
573
+ * @example Get token info
574
+ * ```typescript
575
+ * const info = await chain.getTokenInfo(tokenAddress)
576
+ * console.log(`${info.symbol}: ${info.decimals} decimals`)
577
+ * ```
431
578
  */
432
579
  abstract getTokenInfo(token: string): Promise<TokenInfo>;
433
580
  /**
@@ -439,14 +586,14 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
439
586
  *
440
587
  * @example Query native token balance
441
588
  * ```typescript
442
- * const balance = await chain.getBalance({ address: '0x123...' })
589
+ * const balance = await chain.getBalance({ holder: '0x123...' })
443
590
  * console.log(`Native balance: ${balance}`) // balance in wei
444
591
  * ```
445
592
  *
446
593
  * @example Query ERC20 token balance
447
594
  * ```typescript
448
595
  * const balance = await chain.getBalance({
449
- * address: '0x123...',
596
+ * holder: '0x123...',
450
597
  * token: '0xLINK...'
451
598
  * })
452
599
  * console.log(`LINK balance: ${balance}`) // balance in smallest units
@@ -454,22 +601,52 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
454
601
  */
455
602
  abstract getBalance(opts: GetBalanceOpts): Promise<bigint>;
456
603
  /**
457
- * Fetch TokenAdminRegistry configured in a given OnRamp, Router, etc
458
- * Needed to map a source token to its dest counterparts
459
- * @param address - Some contract for which we can fetch a TokenAdminRegistry (OnRamp, Router, etc.)
460
- * @returns TokenAdminRegistry address
604
+ * Fetch TokenAdminRegistry configured in a given OnRamp, Router, etc.
605
+ * Needed to map a source token to its dest counterparts.
606
+ *
607
+ * @param address - Contract address (OnRamp, Router, etc.)
608
+ * @returns Promise resolving to TokenAdminRegistry address
609
+ *
610
+ * @example Get token registry
611
+ * ```typescript
612
+ * const registry = await chain.getTokenAdminRegistryFor(onRampAddress)
613
+ * console.log(`Registry: ${registry}`)
614
+ * ```
461
615
  */
462
616
  abstract getTokenAdminRegistryFor(address: string): Promise<string>;
463
617
  /**
464
- * Fetch the current fee for a given intended message
618
+ * Fetch the current fee for a given intended message.
619
+ *
465
620
  * @param opts - {@link SendMessageOpts} without approveMax
466
621
  * @returns Fee amount in the feeToken's smallest units
622
+ *
623
+ * @example Calculate message fee
624
+ * ```typescript
625
+ * const fee = await chain.getFee({
626
+ * router: routerAddress,
627
+ * destChainSelector: destSelector,
628
+ * message: { receiver: '0x...', data: '0x' },
629
+ * })
630
+ * console.log(`Fee: ${fee} wei`)
631
+ * ```
467
632
  */
468
633
  abstract getFee(opts: Omit<SendMessageOpts, 'approveMax'>): Promise<bigint>;
469
634
  /**
470
- * Generate unsigned txs for ccipSend'ing a message
635
+ * Generate unsigned txs for ccipSend'ing a message.
636
+ *
471
637
  * @param opts - {@link SendMessageOpts} with sender address
472
- * @returns chain-family specific unsigned txs
638
+ * @returns Promise resolving to chain-family specific unsigned txs
639
+ *
640
+ * @example Generate unsigned transaction
641
+ * ```typescript
642
+ * const unsignedTx = await chain.generateUnsignedSendMessage({
643
+ * router: routerAddress,
644
+ * destChainSelector: destSelector,
645
+ * message: { receiver: '0x...', data: '0x1337' },
646
+ * sender: walletAddress,
647
+ * })
648
+ * // Sign and send with external wallet
649
+ * ```
473
650
  */
474
651
  abstract generateUnsignedSendMessage(opts: SendMessageOpts & {
475
652
  /** Sender address (address of wallet which will send the message) */
@@ -477,11 +654,14 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
477
654
  }): Promise<UnsignedTx[F]>;
478
655
  /**
479
656
  * Send a CCIP message through a router using provided wallet.
657
+ *
480
658
  * @param opts - {@link SendMessageOpts} with chain-specific wallet for signing
481
- * @returns CCIP request
482
- * @throws {@link CCIPWalletNotSignerError} if wallet cannot sign transactions
659
+ * @returns Promise resolving to CCIP request with message details
483
660
  *
484
- * @example
661
+ * @throws {@link CCIPWalletNotSignerError} if wallet is not a valid signer
662
+ * @throws {@link CCIPLaneNotFoundError} if no lane exists to destination
663
+ *
664
+ * @example Send cross-chain message
485
665
  * ```typescript
486
666
  * const request = await chain.sendMessage({
487
667
  * router: '0x...',
@@ -502,64 +682,86 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
502
682
  wallet: unknown;
503
683
  }): Promise<CCIPRequest>;
504
684
  /**
505
- * Fetch supported offchain token data for a request from this network
506
- * @param request - CCIP request, with tx, logs and message
507
- * @returns array with one offchain token data for each token transfer in request
685
+ * Fetch supported offchain token data for a request from this network.
686
+ * It logs but doesn't throw in case it can't fetch attestation, as the transfers may not be
687
+ * from the expected attestation providers. It returns default offchainData=undefined for those.
688
+ *
689
+ * @param request - CCIP request, with tx.hash and message
690
+ * @returns Promise resolving to array with one offchain token data for each token transfer
691
+ *
692
+ * @example Get offchain token data for USDC transfer
693
+ * ```typescript
694
+ * const offchainData = await source.getOffchainTokenData(request)
695
+ * // Use in execution report
696
+ * ```
508
697
  */
509
- abstract getOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]>;
698
+ getOffchainTokenData(request: PickDeep<CCIPRequest, 'tx.hash' | `message`>): Promise<OffchainTokenData[]>;
510
699
  /**
511
- * Generate unsigned tx to manuallyExecute a message
512
- * @param opts - {@link ExecuteReportOpts} with payer address which will send the exec tx
513
- * @returns chain-family specific unsigned txs
700
+ * Generate unsigned tx to manuallyExecute a message.
701
+ *
702
+ * @param opts - {@link ExecuteOpts} with payer address which will send the exec tx
703
+ * @returns Promise resolving to chain-family specific unsigned txs
704
+ *
705
+ * @example Generate unsigned execution tx
706
+ * ```typescript
707
+ * const unsignedTx = await dest.generateUnsignedExecute({
708
+ * offRamp: offRampAddress,
709
+ * input,
710
+ * payer: walletAddress,
711
+ * })
712
+ * // Sign and send with external wallet
713
+ * ```
514
714
  */
515
- abstract generateUnsignedExecuteReport(opts: ExecuteReportOpts & {
715
+ abstract generateUnsignedExecute(opts: ExecuteOpts & {
516
716
  /** address which will be used to send the report tx */
517
717
  payer: string;
518
718
  }): Promise<UnsignedTx[F]>;
519
719
  /**
520
- * Execute messages in report in an offRamp
521
- * @param opts - {@link ExecuteReportOpts} with chain-specific wallet to sign and send tx
522
- * @returns transaction of the execution
720
+ * Execute messages in report in an offRamp.
523
721
  *
524
- * @example
722
+ * @param opts - {@link ExecuteOpts} with chain-specific wallet to sign and send tx
723
+ * @returns Promise resolving to transaction of the execution
724
+ *
725
+ * @throws {@link CCIPWalletNotSignerError} if wallet is not a valid signer
726
+ * @throws {@link CCIPExecTxRevertedError} if execution transaction reverts
727
+ * @throws {@link CCIPMerkleRootMismatchError} if merkle proof is invalid
728
+ *
729
+ * @example Manual execution of pending message
525
730
  * ```typescript
526
- * const execReportProof = calculateManualExecProof(
527
- * messagesInBatch: await source.getMessagesInBatch(request, commit.report),
528
- * request.lane,
529
- * request.message.messageId,
530
- * commit.report.merkleRoot,
531
- * dest,
532
- * )
533
- * const receipt = await dest.executeReport({
534
- * offRamp,
535
- * execReport: {
536
- * ...execReportProof,
537
- * message: request.message,
538
- * offchainTokenData: await source.getOffchainTokenData(request),
539
- * },
540
- * wallet,
541
- * })
542
- * console.log(`Message ID: ${request.message.messageId}`)
731
+ * const input = await source.getExecutionInput({ request, verifications })
732
+ * const receipt = await dest.execute({ offRamp, input, wallet })
733
+ * console.log(`Executed: ${receipt.log.transactionHash}`)
543
734
  * ```
544
735
  * @throws {@link CCIPWalletNotSignerError} if wallet cannot sign transactions
545
736
  * @throws {@link CCIPExecTxNotConfirmedError} if execution transaction fails to confirm
546
737
  */
547
- abstract executeReport(opts: ExecuteReportOpts & {
738
+ abstract execute(opts: ExecuteOpts & {
548
739
  wallet: unknown;
549
740
  }): Promise<CCIPExecution>;
550
741
  /**
551
- * Look for a CommitReport at dest for given CCIP request
552
- * May be specialized by some subclasses
553
- * @param opts - getCommitReport options
554
- * @returns CCIPCommit info
555
- * @throws {@link CCIPCommitNotFoundError} if no commit found for the request
742
+ * Look for a CommitReport at dest for given CCIP request.
743
+ * May be specialized by some subclasses.
744
+ *
745
+ * @param opts - getVerifications options
746
+ * @returns CCIPVerifications
747
+ *
748
+ * @throws {@link CCIPCommitNotFoundError} if no commit found for the request (transient)
749
+ *
750
+ * @example Get commit for a request
751
+ * ```typescript
752
+ * const verifications = await dest.getVerifications({
753
+ * offRamp: offRampAddress,
754
+ * request,
755
+ * })
756
+ * console.log(`Committed at block: ${verifications.log.blockNumber}`)
757
+ * ```
556
758
  */
557
- getCommitReport({ commitStore, request, ...hints }: {
558
- /** address of commitStore (OffRamp in \>=v1.6) */
559
- commitStore: string;
759
+ getVerifications({ offRamp, request, ...hints }: {
760
+ /** address of offRamp or commitStore contract */
761
+ offRamp: string;
560
762
  /** CCIPRequest subset object */
561
- request: PickDeep<CCIPRequest, 'lane' | 'message.sequenceNumber' | 'tx.timestamp'>;
562
- } & Pick<LogFilter, 'page' | 'watch' | 'startBlock'>): Promise<CCIPCommit>;
763
+ request: PickDeep<CCIPRequest, 'lane' | `message.${'sequenceNumber' | 'messageId'}` | 'tx.timestamp'>;
764
+ } & Pick<LogFilter, 'page' | 'watch' | 'startBlock'>): Promise<CCIPVerifications>;
563
765
  /**
564
766
  * Fetches estimated lane latency to a destination chain.
565
767
  * Uses this chain's selector as the source.
@@ -594,11 +796,25 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
594
796
  */
595
797
  getLaneLatency(destChainSelector: bigint): Promise<LaneLatencyResponse>;
596
798
  /**
597
- * Default/generic implementation of getExecutionReceipts
799
+ * Default/generic implementation of getExecutionReceipts.
800
+ * Yields execution receipts for a given offRamp.
801
+ *
598
802
  * @param opts - getExecutionReceipts options
599
803
  * @returns Async generator of CCIPExecution receipts
804
+ *
805
+ * @example Watch for execution receipts
806
+ * ```typescript
807
+ * for await (const exec of dest.getExecutionReceipts({
808
+ * offRamp: offRampAddress,
809
+ * messageId: request.message.messageId,
810
+ * startBlock: commit.log.blockNumber,
811
+ * })) {
812
+ * console.log(`State: ${exec.receipt.state}`)
813
+ * if (exec.receipt.state === ExecutionState.Success) break
814
+ * }
815
+ * ```
600
816
  */
601
- getExecutionReceipts({ offRamp, messageId, sourceChainSelector, commit, ...hints }: {
817
+ getExecutionReceipts({ offRamp, messageId, sourceChainSelector, verifications, ...hints }: {
602
818
  /** address of OffRamp contract */
603
819
  offRamp: string;
604
820
  /** filter: yield only executions for this message */
@@ -606,21 +822,36 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
606
822
  /** filter: yield only executions for this source chain */
607
823
  sourceChainSelector?: bigint;
608
824
  /** optional commit associated with the request, can be used for optimizations in some families */
609
- commit?: CCIPCommit;
825
+ verifications?: CCIPVerifications;
610
826
  } & Pick<LogFilter, 'page' | 'watch' | 'startBlock' | 'startTime'>): AsyncIterableIterator<CCIPExecution>;
611
827
  /**
612
828
  * Fetch first execution receipt inside a transaction.
829
+ *
613
830
  * @internal
614
- * @param tx - transaction hash or transaction object
831
+ * @param tx - Transaction hash or transaction object
615
832
  * @returns CCIP execution object
833
+ *
616
834
  * @throws {@link CCIPExecTxRevertedError} if no execution receipt found in transaction
835
+ *
836
+ * @example Get receipt from execution tx
837
+ * ```typescript
838
+ * const exec = await dest.getExecutionReceiptInTx(execTxHash)
839
+ * console.log(`State: ${exec.receipt.state}`)
840
+ * ```
617
841
  */
618
842
  getExecutionReceiptInTx(tx: string | ChainTransaction): Promise<CCIPExecution>;
619
843
  /**
620
844
  * List tokens supported by given TokenAdminRegistry contract.
845
+ *
621
846
  * @param address - Usually TokenAdminRegistry, but chain may support receiving Router, OnRamp, etc.
622
- * @param opts - Optional parameters (e.g., `page` for pagination range).
623
- * @returns Array of supported token addresses.
847
+ * @param opts - Optional parameters (e.g., `page` for pagination range)
848
+ * @returns Promise resolving to array of supported token addresses
849
+ *
850
+ * @example Get all supported tokens
851
+ * ```typescript
852
+ * const tokens = await chain.getSupportedTokens(registryAddress)
853
+ * console.log(`${tokens.length} tokens supported`)
854
+ * ```
624
855
  */
625
856
  abstract getSupportedTokens(address: string, opts?: {
626
857
  page?: number;
@@ -651,21 +882,27 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
651
882
  * Fetch configuration of a token pool.
652
883
  *
653
884
  * @remarks
654
- * Returns the core configuration of a token pool including which token it manages
655
- * and which router it's registered with.
885
+ * Return type varies by chain:
886
+ * - **EVM**: `typeAndVersion` is always present (required)
887
+ * - **Solana**: Includes extra `tokenPoolProgram` field
888
+ * - **Aptos**: Standard fields only
889
+ * - **Sui/TON**: Throws {@link CCIPNotImplementedError}
656
890
  *
657
- * @example Query pool configuration
891
+ * @example Type-safe access to chain-specific fields
658
892
  * ```typescript
659
- * const config = await chain.getTokenPoolConfig(poolAddress)
660
- * console.log(`Manages token: ${config.token}`)
661
- * console.log(`Router: ${config.router}`)
662
- * if (config.typeAndVersion) {
663
- * console.log(`Version: ${config.typeAndVersion}`)
893
+ * // Use instanceof to narrow the chain type
894
+ * if (chain instanceof SolanaChain) {
895
+ * const config = await chain.getTokenPoolConfig(poolAddress)
896
+ * console.log(config.tokenPoolProgram) // TypeScript knows this exists!
897
+ * } else if (chain instanceof EVMChain) {
898
+ * const config = await chain.getTokenPoolConfig(poolAddress)
899
+ * console.log(config.typeAndVersion) // TypeScript knows this is required!
664
900
  * }
665
901
  * ```
666
902
  *
667
903
  * @param tokenPool - Token pool contract address.
668
904
  * @returns {@link TokenPoolConfig} containing token, router, and version info.
905
+ * @throws {@link CCIPNotImplementedError} on Sui or TON chains
669
906
  */
670
907
  abstract getTokenPoolConfig(tokenPool: string): Promise<TokenPoolConfig>;
671
908
  /**
@@ -731,11 +968,26 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
731
968
  getTokenPoolRemote(tokenPool: string, remoteChainSelector: bigint): Promise<TokenPoolRemote>;
732
969
  /**
733
970
  * Fetch list and info of supported feeTokens.
734
- * @param router - Router address on this chain.
735
- * @returns Mapping of token addresses to respective TokenInfo objects.
971
+ *
972
+ * @param router - Router address on this chain
973
+ * @returns Promise resolving to mapping of token addresses to TokenInfo objects
974
+ *
975
+ * @example Get available fee tokens
976
+ * ```typescript
977
+ * const feeTokens = await chain.getFeeTokens(routerAddress)
978
+ * for (const [addr, info] of Object.entries(feeTokens)) {
979
+ * console.log(`${info.symbol}: ${addr}`)
980
+ * }
981
+ * ```
736
982
  */
737
983
  abstract getFeeTokens(router: string): Promise<Record<string, TokenInfo>>;
738
- /** {@inheritDoc ChainStatic.buildMessageForDest} */
984
+ /**
985
+ * Returns a copy of a message, populating missing fields like `extraArgs` with defaults.
986
+ * It's expected to return a message suitable at least for basic token transfers.
987
+ *
988
+ * @param message - AnyMessage (from source), containing at least `receiver`
989
+ * @returns A message suitable for `sendMessage` to this destination chain family
990
+ */
739
991
  static buildMessageForDest(message: Parameters<ChainStatic['buildMessageForDest']>[0]): AnyMessage;
740
992
  /**
741
993
  * Estimate `ccipReceive` execution cost (gas, computeUnits) for this *dest*
@@ -757,29 +1009,71 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
757
1009
  };
758
1010
  }): Promise<number>;
759
1011
  }
760
- /** Static methods and properties available on Chain class constructors. */
1012
+ /**
1013
+ * Static methods and properties available on Chain class constructors.
1014
+ *
1015
+ * @example Using static methods
1016
+ * ```typescript
1017
+ * // Create chain from URL
1018
+ * const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
1019
+ *
1020
+ * // Decode message from log
1021
+ * const message = EVMChain.decodeMessage(log)
1022
+ *
1023
+ * // Validate address format
1024
+ * const normalized = EVMChain.getAddress('0xABC...')
1025
+ * ```
1026
+ */
761
1027
  export type ChainStatic<F extends ChainFamily = ChainFamily> = Function & {
762
1028
  readonly family: F;
763
1029
  readonly decimals: number;
764
1030
  /**
765
- * async constructor: builds a Chain from a rpc endpoint url
766
- * @param url - rpc endpoint url
767
- * @param ctx - optional context with logger and API client configuration
1031
+ * Async constructor: builds a Chain from an RPC endpoint URL.
1032
+ *
1033
+ * @param url - RPC endpoint URL
1034
+ * @param ctx - Optional context with logger and API client configuration
1035
+ * @returns Promise resolving to Chain instance
1036
+ *
1037
+ * @throws {@link CCIPChainNotFoundError} if chain cannot be identified
1038
+ *
1039
+ * @example Create chain from RPC
1040
+ * ```typescript
1041
+ * const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
1042
+ * console.log(`Connected to: ${chain.network.name}`)
1043
+ * ```
768
1044
  */
769
1045
  fromUrl(url: string, ctx?: ChainContext): Promise<Chain<F>>;
770
1046
  /**
771
- * Try to decode a CCIP message *from* a log/event *originated* from this *source* chain,
772
- * but which may *target* other dest chain families
773
- * iow: the parsing is specific to this chain family, but content may be intended to alien chains
774
- * e.g: EVM-born (abi.encoded) bytearray may output message.computeUnits for Solana
1047
+ * Try to decode a CCIP message from a log/event originated from this source chain.
1048
+ * The parsing is specific to this chain family, but content may target other chains.
1049
+ *
775
1050
  * @param log - Chain generic log
776
- * @returns decoded CCIP message with merged extraArgs
1051
+ * @returns Decoded CCIP message with merged extraArgs, or undefined if not a CCIP message
1052
+ *
1053
+ * @example Decode message from log
1054
+ * ```typescript
1055
+ * const message = EVMChain.decodeMessage(log)
1056
+ * if (message) {
1057
+ * console.log(`Message ID: ${message.messageId}`)
1058
+ * }
1059
+ * ```
777
1060
  */
778
- decodeMessage(log: Pick<Log_, 'data'>): CCIPMessage | undefined;
1061
+ decodeMessage(log: Pick<ChainLog, 'data'>): CCIPMessage | undefined;
779
1062
  /**
780
- * Try to decode an extraArgs array serialized for this chain family
781
- * @param extraArgs - extra args bytes (Uint8Array, HexString or base64)
782
- * @returns object containing decoded extraArgs and their tags
1063
+ * Try to decode an extraArgs array serialized for this chain family.
1064
+ *
1065
+ * @param extraArgs - Extra args bytes (Uint8Array, HexString or base64)
1066
+ * @returns Object containing decoded extraArgs and their tag, or undefined
1067
+ *
1068
+ * @throws {@link CCIPExtraArgsParseError} if bytes cannot be decoded
1069
+ *
1070
+ * @example Decode extra args
1071
+ * ```typescript
1072
+ * const decoded = EVMChain.decodeExtraArgs(message.extraArgs)
1073
+ * if (decoded?._tag === 'EVMExtraArgsV2') {
1074
+ * console.log(`Gas limit: ${decoded.gasLimit}`)
1075
+ * }
1076
+ * ```
783
1077
  */
784
1078
  decodeExtraArgs(extraArgs: BytesLike): (EVMExtraArgsV1 & {
785
1079
  _tag: 'EVMExtraArgsV1';
@@ -792,54 +1086,140 @@ export type ChainStatic<F extends ChainFamily = ChainFamily> = Function & {
792
1086
  }) | (SuiExtraArgsV1 & {
793
1087
  _tag: 'SuiExtraArgsV1';
794
1088
  }) | undefined;
1089
+ /**
1090
+ * Encode extraArgs for this chain family.
1091
+ *
1092
+ * @param extraArgs - Extra args object to encode
1093
+ * @returns Encoded hex string
1094
+ *
1095
+ * @example Encode extra args
1096
+ * ```typescript
1097
+ * const encoded = EVMChain.encodeExtraArgs({
1098
+ * gasLimit: 200000n,
1099
+ * strict: false,
1100
+ * })
1101
+ * ```
1102
+ */
795
1103
  encodeExtraArgs(extraArgs: ExtraArgs): string;
796
1104
  /**
797
- * Decode a commit (CommitReportAccepted) event
1105
+ * Decode a commit (CommitReportAccepted) event.
1106
+ *
798
1107
  * @param log - Chain generic log
799
- * @param lane - if passed, filter or validate reports by lane
800
- * @returns Array of commit reports contained in the log
1108
+ * @param lane - If passed, filter or validate reports by lane
1109
+ * @returns Array of commit reports contained in the log, or undefined
1110
+ *
1111
+ * @example Decode commit from log
1112
+ * ```typescript
1113
+ * const commits = EVMChain.decodeCommits(log, lane)
1114
+ * if (commits) {
1115
+ * console.log(`Found ${commits.length} commit(s)`)
1116
+ * }
1117
+ * ```
801
1118
  */
802
- decodeCommits(log: Pick<Log_, 'data'>, lane?: Lane): CommitReport[] | undefined;
1119
+ decodeCommits(log: Pick<ChainLog, 'data'>, lane?: Lane): CommitReport[] | undefined;
803
1120
  /**
804
- * Decode a receipt (ExecutionStateChanged) event
1121
+ * Decode a receipt (ExecutionStateChanged) event.
1122
+ *
805
1123
  * @param log - Chain generic log
806
1124
  * @returns ExecutionReceipt or undefined if not a recognized receipt
1125
+ *
1126
+ * @example Decode execution receipt
1127
+ * ```typescript
1128
+ * const receipt = EVMChain.decodeReceipt(log)
1129
+ * if (receipt) {
1130
+ * console.log(`State: ${receipt.state}, Message: ${receipt.messageId}`)
1131
+ * }
1132
+ * ```
807
1133
  */
808
- decodeReceipt(log: Pick<Log_, 'data'>): ExecutionReceipt | undefined;
1134
+ decodeReceipt(log: Pick<ChainLog, 'data'>): ExecutionReceipt | undefined;
809
1135
  /**
810
- * Receive a bytes array and try to decode and normalize it as an address of this chain family
1136
+ * Receive a bytes array and try to decode and normalize it as an address of this chain family.
1137
+ *
811
1138
  * @param bytes - Bytes array (Uint8Array, HexString or Base64)
812
1139
  * @returns Address in this chain family's format
1140
+ *
1141
+ * @throws {@link CCIPAddressInvalidEvmError} if invalid EVM address
1142
+ * @throws {@link CCIPDataFormatUnsupportedError} if invalid Aptos/Sui address
1143
+ *
1144
+ * @example Normalize address
1145
+ * ```typescript
1146
+ * const normalized = EVMChain.getAddress('0xABC123...')
1147
+ * console.log(normalized) // checksummed address
1148
+ * ```
813
1149
  */
814
1150
  getAddress(bytes: BytesLike): string;
815
1151
  /**
816
- * Validates a transaction hash format for this chain family
1152
+ * Validates a transaction hash format for this chain family.
1153
+ *
1154
+ * @param v - Value to validate
1155
+ * @returns True if value is a valid transaction hash format
1156
+ *
1157
+ * @example Validate transaction hash
1158
+ * ```typescript
1159
+ * if (EVMChain.isTxHash(userInput)) {
1160
+ * const tx = await chain.getTransaction(userInput)
1161
+ * }
1162
+ * ```
817
1163
  */
818
1164
  isTxHash(v: unknown): v is string;
819
1165
  /**
820
1166
  * Format an address for human-friendly display.
821
1167
  * Defaults to getAddress if not overridden.
1168
+ *
822
1169
  * @param address - Address string in any recognized format
823
1170
  * @returns Human-friendly address string for display
1171
+ *
1172
+ * @example Format address for display
1173
+ * ```typescript
1174
+ * const display = EVMChain.formatAddress?.(rawAddress) ?? rawAddress
1175
+ * console.log(display)
1176
+ * ```
824
1177
  */
825
1178
  formatAddress?(address: string): string;
826
1179
  /**
827
1180
  * Format a transaction hash for human-friendly display.
1181
+ *
828
1182
  * @param hash - Transaction hash string
829
1183
  * @returns Human-friendly hash string for display
1184
+ *
1185
+ * @example Format tx hash for display
1186
+ * ```typescript
1187
+ * const display = EVMChain.formatTxHash?.(rawHash) ?? rawHash
1188
+ * console.log(display)
1189
+ * ```
830
1190
  */
831
1191
  formatTxHash?(hash: string): string;
832
1192
  /**
833
- * Create a leaf hasher for this dest chain and lane
834
- * @param lane - source, dest and onramp lane info
835
- * @param ctx - context object containing logger
836
- * @returns LeafHasher is a function that takes a message and returns a hash of it
1193
+ * Create a leaf hasher for this dest chain and lane.
1194
+ *
1195
+ * @param lane - Source, dest and onramp lane info
1196
+ * @param ctx - Context object containing logger
1197
+ * @returns LeafHasher function that takes a message and returns its hash
1198
+ *
1199
+ * @throws {@link CCIPHasherVersionUnsupportedError} if hasher version unsupported
1200
+ *
1201
+ * @example Create leaf hasher
1202
+ * ```typescript
1203
+ * const hasher = EVMChain.getDestLeafHasher(lane, { logger })
1204
+ * const leafHash = hasher(message)
1205
+ * ```
837
1206
  */
838
1207
  getDestLeafHasher(lane: Lane, ctx?: WithLogger): LeafHasher;
839
1208
  /**
840
- * Try to parse an error or bytearray generated by this chain family
1209
+ * Try to parse an error or bytearray generated by this chain family.
1210
+ *
841
1211
  * @param data - Caught object, string or bytearray
842
- * @returns Ordered record with messages/properties, or undefined if not a recognized error
1212
+ * @returns Ordered record with messages/properties, or undefined/null if not recognized
1213
+ *
1214
+ * @example Parse contract error
1215
+ * ```typescript
1216
+ * try {
1217
+ * await chain.sendMessage(opts)
1218
+ * } catch (err) {
1219
+ * const parsed = EVMChain.parse?.(err)
1220
+ * if (parsed) console.log('Contract error:', parsed)
1221
+ * }
1222
+ * ```
843
1223
  */
844
1224
  parse?(data: unknown): Record<string, unknown> | undefined | null;
845
1225
  /**