@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 SmartContract Chainlink Limited SEZC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,238 @@
1
+ # @chainlink/ccip-cli
2
+
3
+ ## Typescript CLI to interact with CCIP.
4
+
5
+ This tool can be used to query and interact with [CCIP](https://ccip.chain.link) contracts deployed
6
+ in supported blockchains, through its publicly accessible data and methods, requiring only
7
+ compatible RPCs for each involved network.
8
+
9
+ > [!IMPORTANT]
10
+ > This tool is provided under an MIT license and is for convenience and illustration purposes only.
11
+
12
+ ## Installation
13
+
14
+ To install it from latest NpmJS release, do:
15
+
16
+ ```sh
17
+ npm install -g @smartcontractkit/ccip-cli
18
+ ccip-cli --help
19
+ # or
20
+ npx @smartcontractkit/ccip-cli --help
21
+ ```
22
+
23
+ Or run it directly from github or a local clone of the repo (useful for local development):
24
+
25
+ ```sh
26
+ git clone https://github.com/smartcontractkit/ccip-tools-ts
27
+ cd ccip-tools-ts
28
+ npm install # install dependencies
29
+ ./ccip-cli/ccip-cli --help # shell script to run `ccip-cli/src/index.ts`
30
+ # or
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
34
+ ```
35
+
36
+ > [!NOTE]
37
+ > In dev context below, we'll assume you are on `ccip-cli` folder.
38
+
39
+ > [!NOTE]
40
+ > NodeJS version v20+ is required, with v23+ recommended.
41
+ > When running from local folder, it'll try to execute the [src](./src/index.ts) script directly,
42
+ > without an explicit transpilation step. NodeJS v23+ can run `.ts` files directly, while older
43
+ > versions are run with [tsx](https://tsx.is/).
44
+
45
+ ## RPCs
46
+
47
+ All commands require a list of RPCs endpoints for the networks of interest (source and destination).
48
+ Both `http[s]` and `ws[s]` (websocket) URLs are supported.
49
+
50
+ This list can be passed in the command line, through the `-r/--rpcs` option, and are merged with
51
+ those fetched from the rpcs file (`--rpcs-file`, default=`./.env`), which may contain multiple
52
+ endpoints, one per line, with any prefix or suffix (only URLs are parsed).
53
+ The default filename is just for compatibility with previous tools, and isn't required to be an
54
+ actual env file. `.txt`, `.csv` or `.json` arrays should work out of the box.
55
+ `RPC_*` environment variables are also ingested.
56
+
57
+ Once the list is gathered, the CLI connects to all RPCs in parallel on startup and uses the fastest
58
+ to reply for each network.
59
+
60
+ ## Wallet
61
+
62
+ Commands which need to send transactions try to get a private key from a `USER_KEY` environment
63
+ variable.
64
+
65
+ Wallet options can also be passed as `--wallet`, where each chain family may interpret it however it
66
+ can:
67
+ - EVM can receive a 0x-hex private key, or the path to an encrypted json file (e.g. from geth,
68
+ decrypted using the `USER_KEY_PASSWORD` environment variable or prompted password).
69
+ - Solana can receive base58 private key, or the path to an `id.json` file
70
+ (default=`~/.config/solana/id.json`) containing a private key encoded as a json array of numbers.
71
+ - Aptos can receive 0x-hex private key string, or the path of a text file containing it.
72
+
73
+ Additionally, `--wallet ledger` (or `--wallet "ledger:<derivationPath>"`) can be used to connect to
74
+ a Ledger USB device. The derivation path defaults to Ledger Live derivations on each supported
75
+ network, and passing an index selects an account of this derivation:
76
+ E.g. `--wallet ledger:1` uses derivation `m/44'/60'/1'/0/0` for EVM accounts
77
+
78
+ ## Quick command reference:
79
+
80
+ ### Common options
81
+
82
+ - `-v`: Verbose/debug output
83
+ - `--format=pretty` (default): Human-readable tabular output
84
+ - `--format=log`: Basic console logging, may show some more details (e.g. token addresses)
85
+ - `--format=json`: Machine-readable JSON
86
+ - `--page=10000`: limits `eth_getLogs` (and others) pagination/scanning ranges (e.g. for RPCs which
87
+ don't support large ranges)
88
+
89
+ ### `show` (default command)
90
+
91
+ ```sh
92
+ ./ccip-cli [show] <request_transaction_hash> [--log-index num]
93
+ ```
94
+
95
+ Receives a transaction containing a `CCIPSendRequested` (<=v1.5) or `CCIPMessageSent` (>=1.6) event.
96
+ Try every available RPC and uses first network to respond with this transaction.
97
+
98
+ If more than one CCIP messagerequest is present in this transaction, the user is prompted to select
99
+ one form a list, with some basic info on the screen.
100
+ The `--log-index` option allows to pre-select a request non-interactively.
101
+
102
+ If an RPC for dest is also available, scans for the CommitReport for this request, and Execution
103
+ Receipts until a `success` receipt or latest block is hit.
104
+
105
+ ### `manualExec`
106
+
107
+ ```sh
108
+ ./ccip-cli manualExec <request_transaction_hash> [--gas-limit num] [--tokens-gas-limit num]
109
+ ```
110
+
111
+ Try to manually execute the message in source transaction. If more than one found, user is prompted
112
+ same as with `show` command above.
113
+
114
+ `--gas-limit` (aliases `-L`, `--compute-units`) allows to override the exec limit for this message
115
+ (in the OffRamp, not transaction, which is always estimated). `--gas-limit=0` default re-uses limit
116
+ specified in original request.
117
+
118
+ `--tokens-gas-limit` allows to override the gas limit for the token pool operations, if any.
119
+
120
+ `--estimate-gas-limit` option will try to estimate automatically the gas limit override for the
121
+ message execution, based on the current state of the network. That's only for main `ccipReceive`
122
+ exec callback. Tokens gas limit override estimation is not supported for estimation.
123
+
124
+ `--sender-queue` opts into collecting all following messages from the same sender, starting from
125
+ the provided message, and executing all of the eligible ones. By default, only pending
126
+ (non-executed) messages are included. `--exec-failed` includes failed messages as well. This option
127
+ can take some time, specially for older messages, as it needs to scan the source and dest networks
128
+ since request, to find messages and their execution state.
129
+
130
+ #### Solana Special Cases
131
+
132
+ `--force-buffer` to force using a buffer for messages too large to fit in a single transaction
133
+
134
+ `--force-lookup-table` creates a lookup table for all the accounts used in the message, to fit in
135
+ the transaction.
136
+
137
+ If a solana message fails serialization, it's recommended to try with buffer first, then with lookup
138
+ table. The former gets auto-cleared upon successful execution, while the latter needs a grace period
139
+ to be cleared.
140
+ `--clear-leftover-accounts` can be used to scan and wait for the accounts to be cleared, after exec.
141
+
142
+ #### Example
143
+ ```sh
144
+ ./ccip-cli manualExec 0xafd36a0b99d5457e403c918194cb69cd070d991dcbadc99576acfce5020c0b6b \
145
+ --wallet ledger \
146
+ --compute-units 500000 \
147
+ --force-buffer \
148
+ --clear-leftover-accounts
149
+ ```
150
+
151
+ ### `send`
152
+
153
+ ```sh
154
+ ./ccip-cli send 11155111 0x0BF3dE8c5D3e8A2B34D2BEeB17ABfCeBaf363A59 ethereum-testnet-sepolia-arbitrum-1 \
155
+ --receiver 0xAB4f961939BFE6A93567cC57C59eEd7084CE2131 \
156
+ --data 'hello world' \
157
+ --gas-limit 300000 \
158
+ --fee-token 0x779877A7B0D9E8603169DdbD7836e478b4624789 \
159
+ --transfer-tokens 0xFd57b4ddBf88a4e07fF4e34C487b99af2Fe82a05=0.1
160
+ ```
161
+
162
+ Sends a message from router on source network, to dest; positional parameters are:
163
+
164
+ 1. `source`: chainId or name
165
+ 2. `router`: address on source
166
+ 3. `dest`: chainId or name
167
+
168
+ If `--receiver` is omitted, sends to self (sender, see [Wallet](#wallet) section above) address on
169
+ dest, if to same chain family (e.g. EVM-to-EVM). If not same chain family, it is mandatory.
170
+
171
+ If `--data` is not a hex-string, it will be UTF-8 encoded.
172
+
173
+ If `--gas-limit` is omitted, ramp default config (usually 200k) is used.
174
+ It can be `0` to disable execution on receiver.
175
+ `--estimate-gas-limit` can be provided instead, to estimate the gas limit for the message execution.
176
+ It receives a percentage margin (e.g. `--estimate-gas-limit=10` for +10% margin), which is added to
177
+ the estimation before sending the message.
178
+ `--only-estimate` prints gas estimation then exits.
179
+
180
+ If `--fee-token` is not provided, CCIP fee will be paid in native token.
181
+ `--only-get-fee` prints CCIP fee then exits.
182
+
183
+ `--transfer-tokens` can receive multiple pairs of `0xTokenAddr=amount` (source token addresses,
184
+ separated by spaces, terminated with `--` if needed). `amount` will be converted using token
185
+ decimals (e.g. 0.1 = 10^5 of the smallest unit for USDC, which is 6 decimals).
186
+
187
+ `--allow-out-of-order-exec` (`--ooo`) is only available on v1.5+ lanes, and opt-out of _sender_
188
+ `nonce` order enforcement. It's useful for destinations where execution can't be guaranteed
189
+ (e.g. zkOverflow), and required for many destinations.
190
+
191
+ `--approve-max` will approve the maximum possible amount of tokens, if approval is needed for
192
+ either transfer or fee tokens. Default behavior is to approve the strictly needed allowance.
193
+
194
+ ### `parse`
195
+
196
+ ```sh
197
+ ./ccip-cli parse 0xbf16aab6000000000000000000000000779877a7b0d9e8603169ddbd7836e478b4624789
198
+
199
+ Error: EVM2EVMOnRamp_1.2.0.UnsupportedToken(address)
200
+ Args: { token: '0x779877A7B0D9E8603169DdbD7836e478b4624789' }
201
+ ```
202
+
203
+ Attempts to parse hex-encoded function call data, error and revert reasons, for our known contracts.
204
+
205
+ It'll recursively try to decode `returnData` and `error` arguments.
206
+
207
+ ### `getSupportedTokens`
208
+
209
+ ```sh
210
+ ./ccip-cli getSupportedTokens <source> <router> # lists supported tokens
211
+ ./ccip-cli getSupportedTokens <source> <router> [token] # show token and pool details for this token
212
+ ./ccip-cli getSupportedTokens <source> <tokenPool> # same as above, for the pool directly
213
+ ```
214
+
215
+ Source is the network to be queried, as chainID or name.
216
+ If a CCIP `router` address is provided as second parameter, lists all the tokens and its information
217
+ supported in that lane. Type to filter the list.
218
+
219
+ If `token` address is supported as 3rd parameter, pre-selects the token in the list.
220
+
221
+ If `tokenPool` address is provided as 2nd parameter, uses it the same as if having provided
222
+ router + token addresses.
223
+
224
+ In any case, details of the TokenPool and Token will be printed, including all connected remote
225
+ chains and its rate limits state.
226
+
227
+ #### Example
228
+
229
+ ```sh
230
+ # Check tokens supported for transfer from Ethereum to Polygon
231
+ ./ccip-cli getSupportedTokens ethereum-mainnet 0x80226fc0Ee2b096224EeAc085Bb9a8cba1146f7D
232
+ ```
233
+
234
+ #### Output Format Options
235
+
236
+ - `--format pretty` (default): Human-readable output
237
+ - `--format log`: Basic console logging
238
+ - `--format json`: Machine-readable JSON
@@ -0,0 +1,2 @@
1
+ export { Format } from './types.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { Format } from "./types.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA"}
@@ -0,0 +1,56 @@
1
+ import type { Argv } from 'yargs';
2
+ import type { GlobalOpts } from '../index.ts';
3
+ export declare const command = "manualExec <tx-hash>";
4
+ export declare const describe = "Execute manually pending or failed messages";
5
+ export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{
6
+ "tx-hash": string;
7
+ }, "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<{
8
+ 'log-index': {
9
+ type: "number";
10
+ describe: string;
11
+ };
12
+ 'gas-limit': {
13
+ alias: string[];
14
+ type: "number";
15
+ describe: string;
16
+ };
17
+ 'tokens-gas-limit': {
18
+ type: "number";
19
+ describe: string;
20
+ };
21
+ 'estimate-gas-limit': {
22
+ type: "number";
23
+ describe: string;
24
+ example: string;
25
+ conflicts: string;
26
+ };
27
+ wallet: {
28
+ alias: string;
29
+ type: "string";
30
+ describe: string;
31
+ };
32
+ 'force-buffer': {
33
+ type: "boolean";
34
+ describe: string;
35
+ };
36
+ 'force-lookup-table': {
37
+ type: "boolean";
38
+ describe: string;
39
+ };
40
+ 'clear-leftover-accounts': {
41
+ type: "boolean";
42
+ describe: string;
43
+ };
44
+ 'sender-queue': {
45
+ type: "boolean";
46
+ describe: string;
47
+ default: boolean;
48
+ };
49
+ 'exec-failed': {
50
+ type: "boolean";
51
+ describe: string;
52
+ implies: string;
53
+ };
54
+ }>>;
55
+ export declare function handler(argv: Awaited<ReturnType<typeof builder>['argv']> & GlobalOpts): Promise<void>;
56
+ //# sourceMappingURL=manual-exec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manual-exec.d.ts","sourceRoot":"","sources":["../../src/commands/manual-exec.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAgB7C,eAAO,MAAM,OAAO,yBAAyB,CAAA;AAC7C,eAAO,MAAM,QAAQ,gDAAgD,CAAA;AAErE,eAAO,MAAM,OAAO,GAAI,OAAO,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0D7B,CAAA;AAEN,wBAAsB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,iBAe3F"}