@chainlink/ccip-cli 0.0.0 → 0.90.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +238 -0
  3. package/dist/commands/index.d.ts +2 -0
  4. package/dist/commands/index.d.ts.map +1 -0
  5. package/dist/commands/index.js +2 -0
  6. package/dist/commands/index.js.map +1 -0
  7. package/dist/commands/manual-exec.d.ts +56 -0
  8. package/dist/commands/manual-exec.d.ts.map +1 -0
  9. package/dist/commands/manual-exec.js +405 -0
  10. package/dist/commands/manual-exec.js.map +1 -0
  11. package/dist/commands/parse.d.ts +9 -0
  12. package/dist/commands/parse.d.ts.map +1 -0
  13. package/dist/commands/parse.js +47 -0
  14. package/dist/commands/parse.js.map +1 -0
  15. package/dist/commands/send.d.ts +80 -0
  16. package/dist/commands/send.d.ts.map +1 -0
  17. package/dist/commands/send.js +258 -0
  18. package/dist/commands/send.js.map +1 -0
  19. package/dist/commands/show.d.ts +18 -0
  20. package/dist/commands/show.d.ts.map +1 -0
  21. package/dist/commands/show.js +112 -0
  22. package/dist/commands/show.js.map +1 -0
  23. package/dist/commands/supported-tokens.d.ts +37 -0
  24. package/dist/commands/supported-tokens.d.ts.map +1 -0
  25. package/dist/commands/supported-tokens.js +214 -0
  26. package/dist/commands/supported-tokens.js.map +1 -0
  27. package/dist/commands/types.d.ts +7 -0
  28. package/dist/commands/types.d.ts.map +1 -0
  29. package/dist/commands/types.js +6 -0
  30. package/dist/commands/types.js.map +1 -0
  31. package/dist/commands/utils.d.ts +40 -0
  32. package/dist/commands/utils.d.ts.map +1 -0
  33. package/dist/commands/utils.js +330 -0
  34. package/dist/commands/utils.js.map +1 -0
  35. package/dist/index.d.ts +34 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +63 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/providers/aptos.d.ts +15 -0
  40. package/dist/providers/aptos.d.ts.map +1 -0
  41. package/dist/providers/aptos.js +74 -0
  42. package/dist/providers/aptos.js.map +1 -0
  43. package/dist/providers/evm.d.ts +2 -0
  44. package/dist/providers/evm.d.ts.map +1 -0
  45. package/dist/providers/evm.js +42 -0
  46. package/dist/providers/evm.js.map +1 -0
  47. package/dist/providers/index.d.ts +13 -0
  48. package/dist/providers/index.d.ts.map +1 -0
  49. package/dist/providers/index.js +104 -0
  50. package/dist/providers/index.js.map +1 -0
  51. package/dist/providers/solana.d.ts +13 -0
  52. package/dist/providers/solana.d.ts.map +1 -0
  53. package/dist/providers/solana.js +79 -0
  54. package/dist/providers/solana.js.map +1 -0
  55. package/package.json +57 -8
  56. package/src/commands/index.ts +1 -0
  57. package/src/commands/manual-exec.ts +468 -0
  58. package/src/commands/parse.ts +52 -0
  59. package/src/commands/send.ts +316 -0
  60. package/src/commands/show.ts +151 -0
  61. package/src/commands/supported-tokens.ts +245 -0
  62. package/src/commands/types.ts +6 -0
  63. package/src/commands/utils.ts +404 -0
  64. package/src/index.ts +70 -0
  65. package/src/providers/aptos.ts +100 -0
  66. package/src/providers/evm.ts +48 -0
  67. package/src/providers/index.ts +141 -0
  68. package/src/providers/solana.ts +93 -0
  69. package/tsconfig.json +18 -0
