@chainlink/ccip-sdk 0.92.1 → 0.94.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 (232) hide show
  1. package/README.md +20 -18
  2. package/dist/api/index.d.ts +103 -0
  3. package/dist/api/index.d.ts.map +1 -0
  4. package/dist/api/index.js +141 -0
  5. package/dist/api/index.js.map +1 -0
  6. package/dist/api/types.d.ts +38 -0
  7. package/dist/api/types.d.ts.map +1 -0
  8. package/dist/api/types.js +2 -0
  9. package/dist/api/types.js.map +1 -0
  10. package/dist/aptos/index.d.ts +20 -33
  11. package/dist/aptos/index.d.ts.map +1 -1
  12. package/dist/aptos/index.js +41 -29
  13. package/dist/aptos/index.js.map +1 -1
  14. package/dist/aptos/logs.js +1 -1
  15. package/dist/aptos/logs.js.map +1 -1
  16. package/dist/aptos/send.js +1 -1
  17. package/dist/aptos/send.js.map +1 -1
  18. package/dist/aptos/token.js.map +1 -1
  19. package/dist/chain.d.ts +215 -73
  20. package/dist/chain.d.ts.map +1 -1
  21. package/dist/chain.js +103 -20
  22. package/dist/chain.js.map +1 -1
  23. package/dist/commits.d.ts +2 -2
  24. package/dist/commits.d.ts.map +1 -1
  25. package/dist/commits.js +4 -4
  26. package/dist/commits.js.map +1 -1
  27. package/dist/errors/CCIPError.d.ts.map +1 -1
  28. package/dist/errors/CCIPError.js +3 -2
  29. package/dist/errors/CCIPError.js.map +1 -1
  30. package/dist/errors/codes.d.ts +4 -1
  31. package/dist/errors/codes.d.ts.map +1 -1
  32. package/dist/errors/codes.js +6 -1
  33. package/dist/errors/codes.js.map +1 -1
  34. package/dist/errors/index.d.ts +5 -2
  35. package/dist/errors/index.d.ts.map +1 -1
  36. package/dist/errors/index.js +8 -2
  37. package/dist/errors/index.js.map +1 -1
  38. package/dist/errors/recovery.d.ts.map +1 -1
  39. package/dist/errors/recovery.js +4 -1
  40. package/dist/errors/recovery.js.map +1 -1
  41. package/dist/errors/specialized.d.ts +29 -4
  42. package/dist/errors/specialized.d.ts.map +1 -1
  43. package/dist/errors/specialized.js +48 -6
  44. package/dist/errors/specialized.js.map +1 -1
  45. package/dist/evm/errors.js.map +1 -1
  46. package/dist/evm/index.d.ts +24 -48
  47. package/dist/evm/index.d.ts.map +1 -1
  48. package/dist/evm/index.js +82 -66
  49. package/dist/evm/index.js.map +1 -1
  50. package/dist/evm/logs.js.map +1 -1
  51. package/dist/evm/offchain.js +3 -2
  52. package/dist/evm/offchain.js.map +1 -1
  53. package/dist/evm/viem/client-adapter.d.ts +68 -0
  54. package/dist/evm/viem/client-adapter.d.ts.map +1 -0
  55. package/dist/evm/viem/client-adapter.js +104 -0
  56. package/dist/evm/viem/client-adapter.js.map +1 -0
  57. package/dist/evm/viem/index.d.ts +29 -0
  58. package/dist/evm/viem/index.d.ts.map +1 -0
  59. package/dist/evm/viem/index.js +28 -0
  60. package/dist/evm/viem/index.js.map +1 -0
  61. package/dist/evm/viem/types.d.ts +13 -0
  62. package/dist/evm/viem/types.d.ts.map +1 -0
  63. package/dist/evm/viem/types.js +2 -0
  64. package/dist/evm/viem/types.js.map +1 -0
  65. package/dist/evm/viem/wallet-adapter.d.ts +58 -0
  66. package/dist/evm/viem/wallet-adapter.d.ts.map +1 -0
  67. package/dist/evm/viem/wallet-adapter.js +197 -0
  68. package/dist/evm/viem/wallet-adapter.js.map +1 -0
  69. package/dist/execution.d.ts +1 -1
  70. package/dist/execution.d.ts.map +1 -1
  71. package/dist/execution.js +2 -2
  72. package/dist/execution.js.map +1 -1
  73. package/dist/explorer.d.ts +74 -0
  74. package/dist/explorer.d.ts.map +1 -0
  75. package/dist/explorer.js +67 -0
  76. package/dist/explorer.js.map +1 -0
  77. package/dist/gas.js.map +1 -1
  78. package/dist/hasher/merklemulti.js.map +1 -1
  79. package/dist/http-status.d.ts +20 -0
  80. package/dist/http-status.d.ts.map +1 -0
  81. package/dist/http-status.js +25 -0
  82. package/dist/http-status.js.map +1 -0
  83. package/dist/index.d.ts +10 -3
  84. package/dist/index.d.ts.map +1 -1
  85. package/dist/index.js +4 -2
  86. package/dist/index.js.map +1 -1
  87. package/dist/offchain.js.map +1 -1
  88. package/dist/requests.d.ts +12 -6
  89. package/dist/requests.d.ts.map +1 -1
  90. package/dist/requests.js +16 -6
  91. package/dist/requests.js.map +1 -1
  92. package/dist/selectors.d.ts.map +1 -1
  93. package/dist/selectors.js +20 -0
  94. package/dist/selectors.js.map +1 -1
  95. package/dist/solana/cleanup.js +2 -2
  96. package/dist/solana/cleanup.js.map +1 -1
  97. package/dist/solana/exec.js +1 -5
  98. package/dist/solana/exec.js.map +1 -1
  99. package/dist/solana/index.d.ts +33 -58
  100. package/dist/solana/index.d.ts.map +1 -1
  101. package/dist/solana/index.js +126 -73
  102. package/dist/solana/index.js.map +1 -1
  103. package/dist/solana/logs.js +2 -2
  104. package/dist/solana/logs.js.map +1 -1
  105. package/dist/solana/offchain.js +3 -3
  106. package/dist/solana/offchain.js.map +1 -1
  107. package/dist/solana/send.js +1 -1
  108. package/dist/solana/send.js.map +1 -1
  109. package/dist/solana/utils.js +1 -1
  110. package/dist/solana/utils.js.map +1 -1
  111. package/dist/sui/discovery.d.ts.map +1 -1
  112. package/dist/sui/discovery.js +2 -5
  113. package/dist/sui/discovery.js.map +1 -1
  114. package/dist/sui/events.d.ts.map +1 -1
  115. package/dist/sui/events.js +1 -4
  116. package/dist/sui/events.js.map +1 -1
  117. package/dist/sui/index.d.ts +29 -35
  118. package/dist/sui/index.d.ts.map +1 -1
  119. package/dist/sui/index.js +71 -45
  120. package/dist/sui/index.js.map +1 -1
  121. package/dist/sui/manuallyExec/encoder.d.ts.map +1 -1
  122. package/dist/sui/manuallyExec/encoder.js +1 -3
  123. package/dist/sui/manuallyExec/encoder.js.map +1 -1
  124. package/dist/sui/manuallyExec/index.d.ts.map +1 -1
  125. package/dist/sui/manuallyExec/index.js +2 -2
  126. package/dist/sui/manuallyExec/index.js.map +1 -1
  127. package/dist/sui/objects.d.ts.map +1 -1
  128. package/dist/sui/objects.js +6 -5
  129. package/dist/sui/objects.js.map +1 -1
  130. package/dist/ton/exec.d.ts +2 -2
  131. package/dist/ton/exec.d.ts.map +1 -1
  132. package/dist/ton/exec.js.map +1 -1
  133. package/dist/ton/hasher.d.ts.map +1 -1
  134. package/dist/ton/hasher.js +6 -5
  135. package/dist/ton/hasher.js.map +1 -1
  136. package/dist/ton/index.d.ts +54 -49
  137. package/dist/ton/index.d.ts.map +1 -1
  138. package/dist/ton/index.js +332 -236
  139. package/dist/ton/index.js.map +1 -1
  140. package/dist/ton/logs.d.ts +11 -22
  141. package/dist/ton/logs.d.ts.map +1 -1
  142. package/dist/ton/logs.js +95 -118
  143. package/dist/ton/logs.js.map +1 -1
  144. package/dist/ton/types.d.ts +9 -9
  145. package/dist/ton/types.d.ts.map +1 -1
  146. package/dist/ton/types.js +5 -9
  147. package/dist/ton/types.js.map +1 -1
  148. package/dist/ton/utils.d.ts +8 -27
  149. package/dist/ton/utils.d.ts.map +1 -1
  150. package/dist/ton/utils.js +31 -111
  151. package/dist/ton/utils.js.map +1 -1
  152. package/dist/types.d.ts +44 -2
  153. package/dist/types.d.ts.map +1 -1
  154. package/dist/types.js +30 -0
  155. package/dist/types.js.map +1 -1
  156. package/dist/utils.d.ts +7 -5
  157. package/dist/utils.d.ts.map +1 -1
  158. package/dist/utils.js +77 -52
  159. package/dist/utils.js.map +1 -1
  160. package/dist/viem.d.ts +6 -0
  161. package/dist/viem.d.ts.map +1 -0
  162. package/dist/viem.js +6 -0
  163. package/dist/viem.js.map +1 -0
  164. package/package.json +30 -9
  165. package/src/api/index.ts +167 -0
  166. package/src/api/types.ts +39 -0
  167. package/src/aptos/index.ts +71 -64
  168. package/src/aptos/logs.ts +10 -10
  169. package/src/aptos/send.ts +1 -1
  170. package/src/aptos/token.ts +1 -1
  171. package/src/chain.ts +299 -98
  172. package/src/commits.ts +5 -5
  173. package/src/errors/CCIPError.ts +5 -2
  174. package/src/errors/codes.ts +8 -1
  175. package/src/errors/index.ts +15 -2
  176. package/src/errors/recovery.ts +9 -1
  177. package/src/errors/specialized.ts +61 -6
  178. package/src/evm/errors.ts +2 -2
  179. package/src/evm/index.ts +127 -124
  180. package/src/evm/logs.ts +4 -4
  181. package/src/evm/offchain.ts +5 -4
  182. package/src/evm/viem/client-adapter.ts +124 -0
  183. package/src/evm/viem/index.ts +29 -0
  184. package/src/evm/viem/types.ts +14 -0
  185. package/src/evm/viem/wallet-adapter.ts +233 -0
  186. package/src/execution.ts +9 -9
  187. package/src/explorer.ts +90 -0
  188. package/src/gas.ts +2 -2
  189. package/src/hasher/merklemulti.ts +7 -7
  190. package/src/http-status.ts +31 -0
  191. package/src/index.ts +19 -2
  192. package/src/offchain.ts +1 -1
  193. package/src/requests.ts +22 -13
  194. package/src/selectors.ts +20 -0
  195. package/src/solana/cleanup.ts +4 -4
  196. package/src/solana/exec.ts +13 -18
  197. package/src/solana/index.ts +185 -118
  198. package/src/solana/logs.ts +8 -8
  199. package/src/solana/offchain.ts +3 -3
  200. package/src/solana/send.ts +20 -20
  201. package/src/solana/utils.ts +4 -4
  202. package/src/sui/discovery.ts +4 -10
  203. package/src/sui/events.ts +4 -8
  204. package/src/sui/index.ts +94 -73
  205. package/src/sui/manuallyExec/encoder.ts +2 -4
  206. package/src/sui/manuallyExec/index.ts +3 -3
  207. package/src/sui/objects.ts +17 -15
  208. package/src/ton/exec.ts +2 -5
  209. package/src/ton/hasher.ts +7 -5
  210. package/src/ton/index.ts +394 -316
  211. package/src/ton/logs.ts +122 -143
  212. package/src/ton/types.ts +17 -21
  213. package/src/ton/utils.ts +39 -145
  214. package/src/types.ts +47 -2
  215. package/src/utils.ts +98 -66
  216. package/src/viem.ts +5 -0
  217. package/tsconfig.json +3 -2
  218. package/dist/ton/bindings/offramp.d.ts +0 -48
  219. package/dist/ton/bindings/offramp.d.ts.map +0 -1
  220. package/dist/ton/bindings/offramp.js +0 -63
  221. package/dist/ton/bindings/offramp.js.map +0 -1
  222. package/dist/ton/bindings/onramp.d.ts +0 -40
  223. package/dist/ton/bindings/onramp.d.ts.map +0 -1
  224. package/dist/ton/bindings/onramp.js +0 -51
  225. package/dist/ton/bindings/onramp.js.map +0 -1
  226. package/dist/ton/bindings/router.d.ts +0 -47
  227. package/dist/ton/bindings/router.d.ts.map +0 -1
  228. package/dist/ton/bindings/router.js +0 -51
  229. package/dist/ton/bindings/router.js.map +0 -1
  230. package/src/ton/bindings/offramp.ts +0 -96
  231. package/src/ton/bindings/onramp.ts +0 -72
  232. package/src/ton/bindings/router.ts +0 -65
