@chainlink/ccip-sdk 0.97.0 → 1.1.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 +12 -9
- package/dist/api/index.d.ts +7 -3
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +124 -13
- package/dist/api/index.js.map +1 -1
- package/dist/api/types.d.ts +34 -0
- package/dist/api/types.d.ts.map +1 -1
- package/dist/aptos/index.d.ts +4 -6
- package/dist/aptos/index.d.ts.map +1 -1
- package/dist/aptos/index.js +0 -5
- package/dist/aptos/index.js.map +1 -1
- package/dist/aptos/logs.d.ts +2 -2
- package/dist/aptos/logs.d.ts.map +1 -1
- package/dist/chain.d.ts +104 -16
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +97 -9
- package/dist/chain.js.map +1 -1
- package/dist/errors/codes.d.ts +1 -1
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/errors/codes.js +2 -1
- package/dist/errors/codes.js.map +1 -1
- package/dist/errors/index.d.ts +5 -5
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +5 -5
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/recovery.js +1 -1
- package/dist/errors/recovery.js.map +1 -1
- package/dist/errors/specialized.d.ts +22 -19
- package/dist/errors/specialized.d.ts.map +1 -1
- package/dist/errors/specialized.js +30 -25
- package/dist/errors/specialized.js.map +1 -1
- package/dist/evm/abi/OffRamp_2_0.d.ts +24 -12
- package/dist/evm/abi/OffRamp_2_0.d.ts.map +1 -1
- package/dist/evm/abi/OffRamp_2_0.js +16 -8
- package/dist/evm/abi/OffRamp_2_0.js.map +1 -1
- package/dist/evm/abi/OnRamp_2_0.d.ts +1 -1
- package/dist/evm/abi/OnRamp_2_0.js +1 -1
- package/dist/evm/abi/OnRamp_2_0.js.map +1 -1
- package/dist/evm/abi/TokenPool_2_0.d.ts +1552 -0
- package/dist/evm/abi/TokenPool_2_0.d.ts.map +1 -0
- package/dist/evm/abi/TokenPool_2_0.js +1637 -0
- package/dist/evm/abi/TokenPool_2_0.js.map +1 -0
- package/dist/evm/const.d.ts +1 -0
- package/dist/evm/const.d.ts.map +1 -1
- package/dist/evm/const.js +2 -0
- package/dist/evm/const.js.map +1 -1
- package/dist/evm/index.d.ts +11 -7
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +139 -46
- package/dist/evm/index.js.map +1 -1
- package/dist/evm/logs.d.ts +1 -1
- package/dist/evm/logs.js +1 -1
- package/dist/evm/messages.d.ts +2 -33
- package/dist/evm/messages.d.ts.map +1 -1
- package/dist/evm/messages.js +0 -210
- package/dist/evm/messages.js.map +1 -1
- package/dist/evm/offchain.d.ts +1 -14
- package/dist/evm/offchain.d.ts.map +1 -1
- package/dist/evm/offchain.js +1 -133
- package/dist/evm/offchain.js.map +1 -1
- package/dist/gas.d.ts +4 -0
- package/dist/gas.d.ts.map +1 -1
- package/dist/gas.js +27 -21
- package/dist/gas.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/messages.d.ts +34 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +211 -0
- package/dist/messages.js.map +1 -0
- package/dist/offchain.d.ts +23 -6
- package/dist/offchain.d.ts.map +1 -1
- package/dist/offchain.js +92 -17
- package/dist/offchain.js.map +1 -1
- package/dist/requests.d.ts.map +1 -1
- package/dist/requests.js +0 -1
- package/dist/requests.js.map +1 -1
- package/dist/solana/cleanup.js +2 -2
- package/dist/solana/cleanup.js.map +1 -1
- package/dist/solana/exec.js +1 -1
- package/dist/solana/exec.js.map +1 -1
- package/dist/solana/idl/1.6.0/BASE_TOKEN_POOL.d.ts +1 -1
- package/dist/solana/idl/1.6.0/BASE_TOKEN_POOL.js +1 -1
- package/dist/solana/idl/1.6.0/BURN_MINT_TOKEN_POOL.d.ts +1 -1
- package/dist/solana/idl/1.6.0/BURN_MINT_TOKEN_POOL.js +1 -1
- package/dist/solana/idl/1.6.0/CCIP_CCTP_TOKEN_POOL.d.ts +1 -1
- package/dist/solana/idl/1.6.0/CCIP_CCTP_TOKEN_POOL.js +1 -1
- package/dist/solana/idl/1.6.0/CCIP_COMMON.d.ts +16 -1
- package/dist/solana/idl/1.6.0/CCIP_COMMON.d.ts.map +1 -1
- package/dist/solana/idl/1.6.0/CCIP_COMMON.js +16 -1
- package/dist/solana/idl/1.6.0/CCIP_COMMON.js.map +1 -1
- package/dist/solana/idl/1.6.0/CCIP_OFFRAMP.d.ts +1 -1
- package/dist/solana/idl/1.6.0/CCIP_OFFRAMP.js +1 -1
- package/dist/solana/idl/1.6.0/CCIP_ROUTER.d.ts +1 -1
- package/dist/solana/idl/1.6.0/CCIP_ROUTER.js +1 -1
- package/dist/solana/index.d.ts +25 -27
- package/dist/solana/index.d.ts.map +1 -1
- package/dist/solana/index.js +16 -7
- package/dist/solana/index.js.map +1 -1
- package/dist/solana/offchain.d.ts +1 -13
- package/dist/solana/offchain.d.ts.map +1 -1
- package/dist/solana/offchain.js +1 -66
- package/dist/solana/offchain.js.map +1 -1
- package/dist/solana/utils.d.ts +4 -4
- package/dist/solana/utils.d.ts.map +1 -1
- package/dist/solana/utils.js +1 -1
- package/dist/solana/utils.js.map +1 -1
- package/dist/sui/index.d.ts +4 -6
- package/dist/sui/index.d.ts.map +1 -1
- package/dist/sui/index.js +14 -6
- package/dist/sui/index.js.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 +1 -1
- package/dist/ton/exec.js.map +1 -1
- package/dist/ton/index.d.ts +5 -6
- package/dist/ton/index.d.ts.map +1 -1
- package/dist/ton/index.js +3 -5
- package/dist/ton/index.js.map +1 -1
- package/dist/ton/types.d.ts +3 -5
- package/dist/ton/types.d.ts.map +1 -1
- package/dist/ton/types.js.map +1 -1
- package/dist/types.d.ts +10 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +11 -7
- package/src/api/index.ts +145 -17
- package/src/api/types.ts +43 -0
- package/src/aptos/index.ts +4 -11
- package/src/aptos/logs.ts +2 -2
- package/src/chain.ts +148 -23
- package/src/errors/codes.ts +2 -1
- package/src/errors/index.ts +4 -1
- package/src/errors/recovery.ts +1 -1
- package/src/errors/specialized.ts +35 -30
- package/src/evm/abi/OffRamp_2_0.ts +16 -8
- package/src/evm/abi/OnRamp_2_0.ts +1 -1
- package/src/evm/abi/TokenPool_2_0.ts +1636 -0
- package/src/evm/const.ts +2 -0
- package/src/evm/index.ts +234 -85
- package/src/evm/logs.ts +1 -1
- package/src/evm/messages.ts +3 -285
- package/src/evm/offchain.ts +2 -191
- package/src/gas.ts +27 -19
- package/src/index.ts +10 -2
- package/src/messages.ts +278 -0
- package/src/offchain.ts +125 -28
- package/src/requests.ts +2 -3
- package/src/solana/cleanup.ts +2 -2
- package/src/solana/exec.ts +1 -1
- package/src/solana/idl/1.6.0/BASE_TOKEN_POOL.ts +2 -2
- package/src/solana/idl/1.6.0/BURN_MINT_TOKEN_POOL.ts +2 -2
- package/src/solana/idl/1.6.0/CCIP_CCTP_TOKEN_POOL.ts +2 -2
- package/src/solana/idl/1.6.0/CCIP_COMMON.ts +32 -2
- package/src/solana/idl/1.6.0/CCIP_OFFRAMP.ts +2 -2
- package/src/solana/idl/1.6.0/CCIP_ROUTER.ts +2 -2
- package/src/solana/index.ts +27 -17
- package/src/solana/offchain.ts +3 -100
- package/src/solana/utils.ts +8 -5
- package/src/sui/index.ts +22 -12
- package/src/ton/exec.ts +3 -6
- package/src/ton/index.ts +15 -16
- package/src/ton/types.ts +3 -6
- package/src/types.ts +13 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainlink/ccip-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "SDK/Library to interact with CCIP",
|
|
5
5
|
"author": "Chainlink devs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/smartcontractkit/ccip-tools-ts.git"
|
|
10
10
|
},
|
|
11
|
+
"homepage": "https://docs.chain.link/ccip/tools/sdk/",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/smartcontractkit/ccip-tools-ts/issues"
|
|
14
|
+
},
|
|
11
15
|
"type": "module",
|
|
12
16
|
"sideEffects": false,
|
|
13
17
|
"exports": {
|
|
@@ -55,21 +59,21 @@
|
|
|
55
59
|
"@depay/web3-mock": "^15.3.0",
|
|
56
60
|
"@eslint/js": "^9.39.3",
|
|
57
61
|
"@types/bn.js": "^5.2.0",
|
|
58
|
-
"@types/node": "25.3.
|
|
62
|
+
"@types/node": "25.3.5",
|
|
59
63
|
"@types/yargs": "17.0.35",
|
|
60
64
|
"eslint": "^9.39.3",
|
|
61
65
|
"eslint-config-prettier": "10.1.8",
|
|
62
66
|
"eslint-import-resolver-typescript": "4.4.4",
|
|
63
67
|
"eslint-plugin-import": "^2.32.0",
|
|
64
|
-
"eslint-plugin-jsdoc": "^62.7.
|
|
68
|
+
"eslint-plugin-jsdoc": "^62.7.1",
|
|
65
69
|
"eslint-plugin-prettier": "^5.5.5",
|
|
66
|
-
"eslint-plugin-tsdoc": "^0.5.
|
|
70
|
+
"eslint-plugin-tsdoc": "^0.5.2",
|
|
67
71
|
"ethers-abitype": "1.0.3",
|
|
68
72
|
"prettier": "^3.8.1",
|
|
69
73
|
"prool": "^0.0.17",
|
|
70
74
|
"typescript": "5.9.3",
|
|
71
|
-
"typescript-eslint": "8.56.
|
|
72
|
-
"viem": "^2.
|
|
75
|
+
"typescript-eslint": "8.56.1",
|
|
76
|
+
"viem": "^2.47.0"
|
|
73
77
|
},
|
|
74
78
|
"dependencies": {
|
|
75
79
|
"@aptos-labs/ts-sdk": "^5.2.1",
|
|
@@ -94,6 +98,6 @@
|
|
|
94
98
|
},
|
|
95
99
|
"overrides": {
|
|
96
100
|
"bigint-buffer": "npm:@trufflesuite/bigint-buffer@1.1.10",
|
|
97
|
-
"axios": "^1.13.
|
|
101
|
+
"axios": "^1.13.5"
|
|
98
102
|
}
|
|
99
103
|
}
|
package/src/api/index.ts
CHANGED
|
@@ -2,24 +2,26 @@ import { memoize } from 'micro-memoize'
|
|
|
2
2
|
import type { SetRequired } from 'type-fest'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
+
CCIPApiClientNotAvailableError,
|
|
5
6
|
CCIPHttpError,
|
|
6
7
|
CCIPLaneNotFoundError,
|
|
7
8
|
CCIPMessageIdNotFoundError,
|
|
8
9
|
CCIPMessageNotFoundInTxError,
|
|
9
|
-
CCIPNotImplementedError,
|
|
10
10
|
CCIPTimeoutError,
|
|
11
11
|
CCIPUnexpectedPaginationError,
|
|
12
12
|
} from '../errors/index.ts'
|
|
13
13
|
import { HttpStatus } from '../http-status.ts'
|
|
14
|
+
import { decodeMessageV1 } from '../messages.ts'
|
|
14
15
|
import { decodeMessage } from '../requests.ts'
|
|
15
16
|
import {
|
|
16
17
|
type CCIPMessage,
|
|
17
18
|
type CCIPRequest,
|
|
18
|
-
type
|
|
19
|
+
type ChainLog,
|
|
19
20
|
type ExecutionInput,
|
|
20
|
-
type
|
|
21
|
+
type Lane,
|
|
21
22
|
type Logger,
|
|
22
23
|
type NetworkInfo,
|
|
24
|
+
type OffchainTokenData,
|
|
23
25
|
type WithLogger,
|
|
24
26
|
CCIPVersion,
|
|
25
27
|
ChainFamily,
|
|
@@ -30,11 +32,13 @@ import { bigIntReviver, parseJson } from '../utils.ts'
|
|
|
30
32
|
import type {
|
|
31
33
|
APIErrorResponse,
|
|
32
34
|
LaneLatencyResponse,
|
|
35
|
+
RawExecutionInputsResult,
|
|
33
36
|
RawLaneLatencyResponse,
|
|
34
37
|
RawMessageResponse,
|
|
35
38
|
RawMessagesResponse,
|
|
36
39
|
RawNetworkInfo,
|
|
37
40
|
} from './types.ts'
|
|
41
|
+
import { calculateManualExecProof } from '../execution.ts'
|
|
38
42
|
|
|
39
43
|
export type { APICCIPRequestMetadata, APIErrorResponse, LaneLatencyResponse } from './types.ts'
|
|
40
44
|
|
|
@@ -44,6 +48,15 @@ export const DEFAULT_API_BASE_URL = 'https://api.ccip.chain.link'
|
|
|
44
48
|
/** Default timeout for API requests in milliseconds */
|
|
45
49
|
export const DEFAULT_TIMEOUT_MS = 30000
|
|
46
50
|
|
|
51
|
+
/** SDK version string for telemetry header */
|
|
52
|
+
// generate:nofail
|
|
53
|
+
// `export const SDK_VERSION = '${require('./package.json').version}-${require('child_process').execSync('git rev-parse --short HEAD').toString().trim()}'`
|
|
54
|
+
export const SDK_VERSION = '1.1.0-30c18a9'
|
|
55
|
+
// generate:end
|
|
56
|
+
|
|
57
|
+
/** SDK telemetry header name */
|
|
58
|
+
export const SDK_VERSION_HEADER = 'X-SDK-Version'
|
|
59
|
+
|
|
47
60
|
/**
|
|
48
61
|
* Context for CCIPAPIClient initialization.
|
|
49
62
|
*/
|
|
@@ -126,7 +139,7 @@ export class CCIPAPIClient {
|
|
|
126
139
|
static {
|
|
127
140
|
CCIPAPIClient.fromUrl = memoize(
|
|
128
141
|
(baseUrl?: string, ctx?: CCIPAPIClientContext) => new CCIPAPIClient(baseUrl, ctx),
|
|
129
|
-
{ maxArgs: 1 },
|
|
142
|
+
{ maxArgs: 1, transformKey: ([baseUrl]) => [baseUrl ?? DEFAULT_API_BASE_URL] },
|
|
130
143
|
)
|
|
131
144
|
}
|
|
132
145
|
|
|
@@ -136,10 +149,26 @@ export class CCIPAPIClient {
|
|
|
136
149
|
* @param ctx - Optional context with logger and custom fetch
|
|
137
150
|
*/
|
|
138
151
|
constructor(baseUrl?: string, ctx?: CCIPAPIClientContext) {
|
|
152
|
+
if (typeof baseUrl === 'boolean' || (baseUrl as unknown) === null)
|
|
153
|
+
throw new CCIPApiClientNotAvailableError({ context: { baseUrl } }) // shouldn't happen
|
|
139
154
|
this.baseUrl = baseUrl ?? DEFAULT_API_BASE_URL
|
|
140
155
|
this.logger = ctx?.logger ?? console
|
|
141
156
|
this.timeoutMs = ctx?.timeoutMs ?? DEFAULT_TIMEOUT_MS
|
|
142
|
-
this._fetch = ctx?.fetch ?? globalThis.fetch
|
|
157
|
+
this._fetch = ctx?.fetch ?? globalThis.fetch.bind(globalThis)
|
|
158
|
+
|
|
159
|
+
this.getMessageById = memoize(this.getMessageById.bind(this), {
|
|
160
|
+
async: true,
|
|
161
|
+
expires: 4_000,
|
|
162
|
+
maxArgs: 1,
|
|
163
|
+
maxSize: 100,
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
this.getExecutionInput = memoize(this.getExecutionInput.bind(this), {
|
|
167
|
+
async: true,
|
|
168
|
+
expires: 4_000,
|
|
169
|
+
maxArgs: 1,
|
|
170
|
+
maxSize: 100,
|
|
171
|
+
})
|
|
143
172
|
}
|
|
144
173
|
|
|
145
174
|
/**
|
|
@@ -167,7 +196,13 @@ export class CCIPAPIClient {
|
|
|
167
196
|
const timeoutId = setTimeout(() => controller.abort(), this.timeoutMs)
|
|
168
197
|
|
|
169
198
|
try {
|
|
170
|
-
return await this._fetch(url, {
|
|
199
|
+
return await this._fetch(url, {
|
|
200
|
+
signal: controller.signal,
|
|
201
|
+
headers: {
|
|
202
|
+
'Content-Type': 'application/json',
|
|
203
|
+
[SDK_VERSION_HEADER]: `CCIP SDK v${SDK_VERSION}`,
|
|
204
|
+
},
|
|
205
|
+
})
|
|
171
206
|
} catch (error) {
|
|
172
207
|
if (error instanceof Error && error.name === 'AbortError') {
|
|
173
208
|
throw new CCIPTimeoutError(operation, this.timeoutMs)
|
|
@@ -423,15 +458,109 @@ export class CCIPAPIClient {
|
|
|
423
458
|
/**
|
|
424
459
|
* Fetches the execution input for a given message by id.
|
|
425
460
|
* @param messageId - The ID of the message to fetch the execution input for.
|
|
426
|
-
* @returns Either `{ encodedMessage, verifications }` or `{ message, offchainTokenData, ...proof }`, and
|
|
461
|
+
* @returns Either `{ encodedMessage, verifications }` or `{ message, offchainTokenData, ...proof }`, offRamp and lane
|
|
427
462
|
*/
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
463
|
+
async getExecutionInput(messageId: string): Promise<ExecutionInput & Lane & { offRamp: string }> {
|
|
464
|
+
const url = `${this.baseUrl}/v2/messages/${encodeURIComponent(messageId)}/execution-inputs`
|
|
465
|
+
|
|
466
|
+
this.logger.debug(`CCIPAPIClient: GET ${url}`)
|
|
467
|
+
|
|
468
|
+
const response = await this._fetchWithTimeout(url, 'getExecutionInput')
|
|
469
|
+
if (!response.ok) {
|
|
470
|
+
// Try to parse structured error response from API
|
|
471
|
+
let apiError: APIErrorResponse | undefined
|
|
472
|
+
try {
|
|
473
|
+
apiError = parseJson<APIErrorResponse>(await response.text())
|
|
474
|
+
} catch {
|
|
475
|
+
// Response body not JSON, use HTTP status only
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// 404 - Message not found
|
|
479
|
+
if (response.status === HttpStatus.NOT_FOUND) {
|
|
480
|
+
throw new CCIPMessageIdNotFoundError(messageId, {
|
|
481
|
+
context: apiError
|
|
482
|
+
? {
|
|
483
|
+
apiErrorCode: apiError.error,
|
|
484
|
+
apiErrorMessage: apiError.message,
|
|
485
|
+
}
|
|
486
|
+
: undefined,
|
|
487
|
+
})
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// Generic HTTP error for other cases
|
|
491
|
+
throw new CCIPHttpError(response.status, response.statusText, {
|
|
492
|
+
context: apiError
|
|
493
|
+
? {
|
|
494
|
+
apiErrorCode: apiError.error,
|
|
495
|
+
apiErrorMessage: apiError.message,
|
|
496
|
+
}
|
|
497
|
+
: undefined,
|
|
498
|
+
})
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
const raw = JSON.parse(await response.text(), bigIntReviver) as RawExecutionInputsResult
|
|
502
|
+
this.logger.debug('getExecutionInput raw response:', raw)
|
|
503
|
+
|
|
504
|
+
const offRamp = raw.offramp
|
|
505
|
+
let lane: Lane
|
|
506
|
+
if ('encodedMessage' in raw) {
|
|
507
|
+
// CCIP 2.0 messages use MessageV1Codec, which is chain-independent serialization
|
|
508
|
+
const {
|
|
509
|
+
sourceChainSelector,
|
|
510
|
+
destChainSelector,
|
|
511
|
+
onRampAddress: onRamp,
|
|
512
|
+
} = decodeMessageV1(raw.encodedMessage)
|
|
513
|
+
return {
|
|
514
|
+
sourceChainSelector,
|
|
515
|
+
destChainSelector,
|
|
516
|
+
onRamp,
|
|
517
|
+
offRamp,
|
|
518
|
+
version: CCIPVersion.V2_0,
|
|
519
|
+
encodedMessage: raw.encodedMessage,
|
|
520
|
+
verifications: (raw.ccvData ?? []).map((ccvData, i) => ({
|
|
521
|
+
ccvData,
|
|
522
|
+
destAddress: raw.verifierAddresses[i]!,
|
|
523
|
+
})),
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
const messagesInBatch = raw.messageBatch.map(decodeMessage)
|
|
528
|
+
const message = messagesInBatch.find((message) => message.messageId === messageId)!
|
|
529
|
+
if ('onramp' in raw && raw.onramp && raw.version) {
|
|
530
|
+
lane = {
|
|
531
|
+
sourceChainSelector: raw.sourceChainSelector,
|
|
532
|
+
destChainSelector: raw.destChainSelector,
|
|
533
|
+
onRamp: raw.onramp,
|
|
534
|
+
version: raw.version as CCIPVersion,
|
|
535
|
+
}
|
|
536
|
+
} else {
|
|
537
|
+
;({ lane } = await this.getMessageById(messageId))
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
const proof = calculateManualExecProof(messagesInBatch, lane, messageId, raw.merkleRoot, this)
|
|
541
|
+
|
|
542
|
+
const rawMessage = raw.messageBatch.find((message) => message.messageId === messageId)!
|
|
543
|
+
const offchainTokenData: OffchainTokenData[] = rawMessage.tokenAmounts.map(() => undefined)
|
|
544
|
+
if (rawMessage.usdcData?.status === 'complete')
|
|
545
|
+
offchainTokenData[0] = {
|
|
546
|
+
_tag: 'usdc',
|
|
547
|
+
message: rawMessage.usdcData.message_bytes_hex!,
|
|
548
|
+
attestation: rawMessage.usdcData.attestation!,
|
|
549
|
+
}
|
|
550
|
+
else if (rawMessage.lbtcData?.status === 'NOTARIZATION_STATUS_SESSION_APPROVED')
|
|
551
|
+
offchainTokenData[0] = {
|
|
552
|
+
_tag: 'lbtc',
|
|
553
|
+
message_hash: rawMessage.lbtcData.message_hash!,
|
|
554
|
+
attestation: rawMessage.lbtcData.attestation!,
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
return {
|
|
558
|
+
offRamp,
|
|
559
|
+
...lane,
|
|
560
|
+
message,
|
|
561
|
+
offchainTokenData,
|
|
562
|
+
...proof,
|
|
563
|
+
} as ExecutionInput & Lane & { offRamp: string }
|
|
435
564
|
}
|
|
436
565
|
|
|
437
566
|
/**
|
|
@@ -483,7 +612,7 @@ export class CCIPAPIClient {
|
|
|
483
612
|
}
|
|
484
613
|
|
|
485
614
|
// Build log from API data
|
|
486
|
-
const log:
|
|
615
|
+
const log: ChainLog = {
|
|
487
616
|
transactionHash: sendTransactionHash,
|
|
488
617
|
address: raw.onramp,
|
|
489
618
|
data: { message: parseJson(text) },
|
|
@@ -493,11 +622,10 @@ export class CCIPAPIClient {
|
|
|
493
622
|
}
|
|
494
623
|
|
|
495
624
|
// Build tx from API data
|
|
496
|
-
const tx
|
|
625
|
+
const tx = {
|
|
497
626
|
hash: log.transactionHash,
|
|
498
627
|
timestamp: sendTimestamp_,
|
|
499
628
|
from: origin,
|
|
500
|
-
logs: [log],
|
|
501
629
|
blockNumber: Number(sendBlockNumber),
|
|
502
630
|
}
|
|
503
631
|
log.tx = tx
|
package/src/api/types.ts
CHANGED
|
@@ -182,3 +182,46 @@ export type APICCIPRequestMetadata = {
|
|
|
182
182
|
/** Destination network metadata. */
|
|
183
183
|
destNetworkInfo: NetworkInfo
|
|
184
184
|
}
|
|
185
|
+
|
|
186
|
+
// ============================================================================
|
|
187
|
+
// GET /v2/messages/${messageId}/execution-inputs search endpoint types
|
|
188
|
+
// ============================================================================
|
|
189
|
+
|
|
190
|
+
/** Raw API response from GET /v2/messages/:messageId/execution-inputs */
|
|
191
|
+
export type RawExecutionInputsResult = {
|
|
192
|
+
offramp: string
|
|
193
|
+
} & (
|
|
194
|
+
| {
|
|
195
|
+
onramp: string
|
|
196
|
+
sourceChainSelector: bigint
|
|
197
|
+
destChainSelector: bigint
|
|
198
|
+
version: string
|
|
199
|
+
}
|
|
200
|
+
| object
|
|
201
|
+
) &
|
|
202
|
+
(
|
|
203
|
+
| {
|
|
204
|
+
merkleRoot?: string
|
|
205
|
+
messageBatch: {
|
|
206
|
+
[key: string]: unknown
|
|
207
|
+
messageId: string
|
|
208
|
+
tokenAmounts: { token: string; amount: string }[]
|
|
209
|
+
usdcData?: {
|
|
210
|
+
status: 'pending_confirmations' | 'complete'
|
|
211
|
+
attestation?: string
|
|
212
|
+
message_bytes_hex?: string
|
|
213
|
+
}
|
|
214
|
+
lbtcData?: {
|
|
215
|
+
status: 'NOTARIZATION_STATUS_SESSION_APPROVED' | 'NOTARIZATION_STATUS_SESSION_PENDING'
|
|
216
|
+
attestation?: string
|
|
217
|
+
message_hash?: string
|
|
218
|
+
}
|
|
219
|
+
}[]
|
|
220
|
+
}
|
|
221
|
+
| {
|
|
222
|
+
encodedMessage: string
|
|
223
|
+
verificationComplete?: boolean
|
|
224
|
+
ccvData?: string[]
|
|
225
|
+
verifierAddresses: string[]
|
|
226
|
+
}
|
|
227
|
+
)
|
package/src/aptos/index.ts
CHANGED
|
@@ -56,14 +56,13 @@ import {
|
|
|
56
56
|
type CCIPExecution,
|
|
57
57
|
type CCIPMessage,
|
|
58
58
|
type CCIPRequest,
|
|
59
|
+
type ChainLog,
|
|
59
60
|
type ChainTransaction,
|
|
60
61
|
type CommitReport,
|
|
61
62
|
type ExecutionInput,
|
|
62
63
|
type ExecutionReceipt,
|
|
63
64
|
type Lane,
|
|
64
|
-
type Log_,
|
|
65
65
|
type NetworkInfo,
|
|
66
|
-
type OffchainTokenData,
|
|
67
66
|
type WithLogger,
|
|
68
67
|
ChainFamily,
|
|
69
68
|
} from '../types.ts'
|
|
@@ -236,7 +235,7 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
236
235
|
}
|
|
237
236
|
|
|
238
237
|
/** {@inheritDoc Chain.getLogs} */
|
|
239
|
-
async *getLogs(opts: LogFilter & { versionAsHash?: boolean }): AsyncIterableIterator<
|
|
238
|
+
async *getLogs(opts: LogFilter & { versionAsHash?: boolean }): AsyncIterableIterator<ChainLog> {
|
|
240
239
|
yield* streamAptosLogs(this, opts)
|
|
241
240
|
}
|
|
242
241
|
|
|
@@ -415,7 +414,7 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
415
414
|
* @returns Array of CommitReport or undefined if not valid.
|
|
416
415
|
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
417
416
|
*/
|
|
418
|
-
static decodeCommits({ data }: Pick<
|
|
417
|
+
static decodeCommits({ data }: Pick<ChainLog, 'data'>, lane?: Lane): CommitReport[] | undefined {
|
|
419
418
|
if (!data || typeof data != 'object') throw new CCIPAptosLogInvalidError(data)
|
|
420
419
|
const data_ = data as {
|
|
421
420
|
blessed_merkle_roots: unknown[] | undefined
|
|
@@ -449,7 +448,7 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
449
448
|
* @returns ExecutionReceipt or undefined if not valid.
|
|
450
449
|
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
451
450
|
*/
|
|
452
|
-
static decodeReceipt({ data }: Pick<
|
|
451
|
+
static decodeReceipt({ data }: Pick<ChainLog, 'data'>): ExecutionReceipt | undefined {
|
|
453
452
|
if (!data || typeof data != 'object') throw new CCIPAptosLogInvalidError(data)
|
|
454
453
|
const data_ = data as { message_id: string; state: number }
|
|
455
454
|
if (!data_.message_id || !data_.state) return
|
|
@@ -553,12 +552,6 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
553
552
|
return (await this.getMessagesInTx(await this.getTransaction(hash)))[0]!
|
|
554
553
|
}
|
|
555
554
|
|
|
556
|
-
/** {@inheritDoc Chain.getOffchainTokenData} */
|
|
557
|
-
getOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]> {
|
|
558
|
-
// default offchain token data
|
|
559
|
-
return Promise.resolve(request.message.tokenAmounts.map(() => undefined))
|
|
560
|
-
}
|
|
561
|
-
|
|
562
555
|
/**
|
|
563
556
|
* {@inheritDoc Chain.generateUnsignedExecute}
|
|
564
557
|
* @throws {@link CCIPAptosExtraArgsV2RequiredError} if message missing EVMExtraArgsV2 fields
|
package/src/aptos/logs.ts
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
CCIPLogsWatchRequiresStartError,
|
|
16
16
|
CCIPTopicsInvalidError,
|
|
17
17
|
} from '../errors/index.ts'
|
|
18
|
-
import type {
|
|
18
|
+
import type { ChainLog } from '../types.ts'
|
|
19
19
|
import { sleep } from '../utils.ts'
|
|
20
20
|
|
|
21
21
|
const DEFAULT_POLL_INTERVAL = 5e3
|
|
@@ -241,7 +241,7 @@ async function* fetchEventsBackward(
|
|
|
241
241
|
export async function* streamAptosLogs(
|
|
242
242
|
ctx: { provider: Aptos },
|
|
243
243
|
opts: LogFilter & { versionAsHash?: boolean },
|
|
244
|
-
): AsyncGenerator<
|
|
244
|
+
): AsyncGenerator<ChainLog> {
|
|
245
245
|
const limit = 100
|
|
246
246
|
if (!opts.address || !opts.address.includes('::')) throw new CCIPAptosAddressModuleRequiredError()
|
|
247
247
|
if (opts.topics?.length !== 1 || typeof opts.topics[0] !== 'string')
|