@@ -0,0 +1,405 @@
1
+ import { ChainFamily, bigIntReplacer, calculateManualExecProof, discoverOffRamp, estimateExecGasForRequest, fetchAllMessagesInBatch, fetchCCIPRequestsInTx, } from '@chainlink/ccip-sdk';
2
+ import { Format } from "./types.js";
3
+ import { logParsedError, prettyCommit, prettyReceipt, prettyRequest, selectRequest, withDateTimestamp, } from "./utils.js";
4
+ import { fetchChainsFromRpcs } from "../providers/index.js";
5
+ // const MAX_QUEUE = 1000
6
+ // const MAX_EXECS_IN_BATCH = 1
7
+ // const MAX_PENDING_TXS = 25
8
+ export const command = 'manualExec <tx-hash>';
9
+ export const describe = 'Execute manually pending or failed messages';
10
+ export const builder = (yargs) => yargs
11
+ .positional('tx-hash', {
12
+ type: 'string',
13
+ demandOption: true,
14
+ describe: 'transaction hash of the request (source) message',
15
+ })
16
+ .options({
17
+ 'log-index': {
18
+ type: 'number',
19
+ describe: 'Log index of message to execute (if more than one in request tx)',
20
+ },
21
+ 'gas-limit': {
22
+ alias: ['L', 'compute-units'],
23
+ type: 'number',
24
+ describe: 'Override gas limit or compute units for receivers callback (0 keeps original)',
25
+ },
26
+ 'tokens-gas-limit': {
27
+ type: 'number',
28
+ describe: 'Override gas limit for tokens releaseOrMint calls (0 keeps original)',
29
+ },
30
+ 'estimate-gas-limit': {
31
+ type: 'number',
32
+ describe: 'Estimate gas limit for receivers callback; argument is a % margin to add to the estimate',
33
+ example: '10',
34
+ conflicts: 'gas-limit',
35
+ },
36
+ wallet: {
37
+ alias: 'w',
38
+ type: 'string',
39
+ describe: 'Wallet to send transactions with; pass `ledger[:index_or_derivation]` to use Ledger USB hardware wallet, or private key in `USER_KEY` environment variable',
40
+ },
41
+ 'force-buffer': {
42
+ type: 'boolean',
43
+ describe: 'Forces the usage of buffering for Solana execution.',
44
+ },
45
+ 'force-lookup-table': {
46
+ type: 'boolean',
47
+ describe: 'Forces the creation & usage of an ad-hoc lookup table for Solana execution.',
48
+ },
49
+ 'clear-leftover-accounts': {
50
+ type: 'boolean',
51
+ describe: 'Clears buffers (if a previous attempt was aborted) or any ALT owned by this sender.',
52
+ },
53
+ 'sender-queue': {
54
+ type: 'boolean',
55
+ describe: 'Execute all messages in sender queue, starting with the provided tx',
56
+ default: false,
57
+ },
58
+ 'exec-failed': {
59
+ type: 'boolean',
60
+ describe: 'Whether to re-execute failed messages (instead of just non-executed) in sender queue',
61
+ implies: 'sender-queue',
62
+ },
63
+ });
64
+ export async function handler(argv) {
65
+ if (!argv.wallet)
66
+ argv.wallet = process.env['USER_KEY'] || process.env['OWNER_KEY'];
67
+ let destroy;
68
+ const destroy$ = new Promise((resolve) => {
69
+ destroy = resolve;
70
+ });
71
+ // argv.senderQueue
72
+ // ? manualExecSenderQueue(providers, argv.tx_hash, argv)
73
+ // : manualExec(argv, destroy$)
74
+ return manualExec(argv, destroy$)
75
+ .catch((err) => {
76
+ process.exitCode = 1;
77
+ if (!logParsedError(err))
78
+ console.error(err);
79
+ })
80
+ .finally(destroy);
81
+ }
82
+ async function manualExec(argv, destroy) {
83
+ // messageId not yet implemented for Solana
84
+ const [getChain, tx$] = fetchChainsFromRpcs(argv, argv.txHash, destroy);
85
+ const tx = await tx$;
86
+ const source = tx.chain;
87
+ const request = await selectRequest(await fetchCCIPRequestsInTx(tx), 'to know more', argv);
88
+ switch (argv.format) {
89
+ case Format.log: {
90
+ const logPrefix = 'log' in request ? `message ${request.log.index} = ` : 'message = ';
91
+ console.log(logPrefix, withDateTimestamp(request));
92
+ break;
93
+ }
94
+ case Format.pretty:
95
+ await prettyRequest(source, request);
96
+ break;
97
+ case Format.json:
98
+ console.info(JSON.stringify(request, bigIntReplacer, 2));
99
+ break;
100
+ }
101
+ const dest = await getChain(request.lane.destChainSelector);
102
+ const offRamp = await discoverOffRamp(source, dest, request.lane.onRamp);
103
+ const commitStore = await dest.getCommitStoreForOffRamp(offRamp);
104
+ const commit = await dest.fetchCommitReport(commitStore, request, argv);
105
+ switch (argv.format) {
106
+ case Format.log:
107
+ console.log('commit =', commit);
108
+ break;
109
+ case Format.pretty:
110
+ await prettyCommit(dest, commit, request);
111
+ break;
112
+ case Format.json:
113
+ console.info(JSON.stringify(commit, bigIntReplacer, 2));
114
+ break;
115
+ }
116
+ const messagesInBatch = await fetchAllMessagesInBatch(source, request, commit.report, argv);
117
+ const execReportProof = calculateManualExecProof(messagesInBatch, request.lane, request.message.header.messageId, commit.report.merkleRoot);
118
+ const offchainTokenData = await source.fetchOffchainTokenData(request);
119
+ const execReport = {
120
+ ...execReportProof,
121
+ message: request.message,
122
+ offchainTokenData: offchainTokenData,
123
+ };
124
+ if (argv.estimateGasLimit != null &&
125
+ 'gasLimit' in request.message &&
126
+ 'extraArgs' in request.message) {
127
+ if (dest.network.family !== ChainFamily.EVM)
128
+ throw new Error('Gas estimation is only supported for EVM networks for now');
129
+ let estimated = await estimateExecGasForRequest(source, dest, request);
130
+ console.info('Estimated gasLimit override:', estimated);
131
+ estimated += Math.ceil((estimated * argv.estimateGasLimit) / 100);
132
+ if (request.message.gasLimit >= estimated) {
133
+ console.warn('Estimated +', argv.estimateGasLimit, '% margin =', estimated, '< original gasLimit =', request.message.gasLimit, '. Leaving unchanged.');
134
+ }
135
+ else {
136
+ argv.gasLimit = estimated;
137
+ }
138
+ }
139
+ const manualExecTx = await dest.executeReport(offRamp, execReport, argv);
140
+ console.log('🚀 manualExec tx =', manualExecTx.hash, 'to offRamp =', offRamp);
141
+ let found = false;
142
+ for (const log of manualExecTx.logs) {
143
+ const execReceipt = dest.constructor.decodeReceipt(log);
144
+ if (!execReceipt)
145
+ continue;
146
+ const timestamp = await dest.getBlockTimestamp(log.blockNumber);
147
+ const receipt = { receipt: execReceipt, log, timestamp };
148
+ switch (argv.format) {
149
+ case Format.log:
150
+ console.log('receipt =', withDateTimestamp(receipt));
151
+ break;
152
+ case Format.pretty:
153
+ if (!found)
154
+ console.info('Receipts (dest):');
155
+ prettyReceipt(receipt, request, receipt.log.tx?.from ??
156
+ (await dest.getTransaction(receipt.log.transactionHash).catch(() => null))?.from);
157
+ break;
158
+ case Format.json:
159
+ console.info(JSON.stringify(execReceipt, bigIntReplacer, 2));
160
+ break;
161
+ }
162
+ found = true;
163
+ }
164
+ if (!found)
165
+ throw new Error(`Could not find receipt in tx logs`);
166
+ }
167
+ /*
168
+ export async function manualExecSenderQueue(
169
+ providers: Providers,
170
+ txHash: string,
171
+ argv: {
172
+ gasLimit?: number
173
+ tokensGasLimit?: number
174
+ logIndex?: number
175
+ execFailed?: boolean
176
+ format: Format
177
+ page: number
178
+ wallet?: string
179
+ },
180
+ ) {
181
+ const tx = await providers.getTxReceipt(txHash)
182
+ const source = tx.provider
183
+
184
+ let firstRequest
185
+ if (argv.logIndex != null) {
186
+ firstRequest = await fetchCCIPMessageInLog(tx, argv.logIndex)
187
+ } else {
188
+ firstRequest = await selectRequest(await fetchCCIPMessagesInTx(tx), 'to execute')
189
+ }
190
+ switch (argv.format) {
191
+ case Format.log:
192
+ console.log(`message ${firstRequest.log.index} =`, withDateTimestamp(firstRequest))
193
+ break
194
+ case Format.pretty:
195
+ await prettyRequest(source, firstRequest)
196
+ break
197
+ case Format.json:
198
+ console.info(JSON.stringify(firstRequest, bigIntReplacer, 2))
199
+ break
200
+ }
201
+
202
+ const dest = await providers.forChainId(chainIdFromSelector(firstRequest.lane.destChainSelector))
203
+
204
+ const requests: Omit<CCIPRequest, 'timestamp' | 'tx'>[] = []
205
+ for await (const request of fetchRequestsForSender(source, firstRequest)) {
206
+ requests.push(request)
207
+ if (requests.length >= MAX_QUEUE) break
208
+ }
209
+ console.info('Found', requests.length, `requests for "${firstRequest.message.sender}"`)
210
+ if (!requests.length) return
211
+
212
+ let startBlock = await getSomeBlockNumberBefore(dest, firstRequest.timestamp)
213
+ const wallet = (await getWallet(argv)).connect(dest)
214
+ const offRampContract = await discoverOffRamp(wallet, firstRequest.lane, {
215
+ fromBlock: startBlock,
216
+ page: argv.page,
217
+ })
218
+ const senderNonce = await offRampContract.getSenderNonce(firstRequest.message.sender)
219
+ const origRequestsCnt = requests.length,
220
+ last = requests[requests.length - 1]
221
+ while (requests.length && requests[0].message.header.sequenceNumber <= senderNonce) {
222
+ requests.shift()
223
+ }
224
+ console.info(
225
+ 'Found',
226
+ requests.length,
227
+ `requests for "${firstRequest.message.sender}", removed `,
228
+ origRequestsCnt - requests.length,
229
+ 'already executed before senderNonce =',
230
+ senderNonce,
231
+ '. Last source txHash =',
232
+ last.log.transactionHash,
233
+ )
234
+ if (!requests.length) return
235
+ let nonce = await wallet.getNonce()
236
+
237
+ let lastBatch:
238
+ | readonly [CCIPCommit, Omit<CCIPRequest<CCIPVersion>, 'tx' | 'timestamp'>[]]
239
+ | undefined
240
+ const txsPending = []
241
+ for (let i = 0; i < requests.length; ) {
242
+ let commit, batch
243
+ if (!lastBatch || requests[i].message.header.sequenceNumber > lastBatch[0].report.maxSeqNr) {
244
+ commit = await fetchCommitReport(dest, requests[i], {
245
+ startBlock,
246
+ page: argv.page,
247
+ })
248
+ startBlock = commit.log.blockNumber + 1
249
+
250
+ batch = await fetchAllMessagesInBatch(
251
+ source,
252
+ requests[i].lane.destChainSelector,
253
+ requests[i].log,
254
+ commit.report,
255
+ { page: argv.page },
256
+ )
257
+ lastBatch = [commit, batch]
258
+ } else {
259
+ ;[commit, batch] = lastBatch
260
+ }
261
+
262
+ const msgIdsToExec = [] as string[]
263
+ while (
264
+ i < requests.length &&
265
+ requests[i].message.header.sequenceNumber <= commit.report.maxSeqNr &&
266
+ msgIdsToExec.length < MAX_EXECS_IN_BATCH
267
+ ) {
268
+ msgIdsToExec.push(requests[i++].message.header.messageId)
269
+ }
270
+
271
+ const manualExecReport = calculateManualExecProof(
272
+ batch.map(({ message }) => message),
273
+ firstRequest.lane,
274
+ msgIdsToExec,
275
+ commit.report.merkleRoot,
276
+ )
277
+ const requestsToExec = manualExecReport.messages.map(
278
+ ({ header }) =>
279
+ requests.find(({ message }) => message.header.messageId === header.messageId)!,
280
+ )
281
+ const offchainTokenData = await Promise.all(
282
+ requestsToExec.map(async (request) => {
283
+ const tx = await lazyCached(`tx ${request.log.transactionHash}`, () =>
284
+ source.getTransactionReceipt(request.log.transactionHash).then((res) => {
285
+ if (!res) throw new Error(`Tx not found: ${request.log.transactionHash}`)
286
+ return res
287
+ }),
288
+ )
289
+ return fetchOffchainTokenData({ ...request, tx })
290
+ }),
291
+ )
292
+ const execReport = { ...manualExecReport, offchainTokenData }
293
+ const getGasLimitOverride = (message: { gasLimit: bigint } | { extraArgs: string }): bigint => {
294
+ if (argv.gasLimit != null) {
295
+ const argvGasLimit = BigInt(argv.gasLimit)
296
+ let msgGasLimit
297
+ if ('gasLimit' in message) {
298
+ msgGasLimit = message.gasLimit
299
+ } else {
300
+ const parsedArgs = parseExtraArgs(message.extraArgs, source.network.family)
301
+ if (!parsedArgs || !('gasLimit' in parsedArgs) || !parsedArgs.gasLimit) {
302
+ throw new Error(`Missing gasLimit argument`)
303
+ }
304
+ msgGasLimit = BigInt(parsedArgs.gasLimit)
305
+ }
306
+ if (argvGasLimit > msgGasLimit) {
307
+ return argvGasLimit
308
+ }
309
+ }
310
+ return 0n
311
+ }
312
+
313
+ let manualExecTx
314
+ if (firstRequest.lane.version === CCIPVersion.V1_2) {
315
+ const gasOverrides = manualExecReport.messages.map((message) =>
316
+ getGasLimitOverride(message as CCIPMessage<typeof CCIPVersion.V1_2>),
317
+ )
318
+ manualExecTx = await (
319
+ offRampContract as CCIPContract<typeof CCIPContractType.OffRamp, typeof CCIPVersion.V1_2>
320
+ ).manuallyExecute(
321
+ execReport as {
322
+ offchainTokenData: string[][]
323
+ messages: CCIPMessage<typeof CCIPVersion.V1_2>[]
324
+ proofs: string[]
325
+ proofFlagBits: bigint
326
+ },
327
+ gasOverrides,
328
+ { nonce: nonce++, gasLimit: argv.gasLimit ? argv.gasLimit : undefined },
329
+ )
330
+ } else if (firstRequest.lane.version === CCIPVersion.V1_5) {
331
+ const gasOverrides = manualExecReport.messages.map((message) => ({
332
+ receiverExecutionGasLimit: getGasLimitOverride(
333
+ message as CCIPMessage<typeof CCIPVersion.V1_5>,
334
+ ),
335
+ tokenGasOverrides: message.tokenAmounts.map(() => BigInt(argv.tokensGasLimit ?? 0)),
336
+ }))
337
+ manualExecTx = await (
338
+ offRampContract as CCIPContract<typeof CCIPContractType.OffRamp, typeof CCIPVersion.V1_5>
339
+ ).manuallyExecute(
340
+ execReport as {
341
+ offchainTokenData: string[][]
342
+ messages: CCIPMessage<typeof CCIPVersion.V1_5>[]
343
+ proofs: string[]
344
+ proofFlagBits: bigint
345
+ },
346
+ gasOverrides,
347
+ { nonce: nonce++, gasLimit: argv.gasLimit ? argv.gasLimit : undefined },
348
+ )
349
+ } else {
350
+ const gasOverrides = manualExecReport.messages.map((message) => ({
351
+ receiverExecutionGasLimit: getGasLimitOverride(
352
+ message as CCIPMessage<typeof CCIPVersion.V1_6>,
353
+ ),
354
+ tokenGasOverrides: message.tokenAmounts.map(() => BigInt(argv.tokensGasLimit ?? 0)),
355
+ }))
356
+ manualExecTx = await (
357
+ offRampContract as CCIPContract<typeof CCIPContractType.OffRamp, typeof CCIPVersion.V1_6>
358
+ ).manuallyExecute(
359
+ [
360
+ {
361
+ sourceChainSelector: firstRequest.lane.sourceChainSelector,
362
+ messages: execReport.messages as (CCIPMessage<typeof CCIPVersion.V1_6> & {
363
+ gasLimit: bigint
364
+ })[],
365
+ proofs: execReport.proofs,
366
+ proofFlagBits: execReport.proofFlagBits,
367
+ offchainTokenData: execReport.offchainTokenData,
368
+ },
369
+ ],
370
+ [gasOverrides],
371
+ { nonce: nonce++, gasLimit: argv.gasLimit ? argv.gasLimit : undefined },
372
+ )
373
+ }
374
+
375
+ const toExec = requests[i - 1] // log only request data for last msg in msgIdsToExec
376
+ console.log(
377
+ `🚀 [${i}/${requests.length}, ${batch.length} batch, ${msgIdsToExec.length} to exec]`,
378
+ 'source tx =',
379
+ toExec.log.transactionHash,
380
+ 'msgId =',
381
+ toExec.message.header.messageId,
382
+ 'nonce =',
383
+ toExec.message.header.nonce,
384
+ 'manualExec tx =',
385
+ manualExecTx.hash,
386
+ 'to =',
387
+ manualExecTx.to,
388
+ 'gasLimit =',
389
+ manualExecTx.gasLimit,
390
+ )
391
+ txsPending.push(manualExecTx)
392
+ if (txsPending.length >= MAX_PENDING_TXS) {
393
+ console.debug(
394
+ 'awaiting',
395
+ txsPending.length,
396
+ 'txs:',
397
+ txsPending.map((tx) => tx.hash),
398
+ )
399
+ await txsPending[txsPending.length - 1].wait()
400
+ txsPending.length = 0
401
+ }
402
+ }
403
+ }
404
+ */
405
+ //# sourceMappingURL=manual-exec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manual-exec.js","sourceRoot":"","sources":["../../src/commands/manual-exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,WA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CAAC,CAAA;gBAC5C,aAAa,CACX,OAAO,EACP,OAAO,EACP,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI;oBAClB,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CACnF,CAAA;gBACD,MAAK;YACP,KAAK,MAAM,CAAC,IAAI;gBACd,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,CAAA;gBAC5D,MAAK;QACT,CAAC;QACD,KAAK,GAAG,IAAI,CAAA;IACd,CAAC;IACD,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;AAClE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6OE"}
@@ -0,0 +1,9 @@
1
+ import type { Argv } from 'yargs';
2
+ import type { GlobalOpts } from '../index.ts';
3
+ export declare const command: string[];
4
+ export declare const describe = "Try to parse and print errors, revert reasons or function call or event data";
5
+ export declare const builder: (yargs: Argv) => Argv<{
6
+ data: string;
7
+ }>;
8
+ export declare function handler(argv: Awaited<ReturnType<typeof builder>['argv']> & GlobalOpts): void;
9
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/commands/parse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAI7C,eAAO,MAAM,OAAO,UAA4D,CAAA;AAChF,eAAO,MAAM,QAAQ,iFAC2D,CAAA;AAEhF,eAAO,MAAM,OAAO,GAAI,OAAO,IAAI;;EAK/B,CAAA;AAEJ,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,QAOrF"}
@@ -0,0 +1,47 @@
1
+ import { bigIntReplacer, supportedChains } from '@chainlink/ccip-sdk';
2
+ import { Format } from "./types.js";
3
+ import { prettyTable } from "./utils.js";
4
+ export const command = ['parse <data>', 'parseBytes <data>', 'parseData <data>'];
5
+ export const describe = 'Try to parse and print errors, revert reasons or function call or event data';
6
+ export const builder = (yargs) => yargs.positional('data', {
7
+ type: 'string',
8
+ demandOption: true,
9
+ describe: 'router contract address on source',
10
+ });
11
+ export function handler(argv) {
12
+ try {
13
+ parseBytes(argv);
14
+ }
15
+ catch (err) {
16
+ process.exitCode = 1;
17
+ console.error(err);
18
+ }
19
+ }
20
+ function parseBytes(argv) {
21
+ let parsed;
22
+ for (const chain of Object.values(supportedChains)) {
23
+ try {
24
+ parsed = chain.parse?.(argv.data);
25
+ if (parsed)
26
+ break;
27
+ }
28
+ catch (_) {
29
+ // pass
30
+ }
31
+ }
32
+ if (!parsed)
33
+ throw new Error('Unknown data');
34
+ switch (argv.format) {
35
+ case Format.log: {
36
+ console.log(`parsed =`, parsed);
37
+ break;
38
+ }
39
+ case Format.pretty:
40
+ prettyTable(parsed);
41
+ break;
42
+ case Format.json:
43
+ console.info(JSON.stringify(parsed, bigIntReplacer, 2));
44
+ break;
45
+ }
46
+ }
47
+ //# sourceMappingURL=parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/commands/parse.ts"],"names":[],"mappings":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AAC,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;YAC/B,MAAK;QACP,CAAC;QACD,KAAK,MAAM,CAAC,MAAM;YAChB,WAAW,CAAC,MAAM,CAAC,CAAA;YACnB,MAAK;QACP,KAAK,MAAM,CAAC,IAAI;YACd,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,CAAA;YACvD,MAAK;IACT,CAAC;AACH,CAAC"}
@@ -0,0 +1,80 @@
1
+ import type { Argv } from 'yargs';
2
+ import type { GlobalOpts } from '../index.ts';
3
+ export declare const command = "send <source> <router> <dest>";
4
+ export declare const describe = "Send a CCIP message from router on source to dest";
5
+ export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{
6
+ source: string;
7
+ } & {
8
+ router: string;
9
+ } & {
10
+ dest: string;
11
+ }, "data" | "receiver" | "account" | "wallet" | "gas-limit" | "estimate-gas-limit" | "allow-out-of-order-exec" | "fee-token" | "transfer-tokens" | "token-receiver" | "only-get-fee" | "only-estimate" | "approve-max"> & import("yargs").InferredOptionTypes<{
12
+ receiver: {
13
+ alias: string;
14
+ type: "string";
15
+ describe: string;
16
+ };
17
+ data: {
18
+ alias: string;
19
+ type: "string";
20
+ describe: string;
21
+ example: string;
22
+ };
23
+ 'gas-limit': {
24
+ alias: string[];
25
+ type: "number";
26
+ describe: string;
27
+ default: number;
28
+ };
29
+ 'estimate-gas-limit': {
30
+ type: "number";
31
+ describe: string;
32
+ example: string;
33
+ conflicts: string;
34
+ };
35
+ 'allow-out-of-order-exec': {
36
+ alias: string;
37
+ type: "boolean";
38
+ describe: string;
39
+ };
40
+ 'fee-token': {
41
+ type: "string";
42
+ describe: string;
43
+ };
44
+ 'transfer-tokens': {
45
+ alias: string;
46
+ type: "array";
47
+ string: true;
48
+ describe: string;
49
+ example: string;
50
+ };
51
+ wallet: {
52
+ alias: string;
53
+ type: "string";
54
+ describe: string;
55
+ };
56
+ 'token-receiver': {
57
+ type: "string";
58
+ describe: string;
59
+ };
60
+ account: {
61
+ type: "array";
62
+ string: true;
63
+ describe: string;
64
+ example: string;
65
+ };
66
+ 'only-get-fee': {
67
+ type: "boolean";
68
+ describe: string;
69
+ };
70
+ 'only-estimate': {
71
+ type: "boolean";
72
+ describe: string;
73
+ };
74
+ 'approve-max': {
75
+ type: "boolean";
76
+ describe: string;
77
+ };
78
+ }>>;
79
+ export declare function handler(argv: Awaited<ReturnType<typeof builder>['argv']> & GlobalOpts): Promise<void>;
80
+ //# sourceMappingURL=send.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/commands/send.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAK7C,eAAO,MAAM,OAAO,kCAAkC,CAAA;AACtD,eAAO,MAAM,QAAQ,sDAAsD,CAAA;AAE3E,eAAO,MAAM,OAAO,GAAI,OAAO,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkG9B,CAAA;AAEL,wBAAsB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,iBAW3F"}