package/dist/chain.d.ts CHANGED
@@ -1,13 +1,49 @@
1
- import type { BytesLike } from 'ethers';
1
+ import { type BytesLike } from 'ethers';
2
2
  import type { PickDeep, SetOptional } from 'type-fest';
3
+ import { type LaneLatencyResponse, CCIPAPIClient } from './api/index.ts';
3
4
  import type { UnsignedAptosTx } from './aptos/types.ts';
4
5
  import type { UnsignedEVMTx } from './evm/types.ts';
5
6
  import type { EVMExtraArgsV1, EVMExtraArgsV2, ExtraArgs, SVMExtraArgsV1, SuiExtraArgsV1 } from './extra-args.ts';
6
7
  import type { LeafHasher } from './hasher/common.ts';
7
8
  import type { UnsignedSolanaTx } from './solana/types.ts';
8
9
  import type { UnsignedTONTx } from './ton/types.ts';
9
- 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 NetworkInfo, type OffchainTokenData, type WithLogger } from './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 NetworkInfo, type OffchainTokenData, type MessageInput, type WithLogger } from './types.ts';
10
11
  import { util } from './utils.ts';
12
+ /**
13
+ * Context for Chain class initialization.
14
+ * Extends WithLogger with optional API client configuration.
15
+ *
16
+ * @example Default behavior (auto-create API client)
17
+ * ```typescript
18
+ * const chain = await EVMChain.fromUrl(rpcUrl, { logger })
19
+ * await chain.getLaneLatency(destSelector) // Works - uses production API
20
+ * ```
21
+ *
22
+ * @example Custom API endpoint
23
+ * ```typescript
24
+ * const api = new CCIPAPIClient('https://staging-api.example.com', { logger })
25
+ * const chain = await EVMChain.fromUrl(rpcUrl, { apiClient: api, logger })
26
+ * ```
27
+ *
28
+ * @example Explicit opt-out (decentralized mode)
29
+ * ```typescript
30
+ * const chain = await EVMChain.fromUrl(rpcUrl, { apiClient: null, logger })
31
+ * await chain.getLaneLatency(destSelector) // Throws CCIPApiClientNotAvailableError
32
+ * ```
33
+ */
34
+ export type ChainContext = WithLogger & {
35
+ /**
36
+ * CCIP API client instance for lane information queries.
37
+ *
38
+ * - `undefined` (default): Creates CCIPAPIClient with production endpoint
39
+ * (https://api.ccip.chain.link)
40
+ * - `CCIPAPIClient`: Uses provided instance (allows custom URL, fetch, etc.)
41
+ * - `null`: Disables API client entirely (getLaneLatency() will throw)
42
+ *
43
+ * Default: `undefined` (auto-create with production endpoint)
44
+ */
45
+ apiClient?: CCIPAPIClient | null;
46
+ };
11
47
  /**
12
48
  * Filter options for getLogs queries across chains.
13
49
  */
