@chainlink/ccip-cli 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.
- package/dist/commands/lane-latency.d.ts +26 -0
- package/dist/commands/lane-latency.d.ts.map +1 -0
- package/dist/commands/lane-latency.js +73 -0
- package/dist/commands/lane-latency.js.map +1 -0
- package/dist/commands/manual-exec.d.ts.map +1 -1
- package/dist/commands/manual-exec.js +20 -269
- package/dist/commands/manual-exec.js.map +1 -1
- package/dist/commands/send.d.ts +1 -1
- package/dist/commands/send.js +30 -42
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/show.d.ts.map +1 -1
- package/dist/commands/show.js +36 -16
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/utils.d.ts.map +1 -1
- package/dist/commands/utils.js +2 -1
- package/dist/commands/utils.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/providers/aptos.js +1 -1
- package/dist/providers/aptos.js.map +1 -1
- package/dist/providers/evm.js +1 -1
- package/dist/providers/evm.js.map +1 -1
- package/dist/providers/index.d.ts +4 -2
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +11 -8
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/ton.d.ts +8 -5
- package/dist/providers/ton.d.ts.map +1 -1
- package/dist/providers/ton.js +100 -26
- package/dist/providers/ton.js.map +1 -1
- package/package.json +20 -13
- package/src/commands/lane-latency.ts +93 -0
- package/src/commands/manual-exec.ts +18 -267
- package/src/commands/send.ts +34 -52
- package/src/commands/show.ts +40 -22
- package/src/commands/utils.ts +6 -4
- package/src/index.ts +8 -4
- package/src/providers/aptos.ts +1 -1
- package/src/providers/evm.ts +1 -1
- package/src/providers/index.ts +18 -14
- package/src/providers/ton.ts +109 -27
- package/tsconfig.json +3 -2
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Argv } from 'yargs';
|
|
2
|
+
import type { GlobalOpts } from '../index.ts';
|
|
3
|
+
import { type Ctx } from './types.ts';
|
|
4
|
+
export declare const command: string[];
|
|
5
|
+
export declare const describe = "Query real-time lane latency between source and destination chains";
|
|
6
|
+
export declare const aliases: string[];
|
|
7
|
+
/**
|
|
8
|
+
* Yargs builder for the lane-latency command.
|
|
9
|
+
* @param yargs - Yargs instance.
|
|
10
|
+
* @returns Configured yargs instance with command options.
|
|
11
|
+
*/
|
|
12
|
+
export declare const builder: (yargs: Argv) => Argv<{
|
|
13
|
+
source: string;
|
|
14
|
+
} & {
|
|
15
|
+
dest: string;
|
|
16
|
+
} & {
|
|
17
|
+
"api-url": string | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Handler for the lane-latency command.
|
|
21
|
+
* @param argv - Command line arguments.
|
|
22
|
+
*/
|
|
23
|
+
export declare function handler(argv: Awaited<ReturnType<typeof builder>['argv']> & GlobalOpts): Promise<void>;
|
|
24
|
+
/** Exported for testing */
|
|
25
|
+
export declare function getLaneLatencyCmd(ctx: Ctx, argv: Parameters<typeof handler>[0]): Promise<void>;
|
|
26
|
+
//# sourceMappingURL=lane-latency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lane-latency.d.ts","sourceRoot":"","sources":["../../src/commands/lane-latency.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,KAAK,GAAG,EAAU,MAAM,YAAY,CAAA;AAG7C,eAAO,MAAM,OAAO,UAAkE,CAAA;AACtF,eAAO,MAAM,QAAQ,uEAAuE,CAAA;AAC5F,eAAO,MAAM,OAAO,UAAc,CAAA;AAElC;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,IAAI;;;;;;EAe7B,CAAA;AAEN;;;GAGG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,iBAQ3F;AAED,2BAA2B;AAC3B,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,iBAuCpF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { CCIPAPIClient, CCIPApiClientNotAvailableError, bigIntReplacer, networkInfo, } from '@chainlink/ccip-sdk';
|
|
2
|
+
import { Format } from "./types.js";
|
|
3
|
+
import { formatDuration, getCtx, logParsedError, prettyTable } from "./utils.js";
|
|
4
|
+
export const command = ['laneLatency <source> <dest>', 'lane-latency <source> <dest>'];
|
|
5
|
+
export const describe = 'Query real-time lane latency between source and destination chains';
|
|
6
|
+
export const aliases = ['latency'];
|
|
7
|
+
/**
|
|
8
|
+
* Yargs builder for the lane-latency command.
|
|
9
|
+
* @param yargs - Yargs instance.
|
|
10
|
+
* @returns Configured yargs instance with command options.
|
|
11
|
+
*/
|
|
12
|
+
export const builder = (yargs) => yargs
|
|
13
|
+
.positional('source', {
|
|
14
|
+
type: 'string',
|
|
15
|
+
demandOption: true,
|
|
16
|
+
describe: 'Source network (chainId, selector, or name). Example: ethereum-mainnet',
|
|
17
|
+
})
|
|
18
|
+
.positional('dest', {
|
|
19
|
+
type: 'string',
|
|
20
|
+
demandOption: true,
|
|
21
|
+
describe: 'Destination network (chainId, selector, or name). Example: arbitrum-mainnet',
|
|
22
|
+
})
|
|
23
|
+
.option('api-url', {
|
|
24
|
+
type: 'string',
|
|
25
|
+
describe: 'Custom CCIP API URL (defaults to api.ccip.chain.link)',
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Handler for the lane-latency command.
|
|
29
|
+
* @param argv - Command line arguments.
|
|
30
|
+
*/
|
|
31
|
+
export async function handler(argv) {
|
|
32
|
+
const [ctx, destroy] = getCtx(argv);
|
|
33
|
+
return getLaneLatencyCmd(ctx, argv)
|
|
34
|
+
.catch((err) => {
|
|
35
|
+
process.exitCode = 1;
|
|
36
|
+
if (!logParsedError.call(ctx, err))
|
|
37
|
+
ctx.logger.error(err);
|
|
38
|
+
})
|
|
39
|
+
.finally(destroy);
|
|
40
|
+
}
|
|
41
|
+
/** Exported for testing */
|
|
42
|
+
export async function getLaneLatencyCmd(ctx, argv) {
|
|
43
|
+
const { logger } = ctx;
|
|
44
|
+
// Respect --no-api flag - this command requires API access
|
|
45
|
+
if (argv.noApi) {
|
|
46
|
+
throw new CCIPApiClientNotAvailableError({
|
|
47
|
+
context: {
|
|
48
|
+
reason: 'The lane-latency command requires API access. Remove --no-api flag to use this command.',
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const sourceNetwork = networkInfo(argv.source);
|
|
53
|
+
const destNetwork = networkInfo(argv.dest);
|
|
54
|
+
const apiClient = new CCIPAPIClient(argv.apiUrl, { logger });
|
|
55
|
+
const result = await apiClient.getLaneLatency(sourceNetwork.chainSelector, destNetwork.chainSelector);
|
|
56
|
+
switch (argv.format) {
|
|
57
|
+
case Format.json:
|
|
58
|
+
logger.log(JSON.stringify(result, bigIntReplacer, 2));
|
|
59
|
+
break;
|
|
60
|
+
case Format.log:
|
|
61
|
+
logger.log('Lane Latency:', result);
|
|
62
|
+
break;
|
|
63
|
+
default: {
|
|
64
|
+
prettyTable.call(ctx, {
|
|
65
|
+
Source: `${sourceNetwork.name} [${sourceNetwork.chainSelector}]`,
|
|
66
|
+
Destination: `${destNetwork.name} [${destNetwork.chainSelector}]`,
|
|
67
|
+
'Estimated Delivery': `~${formatDuration(result.totalMs / 1000)}`,
|
|
68
|
+
'Latency (ms)': result.totalMs.toLocaleString(),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=lane-latency.js.map
|
|
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Aa,GAAG;gBAChE,WAAW,EAAE,GAAG,WAAW,CAAC,IAAI,KAAK,WAAW,CAAC,aAAa,GAAG;gBACjE,oBAAoB,EAAE,IAAI,cAAc,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE;gBACjE,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE;aAChD,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manual-exec.d.ts","sourceRoot":"","sources":["../../src/commands/manual-exec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manual-exec.d.ts","sourceRoot":"","sources":["../../src/commands/manual-exec.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAiB7C,eAAO,MAAM,OAAO,yBAAyB,CAAA;AAC7C,eAAO,MAAM,QAAQ,gDAAgD,CAAA;AAErE;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiE7B,CAAA;AAEN;;;GAGG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,iBAW3F"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CCIPChainFamilyUnsupportedError,
|
|
1
|
+
import { CCIPChainFamilyUnsupportedError, ChainFamily, bigIntReplacer, calculateManualExecProof, discoverOffRamp, estimateExecGasForRequest, isSupportedTxHash, } from '@chainlink/ccip-sdk';
|
|
2
2
|
import { Format } from "./types.js";
|
|
3
3
|
import { getCtx, logParsedError, prettyCommit, prettyReceipt, prettyRequest, selectRequest, withDateTimestamp, } from "./utils.js";
|
|
4
4
|
import { fetchChainsFromRpcs, loadChainWallet } from "../providers/index.js";
|
|
@@ -95,7 +95,7 @@ async function manualExec(ctx, argv) {
|
|
|
95
95
|
// messageId not yet implemented for Solana
|
|
96
96
|
const [getChain, tx$] = fetchChainsFromRpcs(ctx, argv, argv.txHash);
|
|
97
97
|
const [source, tx] = await tx$;
|
|
98
|
-
const request = await selectRequest(await source.
|
|
98
|
+
const request = await selectRequest(await source.getMessagesInTx(tx), 'to know more', argv);
|
|
99
99
|
switch (argv.format) {
|
|
100
100
|
case Format.log: {
|
|
101
101
|
const logPrefix = 'log' in request ? `message ${request.log.index} = ` : 'message = ';
|
|
@@ -112,21 +112,22 @@ async function manualExec(ctx, argv) {
|
|
|
112
112
|
const dest = await getChain(request.lane.destChainSelector);
|
|
113
113
|
const offRamp = await discoverOffRamp(source, dest, request.lane.onRamp, source);
|
|
114
114
|
const commitStore = await dest.getCommitStoreForOffRamp(offRamp);
|
|
115
|
-
const commit = await dest.
|
|
115
|
+
const commit = await dest.getCommitReport({ ...argv, commitStore, request });
|
|
116
116
|
switch (argv.format) {
|
|
117
117
|
case Format.log:
|
|
118
118
|
logger.log('commit =', commit);
|
|
119
119
|
break;
|
|
120
120
|
case Format.pretty:
|
|
121
|
+
logger.info('Commit (dest):');
|
|
121
122
|
await prettyCommit.call(ctx, dest, commit, request);
|
|
122
123
|
break;
|
|
123
124
|
case Format.json:
|
|
124
125
|
logger.info(JSON.stringify(commit, bigIntReplacer, 2));
|
|
125
126
|
break;
|
|
126
127
|
}
|
|
127
|
-
const messagesInBatch = await source.
|
|
128
|
+
const messagesInBatch = await source.getMessagesInBatch(request, commit.report, argv);
|
|
128
129
|
const execReportProof = calculateManualExecProof(messagesInBatch, request.lane, request.message.messageId, commit.report.merkleRoot, dest);
|
|
129
|
-
const offchainTokenData = await source.
|
|
130
|
+
const offchainTokenData = await source.getOffchainTokenData(request);
|
|
130
131
|
const execReport = {
|
|
131
132
|
...execReportProof,
|
|
132
133
|
message: request.message,
|
|
@@ -150,270 +151,20 @@ async function manualExec(ctx, argv) {
|
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
const [, wallet] = await loadChainWallet(dest, argv);
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
case Format.pretty:
|
|
167
|
-
if (!found)
|
|
168
|
-
logger.info('Receipts (dest):');
|
|
169
|
-
prettyReceipt.call(ctx, receipt, request, receipt.log.tx?.from ??
|
|
170
|
-
(await dest.getTransaction(receipt.log.transactionHash).catch(() => null))?.from);
|
|
171
|
-
break;
|
|
172
|
-
case Format.json:
|
|
173
|
-
logger.info(JSON.stringify(execReceipt, bigIntReplacer, 2));
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
found = true;
|
|
177
|
-
}
|
|
178
|
-
if (!found)
|
|
179
|
-
throw new CCIPReceiptNotFoundError(manualExecTx.hash);
|
|
180
|
-
}
|
|
181
|
-
/*
|
|
182
|
-
export async function manualExecSenderQueue(
|
|
183
|
-
providers: Providers,
|
|
184
|
-
txHash: string,
|
|
185
|
-
argv: {
|
|
186
|
-
gasLimit?: number
|
|
187
|
-
tokensGasLimit?: number
|
|
188
|
-
logIndex?: number
|
|
189
|
-
execFailed?: boolean
|
|
190
|
-
format: Format
|
|
191
|
-
page: number
|
|
192
|
-
wallet?: string
|
|
193
|
-
},
|
|
194
|
-
) {
|
|
195
|
-
const tx = await providers.getTxReceipt(txHash)
|
|
196
|
-
const source = tx.provider
|
|
197
|
-
|
|
198
|
-
let firstRequest
|
|
199
|
-
if (argv.logIndex != null) {
|
|
200
|
-
firstRequest = await fetchCCIPMessageInLog(tx, argv.logIndex)
|
|
201
|
-
} else {
|
|
202
|
-
firstRequest = await selectRequest(await fetchCCIPMessagesInTx(tx), 'to execute')
|
|
203
|
-
}
|
|
204
|
-
switch (argv.format) {
|
|
205
|
-
case Format.log:
|
|
206
|
-
console.log(`message ${firstRequest.log.index} =`, withDateTimestamp(firstRequest))
|
|
207
|
-
break
|
|
208
|
-
case Format.pretty:
|
|
209
|
-
await prettyRequest(source, firstRequest)
|
|
210
|
-
break
|
|
211
|
-
case Format.json:
|
|
212
|
-
console.info(JSON.stringify(firstRequest, bigIntReplacer, 2))
|
|
213
|
-
break
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const dest = await providers.forChainId(chainIdFromSelector(firstRequest.lane.destChainSelector))
|
|
217
|
-
|
|
218
|
-
const requests: Omit<CCIPRequest, 'timestamp' | 'tx'>[] = []
|
|
219
|
-
for await (const request of fetchRequestsForSender(source, firstRequest)) {
|
|
220
|
-
requests.push(request)
|
|
221
|
-
if (requests.length >= MAX_QUEUE) break
|
|
222
|
-
}
|
|
223
|
-
console.info('Found', requests.length, `requests for "${firstRequest.message.sender}"`)
|
|
224
|
-
if (!requests.length) return
|
|
225
|
-
|
|
226
|
-
let startBlock = await getSomeBlockNumberBefore(dest, firstRequest.timestamp)
|
|
227
|
-
const wallet = (await getWallet(argv)).connect(dest)
|
|
228
|
-
const offRampContract = await discoverOffRamp(wallet, firstRequest.lane, {
|
|
229
|
-
fromBlock: startBlock,
|
|
230
|
-
page: argv.page,
|
|
231
|
-
})
|
|
232
|
-
const senderNonce = await offRampContract.getSenderNonce(firstRequest.message.sender)
|
|
233
|
-
const origRequestsCnt = requests.length,
|
|
234
|
-
last = requests[requests.length - 1]
|
|
235
|
-
while (requests.length && requests[0].message.header.sequenceNumber <= senderNonce) {
|
|
236
|
-
requests.shift()
|
|
237
|
-
}
|
|
238
|
-
console.info(
|
|
239
|
-
'Found',
|
|
240
|
-
requests.length,
|
|
241
|
-
`requests for "${firstRequest.message.sender}", removed `,
|
|
242
|
-
origRequestsCnt - requests.length,
|
|
243
|
-
'already executed before senderNonce =',
|
|
244
|
-
senderNonce,
|
|
245
|
-
'. Last source txHash =',
|
|
246
|
-
last.log.transactionHash,
|
|
247
|
-
)
|
|
248
|
-
if (!requests.length) return
|
|
249
|
-
let nonce = await wallet.getNonce()
|
|
250
|
-
|
|
251
|
-
let lastBatch:
|
|
252
|
-
| readonly [CCIPCommit, Omit<CCIPRequest<CCIPVersion>, 'tx' | 'timestamp'>[]]
|
|
253
|
-
| undefined
|
|
254
|
-
const txsPending = []
|
|
255
|
-
for (let i = 0; i < requests.length; ) {
|
|
256
|
-
let commit, batch
|
|
257
|
-
if (!lastBatch || requests[i].message.header.sequenceNumber > lastBatch[0].report.maxSeqNr) {
|
|
258
|
-
commit = await fetchCommitReport(dest, requests[i], {
|
|
259
|
-
startBlock,
|
|
260
|
-
page: argv.page,
|
|
261
|
-
})
|
|
262
|
-
startBlock = commit.log.blockNumber + 1
|
|
263
|
-
|
|
264
|
-
batch = await fetchAllMessagesInBatch(
|
|
265
|
-
source,
|
|
266
|
-
requests[i].lane.destChainSelector,
|
|
267
|
-
requests[i].log,
|
|
268
|
-
commit.report,
|
|
269
|
-
{ page: argv.page },
|
|
270
|
-
)
|
|
271
|
-
lastBatch = [commit, batch]
|
|
272
|
-
} else {
|
|
273
|
-
;[commit, batch] = lastBatch
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
const msgIdsToExec = [] as string[]
|
|
277
|
-
while (
|
|
278
|
-
i < requests.length &&
|
|
279
|
-
requests[i].message.header.sequenceNumber <= commit.report.maxSeqNr &&
|
|
280
|
-
msgIdsToExec.length < MAX_EXECS_IN_BATCH
|
|
281
|
-
) {
|
|
282
|
-
msgIdsToExec.push(requests[i++].message.header.messageId)
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
const manualExecReport = calculateManualExecProof(
|
|
286
|
-
batch.map(({ message }) => message),
|
|
287
|
-
firstRequest.lane,
|
|
288
|
-
msgIdsToExec,
|
|
289
|
-
commit.report.merkleRoot,
|
|
290
|
-
)
|
|
291
|
-
const requestsToExec = manualExecReport.messages.map(
|
|
292
|
-
({ header }) =>
|
|
293
|
-
requests.find(({ message }) => message.header.messageId === header.messageId)!,
|
|
294
|
-
)
|
|
295
|
-
const offchainTokenData = await Promise.all(
|
|
296
|
-
requestsToExec.map(async (request) => {
|
|
297
|
-
const tx = await lazyCached(`tx ${request.log.transactionHash}`, () =>
|
|
298
|
-
source.getTransactionReceipt(request.log.transactionHash).then((res) => {
|
|
299
|
-
if (!res) throw new Error(`Tx not found: ${request.log.transactionHash}`)
|
|
300
|
-
return res
|
|
301
|
-
}),
|
|
302
|
-
)
|
|
303
|
-
return fetchOffchainTokenData({ ...request, tx })
|
|
304
|
-
}),
|
|
305
|
-
)
|
|
306
|
-
const execReport = { ...manualExecReport, offchainTokenData }
|
|
307
|
-
const getGasLimitOverride = (message: { gasLimit: bigint } | { extraArgs: string }): bigint => {
|
|
308
|
-
if (argv.gasLimit != null) {
|
|
309
|
-
const argvGasLimit = BigInt(argv.gasLimit)
|
|
310
|
-
let msgGasLimit
|
|
311
|
-
if ('gasLimit' in message) {
|
|
312
|
-
msgGasLimit = message.gasLimit
|
|
313
|
-
} else {
|
|
314
|
-
const parsedArgs = parseExtraArgs(message.extraArgs, source.network.family)
|
|
315
|
-
if (!parsedArgs || !('gasLimit' in parsedArgs) || !parsedArgs.gasLimit) {
|
|
316
|
-
throw new Error(`Missing gasLimit argument`)
|
|
317
|
-
}
|
|
318
|
-
msgGasLimit = BigInt(parsedArgs.gasLimit)
|
|
319
|
-
}
|
|
320
|
-
if (argvGasLimit > msgGasLimit) {
|
|
321
|
-
return argvGasLimit
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
return 0n
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
let manualExecTx
|
|
328
|
-
if (firstRequest.lane.version === CCIPVersion.V1_2) {
|
|
329
|
-
const gasOverrides = manualExecReport.messages.map((message) =>
|
|
330
|
-
getGasLimitOverride(message as CCIPMessage<typeof CCIPVersion.V1_2>),
|
|
331
|
-
)
|
|
332
|
-
manualExecTx = await (
|
|
333
|
-
offRampContract as CCIPContract<typeof CCIPContractType.OffRamp, typeof CCIPVersion.V1_2>
|
|
334
|
-
).manuallyExecute(
|
|
335
|
-
execReport as {
|
|
336
|
-
offchainTokenData: string[][]
|
|
337
|
-
messages: CCIPMessage<typeof CCIPVersion.V1_2>[]
|
|
338
|
-
proofs: string[]
|
|
339
|
-
proofFlagBits: bigint
|
|
340
|
-
},
|
|
341
|
-
gasOverrides,
|
|
342
|
-
{ nonce: nonce++, gasLimit: argv.gasLimit ? argv.gasLimit : undefined },
|
|
343
|
-
)
|
|
344
|
-
} else if (firstRequest.lane.version === CCIPVersion.V1_5) {
|
|
345
|
-
const gasOverrides = manualExecReport.messages.map((message) => ({
|
|
346
|
-
receiverExecutionGasLimit: getGasLimitOverride(
|
|
347
|
-
message as CCIPMessage<typeof CCIPVersion.V1_5>,
|
|
348
|
-
),
|
|
349
|
-
tokenGasOverrides: message.tokenAmounts.map(() => BigInt(argv.tokensGasLimit ?? 0)),
|
|
350
|
-
}))
|
|
351
|
-
manualExecTx = await (
|
|
352
|
-
offRampContract as CCIPContract<typeof CCIPContractType.OffRamp, typeof CCIPVersion.V1_5>
|
|
353
|
-
).manuallyExecute(
|
|
354
|
-
execReport as {
|
|
355
|
-
offchainTokenData: string[][]
|
|
356
|
-
messages: CCIPMessage<typeof CCIPVersion.V1_5>[]
|
|
357
|
-
proofs: string[]
|
|
358
|
-
proofFlagBits: bigint
|
|
359
|
-
},
|
|
360
|
-
gasOverrides,
|
|
361
|
-
{ nonce: nonce++, gasLimit: argv.gasLimit ? argv.gasLimit : undefined },
|
|
362
|
-
)
|
|
363
|
-
} else {
|
|
364
|
-
const gasOverrides = manualExecReport.messages.map((message) => ({
|
|
365
|
-
receiverExecutionGasLimit: getGasLimitOverride(
|
|
366
|
-
message as CCIPMessage<typeof CCIPVersion.V1_6>,
|
|
367
|
-
),
|
|
368
|
-
tokenGasOverrides: message.tokenAmounts.map(() => BigInt(argv.tokensGasLimit ?? 0)),
|
|
369
|
-
}))
|
|
370
|
-
manualExecTx = await (
|
|
371
|
-
offRampContract as CCIPContract<typeof CCIPContractType.OffRamp, typeof CCIPVersion.V1_6>
|
|
372
|
-
).manuallyExecute(
|
|
373
|
-
[
|
|
374
|
-
{
|
|
375
|
-
sourceChainSelector: firstRequest.lane.sourceChainSelector,
|
|
376
|
-
messages: execReport.messages as (CCIPMessage<typeof CCIPVersion.V1_6> & {
|
|
377
|
-
gasLimit: bigint
|
|
378
|
-
})[],
|
|
379
|
-
proofs: execReport.proofs,
|
|
380
|
-
proofFlagBits: execReport.proofFlagBits,
|
|
381
|
-
offchainTokenData: execReport.offchainTokenData,
|
|
382
|
-
},
|
|
383
|
-
],
|
|
384
|
-
[gasOverrides],
|
|
385
|
-
{ nonce: nonce++, gasLimit: argv.gasLimit ? argv.gasLimit : undefined },
|
|
386
|
-
)
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
const toExec = requests[i - 1] // log only request data for last msg in msgIdsToExec
|
|
390
|
-
console.log(
|
|
391
|
-
`🚀 [${i}/${requests.length}, ${batch.length} batch, ${msgIdsToExec.length} to exec]`,
|
|
392
|
-
'source tx =',
|
|
393
|
-
toExec.log.transactionHash,
|
|
394
|
-
'msgId =',
|
|
395
|
-
toExec.message.header.messageId,
|
|
396
|
-
'nonce =',
|
|
397
|
-
toExec.message.header.nonce,
|
|
398
|
-
'manualExec tx =',
|
|
399
|
-
manualExecTx.hash,
|
|
400
|
-
'to =',
|
|
401
|
-
manualExecTx.to,
|
|
402
|
-
'gasLimit =',
|
|
403
|
-
manualExecTx.gasLimit,
|
|
404
|
-
)
|
|
405
|
-
txsPending.push(manualExecTx)
|
|
406
|
-
if (txsPending.length >= MAX_PENDING_TXS) {
|
|
407
|
-
console.debug(
|
|
408
|
-
'awaiting',
|
|
409
|
-
txsPending.length,
|
|
410
|
-
'txs:',
|
|
411
|
-
txsPending.map((tx) => tx.hash),
|
|
412
|
-
)
|
|
413
|
-
await txsPending[txsPending.length - 1].wait()
|
|
414
|
-
txsPending.length = 0
|
|
154
|
+
const receipt = await dest.executeReport({ ...argv, offRamp, execReport, wallet });
|
|
155
|
+
switch (argv.format) {
|
|
156
|
+
case Format.log:
|
|
157
|
+
logger.log('receipt =', withDateTimestamp(receipt));
|
|
158
|
+
break;
|
|
159
|
+
case Format.pretty:
|
|
160
|
+
logger.info('Receipt (dest):');
|
|
161
|
+
prettyReceipt.call(ctx, receipt, request, receipt.log.tx?.from ??
|
|
162
|
+
(await dest.getTransaction(receipt.log.transactionHash).catch(() => null))?.from);
|
|
163
|
+
break;
|
|
164
|
+
case Format.json:
|
|
165
|
+
logger.info(JSON.stringify(receipt, bigIntReplacer, 2));
|
|
166
|
+
break;
|
|
415
167
|
}
|
|
416
|
-
}
|
|
417
168
|
}
|
|
418
|
-
|
|
169
|
+
// TODO: re-implement executing `sender` queue
|
|
419
170
|
//# sourceMappingURL=manual-exec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manual-exec.js","sourceRoot":"","sources":["../../src/commands/manual-exec.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"manual-exec.js","sourceRoot":"","sources":["../../src/commands/manual-exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,+BAA+B,EAC/B,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,eAAe,EACf,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,kCAAkC,CAAA;AAIzC,OAAO,EAAY,MAAM,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EACL,MAAM,EACN,cAAc,EACd,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,iBAAiB,GAClB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5E,yBAAyB;AACzB,+BAA+B;AAC/B,6BAA6B;AAE7B,MAAM,CAAC,MAAM,OAAO,GAAG,sBAAs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29,7 +29,6 @@ export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{
|
|
|
29
29
|
alias: string[];
|
|
30
30
|
type: "number";
|
|
31
31
|
describe: string;
|
|
32
|
-
default: number;
|
|
33
32
|
};
|
|
34
33
|
'estimate-gas-limit': {
|
|
35
34
|
type: "number";
|
|
@@ -63,6 +62,7 @@ export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{
|
|
|
63
62
|
describe: string;
|
|
64
63
|
};
|
|
65
64
|
account: {
|
|
65
|
+
alias: string;
|
|
66
66
|
type: "array";
|
|
67
67
|
string: true;
|
|
68
68
|
describe: string;
|
package/dist/commands/send.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CCIPArgumentInvalidError, CCIPChainFamilyUnsupportedError, CCIPTokenNotFoundError, ChainFamily, estimateExecGasForRequest, getDataBytes, networkInfo, sourceToDestTokenAmounts, } from '@chainlink/ccip-sdk';
|
|
2
|
-
import {
|
|
2
|
+
import { formatUnits, toUtf8Bytes } from 'ethers';
|
|
3
3
|
import { showRequests } from "./show.js";
|
|
4
4
|
import { getCtx, logParsedError, parseTokenAmounts } from "./utils.js";
|
|
5
5
|
import { fetchChainsFromRpcs, loadChainWallet } from "../providers/index.js";
|
|
@@ -44,7 +44,6 @@ export const builder = (yargs) => yargs
|
|
|
44
44
|
alias: ['L', 'compute-units'],
|
|
45
45
|
type: 'number',
|
|
46
46
|
describe: 'Gas limit for receiver callback execution; defaults to default configured on ramps',
|
|
47
|
-
default: 0,
|
|
48
47
|
},
|
|
49
48
|
'estimate-gas-limit': {
|
|
50
49
|
type: 'number',
|
|
@@ -78,9 +77,10 @@ export const builder = (yargs) => yargs
|
|
|
78
77
|
describe: "Address of the Solana tokenReceiver (if different than program's receiver)",
|
|
79
78
|
},
|
|
80
79
|
account: {
|
|
80
|
+
alias: 'receiver-object-id',
|
|
81
81
|
type: 'array',
|
|
82
82
|
string: true,
|
|
83
|
-
describe: 'List of accounts needed by Solana receiver program; append `=rw` to specify account as writable; can be specified multiple times',
|
|
83
|
+
describe: 'List of accounts needed by Solana receiver program, or receiverObjectIds needed by Sui; On Solana, append `=rw` to specify account as writable; can be specified multiple times',
|
|
84
84
|
example: 'requiredPdaAddress=rw',
|
|
85
85
|
},
|
|
86
86
|
'only-get-fee': {
|
|
@@ -131,30 +131,14 @@ async function sendMessage(ctx, argv) {
|
|
|
131
131
|
data = toUtf8Bytes(argv.data);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
else {
|
|
135
|
-
data = '0x';
|
|
136
|
-
}
|
|
137
134
|
const tokenAmounts = argv.transferTokens?.length
|
|
138
135
|
? await parseTokenAmounts(source, argv.transferTokens)
|
|
139
136
|
: [];
|
|
140
137
|
let receiver = argv.receiver;
|
|
141
|
-
let tokenReceiver;
|
|
142
138
|
let accounts, accountIsWritableBitmap = 0n;
|
|
143
139
|
if (destNetwork.family === ChainFamily.Solana) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
else if (!tokenAmounts.length) {
|
|
147
|
-
tokenReceiver = '11111111111111111111111111111111';
|
|
148
|
-
}
|
|
149
|
-
else if (!dataLength(data)) {
|
|
150
|
-
// sending tokens without data, i.e. not for a receiver contract
|
|
151
|
-
tokenReceiver = receiver;
|
|
152
|
-
receiver = '11111111111111111111111111111111';
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
throw new CCIPArgumentInvalidError('token-receiver', 'required when sending tokens with data to Solana');
|
|
156
|
-
}
|
|
157
|
-
if (argv.account) {
|
|
140
|
+
// parse accounts with or without `=rw` suffix
|
|
141
|
+
if (argv.account?.length) {
|
|
158
142
|
accounts = argv.account.map((account, i) => {
|
|
159
143
|
if (account.endsWith('=rw')) {
|
|
160
144
|
accountIsWritableBitmap |= 1n << BigInt(i);
|
|
@@ -163,11 +147,6 @@ async function sendMessage(ctx, argv) {
|
|
|
163
147
|
return account;
|
|
164
148
|
});
|
|
165
149
|
}
|
|
166
|
-
else
|
|
167
|
-
accounts = [];
|
|
168
|
-
}
|
|
169
|
-
else if (argv.tokenReceiver || argv.account?.length) {
|
|
170
|
-
throw new CCIPArgumentInvalidError('token-receiver/account', 'only valid for Solana destination');
|
|
171
150
|
}
|
|
172
151
|
let walletAddress, wallet;
|
|
173
152
|
if (!receiver) {
|
|
@@ -198,7 +177,7 @@ async function sendMessage(ctx, argv) {
|
|
|
198
177
|
message: {
|
|
199
178
|
sender: walletAddress,
|
|
200
179
|
receiver,
|
|
201
|
-
data,
|
|
180
|
+
data: data || '0x',
|
|
202
181
|
tokenAmounts: destTokenAmounts,
|
|
203
182
|
},
|
|
204
183
|
});
|
|
@@ -207,17 +186,19 @@ async function sendMessage(ctx, argv) {
|
|
|
207
186
|
if (argv.onlyEstimate)
|
|
208
187
|
return;
|
|
209
188
|
}
|
|
210
|
-
//
|
|
211
|
-
//
|
|
189
|
+
// builds a catch-all extraArgs object, which can be massaged by
|
|
190
|
+
// [[Chain.buildMessageForDest]] to create suitable extraArgs with defaults if needed
|
|
212
191
|
const extraArgs = {
|
|
213
|
-
...(argv.allowOutOfOrderExec != null
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
...(
|
|
217
|
-
? {
|
|
218
|
-
:
|
|
219
|
-
|
|
220
|
-
|
|
192
|
+
...(argv.allowOutOfOrderExec != null && {
|
|
193
|
+
allowOutOfOrderExecution: !!argv.allowOutOfOrderExec,
|
|
194
|
+
}),
|
|
195
|
+
...(argv.gasLimit == null
|
|
196
|
+
? {}
|
|
197
|
+
: destNetwork.family === ChainFamily.Solana
|
|
198
|
+
? { computeUnits: BigInt(argv.gasLimit) }
|
|
199
|
+
: { gasLimit: BigInt(argv.gasLimit) }),
|
|
200
|
+
...(!!argv.tokenReceiver && { tokenReceiver: argv.tokenReceiver }),
|
|
201
|
+
...(!!accounts && { accounts, accountIsWritableBitmap }), // accounts also used as Sui receiverObjectIds
|
|
221
202
|
};
|
|
222
203
|
let feeToken, feeTokenInfo;
|
|
223
204
|
if (argv.feeToken) {
|
|
@@ -251,7 +232,11 @@ async function sendMessage(ctx, argv) {
|
|
|
251
232
|
tokenAmounts,
|
|
252
233
|
};
|
|
253
234
|
// calculate fee
|
|
254
|
-
const fee = await source.getFee(
|
|
235
|
+
const fee = await source.getFee({
|
|
236
|
+
...argv,
|
|
237
|
+
destChainSelector: destNetwork.chainSelector,
|
|
238
|
+
message,
|
|
239
|
+
});
|
|
255
240
|
logger.info('Fee:', fee, '=', formatUnits(fee, feeTokenInfo.decimals), !argv.feeToken && feeTokenInfo.symbol.startsWith('W')
|
|
256
241
|
? feeTokenInfo.symbol.substring(1)
|
|
257
242
|
: feeTokenInfo.symbol);
|
|
@@ -259,10 +244,13 @@ async function sendMessage(ctx, argv) {
|
|
|
259
244
|
return;
|
|
260
245
|
if (!walletAddress)
|
|
261
246
|
[walletAddress, wallet] = await loadChainWallet(source, argv);
|
|
262
|
-
const request = await source.sendMessage(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
:
|
|
247
|
+
const request = await source.sendMessage({
|
|
248
|
+
...argv,
|
|
249
|
+
destChainSelector: destNetwork.chainSelector,
|
|
250
|
+
message: { ...message, fee },
|
|
251
|
+
wallet,
|
|
252
|
+
});
|
|
253
|
+
logger.info('🚀 Sending message to', receiver, '@', destNetwork.name, ', tx =>', request.tx.hash, ', messageId =>', request.message.messageId);
|
|
266
254
|
await showRequests(ctx, {
|
|
267
255
|
...argv,
|
|
268
256
|
txHash: request.tx.hash,
|