@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.
- package/README.md +2 -2
- package/dist/all-chains.d.ts +23 -0
- package/dist/all-chains.d.ts.map +1 -0
- package/dist/all-chains.js +24 -0
- package/dist/all-chains.js.map +1 -0
- package/dist/api/index.d.ts +31 -19
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +46 -25
- package/dist/api/index.js.map +1 -1
- package/dist/api/types.d.ts +24 -30
- package/dist/api/types.d.ts.map +1 -1
- package/dist/aptos/exec.d.ts +2 -2
- package/dist/aptos/exec.d.ts.map +1 -1
- package/dist/aptos/exec.js.map +1 -1
- package/dist/aptos/hasher.d.ts.map +1 -1
- package/dist/aptos/hasher.js +1 -1
- package/dist/aptos/hasher.js.map +1 -1
- package/dist/aptos/index.d.ts +43 -15
- package/dist/aptos/index.d.ts.map +1 -1
- package/dist/aptos/index.js +112 -105
- package/dist/aptos/index.js.map +1 -1
- package/dist/aptos/types.d.ts +2 -19
- package/dist/aptos/types.d.ts.map +1 -1
- package/dist/aptos/types.js +0 -11
- package/dist/aptos/types.js.map +1 -1
- package/dist/chain.d.ts +734 -174
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +216 -31
- package/dist/chain.js.map +1 -1
- package/dist/commits.d.ts +4 -6
- package/dist/commits.d.ts.map +1 -1
- package/dist/commits.js +4 -4
- package/dist/commits.js.map +1 -1
- package/dist/errors/CCIPError.d.ts +33 -4
- package/dist/errors/CCIPError.d.ts.map +1 -1
- package/dist/errors/CCIPError.js +33 -4
- package/dist/errors/CCIPError.js.map +1 -1
- package/dist/errors/codes.d.ts +5 -0
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/errors/codes.js +5 -1
- package/dist/errors/codes.js.map +1 -1
- package/dist/errors/index.d.ts +2 -2
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +2 -2
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/recovery.d.ts.map +1 -1
- package/dist/errors/recovery.js +6 -1
- package/dist/errors/recovery.js.map +1 -1
- package/dist/errors/specialized.d.ts +1702 -121
- package/dist/errors/specialized.d.ts.map +1 -1
- package/dist/errors/specialized.js +1729 -125
- package/dist/errors/specialized.js.map +1 -1
- package/dist/errors/utils.d.ts.map +1 -1
- package/dist/errors/utils.js +0 -1
- package/dist/errors/utils.js.map +1 -1
- package/dist/evm/abi/OffRamp_2_0.d.ts +764 -0
- package/dist/evm/abi/OffRamp_2_0.d.ts.map +1 -0
- package/dist/evm/abi/OffRamp_2_0.js +744 -0
- package/dist/evm/abi/OffRamp_2_0.js.map +1 -0
- package/dist/evm/abi/OnRamp_2_0.d.ts +925 -0
- package/dist/evm/abi/OnRamp_2_0.d.ts.map +1 -0
- package/dist/evm/abi/OnRamp_2_0.js +992 -0
- package/dist/evm/abi/OnRamp_2_0.js.map +1 -0
- package/dist/evm/const.d.ts +12 -2
- package/dist/evm/const.d.ts.map +1 -1
- package/dist/evm/const.js +8 -2
- package/dist/evm/const.js.map +1 -1
- package/dist/evm/errors.d.ts.map +1 -1
- package/dist/evm/errors.js +7 -2
- package/dist/evm/errors.js.map +1 -1
- package/dist/evm/extra-args.d.ts +25 -0
- package/dist/evm/extra-args.d.ts.map +1 -0
- package/dist/evm/extra-args.js +309 -0
- package/dist/evm/extra-args.js.map +1 -0
- package/dist/evm/gas.d.ts.map +1 -1
- package/dist/evm/gas.js +7 -12
- package/dist/evm/gas.js.map +1 -1
- package/dist/evm/hasher.d.ts.map +1 -1
- package/dist/evm/hasher.js +23 -13
- package/dist/evm/hasher.js.map +1 -1
- package/dist/evm/index.d.ts +140 -35
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +306 -226
- package/dist/evm/index.js.map +1 -1
- package/dist/evm/messages.d.ts +59 -5
- package/dist/evm/messages.d.ts.map +1 -1
- package/dist/evm/messages.js +210 -0
- package/dist/evm/messages.js.map +1 -1
- package/dist/evm/offchain.js.map +1 -1
- package/dist/evm/types.d.ts +7 -2
- package/dist/evm/types.d.ts.map +1 -1
- package/dist/evm/types.js +22 -1
- package/dist/evm/types.js.map +1 -1
- package/dist/execution.d.ts +62 -22
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +102 -51
- package/dist/execution.js.map +1 -1
- package/dist/extra-args.d.ts +113 -4
- package/dist/extra-args.d.ts.map +1 -1
- package/dist/extra-args.js +38 -3
- package/dist/extra-args.js.map +1 -1
- package/dist/gas.d.ts +31 -5
- package/dist/gas.d.ts.map +1 -1
- package/dist/gas.js +43 -9
- package/dist/gas.js.map +1 -1
- package/dist/index.d.ts +11 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/requests.d.ts +101 -22
- package/dist/requests.d.ts.map +1 -1
- package/dist/requests.js +115 -24
- package/dist/requests.js.map +1 -1
- package/dist/selectors.d.ts.map +1 -1
- package/dist/selectors.js +24 -0
- package/dist/selectors.js.map +1 -1
- package/dist/shared/bcs-codecs.d.ts +61 -0
- package/dist/shared/bcs-codecs.d.ts.map +1 -0
- package/dist/shared/bcs-codecs.js +102 -0
- package/dist/shared/bcs-codecs.js.map +1 -0
- package/dist/shared/constants.d.ts +3 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +3 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/solana/exec.d.ts +2 -2
- package/dist/solana/exec.d.ts.map +1 -1
- package/dist/solana/exec.js.map +1 -1
- package/dist/solana/index.d.ts +148 -30
- package/dist/solana/index.d.ts.map +1 -1
- package/dist/solana/index.js +137 -44
- package/dist/solana/index.js.map +1 -1
- package/dist/sui/hasher.d.ts.map +1 -1
- package/dist/sui/hasher.js +1 -1
- package/dist/sui/hasher.js.map +1 -1
- package/dist/sui/index.d.ts +49 -19
- package/dist/sui/index.d.ts.map +1 -1
- package/dist/sui/index.js +76 -43
- package/dist/sui/index.js.map +1 -1
- package/dist/sui/manuallyExec/encoder.d.ts +2 -2
- package/dist/sui/manuallyExec/encoder.d.ts.map +1 -1
- package/dist/sui/manuallyExec/encoder.js.map +1 -1
- package/dist/sui/manuallyExec/index.d.ts +2 -2
- package/dist/sui/manuallyExec/index.d.ts.map +1 -1
- package/dist/ton/exec.d.ts +2 -2
- package/dist/ton/exec.d.ts.map +1 -1
- package/dist/ton/exec.js.map +1 -1
- package/dist/ton/index.d.ts +66 -27
- package/dist/ton/index.d.ts.map +1 -1
- package/dist/ton/index.js +172 -47
- package/dist/ton/index.js.map +1 -1
- package/dist/ton/send.d.ts +52 -0
- package/dist/ton/send.d.ts.map +1 -0
- package/dist/ton/send.js +166 -0
- package/dist/ton/send.js.map +1 -0
- package/dist/ton/types.d.ts +2 -2
- package/dist/ton/types.d.ts.map +1 -1
- package/dist/ton/types.js.map +1 -1
- package/dist/types.d.ts +148 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +79 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +92 -7
- package/dist/utils.js.map +1 -1
- package/package.json +16 -11
- package/src/all-chains.ts +26 -0
- package/src/api/index.ts +58 -34
- package/src/api/types.ts +24 -31
- package/src/aptos/exec.ts +2 -2
- package/src/aptos/hasher.ts +1 -1
- package/src/aptos/index.ts +127 -129
- package/src/aptos/types.ts +2 -15
- package/src/chain.ts +837 -191
- package/src/commits.ts +9 -9
- package/src/errors/CCIPError.ts +33 -4
- package/src/errors/codes.ts +5 -1
- package/src/errors/index.ts +2 -1
- package/src/errors/recovery.ts +9 -1
- package/src/errors/specialized.ts +1745 -132
- package/src/errors/utils.ts +0 -1
- package/src/evm/abi/OffRamp_2_0.ts +743 -0
- package/src/evm/abi/OnRamp_2_0.ts +991 -0
- package/src/evm/const.ts +10 -3
- package/src/evm/errors.ts +6 -2
- package/src/evm/extra-args.ts +360 -0
- package/src/evm/gas.ts +14 -13
- package/src/evm/hasher.ts +30 -18
- package/src/evm/index.ts +376 -281
- package/src/evm/messages.ts +323 -11
- package/src/evm/offchain.ts +2 -2
- package/src/evm/types.ts +20 -2
- package/src/execution.ts +126 -71
- package/src/extra-args.ts +118 -4
- package/src/gas.ts +44 -11
- package/src/index.ts +14 -11
- package/src/requests.ts +128 -24
- package/src/selectors.ts +24 -0
- package/src/shared/bcs-codecs.ts +132 -0
- package/src/shared/constants.ts +2 -0
- package/src/solana/exec.ts +4 -4
- package/src/solana/index.ts +170 -82
- package/src/sui/hasher.ts +1 -1
- package/src/sui/index.ts +88 -56
- package/src/sui/manuallyExec/encoder.ts +2 -2
- package/src/sui/manuallyExec/index.ts +2 -2
- package/src/ton/exec.ts +2 -2
- package/src/ton/index.ts +220 -58
- package/src/ton/send.ts +222 -0
- package/src/ton/types.ts +2 -2
- package/src/types.ts +173 -30
- package/src/utils.ts +91 -7
- package/dist/aptos/utils.d.ts +0 -12
- package/dist/aptos/utils.d.ts.map +0 -1
- package/dist/aptos/utils.js +0 -15
- package/dist/aptos/utils.js.map +0 -1
- 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
|
|
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 =
|
|
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
|
|
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
|
-
*
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
223
|
+
* Common options for {@link Chain.generateUnsignedExecute} and {@link Chain.execute} methods.
|
|
163
224
|
*/
|
|
164
|
-
export type
|
|
225
|
+
export type ExecuteOpts = ({
|
|
165
226
|
/** address of the OffRamp contract */
|
|
166
227
|
offRamp: string;
|
|
167
|
-
/**
|
|
168
|
-
|
|
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
|
-
*
|
|
202
|
-
* @
|
|
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
|
-
*
|
|
208
|
-
* @
|
|
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
|
-
*
|
|
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
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
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
|
-
*
|
|
263
|
-
*
|
|
264
|
-
* @param
|
|
410
|
+
* To be implemented for chains supporting CCIPVersion <= 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
|
-
|
|
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
|
|
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
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
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 -
|
|
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 -
|
|
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
|
-
*
|
|
296
|
-
* @
|
|
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 -
|
|
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 -
|
|
311
|
-
* @returns OnRamp
|
|
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
|
|
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 -
|
|
319
|
-
* @returns
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
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
|
|
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
|
|
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
|
|
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({
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
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
|
|
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
|
-
*
|
|
418
|
-
* @
|
|
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
|
|
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
|
-
* @
|
|
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
|
|
432
|
-
*
|
|
433
|
-
*
|
|
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
|
|
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
|
-
*
|
|
457
|
-
* @
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
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' | '
|
|
464
|
-
} & Pick<LogFilter, 'page' | 'watch' | 'startBlock'>): Promise<
|
|
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,
|
|
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
|
-
|
|
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 -
|
|
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
|
|
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
|
-
*
|
|
531
|
-
*
|
|
532
|
-
* @
|
|
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
|
-
*
|
|
541
|
-
*
|
|
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
|
|
544
|
-
token: string;
|
|
545
|
-
router: string;
|
|
546
|
-
typeAndVersion?: string;
|
|
547
|
-
}>;
|
|
908
|
+
abstract getTokenPoolConfig(tokenPool: string): Promise<TokenPoolConfig>;
|
|
548
909
|
/**
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
* @
|
|
552
|
-
*
|
|
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
|
-
*
|
|
558
|
-
* @
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
589
|
-
*
|
|
590
|
-
* @param
|
|
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
|
|
595
|
-
* but
|
|
596
|
-
*
|
|
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
|
|
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
|
-
*
|
|
605
|
-
* @
|
|
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 -
|
|
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 (
|
|
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
|
-
*
|
|
656
|
-
* @param
|
|
657
|
-
* @
|
|
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
|
|
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
|
/**
|