@@ -77,6 +113,36 @@ export type UnsignedTx = {
77
113
  [ChainFamily.TON]: UnsignedTONTx;
78
114
  [ChainFamily.Sui]: never;
79
115
  };
116
+ /**
117
+ * Common options for [[getFee]], [[generateUnsignedSendMessage]] and [[sendMessage]] Chain methods
118
+ */
119
+ export type SendMessageOpts = {
120
+ /** Router address on this chain */
121
+ router: string;
122
+ /** Destination network selector. */
123
+ destChainSelector: bigint;
124
+ /** Message to send. If `fee` is omitted, it'll be calculated */
125
+ message: MessageInput;
126
+ /** Approve the maximum amount of tokens to transfer */
127
+ approveMax?: boolean;
128
+ };
129
+ /**
130
+ * Common options for [[generateUnsignedExecuteReport]] and [[executeReport]] Chain methods
131
+ */
132
+ export type ExecuteReportOpts = {
133
+ /** address of the OffRamp contract */
134
+ offRamp: string;
135
+ /** execution report */
136
+ execReport: ExecutionReport;
137
+ /** gasLimit or computeUnits limit override for the ccipReceive call */
138
+ gasLimit?: number;
139
+ /** For EVM, overrides gasLimit on tokenPool call */
140
+ tokensGasLimit?: number;
141
+ /** For Solana, send report in chunks to OffRamp, to later execute */
142
+ forceBuffer?: boolean;
143
+ /** For Solana, create and extend addresses in a lookup table before executing */
144
+ forceLookupTable?: boolean;
145
+ };
80
146
  /**
81
147
  * Works like an interface for a base Chain class, but provides implementation (which can be
82
148
  * specialized) for some basic methods
@@ -86,11 +152,14 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
86
152
  [util.inspect.custom]: () => string;
87
153
  readonly network: NetworkInfo<F>;
88
154
  logger: Logger;
155
+ /** CCIP API client (null if opted out) */
156
+ readonly apiClient: CCIPAPIClient | null;
89
157
  /**
90
158
  * Base constructor for Chain class.
91
159
  * @param network - NetworkInfo object for the Chain instance
160
+ * @param ctx - Optional context with logger and API client configuration
92
161
  */
