@chainlink/ccip-cli 0.90.0 → 0.91.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 +40 -21
- package/dist/commands/index.d.ts +2 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/manual-exec.d.ts +9 -0
- package/dist/commands/manual-exec.d.ts.map +1 -1
- package/dist/commands/manual-exec.js +40 -35
- package/dist/commands/manual-exec.js.map +1 -1
- package/dist/commands/parse.d.ts +9 -0
- package/dist/commands/parse.d.ts.map +1 -1
- package/dist/commands/parse.js +18 -7
- package/dist/commands/parse.js.map +1 -1
- package/dist/commands/send.d.ts +9 -0
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +39 -26
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/show.d.ts +9 -0
- package/dist/commands/show.d.ts.map +1 -1
- package/dist/commands/show.js +46 -39
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/supported-tokens.d.ts +9 -2
- package/dist/commands/supported-tokens.d.ts.map +1 -1
- package/dist/commands/supported-tokens.js +35 -30
- package/dist/commands/supported-tokens.js.map +1 -1
- package/dist/commands/types.d.ts +13 -0
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/types.js +1 -0
- package/dist/commands/types.js.map +1 -1
- package/dist/commands/utils.d.ts +75 -10
- package/dist/commands/utils.d.ts.map +1 -1
- package/dist/commands/utils.js +95 -19
- package/dist/commands/utils.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/providers/aptos.d.ts +35 -0
- package/dist/providers/aptos.d.ts.map +1 -1
- package/dist/providers/aptos.js +34 -9
- package/dist/providers/aptos.js.map +1 -1
- package/dist/providers/evm.d.ts +10 -1
- package/dist/providers/evm.d.ts.map +1 -1
- package/dist/providers/evm.js +11 -5
- package/dist/providers/evm.js.map +1 -1
- package/dist/providers/index.d.ts +15 -8
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +47 -11
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/solana.d.ts +30 -0
- package/dist/providers/solana.d.ts.map +1 -1
- package/dist/providers/solana.js +30 -5
- package/dist/providers/solana.js.map +1 -1
- package/package.json +11 -8
- package/src/commands/index.ts +2 -1
- package/src/commands/manual-exec.ts +40 -33
- package/src/commands/parse.ts +19 -8
- package/src/commands/send.ts +47 -30
- package/src/commands/show.ts +47 -48
- package/src/commands/supported-tokens.ts +35 -30
- package/src/commands/types.ts +15 -0
- package/src/commands/utils.ts +112 -26
- package/src/index.ts +21 -7
- package/src/providers/aptos.ts +33 -8
- package/src/providers/evm.ts +22 -5
- package/src/providers/index.ts +67 -15
- package/src/providers/solana.ts +31 -6
- package/tsconfig.json +2 -1
package/README.md
CHANGED
|
@@ -14,10 +14,10 @@ compatible RPCs for each involved network.
|
|
|
14
14
|
To install it from latest NpmJS release, do:
|
|
15
15
|
|
|
16
16
|
```sh
|
|
17
|
-
npm install -g @
|
|
17
|
+
npm install -g @chainlink/ccip-cli
|
|
18
18
|
ccip-cli --help
|
|
19
19
|
# or
|
|
20
|
-
npx @
|
|
20
|
+
npx @chainlink/ccip-cli --help
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
Or run it directly from github or a local clone of the repo (useful for local development):
|
|
@@ -26,11 +26,8 @@ Or run it directly from github or a local clone of the repo (useful for local de
|
|
|
26
26
|
git clone https://github.com/smartcontractkit/ccip-tools-ts
|
|
27
27
|
cd ccip-tools-ts
|
|
28
28
|
npm install # install dependencies
|
|
29
|
-
./ccip-cli/ccip-cli --help # shell script to run
|
|
30
|
-
#
|
|
31
|
-
npx /path/to/repo/ccip-tools-ts/ccip-cli --help # run from local repo directly
|
|
32
|
-
# or
|
|
33
|
-
npx github:smartcontractkit/ccip-tools-ts/tree/main/ccip-cli --help # or with npx from github
|
|
29
|
+
./ccip-cli/ccip-cli --help # shell script to run `./ccip-cli/src/index.ts`
|
|
30
|
+
alias ccip-cli="$PWD/ccip-cli/ccip-cli" # optional, to run from local repo directly from anywhere
|
|
34
31
|
```
|
|
35
32
|
|
|
36
33
|
> [!NOTE]
|
|
@@ -47,14 +44,27 @@ npx github:smartcontractkit/ccip-tools-ts/tree/main/ccip-cli --help # or with n
|
|
|
47
44
|
All commands require a list of RPCs endpoints for the networks of interest (source and destination).
|
|
48
45
|
Both `http[s]` and `ws[s]` (websocket) URLs are supported.
|
|
49
46
|
|
|
50
|
-
This list can be passed in the command line, through the `-r/--rpcs` option
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
This list can be passed in the command line, through the `-r/--rpcs` option; it may be passed
|
|
48
|
+
multiple times, e.g. `-r <source_rpc> -r <dest_rpc>`, and are merged with those fetched from the
|
|
49
|
+
rpcs file (`--rpcs-file`, default=`./.env`), which may contain multiple endpoints, one per line,
|
|
50
|
+
with any prefix or suffix (only URLs are parsed).
|
|
51
|
+
|
|
53
52
|
The default filename is just for compatibility with previous tools, and isn't required to be an
|
|
54
53
|
actual env file. `.txt`, `.csv` or `.json` arrays should work out of the box.
|
|
55
|
-
`RPC_*` environment variables are also ingested.
|
|
56
54
|
|
|
57
|
-
|
|
55
|
+
Example `.env` file:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
https://eth-sepolia.g.alchemy.com/v2/demo
|
|
59
|
+
ARB_SEPOLIA_RPC: https://arbitrum-sepolia.drpc.org
|
|
60
|
+
RPC_AVALANCHE_TESTNET=https://avalanche-fuji-c-chain-rpc.publicnode.com
|
|
61
|
+
https://api.devnet.solana.com # solana devnet public rpc
|
|
62
|
+
https://api.testnet.aptoslabs.com/v1 // `testnet` only would also work
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Environment variables starting with `RPC_` are also ingested. Suffix is not relevant.
|
|
66
|
+
|
|
67
|
+
Once the list is gathered, CLI connects to all RPCs in parallel on startup and uses the fastest
|
|
58
68
|
to reply for each network.
|
|
59
69
|
|
|
60
70
|
## Wallet
|
|
@@ -75,6 +85,15 @@ a Ledger USB device. The derivation path defaults to Ledger Live derivations on
|
|
|
75
85
|
network, and passing an index selects an account of this derivation:
|
|
76
86
|
E.g. `--wallet ledger:1` uses derivation `m/44'/60'/1'/0/0` for EVM accounts
|
|
77
87
|
|
|
88
|
+
## Chain names and selectors
|
|
89
|
+
|
|
90
|
+
Where required, networks can be referred by name or selector from [chain-selectors](https://github.com/smartcontractkit/chain-selectors).
|
|
91
|
+
ChainIDs follow this pattern:
|
|
92
|
+
|
|
93
|
+
- `EVM`: numeric chain id; e.g. `1` for `ethereum-mainnet`.
|
|
94
|
+
- `Solana`: genesis hash; e.g. `5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d` for `solana-mainnet`
|
|
95
|
+
- `Aptos`, `Sui`: numeric chain id, prefixed with chain family and colon: e.g `aptos:1` for `aptos-mainnet`
|
|
96
|
+
|
|
78
97
|
## Quick command reference:
|
|
79
98
|
|
|
80
99
|
### Common options
|
|
@@ -89,7 +108,7 @@ don't support large ranges)
|
|
|
89
108
|
### `show` (default command)
|
|
90
109
|
|
|
91
110
|
```sh
|
|
92
|
-
|
|
111
|
+
ccip-cli [show] <request_transaction_hash> [--log-index num]
|
|
93
112
|
```
|
|
94
113
|
|
|
95
114
|
Receives a transaction containing a `CCIPSendRequested` (<=v1.5) or `CCIPMessageSent` (>=1.6) event.
|
|
@@ -105,7 +124,7 @@ Receipts until a `success` receipt or latest block is hit.
|
|
|
105
124
|
### `manualExec`
|
|
106
125
|
|
|
107
126
|
```sh
|
|
108
|
-
|
|
127
|
+
ccip-cli manualExec <request_transaction_hash> [--gas-limit num] [--tokens-gas-limit num]
|
|
109
128
|
```
|
|
110
129
|
|
|
111
130
|
Try to manually execute the message in source transaction. If more than one found, user is prompted
|
|
@@ -141,7 +160,7 @@ to be cleared.
|
|
|
141
160
|
|
|
142
161
|
#### Example
|
|
143
162
|
```sh
|
|
144
|
-
|
|
163
|
+
ccip-cli manualExec 0xafd36a0b99d5457e403c918194cb69cd070d991dcbadc99576acfce5020c0b6b \
|
|
145
164
|
--wallet ledger \
|
|
146
165
|
--compute-units 500000 \
|
|
147
166
|
--force-buffer \
|
|
@@ -151,7 +170,7 @@ to be cleared.
|
|
|
151
170
|
### `send`
|
|
152
171
|
|
|
153
172
|
```sh
|
|
154
|
-
|
|
173
|
+
ccip-cli send 11155111 0x0BF3dE8c5D3e8A2B34D2BEeB17ABfCeBaf363A59 ethereum-testnet-sepolia-arbitrum-1 \
|
|
155
174
|
--receiver 0xAB4f961939BFE6A93567cC57C59eEd7084CE2131 \
|
|
156
175
|
--data 'hello world' \
|
|
157
176
|
--gas-limit 300000 \
|
|
@@ -194,7 +213,7 @@ either transfer or fee tokens. Default behavior is to approve the strictly neede
|
|
|
194
213
|
### `parse`
|
|
195
214
|
|
|
196
215
|
```sh
|
|
197
|
-
|
|
216
|
+
ccip-cli parse 0xbf16aab6000000000000000000000000779877a7b0d9e8603169ddbd7836e478b4624789
|
|
198
217
|
|
|
199
218
|
Error: EVM2EVMOnRamp_1.2.0.UnsupportedToken(address)
|
|
200
219
|
Args: { token: '0x779877A7B0D9E8603169DdbD7836e478b4624789' }
|
|
@@ -207,9 +226,9 @@ It'll recursively try to decode `returnData` and `error` arguments.
|
|
|
207
226
|
### `getSupportedTokens`
|
|
208
227
|
|
|
209
228
|
```sh
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
229
|
+
ccip-cli getSupportedTokens <source> <router> # lists supported tokens
|
|
230
|
+
ccip-cli getSupportedTokens <source> <router> [token] # show token and pool details for this token
|
|
231
|
+
ccip-cli getSupportedTokens <source> <tokenPool> # same as above, for the pool directly
|
|
213
232
|
```
|
|
214
233
|
|
|
215
234
|
Source is the network to be queried, as chainID or name.
|
|
@@ -228,7 +247,7 @@ chains and its rate limits state.
|
|
|
228
247
|
|
|
229
248
|
```sh
|
|
230
249
|
# Check tokens supported for transfer from Ethereum to Polygon
|
|
231
|
-
|
|
250
|
+
ccip-cli getSupportedTokens ethereum-mainnet 0x80226fc0Ee2b096224EeAc085Bb9a8cba1146f7D
|
|
232
251
|
```
|
|
233
252
|
|
|
234
253
|
#### Output Format Options
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/commands/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -2,6 +2,11 @@ import type { Argv } from 'yargs';
|
|
|
2
2
|
import type { GlobalOpts } from '../index.ts';
|
|
3
3
|
export declare const command = "manualExec <tx-hash>";
|
|
4
4
|
export declare const describe = "Execute manually pending or failed messages";
|
|
5
|
+
/**
|
|
6
|
+
* Yargs builder for the manual-exec command.
|
|
7
|
+
* @param yargs - Yargs instance.
|
|
8
|
+
* @returns Configured yargs instance with command options.
|
|
9
|
+
*/
|
|
5
10
|
export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{
|
|
6
11
|
"tx-hash": string;
|
|
7
12
|
}, "wallet" | "log-index" | "gas-limit" | "tokens-gas-limit" | "estimate-gas-limit" | "force-buffer" | "force-lookup-table" | "clear-leftover-accounts" | "sender-queue" | "exec-failed"> & import("yargs").InferredOptionTypes<{
|
|
@@ -52,5 +57,9 @@ export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{
|
|
|
52
57
|
implies: string;
|
|
53
58
|
};
|
|
54
59
|
}>>;
|
|
60
|
+
/**
|
|
61
|
+
* Handler for the manual-exec command.
|
|
62
|
+
* @param argv - Command line arguments.
|
|
63
|
+
*/
|
|
55
64
|
export declare function handler(argv: Awaited<ReturnType<typeof builder>['argv']> & GlobalOpts): Promise<void>;
|
|
56
65
|
//# sourceMappingURL=manual-exec.d.ts.map
|
|
@@ -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":"AAYA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0D7B,CAAA;AAEN;;;GAGG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,iBAW3F"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import { ChainFamily, bigIntReplacer, calculateManualExecProof, discoverOffRamp, estimateExecGasForRequest,
|
|
1
|
+
import { ChainFamily, bigIntReplacer, calculateManualExecProof, discoverOffRamp, estimateExecGasForRequest, } from '@chainlink/ccip-sdk';
|
|
2
2
|
import { Format } from "./types.js";
|
|
3
|
-
import { logParsedError, prettyCommit, prettyReceipt, prettyRequest, selectRequest, withDateTimestamp, } from "./utils.js";
|
|
4
|
-
import { fetchChainsFromRpcs } from "../providers/index.js";
|
|
3
|
+
import { getCtx, logParsedError, prettyCommit, prettyReceipt, prettyRequest, selectRequest, withDateTimestamp, } from "./utils.js";
|
|
4
|
+
import { fetchChainsFromRpcs, loadChainWallet } from "../providers/index.js";
|
|
5
5
|
// const MAX_QUEUE = 1000
|
|
6
6
|
// const MAX_EXECS_IN_BATCH = 1
|
|
7
7
|
// const MAX_PENDING_TXS = 25
|
|
8
8
|
export const command = 'manualExec <tx-hash>';
|
|
9
9
|
export const describe = 'Execute manually pending or failed messages';
|
|
10
|
+
/**
|
|
11
|
+
* Yargs builder for the manual-exec command.
|
|
12
|
+
* @param yargs - Yargs instance.
|
|
13
|
+
* @returns Configured yargs instance with command options.
|
|
14
|
+
*/
|
|
10
15
|
export const builder = (yargs) => yargs
|
|
11
16
|
.positional('tx-hash', {
|
|
12
17
|
type: 'string',
|
|
@@ -61,60 +66,59 @@ export const builder = (yargs) => yargs
|
|
|
61
66
|
implies: 'sender-queue',
|
|
62
67
|
},
|
|
63
68
|
});
|
|
69
|
+
/**
|
|
70
|
+
* Handler for the manual-exec command.
|
|
71
|
+
* @param argv - Command line arguments.
|
|
72
|
+
*/
|
|
64
73
|
export async function handler(argv) {
|
|
65
|
-
|
|
66
|
-
argv.wallet = process.env['USER_KEY'] || process.env['OWNER_KEY'];
|
|
67
|
-
let destroy;
|
|
68
|
-
const destroy$ = new Promise((resolve) => {
|
|
69
|
-
destroy = resolve;
|
|
70
|
-
});
|
|
74
|
+
const [controller, ctx] = getCtx(argv);
|
|
71
75
|
// argv.senderQueue
|
|
72
76
|
// ? manualExecSenderQueue(providers, argv.tx_hash, argv)
|
|
73
77
|
// : manualExec(argv, destroy$)
|
|
74
|
-
return manualExec(
|
|
78
|
+
return manualExec(ctx, argv)
|
|
75
79
|
.catch((err) => {
|
|
76
80
|
process.exitCode = 1;
|
|
77
|
-
if (!logParsedError(err))
|
|
78
|
-
|
|
81
|
+
if (!logParsedError.call(ctx, err))
|
|
82
|
+
ctx.logger.error(err);
|
|
79
83
|
})
|
|
80
|
-
.finally(
|
|
84
|
+
.finally(() => controller.abort('Exited'));
|
|
81
85
|
}
|
|
82
|
-
async function manualExec(
|
|
86
|
+
async function manualExec(ctx, argv) {
|
|
87
|
+
const { logger } = ctx;
|
|
83
88
|
// messageId not yet implemented for Solana
|
|
84
|
-
const [getChain, tx$] = fetchChainsFromRpcs(argv, argv.txHash
|
|
85
|
-
const tx = await tx$;
|
|
86
|
-
const
|
|
87
|
-
const request = await selectRequest(await fetchCCIPRequestsInTx(tx), 'to know more', argv);
|
|
89
|
+
const [getChain, tx$] = fetchChainsFromRpcs(ctx, argv, argv.txHash);
|
|
90
|
+
const [source, tx] = await tx$;
|
|
91
|
+
const request = await selectRequest(await source.fetchRequestsInTx(tx), 'to know more', argv);
|
|
88
92
|
switch (argv.format) {
|
|
89
93
|
case Format.log: {
|
|
90
94
|
const logPrefix = 'log' in request ? `message ${request.log.index} = ` : 'message = ';
|
|
91
|
-
|
|
95
|
+
logger.log(logPrefix, withDateTimestamp(request));
|
|
92
96
|
break;
|
|
93
97
|
}
|
|
94
98
|
case Format.pretty:
|
|
95
|
-
await prettyRequest(source, request);
|
|
99
|
+
await prettyRequest.call(ctx, source, request);
|
|
96
100
|
break;
|
|
97
101
|
case Format.json:
|
|
98
|
-
|
|
102
|
+
logger.info(JSON.stringify(request, bigIntReplacer, 2));
|
|
99
103
|
break;
|
|
100
104
|
}
|
|
101
105
|
const dest = await getChain(request.lane.destChainSelector);
|
|
102
|
-
const offRamp = await discoverOffRamp(source, dest, request.lane.onRamp);
|
|
106
|
+
const offRamp = await discoverOffRamp(source, dest, request.lane.onRamp, source);
|
|
103
107
|
const commitStore = await dest.getCommitStoreForOffRamp(offRamp);
|
|
104
108
|
const commit = await dest.fetchCommitReport(commitStore, request, argv);
|
|
105
109
|
switch (argv.format) {
|
|
106
110
|
case Format.log:
|
|
107
|
-
|
|
111
|
+
logger.log('commit =', commit);
|
|
108
112
|
break;
|
|
109
113
|
case Format.pretty:
|
|
110
|
-
await prettyCommit(dest, commit, request);
|
|
114
|
+
await prettyCommit.call(ctx, dest, commit, request);
|
|
111
115
|
break;
|
|
112
116
|
case Format.json:
|
|
113
|
-
|
|
117
|
+
logger.info(JSON.stringify(commit, bigIntReplacer, 2));
|
|
114
118
|
break;
|
|
115
119
|
}
|
|
116
|
-
const messagesInBatch = await fetchAllMessagesInBatch(
|
|
117
|
-
const execReportProof = calculateManualExecProof(messagesInBatch, request.lane, request.message.header.messageId, commit.report.merkleRoot);
|
|
120
|
+
const messagesInBatch = await source.fetchAllMessagesInBatch(request, commit.report, argv);
|
|
121
|
+
const execReportProof = calculateManualExecProof(messagesInBatch, request.lane, request.message.header.messageId, commit.report.merkleRoot, dest);
|
|
118
122
|
const offchainTokenData = await source.fetchOffchainTokenData(request);
|
|
119
123
|
const execReport = {
|
|
120
124
|
...execReportProof,
|
|
@@ -127,17 +131,18 @@ async function manualExec(argv, destroy) {
|
|
|
127
131
|
if (dest.network.family !== ChainFamily.EVM)
|
|
128
132
|
throw new Error('Gas estimation is only supported for EVM networks for now');
|
|
129
133
|
let estimated = await estimateExecGasForRequest(source, dest, request);
|
|
130
|
-
|
|
134
|
+
logger.info('Estimated gasLimit override:', estimated);
|
|
131
135
|
estimated += Math.ceil((estimated * argv.estimateGasLimit) / 100);
|
|
132
136
|
if (request.message.gasLimit >= estimated) {
|
|
133
|
-
|
|
137
|
+
logger.warn('Estimated +', argv.estimateGasLimit, '% margin =', estimated, '< original gasLimit =', request.message.gasLimit, '. Leaving unchanged.');
|
|
134
138
|
}
|
|
135
139
|
else {
|
|
136
140
|
argv.gasLimit = estimated;
|
|
137
141
|
}
|
|
138
142
|
}
|
|
139
|
-
const
|
|
140
|
-
|
|
143
|
+
const [, wallet] = await loadChainWallet(dest, argv);
|
|
144
|
+
const manualExecTx = await dest.executeReport(offRamp, execReport, { ...argv, wallet });
|
|
145
|
+
logger.info('🚀 manualExec tx =', manualExecTx.hash, 'to offRamp =', offRamp);
|
|
141
146
|
let found = false;
|
|
142
147
|
for (const log of manualExecTx.logs) {
|
|
143
148
|
const execReceipt = dest.constructor.decodeReceipt(log);
|
|
@@ -147,16 +152,16 @@ async function manualExec(argv, destroy) {
|
|
|
147
152
|
const receipt = { receipt: execReceipt, log, timestamp };
|
|
148
153
|
switch (argv.format) {
|
|
149
154
|
case Format.log:
|
|
150
|
-
|
|
155
|
+
logger.log('receipt =', withDateTimestamp(receipt));
|
|
151
156
|
break;
|
|
152
157
|
case Format.pretty:
|
|
153
158
|
if (!found)
|
|
154
|
-
|
|
155
|
-
prettyReceipt(receipt, request, receipt.log.tx?.from ??
|
|
159
|
+
logger.info('Receipts (dest):');
|
|
160
|
+
prettyReceipt.call(ctx, receipt, request, receipt.log.tx?.from ??
|
|
156
161
|
(await dest.getTransaction(receipt.log.transactionHash).catch(() => null))?.from);
|
|
157
162
|
break;
|
|
158
163
|
case Format.json:
|
|
159
|
-
|
|
164
|
+
logger.info(JSON.stringify(execReceipt, bigIntReplacer, 2));
|
|
160
165
|
break;
|
|
161
166
|
}
|
|
162
167
|
found = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manual-exec.js","sourceRoot":"","sources":["../../src/commands/manual-exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,eAAe,EACf,yBAAyB,
|
|
1
|
+
{"version":3,"file":"manual-exec.js","sourceRoot":"","sources":["../../src/commands/manual-exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,eAAe,EACf,yBAAyB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AAM;gBAChB,IAAI,CAAC,KAAK;oBAAE,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;gBAC3C,aAAa,CAAC,IAAI,CAChB,GAAG,EACH,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,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,CAAA;gBAC3D,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"}
|
package/dist/commands/parse.d.ts
CHANGED
|
@@ -2,8 +2,17 @@ import type { Argv } from 'yargs';
|
|
|
2
2
|
import type { GlobalOpts } from '../index.ts';
|
|
3
3
|
export declare const command: string[];
|
|
4
4
|
export declare const describe = "Try to parse and print errors, revert reasons or function call or event data";
|
|
5
|
+
/**
|
|
6
|
+
* Yargs builder for the parse command.
|
|
7
|
+
* @param yargs - Yargs instance.
|
|
8
|
+
* @returns Configured yargs instance with command options.
|
|
9
|
+
*/
|
|
5
10
|
export declare const builder: (yargs: Argv) => Argv<{
|
|
6
11
|
data: string;
|
|
7
12
|
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Handler for the parse command.
|
|
15
|
+
* @param argv - Command line arguments.
|
|
16
|
+
*/
|
|
8
17
|
export declare function handler(argv: Awaited<ReturnType<typeof builder>['argv']> & GlobalOpts): void;
|
|
9
18
|
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -1 +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,
|
|
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;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,IAAI;;EAK/B,CAAA;AAEJ;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,QAQrF"}
|
package/dist/commands/parse.js
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
import { bigIntReplacer, supportedChains } from '@chainlink/ccip-sdk';
|
|
2
2
|
import { Format } from "./types.js";
|
|
3
|
-
import { prettyTable } from "./utils.js";
|
|
3
|
+
import { getCtx, prettyTable } from "./utils.js";
|
|
4
4
|
export const command = ['parse <data>', 'parseBytes <data>', 'parseData <data>'];
|
|
5
5
|
export const describe = 'Try to parse and print errors, revert reasons or function call or event data';
|
|
6
|
+
/**
|
|
7
|
+
* Yargs builder for the parse command.
|
|
8
|
+
* @param yargs - Yargs instance.
|
|
9
|
+
* @returns Configured yargs instance with command options.
|
|
10
|
+
*/
|
|
6
11
|
export const builder = (yargs) => yargs.positional('data', {
|
|
7
12
|
type: 'string',
|
|
8
13
|
demandOption: true,
|
|
9
14
|
describe: 'router contract address on source',
|
|
10
15
|
});
|
|
16
|
+
/**
|
|
17
|
+
* Handler for the parse command.
|
|
18
|
+
* @param argv - Command line arguments.
|
|
19
|
+
*/
|
|
11
20
|
export function handler(argv) {
|
|
21
|
+
const [, ctx] = getCtx(argv);
|
|
12
22
|
try {
|
|
13
|
-
parseBytes(argv);
|
|
23
|
+
parseBytes(ctx, argv);
|
|
14
24
|
}
|
|
15
25
|
catch (err) {
|
|
16
26
|
process.exitCode = 1;
|
|
17
|
-
|
|
27
|
+
ctx.logger.error(err);
|
|
18
28
|
}
|
|
19
29
|
}
|
|
20
|
-
function parseBytes(argv) {
|
|
30
|
+
function parseBytes(ctx, argv) {
|
|
31
|
+
const { logger } = ctx;
|
|
21
32
|
let parsed;
|
|
22
33
|
for (const chain of Object.values(supportedChains)) {
|
|
23
34
|
try {
|
|
@@ -33,14 +44,14 @@ function parseBytes(argv) {
|
|
|
33
44
|
throw new Error('Unknown data');
|
|
34
45
|
switch (argv.format) {
|
|
35
46
|
case Format.log: {
|
|
36
|
-
|
|
47
|
+
logger.log(`parsed =`, parsed);
|
|
37
48
|
break;
|
|
38
49
|
}
|
|
39
50
|
case Format.pretty:
|
|
40
|
-
prettyTable(parsed);
|
|
51
|
+
prettyTable.call(ctx, parsed);
|
|
41
52
|
break;
|
|
42
53
|
case Format.json:
|
|
43
|
-
|
|
54
|
+
logger.info(JSON.stringify(parsed, bigIntReplacer, 2));
|
|
44
55
|
break;
|
|
45
56
|
}
|
|
46
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/commands/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAIlF,OAAO,
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/commands/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAIlF,OAAO,EAAY,MAAM,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAEhD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,cAAc,EAAE,mBAAmB,EAAE,kBAAkB,CAAC,CAAA;AAChF,MAAM,CAAC,MAAM,QAAQ,GACnB,8EAA8E,CAAA;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAW,EAAE,EAAE,CACrC,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE;IACvB,IAAI,EAAE,QAAQ;IACd,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE,mCAAmC;CAC9C,CAAC,CAAA;AAEJ;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,IAA8D;IACpF,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;IAC5B,IAAI,CAAC;QACH,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACvB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACpB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,GAAQ,EAAE,IAAmC;IAC/D,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAA;IACtB,IAAI,MAAM,CAAA;IACV,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC;QACnD,IAAI,CAAC;YACH,MAAM,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACjC,IAAI,MAAM;gBAAE,MAAK;QACnB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO;QACT,CAAC;IACH,CAAC;IACD,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAA;IAE5C,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAChB,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;YAC9B,MAAK;QACP,CAAC;QACD,KAAK,MAAM,CAAC,MAAM;YAChB,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;YAC7B,MAAK;QACP,KAAK,MAAM,CAAC,IAAI;YACd,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,CAAA;YACtD,MAAK;IACT,CAAC;AACH,CAAC"}
|
package/dist/commands/send.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ import type { Argv } from 'yargs';
|
|
|
2
2
|
import type { GlobalOpts } from '../index.ts';
|
|
3
3
|
export declare const command = "send <source> <router> <dest>";
|
|
4
4
|
export declare const describe = "Send a CCIP message from router on source to dest";
|
|
5
|
+
/**
|
|
6
|
+
* Yargs builder for the send command.
|
|
7
|
+
* @param yargs - Yargs instance.
|
|
8
|
+
* @returns Configured yargs instance with command options.
|
|
9
|
+
*/
|
|
5
10
|
export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{
|
|
6
11
|
source: string;
|
|
7
12
|
} & {
|
|
@@ -76,5 +81,9 @@ export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{
|
|
|
76
81
|
describe: string;
|
|
77
82
|
};
|
|
78
83
|
}>>;
|
|
84
|
+
/**
|
|
85
|
+
* Handler for the send command.
|
|
86
|
+
* @param argv - Command line arguments.
|
|
87
|
+
*/
|
|
79
88
|
export declare function handler(argv: Awaited<ReturnType<typeof builder>['argv']> & GlobalOpts): Promise<void>;
|
|
80
89
|
//# sourceMappingURL=send.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/commands/send.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/commands/send.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAW7C,eAAO,MAAM,OAAO,kCAAkC,CAAA;AACtD,eAAO,MAAM,QAAQ,sDAAsD,CAAA;AAE3E;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkG9B,CAAA;AAEL;;;GAGG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,iBAQ3F"}
|
package/dist/commands/send.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { ChainFamily, bigIntReplacer, estimateExecGasForRequest,
|
|
1
|
+
import { ChainFamily, bigIntReplacer, estimateExecGasForRequest, getDataBytes, networkInfo, sourceToDestTokenAmounts, } from '@chainlink/ccip-sdk';
|
|
2
2
|
import { dataLength, formatUnits, toUtf8Bytes } from 'ethers';
|
|
3
3
|
import { Format } from "./types.js";
|
|
4
|
-
import { logParsedError, parseTokenAmounts, prettyRequest, withDateTimestamp } from "./utils.js";
|
|
5
|
-
import { fetchChainsFromRpcs } from "../providers/index.js";
|
|
4
|
+
import { getCtx, logParsedError, parseTokenAmounts, prettyRequest, withDateTimestamp, } from "./utils.js";
|
|
5
|
+
import { fetchChainsFromRpcs, loadChainWallet } from "../providers/index.js";
|
|
6
6
|
export const command = 'send <source> <router> <dest>';
|
|
7
7
|
export const describe = 'Send a CCIP message from router on source to dest';
|
|
8
|
+
/**
|
|
9
|
+
* Yargs builder for the send command.
|
|
10
|
+
* @param yargs - Yargs instance.
|
|
11
|
+
* @returns Configured yargs instance with command options.
|
|
12
|
+
*/
|
|
8
13
|
export const builder = (yargs) => yargs
|
|
9
14
|
.positional('source', {
|
|
10
15
|
type: 'string',
|
|
@@ -92,23 +97,25 @@ export const builder = (yargs) => yargs
|
|
|
92
97
|
},
|
|
93
98
|
})
|
|
94
99
|
.check(({ 'transfer-tokens': transferTokens }) => !transferTokens || transferTokens.every((t) => /^[^=]+=\d+(\.\d+)?$/.test(t)));
|
|
100
|
+
/**
|
|
101
|
+
* Handler for the send command.
|
|
102
|
+
* @param argv - Command line arguments.
|
|
103
|
+
*/
|
|
95
104
|
export async function handler(argv) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
destroy = resolve;
|
|
99
|
-
});
|
|
100
|
-
return sendMessage(argv, destroy$)
|
|
105
|
+
const [controller, ctx] = getCtx(argv);
|
|
106
|
+
return sendMessage(ctx, argv)
|
|
101
107
|
.catch((err) => {
|
|
102
108
|
process.exitCode = 1;
|
|
103
|
-
if (!logParsedError(err))
|
|
104
|
-
|
|
109
|
+
if (!logParsedError.call(ctx, err))
|
|
110
|
+
ctx.logger.error(err);
|
|
105
111
|
})
|
|
106
|
-
.finally(
|
|
112
|
+
.finally(() => controller.abort('Exited'));
|
|
107
113
|
}
|
|
108
|
-
async function sendMessage(
|
|
114
|
+
async function sendMessage(ctx, argv) {
|
|
115
|
+
const { logger } = ctx;
|
|
109
116
|
const sourceNetwork = networkInfo(argv.source);
|
|
110
117
|
const destNetwork = networkInfo(argv.dest);
|
|
111
|
-
const getChain = fetchChainsFromRpcs(
|
|
118
|
+
const getChain = fetchChainsFromRpcs(ctx, argv);
|
|
112
119
|
const source = await getChain(sourceNetwork.name);
|
|
113
120
|
let data;
|
|
114
121
|
if (argv.data) {
|
|
@@ -157,10 +164,12 @@ async function sendMessage(argv, destroy) {
|
|
|
157
164
|
else if (argv.tokenReceiver || argv.account?.length) {
|
|
158
165
|
throw new Error('--token-receiver and --account intended only for Solana dest');
|
|
159
166
|
}
|
|
167
|
+
let walletAddress, wallet;
|
|
160
168
|
if (!receiver) {
|
|
161
169
|
if (sourceNetwork.family !== destNetwork.family)
|
|
162
170
|
throw new Error('--receiver is required when sending to a different chain family');
|
|
163
|
-
|
|
171
|
+
[walletAddress, wallet] = await loadChainWallet(source, argv);
|
|
172
|
+
receiver = walletAddress; // send to self if same family
|
|
164
173
|
}
|
|
165
174
|
if (argv.estimateGasLimit != null || argv.onlyEstimate) {
|
|
166
175
|
// TODO: implement for all chain families
|
|
@@ -175,16 +184,18 @@ async function sendMessage(argv, destroy) {
|
|
|
175
184
|
version: (await source.typeAndVersion(onRamp))[1],
|
|
176
185
|
};
|
|
177
186
|
const destTokenAmounts = await sourceToDestTokenAmounts(source, destNetwork.chainSelector, onRamp, tokenAmounts);
|
|
187
|
+
if (!walletAddress)
|
|
188
|
+
[walletAddress, wallet] = await loadChainWallet(source, argv);
|
|
178
189
|
const estimated = await estimateExecGasForRequest(source, dest, {
|
|
179
190
|
lane,
|
|
180
191
|
message: {
|
|
181
|
-
sender:
|
|
192
|
+
sender: walletAddress,
|
|
182
193
|
receiver,
|
|
183
194
|
data,
|
|
184
195
|
tokenAmounts: destTokenAmounts,
|
|
185
196
|
},
|
|
186
197
|
});
|
|
187
|
-
|
|
198
|
+
logger.log('Estimated gasLimit:', estimated);
|
|
188
199
|
argv.gasLimit = Math.ceil(estimated * (1 + (argv.estimateGasLimit ?? 0) / 100));
|
|
189
200
|
if (argv.onlyEstimate)
|
|
190
201
|
return;
|
|
@@ -208,8 +219,8 @@ async function sendMessage(argv, destroy) {
|
|
|
208
219
|
feeTokenInfo = await source.getTokenInfo(feeToken);
|
|
209
220
|
}
|
|
210
221
|
catch (_) {
|
|
211
|
-
const feeTokens = await source.
|
|
212
|
-
|
|
222
|
+
const feeTokens = await source.getFeeTokens(argv.router);
|
|
223
|
+
logger.debug('supported feeTokens:', feeTokens);
|
|
213
224
|
for (const [token, info] of Object.entries(feeTokens)) {
|
|
214
225
|
if (info.symbol === 'UNKNOWN' || info.symbol !== argv.feeToken)
|
|
215
226
|
continue;
|
|
@@ -234,24 +245,26 @@ async function sendMessage(argv, destroy) {
|
|
|
234
245
|
};
|
|
235
246
|
// calculate fee
|
|
236
247
|
const fee = await source.getFee(argv.router, destNetwork.chainSelector, message);
|
|
237
|
-
|
|
248
|
+
logger.info('Fee:', fee, '=', formatUnits(fee, feeTokenInfo.decimals), !argv.feeToken && feeTokenInfo.symbol.startsWith('W')
|
|
238
249
|
? feeTokenInfo.symbol.substring(1)
|
|
239
250
|
: feeTokenInfo.symbol);
|
|
240
251
|
if (argv.onlyGetFee)
|
|
241
252
|
return;
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
253
|
+
if (!walletAddress)
|
|
254
|
+
[walletAddress, wallet] = await loadChainWallet(source, argv);
|
|
255
|
+
const request = await source.sendMessage(argv.router, destNetwork.chainSelector, { ...message, fee }, { ...argv, wallet });
|
|
256
|
+
logger.info('🚀 Sending message to', tokenReceiver && tokenReceiver !== '11111111111111111111111111111111'
|
|
257
|
+
? tokenReceiver
|
|
258
|
+
: receiver, '@', destNetwork.name, ', tx =>', request.tx.hash, ', messageId =>', request.message.header.messageId);
|
|
246
259
|
switch (argv.format) {
|
|
247
260
|
case Format.log:
|
|
248
|
-
|
|
261
|
+
logger.log(`message ${request.log.index} =`, withDateTimestamp(request));
|
|
249
262
|
break;
|
|
250
263
|
case Format.pretty:
|
|
251
|
-
await prettyRequest(source, request);
|
|
264
|
+
await prettyRequest.call(ctx, source, request);
|
|
252
265
|
break;
|
|
253
266
|
case Format.json:
|
|
254
|
-
|
|
267
|
+
logger.info(JSON.stringify(request, bigIntReplacer, 2));
|
|
255
268
|
break;
|
|
256
269
|
}
|
|
257
270
|
}
|