@chainlink/ccip-sdk 0.95.0 → 0.97.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +2 -2
  2. package/dist/all-chains.d.ts +23 -0
  3. package/dist/all-chains.d.ts.map +1 -0
  4. package/dist/all-chains.js +24 -0
  5. package/dist/all-chains.js.map +1 -0
  6. package/dist/api/index.d.ts +31 -19
  7. package/dist/api/index.d.ts.map +1 -1
  8. package/dist/api/index.js +46 -25
  9. package/dist/api/index.js.map +1 -1
  10. package/dist/api/types.d.ts +24 -30
  11. package/dist/api/types.d.ts.map +1 -1
  12. package/dist/aptos/exec.d.ts +2 -2
  13. package/dist/aptos/exec.d.ts.map +1 -1
  14. package/dist/aptos/exec.js.map +1 -1
  15. package/dist/aptos/hasher.d.ts.map +1 -1
  16. package/dist/aptos/hasher.js +1 -1
  17. package/dist/aptos/hasher.js.map +1 -1
  18. package/dist/aptos/index.d.ts +43 -15
  19. package/dist/aptos/index.d.ts.map +1 -1
  20. package/dist/aptos/index.js +112 -105
  21. package/dist/aptos/index.js.map +1 -1
  22. package/dist/aptos/types.d.ts +2 -19
  23. package/dist/aptos/types.d.ts.map +1 -1
  24. package/dist/aptos/types.js +0 -11
  25. package/dist/aptos/types.js.map +1 -1
  26. package/dist/chain.d.ts +734 -174
  27. package/dist/chain.d.ts.map +1 -1
  28. package/dist/chain.js +216 -31
  29. package/dist/chain.js.map +1 -1
  30. package/dist/commits.d.ts +4 -6
  31. package/dist/commits.d.ts.map +1 -1
  32. package/dist/commits.js +4 -4
  33. package/dist/commits.js.map +1 -1
  34. package/dist/errors/CCIPError.d.ts +33 -4
  35. package/dist/errors/CCIPError.d.ts.map +1 -1
  36. package/dist/errors/CCIPError.js +33 -4
  37. package/dist/errors/CCIPError.js.map +1 -1
  38. package/dist/errors/codes.d.ts +5 -0
  39. package/dist/errors/codes.d.ts.map +1 -1
  40. package/dist/errors/codes.js +5 -1
  41. package/dist/errors/codes.js.map +1 -1
  42. package/dist/errors/index.d.ts +2 -2
  43. package/dist/errors/index.d.ts.map +1 -1
  44. package/dist/errors/index.js +2 -2
  45. package/dist/errors/index.js.map +1 -1
  46. package/dist/errors/recovery.d.ts.map +1 -1
  47. package/dist/errors/recovery.js +6 -1
  48. package/dist/errors/recovery.js.map +1 -1
  49. package/dist/errors/specialized.d.ts +1702 -121
  50. package/dist/errors/specialized.d.ts.map +1 -1
  51. package/dist/errors/specialized.js +1729 -125
  52. package/dist/errors/specialized.js.map +1 -1
  53. package/dist/errors/utils.d.ts.map +1 -1
  54. package/dist/errors/utils.js +0 -1
  55. package/dist/errors/utils.js.map +1 -1
  56. package/dist/evm/abi/OffRamp_2_0.d.ts +764 -0
  57. package/dist/evm/abi/OffRamp_2_0.d.ts.map +1 -0
  58. package/dist/evm/abi/OffRamp_2_0.js +744 -0
  59. package/dist/evm/abi/OffRamp_2_0.js.map +1 -0
  60. package/dist/evm/abi/OnRamp_2_0.d.ts +925 -0
  61. package/dist/evm/abi/OnRamp_2_0.d.ts.map +1 -0
  62. package/dist/evm/abi/OnRamp_2_0.js +992 -0
  63. package/dist/evm/abi/OnRamp_2_0.js.map +1 -0
  64. package/dist/evm/const.d.ts +12 -2
  65. package/dist/evm/const.d.ts.map +1 -1
  66. package/dist/evm/const.js +8 -2
  67. package/dist/evm/const.js.map +1 -1
  68. package/dist/evm/errors.d.ts.map +1 -1
  69. package/dist/evm/errors.js +7 -2
  70. package/dist/evm/errors.js.map +1 -1
  71. package/dist/evm/extra-args.d.ts +25 -0
  72. package/dist/evm/extra-args.d.ts.map +1 -0
  73. package/dist/evm/extra-args.js +309 -0
  74. package/dist/evm/extra-args.js.map +1 -0
  75. package/dist/evm/gas.d.ts.map +1 -1
  76. package/dist/evm/gas.js +7 -12
  77. package/dist/evm/gas.js.map +1 -1
  78. package/dist/evm/hasher.d.ts.map +1 -1
  79. package/dist/evm/hasher.js +23 -13
  80. package/dist/evm/hasher.js.map +1 -1
  81. package/dist/evm/index.d.ts +140 -35
  82. package/dist/evm/index.d.ts.map +1 -1
  83. package/dist/evm/index.js +306 -226
  84. package/dist/evm/index.js.map +1 -1
  85. package/dist/evm/messages.d.ts +59 -5
  86. package/dist/evm/messages.d.ts.map +1 -1
  87. package/dist/evm/messages.js +210 -0
  88. package/dist/evm/messages.js.map +1 -1
  89. package/dist/evm/offchain.js.map +1 -1
  90. package/dist/evm/types.d.ts +7 -2
  91. package/dist/evm/types.d.ts.map +1 -1
  92. package/dist/evm/types.js +22 -1
  93. package/dist/evm/types.js.map +1 -1
  94. package/dist/execution.d.ts +62 -22
  95. package/dist/execution.d.ts.map +1 -1
  96. package/dist/execution.js +102 -51
  97. package/dist/execution.js.map +1 -1
  98. package/dist/extra-args.d.ts +113 -4
  99. package/dist/extra-args.d.ts.map +1 -1
  100. package/dist/extra-args.js +38 -3
  101. package/dist/extra-args.js.map +1 -1
  102. package/dist/gas.d.ts +31 -5
  103. package/dist/gas.d.ts.map +1 -1
  104. package/dist/gas.js +43 -9
  105. package/dist/gas.js.map +1 -1
  106. package/dist/index.d.ts +11 -10
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +8 -8
  109. package/dist/index.js.map +1 -1
  110. package/dist/requests.d.ts +101 -22
  111. package/dist/requests.d.ts.map +1 -1
  112. package/dist/requests.js +115 -24
  113. package/dist/requests.js.map +1 -1
  114. package/dist/selectors.d.ts.map +1 -1
  115. package/dist/selectors.js +24 -0
  116. package/dist/selectors.js.map +1 -1
  117. package/dist/shared/bcs-codecs.d.ts +61 -0
  118. package/dist/shared/bcs-codecs.d.ts.map +1 -0
  119. package/dist/shared/bcs-codecs.js +102 -0
  120. package/dist/shared/bcs-codecs.js.map +1 -0
  121. package/dist/shared/constants.d.ts +3 -0
  122. package/dist/shared/constants.d.ts.map +1 -0
  123. package/dist/shared/constants.js +3 -0
  124. package/dist/shared/constants.js.map +1 -0
  125. package/dist/solana/exec.d.ts +2 -2
  126. package/dist/solana/exec.d.ts.map +1 -1
  127. package/dist/solana/exec.js.map +1 -1
  128. package/dist/solana/index.d.ts +148 -30
  129. package/dist/solana/index.d.ts.map +1 -1
  130. package/dist/solana/index.js +137 -44
  131. package/dist/solana/index.js.map +1 -1
  132. package/dist/sui/hasher.d.ts.map +1 -1
  133. package/dist/sui/hasher.js +1 -1
  134. package/dist/sui/hasher.js.map +1 -1
  135. package/dist/sui/index.d.ts +49 -19
  136. package/dist/sui/index.d.ts.map +1 -1
  137. package/dist/sui/index.js +76 -43
  138. package/dist/sui/index.js.map +1 -1
  139. package/dist/sui/manuallyExec/encoder.d.ts +2 -2
  140. package/dist/sui/manuallyExec/encoder.d.ts.map +1 -1
  141. package/dist/sui/manuallyExec/encoder.js.map +1 -1
  142. package/dist/sui/manuallyExec/index.d.ts +2 -2
  143. package/dist/sui/manuallyExec/index.d.ts.map +1 -1
  144. package/dist/ton/exec.d.ts +2 -2
  145. package/dist/ton/exec.d.ts.map +1 -1
  146. package/dist/ton/exec.js.map +1 -1
  147. package/dist/ton/index.d.ts +66 -27
  148. package/dist/ton/index.d.ts.map +1 -1
  149. package/dist/ton/index.js +172 -47
  150. package/dist/ton/index.js.map +1 -1
  151. package/dist/ton/send.d.ts +52 -0
  152. package/dist/ton/send.d.ts.map +1 -0
  153. package/dist/ton/send.js +166 -0
  154. package/dist/ton/send.js.map +1 -0
  155. package/dist/ton/types.d.ts +2 -2
  156. package/dist/ton/types.d.ts.map +1 -1
  157. package/dist/ton/types.js.map +1 -1
  158. package/dist/types.d.ts +148 -12
  159. package/dist/types.d.ts.map +1 -1
  160. package/dist/types.js +6 -1
  161. package/dist/types.js.map +1 -1
  162. package/dist/utils.d.ts +79 -4
  163. package/dist/utils.d.ts.map +1 -1
  164. package/dist/utils.js +92 -7
  165. package/dist/utils.js.map +1 -1
  166. package/package.json +16 -11
  167. package/src/all-chains.ts +26 -0
  168. package/src/api/index.ts +58 -34
  169. package/src/api/types.ts +24 -31
  170. package/src/aptos/exec.ts +2 -2
  171. package/src/aptos/hasher.ts +1 -1
  172. package/src/aptos/index.ts +127 -129
  173. package/src/aptos/types.ts +2 -15
  174. package/src/chain.ts +837 -191
  175. package/src/commits.ts +9 -9
  176. package/src/errors/CCIPError.ts +33 -4
  177. package/src/errors/codes.ts +5 -1
  178. package/src/errors/index.ts +2 -1
  179. package/src/errors/recovery.ts +9 -1
  180. package/src/errors/specialized.ts +1745 -132
  181. package/src/errors/utils.ts +0 -1
  182. package/src/evm/abi/OffRamp_2_0.ts +743 -0
  183. package/src/evm/abi/OnRamp_2_0.ts +991 -0
  184. package/src/evm/const.ts +10 -3
  185. package/src/evm/errors.ts +6 -2
  186. package/src/evm/extra-args.ts +360 -0
  187. package/src/evm/gas.ts +14 -13
  188. package/src/evm/hasher.ts +30 -18
  189. package/src/evm/index.ts +376 -281
  190. package/src/evm/messages.ts +323 -11
  191. package/src/evm/offchain.ts +2 -2
  192. package/src/evm/types.ts +20 -2
  193. package/src/execution.ts +126 -71
  194. package/src/extra-args.ts +118 -4
  195. package/src/gas.ts +44 -11
  196. package/src/index.ts +14 -11
  197. package/src/requests.ts +128 -24
  198. package/src/selectors.ts +24 -0
  199. package/src/shared/bcs-codecs.ts +132 -0
  200. package/src/shared/constants.ts +2 -0
  201. package/src/solana/exec.ts +4 -4
  202. package/src/solana/index.ts +170 -82
  203. package/src/sui/hasher.ts +1 -1
  204. package/src/sui/index.ts +88 -56
  205. package/src/sui/manuallyExec/encoder.ts +2 -2
  206. package/src/sui/manuallyExec/index.ts +2 -2
  207. package/src/ton/exec.ts +2 -2
  208. package/src/ton/index.ts +220 -58
  209. package/src/ton/send.ts +222 -0
  210. package/src/ton/types.ts +2 -2
  211. package/src/types.ts +173 -30
  212. package/src/utils.ts +91 -7
  213. package/dist/aptos/utils.d.ts +0 -12
  214. package/dist/aptos/utils.d.ts.map +0 -1
  215. package/dist/aptos/utils.js +0 -15
  216. package/dist/aptos/utils.js.map +0 -1
  217. package/src/aptos/utils.ts +0 -24