93
- constructor(network: NetworkInfo, { logger }?: WithLogger);
162
+ constructor(network: NetworkInfo, ctx?: ChainContext);
94
163
  /** Cleanup method to release resources (e.g., close connections). */
95
164
  destroy?(): void | Promise<void>;
96
165
  /**
@@ -109,14 +178,21 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
109
178
  * Confirm a log tx is finalized or wait for it to be finalized
110
179
  * Throws if it isn't included (e.g. a reorg)
111
180
  */
112
- waitFinalized({ log, tx, }: SetOptional<PickDeep<CCIPRequest, `log.${'address' | 'blockNumber' | 'transactionHash' | 'topics' | 'tx.timestamp'}` | 'tx.timestamp'>, 'tx'>, finality?: number | 'finalized', cancel$?: Promise<unknown>): Promise<true>;
181
+ waitFinalized({ request: { log, tx }, finality, cancel$, }: {
182
+ request: SetOptional<PickDeep<CCIPRequest, `log.${'address' | 'blockNumber' | 'transactionHash' | 'topics' | 'tx.timestamp'}` | 'tx.timestamp'>, 'tx'>;
183
+ finality?: number | 'finalized';
184
+ cancel$?: Promise<unknown>;
185
+ }): Promise<true>;
113
186
  /**
114
187
  * An async generator that yields logs based on the provided options.
115
188
  * @param opts - Options object containing:
116
189
  * - `startBlock`: if provided, fetch and generate logs forward starting from this block;
117
- * otherwise, returns logs backwards in time from endBlock;
118
- * optionally, startTime may be provided to fetch logs forward starting from this time
119
- * - `endBlock`: if omitted, use latest block
190
+ * otherwise, returns logs backwards in time from endBlock;
191
+ * optionally, startTime may be provided to fetch logs forward starting from this time
192
+ * - `startTime`: instead of a startBlock, a start timestamp may be provided;
193
+ * if either is provided, fetch logs forward from this starting point; otherwise, backwards
194
+ * - `endBlock`: if omitted, use latest block; can be a block number, 'latest', 'finalized' or
195
+ * negative finality block depth
120
196
  * - `endBefore`: optional hint signature for end of iteration, instead of endBlock
121
197
  * - `address`: if provided, fetch logs for this address only (may be required in some
122
198
  * networks/implementations)
@@ -125,6 +201,7 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
125
201
  * some networks/implementations may not be able to filter topics other than topic0s, so one may
126
202
  * want to assume those are optimization hints, instead of hard filters, and verify results
127
203
  * - `page`: if provided, try to use this page/range for batches
204
+ * - `watch`: true or cancellation promise, getLogs continuously after initial fetch
128
205
  * @returns An async iterable iterator of logs.
129
206
  */
130
207
  abstract getLogs(opts: LogFilter): AsyncIterableIterator<Log_>;
@@ -133,14 +210,14 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
133
210
  * @param tx - ChainTransaction or txHash to fetch requests from
134
211
  * @returns CCIP messages in the transaction (at least one)
135
212
  **/
136
- abstract fetchRequestsInTx(tx: string | ChainTransaction): Promise<CCIPRequest[]>;
213
+ abstract getMessagesInTx(tx: string | ChainTransaction): Promise<CCIPRequest[]>;
137
214
  /**
138
215
  * Scan for a CCIP request by message ID
139
216
  * @param messageId - message ID to fetch request for
140
217
  * @param onRamp - address may be required in some implementations, and throw if missing
141
218
  * @returns CCIPRequest
142
219
  **/
143
- fetchRequestById?(messageId: string, onRamp?: string, opts?: {
220
+ getMessageById?(messageId: string, onRamp?: string, opts?: {
144
221
  page?: number;
145
222
  }): Promise<CCIPRequest>;
146
223
  /**
@@ -149,7 +226,7 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
149
226
  * @param commit - CommitReport range (min, max).
150
227
  * @param opts - Optional parameters (e.g., `page` for pagination width).
151
228
  */
152
- abstract fetchAllMessagesInBatch<R extends PickDeep<CCIPRequest, 'lane' | `log.${'topics' | 'address' | 'blockNumber'}` | 'message.sequenceNumber'>>(request: R, commit: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>, opts?: {
229
+ abstract getMessagesInBatch<R extends PickDeep<CCIPRequest, 'lane' | `log.${'topics' | 'address' | 'blockNumber'}` | 'message.sequenceNumber'>>(request: R, commit: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>, opts?: {
153
230
  page?: number;
154
231
  }): Promise<R['message'][]>;
155
232
  /**
@@ -232,99 +309,154 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
232
309
  abstract getTokenAdminRegistryFor(address: string): Promise<string>;
233
310
  /**
234
311
  * Fetch the current fee for a given intended message
235
- * @param router - router address on this chain
236
- * @param destChainSelector - dest network selector
237
- * @param message - message to send
312
+ * @param opts - {@link SendMessageOpts} without approveMax
238
313
  */
239
- abstract getFee(router: string, destChainSelector: bigint, message: AnyMessage): Promise<bigint>;
314
+ abstract getFee(opts: Omit<SendMessageOpts, 'approveMax'>): Promise<bigint>;
240
315
  /**
241
316
  * Generate unsigned txs for ccipSend'ing a message
242
- * @param sender - sender address
243
- * @param router - address of the Router contract
244
- * @param destChainSelector - chainSelector of destination chain
245
- * @param message - AnyMessage to send; if `fee` is not present, it'll be calculated
246
- * @param approveMax - if tokens approvals are needed, opt into approving maximum allowance
317
+ * @param opts - {@link SendMessageOpts} with sender address
247
318
  * @returns chain-family specific unsigned txs
248
319
  */
249
- abstract generateUnsignedSendMessage(sender: string, router: string, destChainSelector: bigint, message: AnyMessage & {
250
- fee?: bigint;
251
- }, opts?: {
252
- approveMax?: boolean;
320
+ abstract generateUnsignedSendMessage(opts: SendMessageOpts & {
321
+ /** Sender address (address of wallet which will send the message) */
322
+ sender: string;
253
323
  }): Promise<UnsignedTx[F]>;
254
324
  /**
255
325
  * Send a CCIP message through a router using provided wallet.
256
- * @param router - Router address on this chain.
257
- * @param destChainSelector - Destination network selector.
258
- * @param message - Message to send.
259
- * @param opts - Optional parameters:
260
- * - `wallet`: cli or environmental parameters to help pick a wallet
261
- * - `approveMax`: approve the maximum amount of tokens to transfer
262
- */
263
- abstract sendMessage(router: string, destChainSelector: bigint, message: AnyMessage & {
264
- fee?: bigint;
265
- }, opts: {
326
+ * @param opts - {@link SendMessageOpts} with chain-specific wallet for signing
327
+ * @returns CCIP request
328
+ *
329
+ * @example
330
+ * ```typescript
331
+ * const request = await chain.sendMessage({
332
+ * router: '0x...',
333
+ * destChainSelector: 4949039107694359620n,
334
+ * message: {
335
+ * receiver: '0x...',
336
+ * data: '0x1337',
337
+ * tokenAmounts: [{ token: '0x...', amount: 100n }],
338
+ * feeToken: '0xLinkToken',
339
+ * },
340
+ * wallet: signer,
341
+ * })
342
+ * console.log(`Message ID: ${request.message.messageId}`)
343
+ * ```
344
+ */
345
+ abstract sendMessage(opts: SendMessageOpts & {
346
+ /** Signer instance (chain-dependent) */
266
347
  wallet: unknown;
267
- approveMax?: boolean;
268
348
  }): Promise<CCIPRequest>;
269
349
  /**
270
350
  * Fetch supported offchain token data for a request from this network
271
351
  * @param request - CCIP request, with tx, logs and message
272
352
  * @returns array with one offchain token data for each token transfer in request
273
353
  */
274
- abstract fetchOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]>;
354
+ abstract getOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]>;
275
355
  /**
276
356
  * Generate unsigned tx to manuallyExecute a message
277
- * @param payer - address which will be used to transmit the report tx
278
- * @param offRamp - address of the OffRamp contract
279
- * @param execReport - execution report
280
- * @param gasLimit - gasLimit or computeUnits limit override for the ccipReceive call
281
- * @param tokensGasLimit - For EVM, overrides gasLimit on tokenpPool call
282
- * @param forceBuffer - For Solana, send report in chunks to OffRamp, to later execute
283
- * @param forceLookupTable - For Solana, create and extend addresses in a lookup table before executing
357
+ * @param opts - {@link ExecuteReportOpts} with payer address which will send the exec tx
284
358
  * @returns chain-family specific unsigned txs
285
359
  */
286
- abstract generateUnsignedExecuteReport(payer: string, offRamp: string, execReport: ExecutionReport, opts: {
287
- gasLimit?: number;
288
- tokensGasLimit?: number;
289
- forceBuffer?: boolean;
290
- forceLookupTable?: boolean;
360
+ abstract generateUnsignedExecuteReport(opts: ExecuteReportOpts & {
361
+ /** address which will be used to send the report tx */
362
+ payer: string;
291
363
  }): Promise<UnsignedTx[F]>;
292
364
  /**
293
365
  * Execute messages in report in an offRamp
294
- * @param offRamp - offRamp address on this dest chain
295
- * @param execReport - execution report containing messages to execute, proofs and offchainTokenData
296
- * @param opts - general options for execution (see [[generateUnsignedExecuteReport]])
297
- * @param wallet - chain-specific wallet or signer instance, to sign transactions
366
+ * @param opts - {@link ExecuteReportOpts} with chain-specific wallet to sign and send tx
298
367
  * @returns transaction of the execution
299
- */
300
- abstract executeReport(offRamp: string, execReport: ExecutionReport, opts: {
368
+ *
369
+ * @example
370
+ * ```typescript
371
+ * const execReportProof = calculateManualExecProof(
372
+ * messagesInBatch: await source.getMessagesInBatch(request, commit.report),
373
+ * request.lane,
374
+ * request.message.messageId,
375
+ * commit.report.merkleRoot,
376
+ * dest,
377
+ * )
378
+ * const receipt = await dest.executeReport({
379
+ * offRamp,
380
+ * execReport: {
381
+ * ...execReportProof,
382
+ * message: request.message,
383
+ * offchainTokenData: await source.getOffchainTokenData(request),
384
+ * },
385
+ * wallet,
386
+ * })
387
+ * console.log(`Message ID: ${request.message.messageId}`)
388
+ * ```
389
+ */
390
+ abstract executeReport(opts: ExecuteReportOpts & {
301
391
  wallet: unknown;
302
- gasLimit?: number;
303
- tokensGasLimit?: number;
304
- forceBuffer?: boolean;
305
- forceLookupTable?: boolean;
306
- }): Promise<ChainTransaction>;
392
+ }): Promise<CCIPExecution>;
307
393
  /**
308
394
  * Look for a CommitReport at dest for given CCIP request
309
395
  * May be specialized by some subclasses
310
- *
311
- * @param commitStore - Commit store address
312
- * @param request - CCIPRequest to get commit info for
313
- * @param hints - Additional filtering hints
396
+ * @param opts - getCommitReport options
314
397
  * @returns CCIPCommit info, or reject if none found
315
398
  **/
316
- fetchCommitReport(commitStore: string, request: PickDeep<CCIPRequest, 'lane' | 'message.sequenceNumber' | 'tx.timestamp'>, hints?: Pick<LogFilter, 'page' | 'watch'> & {
317
- startBlock?: number;
318
- }): Promise<CCIPCommit>;
319
- /**
320
- * Default/generic implementation of fetchExecutionReceipts
321
- * @param offRamp - Off-ramp address
322
- * @param request - CCIPRequest to get execution receipts for
323
- * @param commit - CCIPCommit info to help narrowing search for executions
324
- * @param hints - Additional filtering hints
399
+ getCommitReport({ commitStore, request, ...hints }: {
400
+ /** address of commitStore (OffRamp in \>=v1.6) */
401
+ commitStore: string;
402
+ /** CCIPRequest subset object */
403
+ request: PickDeep<CCIPRequest, 'lane' | 'message.sequenceNumber' | 'tx.timestamp'>;
404
+ } & Pick<LogFilter, 'page' | 'watch' | 'startBlock'>): Promise<CCIPCommit>;
405
+ /**
406
+ * Fetches estimated lane latency to a destination chain.
407
+ * Uses this chain's selector as the source.
408
+ *
409
+ * @param destChainSelector - Destination CCIP chain selector (bigint)
410
+ * @returns Promise resolving to {@link LaneLatencyResponse} containing:
411
+ * - `lane.sourceNetworkInfo` - Source chain metadata (name, selector, chainId)
412
+ * - `lane.destNetworkInfo` - Destination chain metadata
413
+ * - `lane.routerAddress` - Router contract address on source chain
414
+ * - `totalMs` - Estimated delivery time in milliseconds
415
+ *
416
+ * @throws {@link CCIPApiClientNotAvailableError} if apiClient was disabled (set to `null`)
417
+ * @throws {@link CCIPHttpError} if API request fails (network error, 4xx, 5xx status)
418
+ *
419
+ * @remarks
420
+ * Each call makes a fresh API request. Consider caching results if making
421
+ * frequent calls for the same lane.
422
+ *
423
+ * @example Get estimated delivery time
424
+ * ```typescript
425
+ * const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
426
+ * try {
427
+ * const latency = await chain.getLaneLatency(4949039107694359620n) // Arbitrum
428
+ * console.log(`Estimated delivery: ${Math.round(latency.totalMs / 60000)} minutes`)
429
+ * console.log(`Router: ${latency.lane.routerAddress}`)
430
+ * } catch (err) {
431
+ * if (err instanceof CCIPHttpError) {
432
+ * console.error(`API error: ${err.context.apiErrorCode}`)
433
+ * }
434
+ * }
435
+ * ```
436
+ */
437
+ getLaneLatency(destChainSelector: bigint): Promise<LaneLatencyResponse>;
438
+ /**
439
+ * Default/generic implementation of getExecutionReceipts
440
+ * @param opts - getExecutionReceipts options
325
441
  * @returns Async generator of CCIPExecution receipts
326
442
  */
327
- fetchExecutionReceipts(offRamp: string, request: PickDeep<CCIPRequest, 'lane' | 'message.messageId' | 'tx.timestamp'>, commit?: CCIPCommit, hints?: Pick<LogFilter, 'page' | 'watch'>): AsyncIterableIterator<CCIPExecution>;
443
+ getExecutionReceipts({ offRamp, messageId, sourceChainSelector, commit, ...hints }: {
444
+ /** address of OffRamp contract */
445
+ offRamp: string;
446
+ /** filter: yield only executions for this message */
447
+ messageId?: string;
448
+ /** filter: yield only executions for this source chain */
449
+ sourceChainSelector?: bigint;
450
+ /** optional commit associated with the request, can be used for optimizations in some families */
451
+ commit?: CCIPCommit;
452
+ } & Pick<LogFilter, 'page' | 'watch' | 'startBlock' | 'startTime'>): AsyncIterableIterator<CCIPExecution>;
453
+ /**
454
+ * Fetch first execution receipt inside a transaction.
455
+ * @internal
456
+ * @param tx - transaction hash or transaction object
457
+ * @returns CCIP execution object
458
+ */
459
+ getExecutionReceiptInTx(tx: string | ChainTransaction): Promise<CCIPExecution>;
328
460
  /**
329
461
  * List tokens supported by given TokenAdminRegistry contract.
330
462
  * @param address - Usually TokenAdminRegistry, but chain may support receiving Router, OnRamp, etc.
@@ -366,6 +498,8 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
366
498
  * @returns Mapping of token addresses to respective TokenInfo objects.
367
499
  */
368
500
  abstract getFeeTokens(router: string): Promise<Record<string, TokenInfo>>;
501
+ /** {@inheritDoc ChainStatic.buildMessageForDest} */
502
+ static buildMessageForDest(message: Parameters<ChainStatic['buildMessageForDest']>[0]): AnyMessage;
369
503
  }
370
504
  /** Static methods and properties available on Chain class constructors. */
371
505
  export type ChainStatic<F extends ChainFamily = ChainFamily> = Function & {
@@ -374,8 +508,9 @@ export type ChainStatic<F extends ChainFamily = ChainFamily> = Function & {
374
508
  /**
375
509
  * async constructor: builds a Chain from a rpc endpoint url
376
510
  * @param url - rpc endpoint url
511
+ * @param ctx - optional context with logger and API client configuration
377
512
  */
378
- fromUrl(url: string, ctx?: WithLogger): Promise<Chain<F>>;
513
+ fromUrl(url: string, ctx?: ChainContext): Promise<Chain<F>>;
379
514
  /**
380
515
  * Try to decode a CCIP message *from* a log/event *originated* from this *source* chain,
381
516
  * but which may *target* other dest chain families
@@ -449,6 +584,13 @@ export type ChainStatic<F extends ChainFamily = ChainFamily> = Function & {
449
584
  * @returns Ordered record with messages/properties, or undefined if not a recognized error
450
585
  */
451
586
  parse?(data: unknown): Record<string, unknown> | undefined | null;
587
+ /**
588
+ * Returns a copy of a message, populating missing fields like `extraArgs` with defaults
589
+ * It's expected to return a message suitable at least for basic token transfers
590
+ * @param message - AnyMessage (from source), containing at least `receiver`
591
+ * @returns A message suitable for `sendMessage` to this destination chain family
592
+ */
593
+ buildMessageForDest(message: MessageInput): AnyMessage;
452
594
  };
453
595
  /** Function type for getting a Chain instance by ID, selector, or name. */
454
596
  export type ChainGetter = (idOrSelectorOrName: number | string | bigint) => Promise<Chain>;
@@ -1 +1 @@
1
- {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,C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EAAE,MAAM,GAAG,MAAM,CAAA;IACnC;;;;;OAKG;IACH,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,UAAU,CAAA;IAC3D;;;;OAIG;IACH,KAAK,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI,CAAA;IACjE;;;;;OAKG;IACH,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,UAAU,CAAA;CACvD,CAAA;AAED,2EAA2E;AAC3E,MAAM,MAAM,WAAW,GAAG,CAAC,kBAAkB,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC,CAAA"}
package/dist/chain.js CHANGED
@@ -1,5 +1,8 @@
1
- import { fetchCommitReport } from "./commits.js";
2
- import { CCIPChainFamilyMismatchError, CCIPTransactionNotFinalizedError } from "./errors/index.js";
1
+ import { dataLength } from 'ethers';
2
+ import { CCIPAPIClient } from "./api/index.js";
3
+ import { getCommitReport } from "./commits.js";
4
+ import { CCIPApiClientNotAvailableError, CCIPChainFamilyMismatchError, CCIPExecTxRevertedError, CCIPTransactionNotFinalizedError, } from "./errors/index.js";
5
+ import { DEFAULT_GAS_LIMIT } from "./evm/const.js";
3
6
  import { ExecutionState, } from "./types.js";
4
7
  import { util } from "./utils.js";
5
8
  /**
@@ -9,15 +12,29 @@ import { util } from "./utils.js";
9
12
  export class Chain {
10
13
  network;
11
14
  logger;
15
+ /** CCIP API client (null if opted out) */
16
+ apiClient;
12
17
  /**
13
18
  * Base constructor for Chain class.
14
19
  * @param network - NetworkInfo object for the Chain instance
20
+ * @param ctx - Optional context with logger and API client configuration
15
21
  */
16
- constructor(network, { logger = console } = {}) {
22
+ constructor(network, ctx) {
23
+ const { logger = console, apiClient } = ctx ?? {};
17
24
  if (network.family !== this.constructor.family)
18
25
  throw new CCIPChainFamilyMismatchError(this.constructor.name, this.constructor.family, network.family);
19
26
  this.network = network;
20
27
  this.logger = logger;
28
+ // API client initialization: default enabled, null = explicit opt-out
29
+ if (apiClient === null) {
30
+ this.apiClient = null; // Explicit opt-out
31
+ }
32
+ else if (apiClient !== undefined) {
33
+ this.apiClient = apiClient; // Use provided instance
34
+ }
35
+ else {
36
+ this.apiClient = new CCIPAPIClient(undefined, { logger }); // Default
37
+ }
21
38
  }
22
39
  /** Custom inspector for Node.js util.inspect. */
23
40
  [util.inspect.custom]() {
@@ -27,7 +44,7 @@ export class Chain {
27
44
  * Confirm a log tx is finalized or wait for it to be finalized
28
45
  * Throws if it isn't included (e.g. a reorg)
29
46
  */
30
- async waitFinalized({ log, tx, }, finality = 'finalized', cancel$) {
47
+ async waitFinalized({ request: { log, tx }, finality = 'finalized', cancel$, }) {
31
48
  const timestamp = log.tx?.timestamp ?? tx?.timestamp;
32
49
  if (!timestamp || Date.now() / 1e3 - timestamp > 60) {
33
50
  // only try to fetch tx if request is old enough (>60s)
@@ -57,34 +74,70 @@ export class Chain {
57
74
  /**
58
75
  * Look for a CommitReport at dest for given CCIP request
59
76
  * May be specialized by some subclasses
60
- *
61
- * @param commitStore - Commit store address
62
- * @param request - CCIPRequest to get commit info for
63
- * @param hints - Additional filtering hints
77
+ * @param opts - getCommitReport options
64
78
  * @returns CCIPCommit info, or reject if none found
65
79
  **/
66
- async fetchCommitReport(commitStore, request, hints) {
67
- return fetchCommitReport(this, commitStore, request, hints);
80
+ async getCommitReport({ commitStore, request, ...hints }) {
81
+ return getCommitReport(this, commitStore, request, hints);
82
+ }
83
+ /**
84
+ * Fetches estimated lane latency to a destination chain.
85
+ * Uses this chain's selector as the source.
86
+ *
87
+ * @param destChainSelector - Destination CCIP chain selector (bigint)
88
+ * @returns Promise resolving to {@link LaneLatencyResponse} containing:
89
+ * - `lane.sourceNetworkInfo` - Source chain metadata (name, selector, chainId)
90
+ * - `lane.destNetworkInfo` - Destination chain metadata
91
+ * - `lane.routerAddress` - Router contract address on source chain
92
+ * - `totalMs` - Estimated delivery time in milliseconds
93
+ *
94
+ * @throws {@link CCIPApiClientNotAvailableError} if apiClient was disabled (set to `null`)
95
+ * @throws {@link CCIPHttpError} if API request fails (network error, 4xx, 5xx status)
96
+ *
97
+ * @remarks
98
+ * Each call makes a fresh API request. Consider caching results if making
99
+ * frequent calls for the same lane.
100
+ *
101
+ * @example Get estimated delivery time
102
+ * ```typescript
103
+ * const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
104
+ * try {
105
+ * const latency = await chain.getLaneLatency(4949039107694359620n) // Arbitrum
106
+ * console.log(`Estimated delivery: ${Math.round(latency.totalMs / 60000)} minutes`)
107
+ * console.log(`Router: ${latency.lane.routerAddress}`)
108
+ * } catch (err) {
109
+ * if (err instanceof CCIPHttpError) {
110
+ * console.error(`API error: ${err.context.apiErrorCode}`)
111
+ * }
112
+ * }
113
+ * ```
114
+ */
115
+ async getLaneLatency(destChainSelector) {
116
+ if (!this.apiClient) {
117
+ throw new CCIPApiClientNotAvailableError();
118
+ }
119
+ return this.apiClient.getLaneLatency(this.network.chainSelector, destChainSelector);
68
120
  }
69
121
  /**
70
- * Default/generic implementation of fetchExecutionReceipts
71
- * @param offRamp - Off-ramp address
72
- * @param request - CCIPRequest to get execution receipts for
73
- * @param commit - CCIPCommit info to help narrowing search for executions
74
- * @param hints - Additional filtering hints
122
+ * Default/generic implementation of getExecutionReceipts
123
+ * @param opts - getExecutionReceipts options
75
124
  * @returns Async generator of CCIPExecution receipts
76
125
  */
77
- async *fetchExecutionReceipts(offRamp, request, commit, hints) {
78
- const onlyLast = !commit?.log.blockNumber && !request.tx.timestamp; // backwards
126
+ async *getExecutionReceipts({ offRamp, messageId, sourceChainSelector, commit, ...hints }) {
127
+ hints.startBlock ??= commit?.log.blockNumber;
128
+ const onlyLast = !hints.startTime && !hints.startBlock; // backwards
79
129
  for await (const log of this.getLogs({
80
- startBlock: commit?.log.blockNumber,
81
- startTime: request.tx.timestamp,
82
130
  address: offRamp,
83
131
  topics: ['ExecutionStateChanged'],
84
132
  ...hints,
85
133
  })) {
86
134
  const receipt = this.constructor.decodeReceipt(log);
87
- if (!receipt || receipt.messageId !== request.message.messageId)
135
+ // filters
136
+ if (!receipt ||
137
+ (messageId && receipt.messageId !== messageId) ||
138
+ (sourceChainSelector &&
139
+ receipt.sourceChainSelector &&
140
+ receipt.sourceChainSelector !== sourceChainSelector))
88
141
  continue;
89
142
  const timestamp = log.tx?.timestamp ?? (await this.getBlockTimestamp(log.blockNumber));
90
143
  yield { receipt, log, timestamp };
@@ -92,5 +145,35 @@ export class Chain {
92
145
  break;
93
146
  }
94
147
  }
148
+ /**
149
+ * Fetch first execution receipt inside a transaction.
150
+ * @internal
151
+ * @param tx - transaction hash or transaction object
152
+ * @returns CCIP execution object
153
+ */
154
+ async getExecutionReceiptInTx(tx) {
155
+ if (typeof tx === 'string')
156
+ tx = await this.getTransaction(tx);
157
+ for (const log of tx.logs) {
158
+ const rcpt = this.constructor.decodeReceipt(log);
159
+ if (!rcpt)
160
+ continue;
161
+ const timestamp = tx.timestamp;
162
+ return { receipt: rcpt, log, timestamp };
163
+ }
164
+ throw new CCIPExecTxRevertedError(tx.hash);
165
+ }
166
+ /** {@inheritDoc ChainStatic.buildMessageForDest} */
167
+ static buildMessageForDest(message) {
168
+ // default to GenericExtraArgsV2, aka EVMExtraArgsV2
169
+ return {
170
+ ...message,
171
+ extraArgs: {
172
+ gasLimit: message.data && dataLength(message.data) ? DEFAULT_GAS_LIMIT : 0n,
173
+ allowOutOfOrderExecution: true,
174
+ ...message.extraArgs,
175
+ },
176
+ };
177
+ }
95
178
  }
96
179
  //# sourceMappingURL=chain.js.map