package/dist/chain.d.ts CHANGED
@@ -3,11 +3,11 @@ import type { PickDeep, SetOptional } from 'type-fest';
3
3
  import { type LaneLatencyResponse, CCIPAPIClient } from './api/index.ts';
4
4
  import type { UnsignedAptosTx } from './aptos/types.ts';
5
5
  import type { UnsignedEVMTx } from './evm/types.ts';
6
- import type { EVMExtraArgsV1, EVMExtraArgsV2, ExtraArgs, SVMExtraArgsV1, SuiExtraArgsV1 } from './extra-args.ts';
6
+ import type { EVMExtraArgsV1, EVMExtraArgsV2, ExtraArgs, GenericExtraArgsV3, SVMExtraArgsV1, SuiExtraArgsV1 } from './extra-args.ts';
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 ChainTransaction, type CommitReport, type ExecutionInput, type ExecutionReceipt, type Lane, type Log_, 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
  *
@@ -35,8 +35,7 @@ export type ChainContext = WithLogger & {
35
35
  /**
36
36
  * CCIP API client instance for lane information queries.
37
37
  *
38
- * - `undefined` (default): Creates CCIPAPIClient with production endpoint
39
- * (https://api.ccip.chain.link)
38
+ * - `undefined` (default): Creates CCIPAPIClient with {@link DEFAULT_API_BASE_URL}
40
39
  * - `CCIPAPIClient`: Uses provided instance (allows custom URL, fetch, etc.)
41
40
  * - `null`: Disables API client entirely (getLaneLatency() will throw)
42
41
  *
@@ -111,29 +110,91 @@ export type GetBalanceOpts = {
111
110
  };
112
111
  /**
113
112
  * Rate limiter state for token pool configurations.
114
- * Null if rate limiting is disabled.
113
+ *
114
+ * @remarks
115
+ * - Returns the rate limiter bucket state when rate limiting is **enabled**
116
+ * - Returns `null` when rate limiting is **disabled** (unlimited throughput)
117
+ *
118
+ * @example Handling nullable state
119
+ * ```typescript
120
+ * const remote = await chain.getTokenPoolRemotes(poolAddress)
121
+ * const state = remote['ethereum-mainnet'].inboundRateLimiterState
122
+ *
123
+ * if (state === null) {
124
+ * console.log('Rate limiting disabled - unlimited throughput')
125
+ * } else {
126
+ * console.log(`Capacity: ${state.capacity}, Available: ${state.tokens}`)
127
+ * }
128
+ * ```
115
129
  */
116
130
  export type RateLimiterState = {
117
131
  /** Current token balance in the rate limiter bucket. */
118
132
  tokens: bigint;
119
133
  /** Maximum capacity of the rate limiter bucket. */
120
134
  capacity: bigint;
121
- /** Rate at which tokens are replenished. */
135
+ /** Rate at which tokens are replenished (tokens per second). */
122
136
  rate: bigint;
123
137
  } | null;
124
138
  /**
125
- * Remote token pool configuration for a specific chain.
139
+ * Remote token pool configuration for a specific destination chain.
140
+ *
141
+ * @remarks
142
+ * Each entry represents the configuration needed to transfer tokens
143
+ * from the current chain to a specific destination chain.
126
144
  */
127
145
  export type TokenPoolRemote = {
128
146
  /** Address of the remote token on the destination chain. */
129
147
  remoteToken: string;
130
- /** Addresses of remote token pools. */
148
+ /**
149
+ * Addresses of remote token pools on the destination chain.
150
+ *
151
+ * @remarks
152
+ * Multiple pools may exist for:
153
+ * - Redundancy (failover if one pool is unavailable)
154
+ * - Capacity aggregation across pools
155
+ * - Version management (different pool implementations)
156
+ */
131
157
  remotePools: string[];
132
158
  /** Inbound rate limiter state for tokens coming into this chain. */
133
159
  inboundRateLimiterState: RateLimiterState;
134
160
  /** Outbound rate limiter state for tokens leaving this chain. */
135
161
  outboundRateLimiterState: RateLimiterState;
136
162
  };
163
+ /**
164
+ * Token pool configuration returned by {@link Chain.getTokenPoolConfig}.
165
+ *
166
+ * @remarks
167
+ * Contains the core configuration of a token pool including the token it manages,
168
+ * the router it's registered with, and optionally its version identifier.
169
+ */
170
+ export type TokenPoolConfig = {
171
+ /** Address of the token managed by this pool. */
172
+ token: string;
173
+ /** Address of the CCIP router this pool is registered with. */
174
+ router: string;
175
+ /**
176
+ * Version identifier string (e.g., "BurnMintTokenPool 1.5.1").
177
+ *
178
+ * @remarks
179
+ * May be undefined for older pool implementations that don't expose this method.
180
+ */
181
+ typeAndVersion?: string;
182
+ };
183
+ /**
184
+ * Token configuration from a TokenAdminRegistry, returned by {@link Chain.getRegistryTokenConfig}.
185
+ *
186
+ * @remarks
187
+ * The TokenAdminRegistry tracks which administrator controls each token
188
+ * and which pool is authorized to handle transfers.
189
+ */
190
+ export type RegistryTokenConfig = {
191
+ /** Address of the current administrator for this token. */
192
+ administrator: string;
193
+ /** Address of pending administrator (if ownership transfer is in progress). */
194
+ pendingAdministrator?: string;
195
+ /** Address of the token pool authorized to handle this token's transfers. */
196
+ tokenPool?: string;
197
+ };
137
198
  /**
138
199
  * Maps chain family to respective unsigned transaction type.
139
200
  */
@@ -146,7 +207,7 @@ export type UnsignedTx = {
146
207
  [ChainFamily.Unknown]: never;
147
208
  };
148
209
  /**
149
- * Common options for [[getFee]], [[generateUnsignedSendMessage]] and [[sendMessage]] Chain methods
210
+ * Common options for {@link Chain.getFee}, {@link Chain.generateUnsignedSendMessage} and {@link Chain.sendMessage} methods.
150
211
  */
151
212
  export type SendMessageOpts = {
152
213
  /** Router address on this chain */
@@ -159,13 +220,20 @@ export type SendMessageOpts = {
159
220
  approveMax?: boolean;
160
221
  };
161
222
  /**
162
- * Common options for [[generateUnsignedExecuteReport]] and [[executeReport]] Chain methods
223
+ * Common options for {@link Chain.generateUnsignedExecute} and {@link Chain.execute} methods.
163
224
  */
164
- export type ExecuteReportOpts = {
225
+ export type ExecuteOpts = ({
165
226
  /** address of the OffRamp contract */
166
227
  offRamp: string;
167
- /** execution report */
168
- 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
+ }) & {
169
237
  /** gasLimit or computeUnits limit override for the ccipReceive call */
170
238
  gasLimit?: number;
171
239
  /** For EVM, overrides gasLimit on tokenPool call */
@@ -192,25 +260,69 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
192
260
  * Base constructor for Chain class.
193
261
  * @param network - NetworkInfo object for the Chain instance
194
262
  * @param ctx - Optional context with logger and API client configuration
263
+ * @throws {@link CCIPChainFamilyMismatchError} if network family doesn't match the Chain subclass
195
264
  */
196
265
  constructor(network: NetworkInfo, ctx?: ChainContext);
197
266
  /** Cleanup method to release resources (e.g., close connections). */
198
267
  destroy?(): void | Promise<void>;
199
268
  /**
200
- * Fetch the timestamp of a given block
201
- * @param block - positive block number, negative finality depth or 'finalized' tag
202
- * @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
+ *
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
+ * ```
203
282
  */
204
283
  abstract getBlockTimestamp(block: number | 'finalized'): Promise<number>;
205
284
  /**
206
- * Fetch a transaction by its hash
207
- * @param hash - transaction hash
208
- * @returns generic transaction details
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
+ * ```
209
304
  */
210
305
  abstract getTransaction(hash: string): Promise<ChainTransaction>;
211
306
  /**
212
- * Confirm a log tx is finalized or wait for it to be finalized
213
- * Throws if it isn't included (e.g. a reorg)
307
+ * Confirm a log tx is finalized or wait for it to be finalized.
308
+ *
309
+ * @param opts - Options containing the request, finality level, and optional cancel promise
310
+ * @returns true when the transaction is finalized
311
+ *
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
+ * ```
214
326
  */
215
327
  waitFinalized({ request: { log, tx }, finality, cancel$, }: {
216
328
  request: SetOptional<PickDeep<CCIPRequest, `log.${'address' | 'blockNumber' | 'transactionHash' | 'topics' | 'tx.timestamp'}` | 'tx.timestamp'>, 'tx'>;
@@ -237,105 +349,232 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
237
349
  * - `page`: if provided, try to use this page/range for batches
238
350
  * - `watch`: true or cancellation promise, getLogs continuously after initial fetch
239
351
  * @returns An async iterable iterator of logs.
352
+ * @throws {@link CCIPLogsWatchRequiresFinalityError} if watch mode is used without a finality endBlock tag
353
+ * @throws {@link CCIPLogsWatchRequiresStartError} if watch mode is used without startBlock or startTime
354
+ * @throws {@link CCIPLogsAddressRequiredError} if address is required but not provided (chain-specific)
240
355
  */
241
356
  abstract getLogs(opts: LogFilter): AsyncIterableIterator<Log_>;
242
357
  /**
243
- * Fetch all CCIP requests in a transaction
358
+ * Fetch all CCIP requests in a transaction.
359
+ *
244
360
  * @param tx - ChainTransaction or txHash to fetch requests from
245
- * @returns CCIP messages in the transaction (at least one)
246
- **/
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
+ * ```
374
+ */
247
375
  getMessagesInTx(tx: string | ChainTransaction): Promise<CCIPRequest[]>;
248
376
  /**
249
- * Fetch a message by ID.
250
- * Default implementation just tries API.
251
- * Children may override to fetch from chain as fallback
252
- * @param messageId - message ID to fetch request for
253
- * @param _opts - onRamp may be required in some implementations, and throw if missing
254
- * @returns CCIPRequest
255
- **/
377
+ * Fetch a CCIP message by its unique message ID.
378
+ *
379
+ * @remarks
380
+ * Uses the CCIP API to retrieve message details. The returned request includes
381
+ * a `metadata` field with API-specific information.
382
+ *
383
+ * @example
384
+ * ```typescript
385
+ * const request = await chain.getMessageById(messageId)
386
+ * console.log(`Sender: ${request.message.sender}`)
387
+ *
388
+ * if (request.metadata) {
389
+ * console.log(`Status: ${request.metadata.status}`)
390
+ * if (request.metadata.deliveryTime) {
391
+ * console.log(`Delivered in ${request.metadata.deliveryTime}ms`)
392
+ * }
393
+ * }
394
+ * ```
395
+ *
396
+ * @param messageId - The unique message ID (0x + 64 hex chars)
397
+ * @param _opts - Optional: `onRamp` hint for non-EVM chains
398
+ * @returns CCIPRequest with `metadata` populated from API
399
+ * @throws {@link CCIPApiClientNotAvailableError} if API disabled
400
+ * @throws {@link CCIPMessageIdNotFoundError} if message not found
401
+ * @throws {@link CCIPOnRampRequiredError} if onRamp is required but not provided
402
+ * @throws {@link CCIPHttpError} if API request fails
403
+ */
256
404
  getMessageById(messageId: string, _opts?: {
257
405
  page?: number;
258
406
  onRamp?: string;
259
407
  }): Promise<CCIPRequest>;
260
408
  /**
261
409
  * Fetches all CCIP messages contained in a given commit batch.
262
- * @param request - CCIPRequest to fetch batch for.
263
- * @param commit - CommitReport range (min, max).
264
- * @param opts - Optional parameters (e.g., `page` for pagination width).
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
+ *
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
+ * ```
265
425
  */
266
- 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?: {
267
427
  page?: number;
268
428
  }): Promise<R['message'][]>;
269
429
  /**
270
- * 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
+ *
271
443
  * @param address - CCIP contract address
272
- * @returns type - parsed type of the contract, e.g. `OnRamp`
273
- * @returns version - parsed version of the contract, e.g. `1.6.0`
274
- * @returns typeAndVersion - original (unparsed) typeAndVersion() string
275
- * @returns suffix - suffix of the version, if any (e.g. `-dev`)
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
+ * ```
276
460
  */
277
461
  abstract typeAndVersion(address: string): Promise<[type: string, version: string, typeAndVersion: string, suffix?: string]>;
278
462
  /**
279
- * Fetch the Router address set in OnRamp config
280
- * 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
+ *
281
466
  * @param onRamp - OnRamp contract address
282
- * @param destChainSelector - destination chain selector
283
- * @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
+ * ```
284
477
  */
285
478
  abstract getRouterForOnRamp(onRamp: string, destChainSelector: bigint): Promise<string>;
286
479
  /**
287
- * Fetch the Router address set in OffRamp config
480
+ * Fetch the Router address set in OffRamp config.
481
+ *
288
482
  * @param offRamp - OffRamp contract address
289
- * @param sourceChainSelector - source chain selector
290
- * @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
+ * ```
291
493
  */
292
494
  abstract getRouterForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string>;
293
495
  /**
294
- * Get the native token address for a Router
295
- * @param router - router contract address
296
- * @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
+ * ```
297
506
  */
298
507
  abstract getNativeTokenForRouter(router: string): Promise<string>;
299
508
  /**
300
- * Fetch the OffRamps allowlisted in a Router
301
- * 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
+ *
302
512
  * @param router - Router contract address
303
- * @param sourceChainSelector - source chain selector
304
- * @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
+ * ```
305
521
  */
306
522
  abstract getOffRampsForRouter(router: string, sourceChainSelector: bigint): Promise<string[]>;
307
523
  /**
308
- * Fetch the OnRamp registered in a Router for a destination chain
524
+ * Fetch the OnRamp registered in a Router for a destination chain.
525
+ *
309
526
  * @param router - Router contract address
310
- * @param destChainSelector - destination chain selector
311
- * @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
+ * ```
312
537
  */
313
538
  abstract getOnRampForRouter(router: string, destChainSelector: bigint): Promise<string>;
314
539
  /**
315
- * Fetch the OnRamp address set in OffRamp config
316
- * 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
+ *
317
543
  * @param offRamp - OffRamp contract address
318
- * @param sourceChainSelector - source chain selector
319
- * @returns OnRamp address
320
- */
321
- abstract getOnRampForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string>;
322
- /**
323
- * Fetch the CommitStore set in OffRamp config (CCIP v1.5 and earlier).
324
- * For CCIP v1.6 and later, it should return the offRamp address.
325
- * @param offRamp - OffRamp contract address.
326
- * @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
+ * ```
327
552
  */
328
- abstract getCommitStoreForOffRamp(offRamp: string): Promise<string>;
553
+ abstract getOnRampsForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string[]>;
329
554
  /**
330
- * Fetch the TokenPool's token/mint
555
+ * Fetch the TokenPool's token/mint.
556
+ *
331
557
  * @param tokenPool - TokenPool address
332
- * @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
+ * ```
333
565
  */
334
566
  abstract getTokenForTokenPool(tokenPool: string): Promise<string>;
335
567
  /**
336
- * Fetch token metadata
568
+ * Fetch token metadata.
569
+ *
337
570
  * @param token - Token address
338
- * @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
+ * ```
339
578
  */
340
579
  abstract getTokenInfo(token: string): Promise<TokenInfo>;
341
580
  /**
@@ -347,14 +586,14 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
347
586
  *
348
587
  * @example Query native token balance
349
588
  * ```typescript
350
- * const balance = await chain.getBalance({ address: '0x123...' })
589
+ * const balance = await chain.getBalance({ holder: '0x123...' })
351
590
  * console.log(`Native balance: ${balance}`) // balance in wei
352
591
  * ```
353
592
  *
354
593
  * @example Query ERC20 token balance
355
594
  * ```typescript
356
595
  * const balance = await chain.getBalance({
357
- * address: '0x123...',
596
+ * holder: '0x123...',
358
597
  * token: '0xLINK...'
359
598
  * })
360
599
  * console.log(`LINK balance: ${balance}`) // balance in smallest units
@@ -362,20 +601,52 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
362
601
  */
363
602
  abstract getBalance(opts: GetBalanceOpts): Promise<bigint>;
364
603
  /**
365
- * Fetch TokenAdminRegistry configured in a given OnRamp, Router, etc
366
- * Needed to map a source token to its dest counterparts
367
- * @param onRamp - Some contract for which we can fetch a TokenAdminRegistry
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
+ * ```
368
615
  */
369
616
  abstract getTokenAdminRegistryFor(address: string): Promise<string>;
370
617
  /**
371
- * Fetch the current fee for a given intended message
618
+ * Fetch the current fee for a given intended message.
619
+ *
372
620
  * @param opts - {@link SendMessageOpts} without approveMax
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
+ * ```
373
632
  */
374
633
  abstract getFee(opts: Omit<SendMessageOpts, 'approveMax'>): Promise<bigint>;
375
634
  /**
376
- * Generate unsigned txs for ccipSend'ing a message
635
+ * Generate unsigned txs for ccipSend'ing a message.
636
+ *
377
637
  * @param opts - {@link SendMessageOpts} with sender address
378
- * @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
+ * ```
379
650
  */
380
651
  abstract generateUnsignedSendMessage(opts: SendMessageOpts & {
381
652
  /** Sender address (address of wallet which will send the message) */
@@ -383,10 +654,14 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
383
654
  }): Promise<UnsignedTx[F]>;
384
655
  /**
385
656
  * Send a CCIP message through a router using provided wallet.
657
+ *
386
658
  * @param opts - {@link SendMessageOpts} with chain-specific wallet for signing
387
- * @returns CCIP request
659
+ * @returns Promise resolving to CCIP request with message details
388
660
  *
389
- * @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
390
665
  * ```typescript
391
666
  * const request = await chain.sendMessage({
392
667
  * router: '0x...',
@@ -407,61 +682,87 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
407
682
  wallet: unknown;
408
683
  }): Promise<CCIPRequest>;
409
684
  /**
410
- * Fetch supported offchain token data for a request from this network
685
+ * Fetch supported offchain token data for a request from this network.
686
+ *
411
687
  * @param request - CCIP request, with tx, logs and message
412
- * @returns array with one offchain token data for each token transfer in request
688
+ * @returns Promise resolving to array with one offchain token data for each token transfer
689
+ *
690
+ * @throws {@link CCIPUsdcAttestationError} if USDC attestation fetch fails (transient)
691
+ * @throws {@link CCIPLbtcAttestationError} if LBTC attestation fetch fails (transient)
692
+ *
693
+ * @example Get offchain token data for USDC transfer
694
+ * ```typescript
695
+ * const offchainData = await source.getOffchainTokenData(request)
696
+ * // Use in execution report
697
+ * ```
413
698
  */
414
699
  abstract getOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]>;
415
700
  /**
416
- * Generate unsigned tx to manuallyExecute a message
417
- * @param opts - {@link ExecuteReportOpts} with payer address which will send the exec tx
418
- * @returns chain-family specific unsigned txs
701
+ * Generate unsigned tx to manuallyExecute a message.
702
+ *
703
+ * @param opts - {@link ExecuteOpts} with payer address which will send the exec tx
704
+ * @returns Promise resolving to chain-family specific unsigned txs
705
+ *
706
+ * @example Generate unsigned execution tx
707
+ * ```typescript
708
+ * const unsignedTx = await dest.generateUnsignedExecute({
709
+ * offRamp: offRampAddress,
710
+ * execReport,
711
+ * payer: walletAddress,
712
+ * })
713
+ * // Sign and send with external wallet
714
+ * ```
419
715
  */
420
- abstract generateUnsignedExecuteReport(opts: ExecuteReportOpts & {
716
+ abstract generateUnsignedExecute(opts: ExecuteOpts & {
421
717
  /** address which will be used to send the report tx */
422
718
  payer: string;
423
719
  }): Promise<UnsignedTx[F]>;
424
720
  /**
425
- * Execute messages in report in an offRamp
426
- * @param opts - {@link ExecuteReportOpts} with chain-specific wallet to sign and send tx
427
- * @returns transaction of the execution
721
+ * Execute messages in report in an offRamp.
428
722
  *
429
- * @example
723
+ * @param opts - {@link ExecuteOpts} with chain-specific wallet to sign and send tx
724
+ * @returns Promise resolving to transaction of the execution
725
+ *
726
+ * @throws {@link CCIPWalletNotSignerError} if wallet is not a valid signer
727
+ * @throws {@link CCIPExecTxRevertedError} if execution transaction reverts
728
+ * @throws {@link CCIPMerkleRootMismatchError} if merkle proof is invalid
729
+ *
730
+ * @example Manual execution of pending message
430
731
  * ```typescript
431
- * const execReportProof = calculateManualExecProof(
432
- * messagesInBatch: await source.getMessagesInBatch(request, commit.report),
433
- * request.lane,
434
- * request.message.messageId,
435
- * commit.report.merkleRoot,
436
- * dest,
437
- * )
438
- * const receipt = await dest.executeReport({
439
- * offRamp,
440
- * execReport: {
441
- * ...execReportProof,
442
- * message: request.message,
443
- * offchainTokenData: await source.getOffchainTokenData(request),
444
- * },
445
- * wallet,
446
- * })
447
- * console.log(`Message ID: ${request.message.messageId}`)
732
+ * const input = await source.getExecutionInput({ request, verifications })
733
+ * const receipt = await dest.execute({ offRamp, input, wallet })
734
+ * console.log(`Executed: ${receipt.log.transactionHash}`)
448
735
  * ```
736
+ * @throws {@link CCIPWalletNotSignerError} if wallet cannot sign transactions
737
+ * @throws {@link CCIPExecTxNotConfirmedError} if execution transaction fails to confirm
449
738
  */
450
- abstract executeReport(opts: ExecuteReportOpts & {
739
+ abstract execute(opts: ExecuteOpts & {
451
740
  wallet: unknown;
452
741
  }): Promise<CCIPExecution>;
453
742
  /**
454
- * Look for a CommitReport at dest for given CCIP request
455
- * May be specialized by some subclasses
456
- * @param opts - getCommitReport options
457
- * @returns CCIPCommit info, or reject if none found
458
- **/
459
- getCommitReport({ commitStore, request, ...hints }: {
460
- /** address of commitStore (OffRamp in \>=v1.6) */
461
- commitStore: string;
743
+ * Look for a CommitReport at dest for given CCIP request.
744
+ * May be specialized by some subclasses.
745
+ *
746
+ * @param opts - getVerifications options
747
+ * @returns CCIPCommit info
748
+ *
749
+ * @throws {@link CCIPCommitNotFoundError} if no commit found for the request (transient)
750
+ *
751
+ * @example Get commit for a request
752
+ * ```typescript
753
+ * const verifications = await dest.getVerifications({
754
+ * offRamp: offRampAddress,
755
+ * request,
756
+ * })
757
+ * console.log(`Committed at block: ${verifications.log.blockNumber}`)
758
+ * ```
759
+ */
760
+ getVerifications({ offRamp, request, ...hints }: {
761
+ /** address of offRamp or commitStore contract */
762
+ offRamp: string;
462
763
  /** CCIPRequest subset object */
463
- request: PickDeep<CCIPRequest, 'lane' | 'message.sequenceNumber' | 'tx.timestamp'>;
464
- } & Pick<LogFilter, 'page' | 'watch' | 'startBlock'>): Promise<CCIPCommit>;
764
+ request: PickDeep<CCIPRequest, 'lane' | `message.${'sequenceNumber' | 'messageId'}` | 'tx.timestamp'>;
765
+ } & Pick<LogFilter, 'page' | 'watch' | 'startBlock'>): Promise<CCIPVerifications>;
465
766
  /**
466
767
  * Fetches estimated lane latency to a destination chain.
467
768
  * Uses this chain's selector as the source.
@@ -496,11 +797,25 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
496
797
  */
497
798
  getLaneLatency(destChainSelector: bigint): Promise<LaneLatencyResponse>;
498
799
  /**
499
- * Default/generic implementation of getExecutionReceipts
800
+ * Default/generic implementation of getExecutionReceipts.
801
+ * Yields execution receipts for a given offRamp.
802
+ *
500
803
  * @param opts - getExecutionReceipts options
501
804
  * @returns Async generator of CCIPExecution receipts
805
+ *
806
+ * @example Watch for execution receipts
807
+ * ```typescript
808
+ * for await (const exec of dest.getExecutionReceipts({
809
+ * offRamp: offRampAddress,
810
+ * messageId: request.message.messageId,
811
+ * startBlock: commit.log.blockNumber,
812
+ * })) {
813
+ * console.log(`State: ${exec.receipt.state}`)
814
+ * if (exec.receipt.state === ExecutionState.Success) break
815
+ * }
816
+ * ```
502
817
  */
503
- getExecutionReceipts({ offRamp, messageId, sourceChainSelector, commit, ...hints }: {
818
+ getExecutionReceipts({ offRamp, messageId, sourceChainSelector, verifications, ...hints }: {
504
819
  /** address of OffRamp contract */
505
820
  offRamp: string;
506
821
  /** filter: yield only executions for this message */
@@ -508,57 +823,172 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
508
823
  /** filter: yield only executions for this source chain */
509
824
  sourceChainSelector?: bigint;
510
825
  /** optional commit associated with the request, can be used for optimizations in some families */
511
- commit?: CCIPCommit;
826
+ verifications?: CCIPVerifications;
512
827
  } & Pick<LogFilter, 'page' | 'watch' | 'startBlock' | 'startTime'>): AsyncIterableIterator<CCIPExecution>;
513
828
  /**
514
829
  * Fetch first execution receipt inside a transaction.
830
+ *
515
831
  * @internal
516
- * @param tx - transaction hash or transaction object
832
+ * @param tx - Transaction hash or transaction object
517
833
  * @returns CCIP execution object
834
+ *
835
+ * @throws {@link CCIPExecTxRevertedError} if no execution receipt found in transaction
836
+ *
837
+ * @example Get receipt from execution tx
838
+ * ```typescript
839
+ * const exec = await dest.getExecutionReceiptInTx(execTxHash)
840
+ * console.log(`State: ${exec.receipt.state}`)
841
+ * ```
518
842
  */
519
843
  getExecutionReceiptInTx(tx: string | ChainTransaction): Promise<CCIPExecution>;
520
844
  /**
521
845
  * List tokens supported by given TokenAdminRegistry contract.
846
+ *
522
847
  * @param address - Usually TokenAdminRegistry, but chain may support receiving Router, OnRamp, etc.
523
- * @param opts - Optional parameters (e.g., `page` for pagination range).
524
- * @returns Array of supported token addresses.
848
+ * @param opts - Optional parameters (e.g., `page` for pagination range)
849
+ * @returns Promise resolving to array of supported token addresses
850
+ *
851
+ * @example Get all supported tokens
852
+ * ```typescript
853
+ * const tokens = await chain.getSupportedTokens(registryAddress)
854
+ * console.log(`${tokens.length} tokens supported`)
855
+ * ```
525
856
  */
526
857
  abstract getSupportedTokens(address: string, opts?: {
527
858
  page?: number;
528
859
  }): Promise<string[]>;
529
860
  /**
530
- * Get TokenConfig for a given token address in a TokenAdminRegistry
531
- * @param address - TokenAdminRegistry contract address
532
- * @param token - Token address
861
+ * Fetch token configuration from a TokenAdminRegistry.
862
+ *
863
+ * @remarks
864
+ * The TokenAdminRegistry is a contract that tracks token administrators and their
865
+ * associated pools. Each token has an administrator who can update pool configurations.
866
+ *
867
+ * @example Query a token's registry configuration
868
+ * ```typescript
869
+ * const config = await chain.getRegistryTokenConfig(registryAddress, tokenAddress)
870
+ * console.log(`Administrator: ${config.administrator}`)
871
+ * if (config.tokenPool) {
872
+ * console.log(`Pool: ${config.tokenPool}`)
873
+ * }
874
+ * ```
875
+ *
876
+ * @param registry - TokenAdminRegistry contract address.
877
+ * @param token - Token address to query.
878
+ * @returns {@link RegistryTokenConfig} containing administrator and pool information.
879
+ * @throws {@link CCIPTokenNotInRegistryError} if token is not registered.
533
880
  */
534
- abstract getRegistryTokenConfig(registry: string, token: string): Promise<{
535
- administrator: string;
536
- pendingAdministrator?: string;
537
- tokenPool?: string;
538
- }>;
881
+ abstract getRegistryTokenConfig(registry: string, token: string): Promise<RegistryTokenConfig>;
539
882
  /**
540
- * Get TokenPool state and configurations
541
- * @param tokenPool - Token pool address
883
+ * Fetch configuration of a token pool.
884
+ *
885
+ * @remarks
886
+ * Return type varies by chain:
887
+ * - **EVM**: `typeAndVersion` is always present (required)
888
+ * - **Solana**: Includes extra `tokenPoolProgram` field
889
+ * - **Aptos**: Standard fields only
890
+ * - **Sui/TON**: Throws {@link CCIPNotImplementedError}
891
+ *
892
+ * @example Type-safe access to chain-specific fields
893
+ * ```typescript
894
+ * // Use instanceof to narrow the chain type
895
+ * if (chain instanceof SolanaChain) {
896
+ * const config = await chain.getTokenPoolConfig(poolAddress)
897
+ * console.log(config.tokenPoolProgram) // TypeScript knows this exists!
898
+ * } else if (chain instanceof EVMChain) {
899
+ * const config = await chain.getTokenPoolConfig(poolAddress)
900
+ * console.log(config.typeAndVersion) // TypeScript knows this is required!
901
+ * }
902
+ * ```
903
+ *
904
+ * @param tokenPool - Token pool contract address.
905
+ * @returns {@link TokenPoolConfig} containing token, router, and version info.
906
+ * @throws {@link CCIPNotImplementedError} on Sui or TON chains
542
907
  */
543
- abstract getTokenPoolConfigs(tokenPool: string): Promise<{
544
- token: string;
545
- router: string;
546
- typeAndVersion?: string;
547
- }>;
908
+ abstract getTokenPoolConfig(tokenPool: string): Promise<TokenPoolConfig>;
548
909
  /**
549
- * Get TokenPool remote configurations.
550
- * @param tokenPool - Token pool address.
551
- * @param remoteChainSelector - If provided, only return remotes for the specified chain (may error if remote not supported).
552
- * @returns Record of network names and remote configurations (remoteToken, remotePools, rateLimitStates).
910
+ * Fetch remote chain configurations for a token pool.
911
+ *
912
+ * @remarks
913
+ * A token pool maintains configurations for each destination chain it supports.
914
+ * The returned Record maps chain names to their respective configurations.
915
+ *
916
+ * @example Get all supported destinations
917
+ * ```typescript
918
+ * const remotes = await chain.getTokenPoolRemotes(poolAddress)
919
+ * // Returns: {
920
+ * // "ethereum-mainnet": { remoteToken: "0x...", remotePools: [...], ... },
921
+ * // "ethereum-mainnet-arbitrum-1": { remoteToken: "0x...", remotePools: [...], ... },
922
+ * // "solana-mainnet": { remoteToken: "...", remotePools: [...], ... }
923
+ * // }
924
+ *
925
+ * // Access a specific chain's config
926
+ * const arbConfig = remotes['ethereum-mainnet']
927
+ * console.log(`Remote token: ${arbConfig.remoteToken}`)
928
+ * ```
929
+ *
930
+ * @example Filter to a specific destination
931
+ * ```typescript
932
+ * import { networkInfo } from '@chainlink/ccip-sdk'
933
+ *
934
+ * const arbitrumSelector = 4949039107694359620n
935
+ * const remotes = await chain.getTokenPoolRemotes(poolAddress, arbitrumSelector)
936
+ * // Returns only: { "arbitrum-mainnet": { ... } }
937
+ *
938
+ * const chainName = networkInfo(arbitrumSelector).name
939
+ * const config = remotes[chainName]
940
+ * ```
941
+ *
942
+ * @param tokenPool - Token pool address on the current chain.
943
+ * @param remoteChainSelector - Optional chain selector to filter results to a single destination.
944
+ * @returns Record where keys are chain names (e.g., "ethereum-mainnet") and values are {@link TokenPoolRemote} configs.
945
+ * @throws {@link CCIPTokenPoolChainConfigNotFoundError} if remoteChainSelector is specified but not configured.
553
946
  */
554
947
  abstract getTokenPoolRemotes(tokenPool: string, remoteChainSelector?: bigint): Promise<Record<string, TokenPoolRemote>>;
948
+ /**
949
+ * Fetch remote chain configuration for a token pool for a specific destination.
950
+ *
951
+ * @remarks
952
+ * Convenience wrapper around {@link getTokenPoolRemotes} that returns a single
953
+ * configuration instead of a Record. Use this when you need configuration for
954
+ * a specific destination chain.
955
+ *
956
+ * @example
957
+ * ```typescript
958
+ * const arbitrumSelector = 4949039107694359620n
959
+ * const remote = await chain.getTokenPoolRemote(poolAddress, arbitrumSelector)
960
+ * console.log(`Remote token: ${remote.remoteToken}`)
961
+ * console.log(`Remote pools: ${remote.remotePools.join(', ')}`)
962
+ * ```
963
+ *
964
+ * @param tokenPool - Token pool address on the current chain.
965
+ * @param remoteChainSelector - Chain selector of the desired remote chain.
966
+ * @returns TokenPoolRemote config for the specified remote chain.
967
+ * @throws {@link CCIPTokenPoolChainConfigNotFoundError} if no configuration found for the specified remote chain.
968
+ */
969
+ getTokenPoolRemote(tokenPool: string, remoteChainSelector: bigint): Promise<TokenPoolRemote>;
555
970
  /**
556
971
  * Fetch list and info of supported feeTokens.
557
- * @param router - Router address on this chain.
558
- * @returns Mapping of token addresses to respective TokenInfo objects.
972
+ *
973
+ * @param router - Router address on this chain
974
+ * @returns Promise resolving to mapping of token addresses to TokenInfo objects
975
+ *
976
+ * @example Get available fee tokens
977
+ * ```typescript
978
+ * const feeTokens = await chain.getFeeTokens(routerAddress)
979
+ * for (const [addr, info] of Object.entries(feeTokens)) {
980
+ * console.log(`${info.symbol}: ${addr}`)
981
+ * }
982
+ * ```
559
983
  */
560
984
  abstract getFeeTokens(router: string): Promise<Record<string, TokenInfo>>;
561
- /** {@inheritDoc ChainStatic.buildMessageForDest} */
985
+ /**
986
+ * Returns a copy of a message, populating missing fields like `extraArgs` with defaults.
987
+ * It's expected to return a message suitable at least for basic token transfers.
988
+ *
989
+ * @param message - AnyMessage (from source), containing at least `receiver`
990
+ * @returns A message suitable for `sendMessage` to this destination chain family
991
+ */
562
992
  static buildMessageForDest(message: Parameters<ChainStatic['buildMessageForDest']>[0]): AnyMessage;
563
993
  /**
564
994
  * Estimate `ccipReceive` execution cost (gas, computeUnits) for this *dest*
@@ -580,87 +1010,217 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
580
1010
  };
581
1011
  }): Promise<number>;
582
1012
  }
583
- /** Static methods and properties available on Chain class constructors. */
1013
+ /**
1014
+ * Static methods and properties available on Chain class constructors.
1015
+ *
1016
+ * @example Using static methods
1017
+ * ```typescript
1018
+ * // Create chain from URL
1019
+ * const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
1020
+ *
1021
+ * // Decode message from log
1022
+ * const message = EVMChain.decodeMessage(log)
1023
+ *
1024
+ * // Validate address format
1025
+ * const normalized = EVMChain.getAddress('0xABC...')
1026
+ * ```
1027
+ */
584
1028
  export type ChainStatic<F extends ChainFamily = ChainFamily> = Function & {
585
1029
  readonly family: F;
586
1030
  readonly decimals: number;
587
1031
  /**
588
- * async constructor: builds a Chain from a rpc endpoint url
589
- * @param url - rpc endpoint url
590
- * @param ctx - optional context with logger and API client configuration
1032
+ * Async constructor: builds a Chain from an RPC endpoint URL.
1033
+ *
1034
+ * @param url - RPC endpoint URL
1035
+ * @param ctx - Optional context with logger and API client configuration
1036
+ * @returns Promise resolving to Chain instance
1037
+ *
1038
+ * @throws {@link CCIPChainNotFoundError} if chain cannot be identified
1039
+ *
1040
+ * @example Create chain from RPC
1041
+ * ```typescript
1042
+ * const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
1043
+ * console.log(`Connected to: ${chain.network.name}`)
1044
+ * ```
591
1045
  */
592
1046
  fromUrl(url: string, ctx?: ChainContext): Promise<Chain<F>>;
593
1047
  /**
594
- * Try to decode a CCIP message *from* a log/event *originated* from this *source* chain,
595
- * but which may *target* other dest chain families
596
- * iow: the parsing is specific to this chain family, but content may be intended to alien chains
597
- * e.g: EVM-born (abi.encoded) bytearray may output message.computeUnits for Solana
1048
+ * Try to decode a CCIP message from a log/event originated from this source chain.
1049
+ * The parsing is specific to this chain family, but content may target other chains.
1050
+ *
598
1051
  * @param log - Chain generic log
599
- * @returns decoded CCIP message with merged extraArgs
1052
+ * @returns Decoded CCIP message with merged extraArgs, or undefined if not a CCIP message
1053
+ *
1054
+ * @example Decode message from log
1055
+ * ```typescript
1056
+ * const message = EVMChain.decodeMessage(log)
1057
+ * if (message) {
1058
+ * console.log(`Message ID: ${message.messageId}`)
1059
+ * }
1060
+ * ```
600
1061
  */
601
1062
  decodeMessage(log: Pick<Log_, 'data'>): CCIPMessage | undefined;
602
1063
  /**
603
- * Try to decode an extraArgs array serialized for this chain family
604
- * @param extraArgs - extra args bytes (Uint8Array, HexString or base64)
605
- * @returns object containing decoded extraArgs and their tags
1064
+ * Try to decode an extraArgs array serialized for this chain family.
1065
+ *
1066
+ * @param extraArgs - Extra args bytes (Uint8Array, HexString or base64)
1067
+ * @returns Object containing decoded extraArgs and their tag, or undefined
1068
+ *
1069
+ * @throws {@link CCIPExtraArgsParseError} if bytes cannot be decoded
1070
+ *
1071
+ * @example Decode extra args
1072
+ * ```typescript
1073
+ * const decoded = EVMChain.decodeExtraArgs(message.extraArgs)
1074
+ * if (decoded?._tag === 'EVMExtraArgsV2') {
1075
+ * console.log(`Gas limit: ${decoded.gasLimit}`)
1076
+ * }
1077
+ * ```
606
1078
  */
607
1079
  decodeExtraArgs(extraArgs: BytesLike): (EVMExtraArgsV1 & {
608
1080
  _tag: 'EVMExtraArgsV1';
609
1081
  }) | (EVMExtraArgsV2 & {
610
1082
  _tag: 'EVMExtraArgsV2';
1083
+ }) | (GenericExtraArgsV3 & {
1084
+ _tag: 'GenericExtraArgsV3';
611
1085
  }) | (SVMExtraArgsV1 & {
612
1086
  _tag: 'SVMExtraArgsV1';
613
1087
  }) | (SuiExtraArgsV1 & {
614
1088
  _tag: 'SuiExtraArgsV1';
615
1089
  }) | undefined;
1090
+ /**
1091
+ * Encode extraArgs for this chain family.
1092
+ *
1093
+ * @param extraArgs - Extra args object to encode
1094
+ * @returns Encoded hex string
1095
+ *
1096
+ * @example Encode extra args
1097
+ * ```typescript
1098
+ * const encoded = EVMChain.encodeExtraArgs({
1099
+ * gasLimit: 200000n,
1100
+ * strict: false,
1101
+ * })
1102
+ * ```
1103
+ */
616
1104
  encodeExtraArgs(extraArgs: ExtraArgs): string;
617
1105
  /**
618
- * Decode a commit (CommitReportAccepted) event
1106
+ * Decode a commit (CommitReportAccepted) event.
1107
+ *
619
1108
  * @param log - Chain generic log
620
- * @param lane - if passed, filter or validate reports by lane
621
- * @returns Array of commit reports contained in the log
1109
+ * @param lane - If passed, filter or validate reports by lane
1110
+ * @returns Array of commit reports contained in the log, or undefined
1111
+ *
1112
+ * @example Decode commit from log
1113
+ * ```typescript
1114
+ * const commits = EVMChain.decodeCommits(log, lane)
1115
+ * if (commits) {
1116
+ * console.log(`Found ${commits.length} commit(s)`)
1117
+ * }
1118
+ * ```
622
1119
  */
623
1120
  decodeCommits(log: Pick<Log_, 'data'>, lane?: Lane): CommitReport[] | undefined;
624
1121
  /**
625
- * Decode a receipt (ExecutioStateChanged) event
1122
+ * Decode a receipt (ExecutionStateChanged) event.
1123
+ *
626
1124
  * @param log - Chain generic log
627
1125
  * @returns ExecutionReceipt or undefined if not a recognized receipt
1126
+ *
1127
+ * @example Decode execution receipt
1128
+ * ```typescript
1129
+ * const receipt = EVMChain.decodeReceipt(log)
1130
+ * if (receipt) {
1131
+ * console.log(`State: ${receipt.state}, Message: ${receipt.messageId}`)
1132
+ * }
1133
+ * ```
628
1134
  */
629
1135
  decodeReceipt(log: Pick<Log_, 'data'>): ExecutionReceipt | undefined;
630
1136
  /**
631
- * Receive a bytes array and try to decode and normalize it as an address of this chain family
1137
+ * Receive a bytes array and try to decode and normalize it as an address of this chain family.
1138
+ *
632
1139
  * @param bytes - Bytes array (Uint8Array, HexString or Base64)
633
1140
  * @returns Address in this chain family's format
1141
+ *
1142
+ * @throws {@link CCIPAddressInvalidEvmError} if invalid EVM address
1143
+ * @throws {@link CCIPDataFormatUnsupportedError} if invalid Aptos/Sui address
1144
+ *
1145
+ * @example Normalize address
1146
+ * ```typescript
1147
+ * const normalized = EVMChain.getAddress('0xABC123...')
1148
+ * console.log(normalized) // checksummed address
1149
+ * ```
634
1150
  */
635
1151
  getAddress(bytes: BytesLike): string;
636
1152
  /**
637
- * Validates a transaction hash format for this chain family
1153
+ * Validates a transaction hash format for this chain family.
1154
+ *
1155
+ * @param v - Value to validate
1156
+ * @returns True if value is a valid transaction hash format
1157
+ *
1158
+ * @example Validate transaction hash
1159
+ * ```typescript
1160
+ * if (EVMChain.isTxHash(userInput)) {
1161
+ * const tx = await chain.getTransaction(userInput)
1162
+ * }
1163
+ * ```
638
1164
  */
639
1165
  isTxHash(v: unknown): v is string;
640
1166
  /**
641
1167
  * Format an address for human-friendly display.
642
1168
  * Defaults to getAddress if not overridden.
1169
+ *
643
1170
  * @param address - Address string in any recognized format
644
1171
  * @returns Human-friendly address string for display
1172
+ *
1173
+ * @example Format address for display
1174
+ * ```typescript
1175
+ * const display = EVMChain.formatAddress?.(rawAddress) ?? rawAddress
1176
+ * console.log(display)
1177
+ * ```
645
1178
  */
646
1179
  formatAddress?(address: string): string;
647
1180
  /**
648
1181
  * Format a transaction hash for human-friendly display.
1182
+ *
649
1183
  * @param hash - Transaction hash string
650
1184
  * @returns Human-friendly hash string for display
1185
+ *
1186
+ * @example Format tx hash for display
1187
+ * ```typescript
1188
+ * const display = EVMChain.formatTxHash?.(rawHash) ?? rawHash
1189
+ * console.log(display)
1190
+ * ```
651
1191
  */
652
1192
  formatTxHash?(hash: string): string;
653
1193
  /**
654
- * Create a leaf hasher for this dest chain and lane
655
- * @param lane - source, dest and onramp lane info
656
- * @param ctx - context object containing logger
657
- * @returns LeafHasher is a function that takes a message and returns a hash of it
1194
+ * Create a leaf hasher for this dest chain and lane.
1195
+ *
1196
+ * @param lane - Source, dest and onramp lane info
1197
+ * @param ctx - Context object containing logger
1198
+ * @returns LeafHasher function that takes a message and returns its hash
1199
+ *
1200
+ * @throws {@link CCIPHasherVersionUnsupportedError} if hasher version unsupported
1201
+ *
1202
+ * @example Create leaf hasher
1203
+ * ```typescript
1204
+ * const hasher = EVMChain.getDestLeafHasher(lane, { logger })
1205
+ * const leafHash = hasher(message)
1206
+ * ```
658
1207
  */
659
1208
  getDestLeafHasher(lane: Lane, ctx?: WithLogger): LeafHasher;
660
1209
  /**
661
- * Try to parse an error or bytearray generated by this chain family
1210
+ * Try to parse an error or bytearray generated by this chain family.
1211
+ *
662
1212
  * @param data - Caught object, string or bytearray
663
- * @returns Ordered record with messages/properties, or undefined if not a recognized error
1213
+ * @returns Ordered record with messages/properties, or undefined/null if not recognized
1214
+ *
1215
+ * @example Parse contract error
1216
+ * ```typescript
1217
+ * try {
1218
+ * await chain.sendMessage(opts)
1219
+ * } catch (err) {
1220
+ * const parsed = EVMChain.parse?.(err)
1221
+ * if (parsed) console.log('Contract error:', parsed)
1222
+ * }
1223
+ * ```
664
1224
  */
665
1225
  parse?(data: unknown): Record<string, unknown> | undefined | null;
666
1226
  /**