evm-deployer 0.0.1
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/AUTHORS.rst +43 -0
- package/COPYING +661 -0
- package/README.md +92 -0
- package/dist/evm-deployer/evm-deployer.js +2 -0
- package/dist/evm-deployer/fs-worker.js +1 -0
- package/dist/evm-deployer/index.html +24 -0
- package/dist/libevm-deployer/fs-worker.js +1 -0
- package/dist/libevm-deployer/index.html +24 -0
- package/dist/libevm-deployer/libevm-deployer.js +2 -0
- package/evm-deployer +1022 -0
- package/lib/deployer +602 -0
- package/libevm-deployer +174 -0
- package/package.json +134 -0
package/evm-deployer
ADDED
|
@@ -0,0 +1,1022 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
|
+
|
|
5
|
+
/** ----------------------------------------------------------------
|
|
6
|
+
* evm-wallet.js
|
|
7
|
+
* ----------------------------------------------------------------
|
|
8
|
+
* Copyright ©
|
|
9
|
+
* Pellegrino Prevete
|
|
10
|
+
* 2024, 2025, 2026
|
|
11
|
+
*
|
|
12
|
+
* All rights reserved
|
|
13
|
+
* ----------------------------------------------------------------
|
|
14
|
+
*
|
|
15
|
+
* This program is free software: you can redistribute it and/or
|
|
16
|
+
* modify it under the terms of the GNU General Public License as
|
|
17
|
+
* published by the Free Software Foundation, either version 3 of
|
|
18
|
+
* the License, or (at your option) any later version.
|
|
19
|
+
*
|
|
20
|
+
* This program is distributed in the hope that it will be useful,
|
|
21
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
22
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
23
|
+
* GNU General Public License for more details.
|
|
24
|
+
*
|
|
25
|
+
* You should have received a copy of the GNU General Public License
|
|
26
|
+
* along with this program.
|
|
27
|
+
* If not, see <https://www.gnu.org/licenses/>.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/* LibEVM writable globals */
|
|
31
|
+
|
|
32
|
+
/* global
|
|
33
|
+
wallet_name:
|
|
34
|
+
writable */
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/* eslint-disable
|
|
38
|
+
no-unused-vars */
|
|
39
|
+
|
|
40
|
+
const
|
|
41
|
+
_libcrash =
|
|
42
|
+
require(
|
|
43
|
+
'crash-js');
|
|
44
|
+
/* global
|
|
45
|
+
_argv_get */
|
|
46
|
+
const
|
|
47
|
+
_argv_get =
|
|
48
|
+
_libcrash._argv_get;
|
|
49
|
+
/* global
|
|
50
|
+
_argv_url_get */
|
|
51
|
+
const
|
|
52
|
+
_argv_url_get =
|
|
53
|
+
_libcrash._argv_url_get;
|
|
54
|
+
/* global
|
|
55
|
+
_cmdline_check */
|
|
56
|
+
const
|
|
57
|
+
_cmdline_check =
|
|
58
|
+
_libcrash._cmdline_check;
|
|
59
|
+
/* global
|
|
60
|
+
_homedir_get */
|
|
61
|
+
const
|
|
62
|
+
_homedir_get =
|
|
63
|
+
_libcrash._homedir_get;
|
|
64
|
+
/* global
|
|
65
|
+
_get_date_human */
|
|
66
|
+
const
|
|
67
|
+
_get_date_human =
|
|
68
|
+
_libcrash._get_date_human;
|
|
69
|
+
/* global
|
|
70
|
+
_msg_info */
|
|
71
|
+
const
|
|
72
|
+
_msg_info =
|
|
73
|
+
_libcrash._msg_info;
|
|
74
|
+
/* global
|
|
75
|
+
_msg_error */
|
|
76
|
+
const
|
|
77
|
+
_msg_error =
|
|
78
|
+
_libcrash._msg_error;
|
|
79
|
+
/* global
|
|
80
|
+
_process_exit */
|
|
81
|
+
const
|
|
82
|
+
_process_exit =
|
|
83
|
+
_libcrash._process_exit;
|
|
84
|
+
const
|
|
85
|
+
_evm_wallet_module =
|
|
86
|
+
require(
|
|
87
|
+
"evm-wallet.js");
|
|
88
|
+
/* global
|
|
89
|
+
_evm_wallet:
|
|
90
|
+
writable */
|
|
91
|
+
_evm_wallet =
|
|
92
|
+
_evm_wallet_module._evm_wallet;
|
|
93
|
+
const
|
|
94
|
+
_libevm_module =
|
|
95
|
+
require(
|
|
96
|
+
"libevm");
|
|
97
|
+
/* global
|
|
98
|
+
_libevm_cmdline_parse */
|
|
99
|
+
const
|
|
100
|
+
_libevm_cmdline_parse =
|
|
101
|
+
_libevm_module._libevm_cmdline_parse;
|
|
102
|
+
/* global
|
|
103
|
+
_libevm_global_variables */
|
|
104
|
+
const
|
|
105
|
+
_libevm_global_variables =
|
|
106
|
+
_libevm_module._libevm_global_variables;
|
|
107
|
+
/* global
|
|
108
|
+
_libevm_url_parse */
|
|
109
|
+
const
|
|
110
|
+
_libevm_url_parse =
|
|
111
|
+
_libevm_module._libevm_url_parse;
|
|
112
|
+
/* global
|
|
113
|
+
_wallet_overrides_set */
|
|
114
|
+
const
|
|
115
|
+
_wallet_overrides_set =
|
|
116
|
+
_libevm_module._wallet_overrides_set;
|
|
117
|
+
|
|
118
|
+
function
|
|
119
|
+
_global_variables() {
|
|
120
|
+
/* global
|
|
121
|
+
app_name:
|
|
122
|
+
writable */
|
|
123
|
+
app_name =
|
|
124
|
+
"evm-wallet.js";
|
|
125
|
+
/* global
|
|
126
|
+
runtime_environment:
|
|
127
|
+
writable */
|
|
128
|
+
runtime_environment =
|
|
129
|
+
"";
|
|
130
|
+
/* global
|
|
131
|
+
app_opts:
|
|
132
|
+
writable */
|
|
133
|
+
app_opts =
|
|
134
|
+
[];
|
|
135
|
+
/* global
|
|
136
|
+
call_date:
|
|
137
|
+
writable */
|
|
138
|
+
call_date =
|
|
139
|
+
"";
|
|
140
|
+
/* global
|
|
141
|
+
config_dir:
|
|
142
|
+
writable */
|
|
143
|
+
config_dir =
|
|
144
|
+
"";
|
|
145
|
+
/* global
|
|
146
|
+
cache_dir:
|
|
147
|
+
writable */
|
|
148
|
+
cache_dir =
|
|
149
|
+
"";
|
|
150
|
+
/* global
|
|
151
|
+
tasks_parallel:
|
|
152
|
+
writable */
|
|
153
|
+
tasks_parallel =
|
|
154
|
+
"";
|
|
155
|
+
/* global
|
|
156
|
+
target_networks:
|
|
157
|
+
writable */
|
|
158
|
+
target_networks =
|
|
159
|
+
[];
|
|
160
|
+
/* global
|
|
161
|
+
target_command:
|
|
162
|
+
writable */
|
|
163
|
+
target_command =
|
|
164
|
+
"";
|
|
165
|
+
/* global
|
|
166
|
+
target_key:
|
|
167
|
+
writable */
|
|
168
|
+
target_key =
|
|
169
|
+
"";
|
|
170
|
+
/* global
|
|
171
|
+
target_value:
|
|
172
|
+
writable */
|
|
173
|
+
target_value =
|
|
174
|
+
"";
|
|
175
|
+
/* global
|
|
176
|
+
output_type:
|
|
177
|
+
writable */
|
|
178
|
+
output_type =
|
|
179
|
+
"";
|
|
180
|
+
/* global
|
|
181
|
+
currency_type:
|
|
182
|
+
writable */
|
|
183
|
+
currency_type =
|
|
184
|
+
"";
|
|
185
|
+
/* global
|
|
186
|
+
currency_address:
|
|
187
|
+
writable */
|
|
188
|
+
currency_address =
|
|
189
|
+
"";
|
|
190
|
+
/* global
|
|
191
|
+
networks_all:
|
|
192
|
+
writable */
|
|
193
|
+
networks_all =
|
|
194
|
+
"";
|
|
195
|
+
/* global
|
|
196
|
+
rpc_selection:
|
|
197
|
+
writable */
|
|
198
|
+
rpc_selection =
|
|
199
|
+
"";
|
|
200
|
+
/* global
|
|
201
|
+
key_fingerprint:
|
|
202
|
+
writable */
|
|
203
|
+
key_fingerprint =
|
|
204
|
+
"";
|
|
205
|
+
/* global
|
|
206
|
+
explorer_selection:
|
|
207
|
+
writable */
|
|
208
|
+
explorer_selection =
|
|
209
|
+
"";
|
|
210
|
+
/* global
|
|
211
|
+
retries_max:
|
|
212
|
+
writable */
|
|
213
|
+
retries_max =
|
|
214
|
+
"";
|
|
215
|
+
/* global
|
|
216
|
+
call_timeout:
|
|
217
|
+
writable */
|
|
218
|
+
call_timeout =
|
|
219
|
+
"";
|
|
220
|
+
/* global
|
|
221
|
+
measure_unit:
|
|
222
|
+
writable */
|
|
223
|
+
measure_unit =
|
|
224
|
+
"";
|
|
225
|
+
/* global
|
|
226
|
+
balance_lifespan:
|
|
227
|
+
writable */
|
|
228
|
+
balance_lifespan =
|
|
229
|
+
"";
|
|
230
|
+
/* global
|
|
231
|
+
qr_support:
|
|
232
|
+
writable */
|
|
233
|
+
qr_support =
|
|
234
|
+
"";
|
|
235
|
+
/* global
|
|
236
|
+
quiet:
|
|
237
|
+
writable */
|
|
238
|
+
quiet =
|
|
239
|
+
"";
|
|
240
|
+
/* global
|
|
241
|
+
verbose:
|
|
242
|
+
writable */
|
|
243
|
+
verbose =
|
|
244
|
+
"";
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function
|
|
248
|
+
_tasks_parallel_auto_detect() {
|
|
249
|
+
if ( networks_all == "y" ) {
|
|
250
|
+
tasks_parallel =
|
|
251
|
+
10;
|
|
252
|
+
}
|
|
253
|
+
else if ( networks_all == "n" ) {
|
|
254
|
+
tasks_parallel =
|
|
255
|
+
1;
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
const
|
|
259
|
+
_msg =
|
|
260
|
+
`Invalid value '${tasks_parallel}' ` +
|
|
261
|
+
`for variable '${tasks_parallel}'`;
|
|
262
|
+
_msg_error(
|
|
263
|
+
_msg,
|
|
264
|
+
1);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function
|
|
269
|
+
_call_timeout_auto_detect() {
|
|
270
|
+
if ( typeof(
|
|
271
|
+
call_timeout) == "undefined" ||
|
|
272
|
+
call_timeout == "" ) {
|
|
273
|
+
if ( target_command == "get" ) {
|
|
274
|
+
call_timeout =
|
|
275
|
+
"30000";
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
call_timeout =
|
|
279
|
+
"300000";
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function
|
|
285
|
+
_target_key_auto_detect() {
|
|
286
|
+
if ( typeof(
|
|
287
|
+
target_key) == "undefined" ||
|
|
288
|
+
target_key == "" ) {
|
|
289
|
+
if ( target_command == "get" ) {
|
|
290
|
+
target_key =
|
|
291
|
+
"name";
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function
|
|
297
|
+
_key_fingerprint_auto_detect() {
|
|
298
|
+
if ( wallet_name != "" ) {
|
|
299
|
+
// TODO:
|
|
300
|
+
// implement EVM GNUPG in Javascript
|
|
301
|
+
true;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function
|
|
306
|
+
_output_type_check() {
|
|
307
|
+
let
|
|
308
|
+
_flag,
|
|
309
|
+
_type;
|
|
310
|
+
_flag =
|
|
311
|
+
"false";
|
|
312
|
+
const
|
|
313
|
+
_output_types = [
|
|
314
|
+
"",
|
|
315
|
+
"name",
|
|
316
|
+
"address",
|
|
317
|
+
"fingerprint"
|
|
318
|
+
];
|
|
319
|
+
for ( _type of _output_types ) {
|
|
320
|
+
if ( output_type == _type ) {
|
|
321
|
+
_flag =
|
|
322
|
+
"true";
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if ( _flag == "false" ) {
|
|
327
|
+
const
|
|
328
|
+
_msg =
|
|
329
|
+
`Invalid output type '${output_type}'.`;
|
|
330
|
+
_msg_error(
|
|
331
|
+
_msg,
|
|
332
|
+
1);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
async function
|
|
337
|
+
_overrides_set() {
|
|
338
|
+
if ( call_date == "" ) {
|
|
339
|
+
call_date =
|
|
340
|
+
_get_date_human();
|
|
341
|
+
}
|
|
342
|
+
if ( typeof(
|
|
343
|
+
wallet_name) == "undefined" ||
|
|
344
|
+
wallet_name == "" ) {
|
|
345
|
+
wallet_name =
|
|
346
|
+
"default";
|
|
347
|
+
}
|
|
348
|
+
if ( typeof(
|
|
349
|
+
target_command) == "undefined" ||
|
|
350
|
+
target_command == "" ) {
|
|
351
|
+
target_command =
|
|
352
|
+
"get";
|
|
353
|
+
}
|
|
354
|
+
if ( networks_all == "" ) {
|
|
355
|
+
networks_all =
|
|
356
|
+
"n";
|
|
357
|
+
}
|
|
358
|
+
_tasks_parallel_auto_detect();
|
|
359
|
+
_call_timeout_auto_detect();
|
|
360
|
+
if ( config_dir == "" ) {
|
|
361
|
+
const
|
|
362
|
+
_home =
|
|
363
|
+
_homedir_get();
|
|
364
|
+
config_dir =
|
|
365
|
+
`${_home}/.config/evm-wallet`;
|
|
366
|
+
}
|
|
367
|
+
if ( cache_dir == "" ) {
|
|
368
|
+
cache_dir =
|
|
369
|
+
`${_homedir_get()}/.cache/evm-wallet`;
|
|
370
|
+
}
|
|
371
|
+
_target_key_auto_detect();
|
|
372
|
+
if ( balance_lifespan == "" ) {
|
|
373
|
+
balance_lifespan =
|
|
374
|
+
"3600";
|
|
375
|
+
}
|
|
376
|
+
if ( typeof(
|
|
377
|
+
retries_max) == "undefined" ||
|
|
378
|
+
retries_max == "" ) {
|
|
379
|
+
retries_max =
|
|
380
|
+
"2";
|
|
381
|
+
}
|
|
382
|
+
if ( typeof(
|
|
383
|
+
measure_unit) == "undefined" ||
|
|
384
|
+
measure_unit == "" ) {
|
|
385
|
+
measure_unit =
|
|
386
|
+
"ether";
|
|
387
|
+
}
|
|
388
|
+
if ( currency_type == "" ) {
|
|
389
|
+
if ( currency_address == "" ) {
|
|
390
|
+
currency_type =
|
|
391
|
+
"gas";
|
|
392
|
+
}
|
|
393
|
+
else if ( currency_address != "" ) {
|
|
394
|
+
currency_type =
|
|
395
|
+
"erc20";
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if ( rpc_selection == "" ) {
|
|
399
|
+
// TODO:
|
|
400
|
+
// remove all references to that
|
|
401
|
+
// monster
|
|
402
|
+
rpc_selection =
|
|
403
|
+
"kirsh";
|
|
404
|
+
}
|
|
405
|
+
if ( explorer_selection == "" ) {
|
|
406
|
+
// TODO:
|
|
407
|
+
// remove all references to that
|
|
408
|
+
// humunculus
|
|
409
|
+
explorer_selection =
|
|
410
|
+
"kirsh";
|
|
411
|
+
}
|
|
412
|
+
// TODO:
|
|
413
|
+
// explorers api keys, optional frankly
|
|
414
|
+
// since theres the evm-contracts-source-index
|
|
415
|
+
const
|
|
416
|
+
_wallet_set_up =
|
|
417
|
+
await _wallet_overrides_set(
|
|
418
|
+
"evm-wallet",
|
|
419
|
+
wallet_name,
|
|
420
|
+
"y",
|
|
421
|
+
"n");
|
|
422
|
+
if ( target_networks.length < 1 &&
|
|
423
|
+
networks_all == "n" ) {
|
|
424
|
+
target_networks.push(
|
|
425
|
+
100);
|
|
426
|
+
}
|
|
427
|
+
_key_fingerprint_auto_detect();
|
|
428
|
+
_output_type_check();
|
|
429
|
+
// See https://github.com/openpgpjs/openpgpjs/issues/2004
|
|
430
|
+
if ( qr_support == "" ) {
|
|
431
|
+
qr_support =
|
|
432
|
+
"n";
|
|
433
|
+
}
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function
|
|
438
|
+
_config_show() {
|
|
439
|
+
/* LibEVM-defined global variables */
|
|
440
|
+
/* global
|
|
441
|
+
api_key */
|
|
442
|
+
/* global
|
|
443
|
+
wallet_address */
|
|
444
|
+
/* global
|
|
445
|
+
wallet_password */
|
|
446
|
+
/* global
|
|
447
|
+
wallet_path */
|
|
448
|
+
/* global
|
|
449
|
+
wallet_seed */
|
|
450
|
+
let
|
|
451
|
+
_line;
|
|
452
|
+
const
|
|
453
|
+
_text = [
|
|
454
|
+
`${app_name} configuration:`,
|
|
455
|
+
` Call date: ${call_date}`,
|
|
456
|
+
` Runtime environment: ${runtime_environment}`,
|
|
457
|
+
` Target command: ${target_command}`,
|
|
458
|
+
` Wallet name: ${wallet_name}`,
|
|
459
|
+
` Target key: ${target_key}`,
|
|
460
|
+
` Target value: ${target_value}`,
|
|
461
|
+
` All networks: ${networks_all}`,
|
|
462
|
+
` RPC selection method: ${rpc_selection}`,
|
|
463
|
+
` Explorers selection method: ${explorer_selection}`,
|
|
464
|
+
` Measure unit: ${measure_unit}`,
|
|
465
|
+
` Balance lifespan: ${balance_lifespan}`,
|
|
466
|
+
` Send options:`,
|
|
467
|
+
` Currency type: ${currency_type}`,
|
|
468
|
+
` Currency address: ${currency_address}`,
|
|
469
|
+
` List options:`,
|
|
470
|
+
` Output type: ${output_type}`,
|
|
471
|
+
` Credentials options:`,
|
|
472
|
+
` Wallet path: ${wallet_path}`,
|
|
473
|
+
` Wallet seed: ${wallet_seed}`,
|
|
474
|
+
` API Key: ${api_key}`,
|
|
475
|
+
` Wallet address: ${wallet_address}`,
|
|
476
|
+
` Key fingerprint: ${key_fingerprint}`,
|
|
477
|
+
` Quantum resistant ciphers: ${qr_support}`,
|
|
478
|
+
` Network options:`,
|
|
479
|
+
` Maximum retries: ${retries_max}`,
|
|
480
|
+
` Call timeout: ${call_timeout}`,
|
|
481
|
+
` Parallel tasks: ${tasks_parallel}`,
|
|
482
|
+
` LibEVM options:`,
|
|
483
|
+
` Target network: ${target_networks[0]}`,
|
|
484
|
+
` Application options:`,
|
|
485
|
+
` Configuration directory: ${config_dir}`,
|
|
486
|
+
` Cache directory: ${cache_dir}`,
|
|
487
|
+
];
|
|
488
|
+
for ( _line of _text ) {
|
|
489
|
+
_msg_info(
|
|
490
|
+
_line);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function
|
|
495
|
+
_usage(
|
|
496
|
+
_exit_code) {
|
|
497
|
+
let
|
|
498
|
+
_line;
|
|
499
|
+
const
|
|
500
|
+
_text = [
|
|
501
|
+
"EVM networks wallet",
|
|
502
|
+
"",
|
|
503
|
+
"Usage:",
|
|
504
|
+
"",
|
|
505
|
+
" evm-wallet.js",
|
|
506
|
+
" [options]",
|
|
507
|
+
" <command>",
|
|
508
|
+
" <command-args>",
|
|
509
|
+
"",
|
|
510
|
+
" commands:",
|
|
511
|
+
" get",
|
|
512
|
+
" <wallet-name>",
|
|
513
|
+
" <key>",
|
|
514
|
+
" list",
|
|
515
|
+
" <filter>",
|
|
516
|
+
" set",
|
|
517
|
+
" <wallet-name>",
|
|
518
|
+
" <key>",
|
|
519
|
+
" <value>",
|
|
520
|
+
" send",
|
|
521
|
+
" <address>",
|
|
522
|
+
" <amount>",
|
|
523
|
+
"",
|
|
524
|
+
" keys:",
|
|
525
|
+
" address",
|
|
526
|
+
" balance",
|
|
527
|
+
" name",
|
|
528
|
+
" seed",
|
|
529
|
+
"",
|
|
530
|
+
" networks:",
|
|
531
|
+
" all those supported by",
|
|
532
|
+
" 'evm-chains-info' as",
|
|
533
|
+
" well as direct RPC addresses",
|
|
534
|
+
"",
|
|
535
|
+
" options:",
|
|
536
|
+
"",
|
|
537
|
+
" -R --rpc-selection RPC selection method.",
|
|
538
|
+
` <rpc-selection> Default: '${rpc_selection}`,
|
|
539
|
+
"",
|
|
540
|
+
" -S --explorer-selection Network explorer selection method.",
|
|
541
|
+
` <explorer-selection-method> Default: '${explorer_selection}'`,
|
|
542
|
+
"",
|
|
543
|
+
" -r --retries-max Maximum number of retries before",
|
|
544
|
+
" <retries-max> failure.",
|
|
545
|
+
` Default: '${retries_max}'`,
|
|
546
|
+
"",
|
|
547
|
+
" -u --measure-unit Measure unit. It can be",
|
|
548
|
+
" <measure-unit> 'ether' or 'wei'.",
|
|
549
|
+
` Default: '${measure_unit}'`,
|
|
550
|
+
"",
|
|
551
|
+
" -l --balance-lifespan Maximum threshold in seconds",
|
|
552
|
+
" <balance-lifespan> from now after which to consider",
|
|
553
|
+
" the balance outdated.",
|
|
554
|
+
` Default: '${balance_lifespan}'`,
|
|
555
|
+
"",
|
|
556
|
+
" -a --networks-all Operation valid for all available",
|
|
557
|
+
" networks.",
|
|
558
|
+
` Default: '${networks_all}'`,
|
|
559
|
+
"",
|
|
560
|
+
" -P --tasks-parallel Tasks to perform in",
|
|
561
|
+
" <tasks-parallel> parallel/concurrently.",
|
|
562
|
+
` Default: '${tasks_parallel}'`,
|
|
563
|
+
"",
|
|
564
|
+
" -Q --qr-support Quantum resistance support.",
|
|
565
|
+
` <y/n> Default: '${qr_support}'`,
|
|
566
|
+
"",
|
|
567
|
+
" list options:",
|
|
568
|
+
"",
|
|
569
|
+
" -o --output-type It can be 'name', 'address',",
|
|
570
|
+
" <output-type> 'name', 'fingerprint'.",
|
|
571
|
+
` Default: '${output_type}'`,
|
|
572
|
+
"",
|
|
573
|
+
" send options:",
|
|
574
|
+
"",
|
|
575
|
+
" -t --currency-type Currency type.",
|
|
576
|
+
" <currency-type> It can be 'gas or 'erc20'.",
|
|
577
|
+
` Default: '${currency_type}'`,
|
|
578
|
+
"",
|
|
579
|
+
" -C --currency Address of the ERC20 token",
|
|
580
|
+
" <address> on the network, if type is 'erc20'.",
|
|
581
|
+
` Default: '${currency_address}'`,
|
|
582
|
+
"",
|
|
583
|
+
" credentials options:",
|
|
584
|
+
"",
|
|
585
|
+
" -w --wallet-path Wallet file path.",
|
|
586
|
+
` <wallet-path> Default: '${wallet_path}'`,
|
|
587
|
+
"",
|
|
588
|
+
" -p --wallet-password Wallet password file.",
|
|
589
|
+
` <wallet-password> Default: '${wallet_password}'`,
|
|
590
|
+
"",
|
|
591
|
+
" -s --wallet-seed Wallet seed file.",
|
|
592
|
+
` <wallet-seed> Default: '${wallet_seed}'`,
|
|
593
|
+
"",
|
|
594
|
+
" -k --api-key Etherscan-like service key.",
|
|
595
|
+
` <wallet-seed> Default: '${api_key}'`,
|
|
596
|
+
"",
|
|
597
|
+
" libEVM options:",
|
|
598
|
+
"",
|
|
599
|
+
" -n --network EVM network name. Accepted",
|
|
600
|
+
" <network> are all those supported by",
|
|
601
|
+
" 'evm-chains-info' and RPC addresses.",
|
|
602
|
+
"",
|
|
603
|
+
" application options:",
|
|
604
|
+
"",
|
|
605
|
+
" -K --config-dir Configuration directory.",
|
|
606
|
+
` <config-dir> Default: '${config_dir}'`,
|
|
607
|
+
"",
|
|
608
|
+
" -W --cache-dir Cache directory.",
|
|
609
|
+
` <cache-dir> Default: '${cache_dir}'`,
|
|
610
|
+
"",
|
|
611
|
+
" -h --help This message.",
|
|
612
|
+
" -v --verbose Enable verbose output.",
|
|
613
|
+
"",
|
|
614
|
+
];
|
|
615
|
+
for ( _line of _text ) {
|
|
616
|
+
console.log(
|
|
617
|
+
_line);
|
|
618
|
+
}
|
|
619
|
+
_process_exit(
|
|
620
|
+
_exit_code);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
async function
|
|
624
|
+
_cmdline_parse() {
|
|
625
|
+
let
|
|
626
|
+
_help_display;
|
|
627
|
+
const
|
|
628
|
+
_argv_args = {
|
|
629
|
+
"booleans": [
|
|
630
|
+
"h",
|
|
631
|
+
"help",
|
|
632
|
+
"v",
|
|
633
|
+
"verbose"
|
|
634
|
+
],
|
|
635
|
+
"string":
|
|
636
|
+
true
|
|
637
|
+
};
|
|
638
|
+
const
|
|
639
|
+
_argv =
|
|
640
|
+
_argv_get(
|
|
641
|
+
_argv_args);
|
|
642
|
+
const
|
|
643
|
+
_options =
|
|
644
|
+
_argv[
|
|
645
|
+
"_"];
|
|
646
|
+
quiet =
|
|
647
|
+
"y";
|
|
648
|
+
runtime_environment =
|
|
649
|
+
"node";
|
|
650
|
+
if ( _argv["h"] == true ) {
|
|
651
|
+
_help_display =
|
|
652
|
+
true;
|
|
653
|
+
}
|
|
654
|
+
if ( _argv["help"] == true ) {
|
|
655
|
+
_help_display =
|
|
656
|
+
true;
|
|
657
|
+
}
|
|
658
|
+
if ( ( _options.indexOf(
|
|
659
|
+
"--help") > -1 ||
|
|
660
|
+
_options.indexOf(
|
|
661
|
+
"-h") > -1) ) {
|
|
662
|
+
_help_display =
|
|
663
|
+
true;
|
|
664
|
+
}
|
|
665
|
+
if ( _help_display ) {
|
|
666
|
+
quiet =
|
|
667
|
+
"n";
|
|
668
|
+
await _overrides_set();
|
|
669
|
+
_usage(
|
|
670
|
+
0);
|
|
671
|
+
}
|
|
672
|
+
if ( typeof(
|
|
673
|
+
_argv) != "undefined" &&
|
|
674
|
+
0 < _argv[
|
|
675
|
+
"_"].length ) {
|
|
676
|
+
target_command =
|
|
677
|
+
_argv[
|
|
678
|
+
"_"][
|
|
679
|
+
0];
|
|
680
|
+
}
|
|
681
|
+
if ( typeof(
|
|
682
|
+
_argv) != "undefined" &&
|
|
683
|
+
1 < _argv[
|
|
684
|
+
"_"].length ) {
|
|
685
|
+
if ( target_command == "list" ) {
|
|
686
|
+
target_key =
|
|
687
|
+
_argv[
|
|
688
|
+
"_"][
|
|
689
|
+
1];
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
/* eslint-disable-next-line
|
|
693
|
+
no-global-assign */
|
|
694
|
+
wallet_name =
|
|
695
|
+
_argv[
|
|
696
|
+
"_"][
|
|
697
|
+
1];
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
if ( typeof(
|
|
701
|
+
_argv) != "undefined" &&
|
|
702
|
+
2 < _argv[
|
|
703
|
+
"_"].length ) {
|
|
704
|
+
if ( target_command == "list" ) {
|
|
705
|
+
true;
|
|
706
|
+
}
|
|
707
|
+
else if ( target_command == "send" ) {
|
|
708
|
+
const _key = _argv._[2];
|
|
709
|
+
target_key =
|
|
710
|
+
_argv[
|
|
711
|
+
"_"][
|
|
712
|
+
2].toString();
|
|
713
|
+
}
|
|
714
|
+
else {
|
|
715
|
+
/* eslint-disable-next-line
|
|
716
|
+
no-global-assign */
|
|
717
|
+
target_key =
|
|
718
|
+
_argv[
|
|
719
|
+
"_"][
|
|
720
|
+
2];
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
if ( typeof(
|
|
724
|
+
_argv) != "undefined" &&
|
|
725
|
+
2 < _argv[
|
|
726
|
+
"_"].length ) {
|
|
727
|
+
target_key =
|
|
728
|
+
_argv[
|
|
729
|
+
"_"][
|
|
730
|
+
2];
|
|
731
|
+
}
|
|
732
|
+
if ( typeof(
|
|
733
|
+
_argv) != "undefined" &&
|
|
734
|
+
3 < _argv[
|
|
735
|
+
"_"].length ) {
|
|
736
|
+
target_value =
|
|
737
|
+
_argv[
|
|
738
|
+
"_"][
|
|
739
|
+
3];
|
|
740
|
+
}
|
|
741
|
+
if ( "R" in _argv ) {
|
|
742
|
+
rpc_selection =
|
|
743
|
+
_argv[
|
|
744
|
+
"R"];
|
|
745
|
+
}
|
|
746
|
+
if ( "rpc-selection" in _argv ) {
|
|
747
|
+
rpc_selection =
|
|
748
|
+
_argv[
|
|
749
|
+
"rpc-selection"];
|
|
750
|
+
}
|
|
751
|
+
if ( "S" in _argv ) {
|
|
752
|
+
explorer_selection =
|
|
753
|
+
_argv[
|
|
754
|
+
"S"];
|
|
755
|
+
}
|
|
756
|
+
if ( "explorer-selection" in _argv ) {
|
|
757
|
+
explorer_selection =
|
|
758
|
+
_argv[
|
|
759
|
+
"explorer-selection"];
|
|
760
|
+
}
|
|
761
|
+
if ( "r" in _argv ) {
|
|
762
|
+
retries_max =
|
|
763
|
+
_argv[
|
|
764
|
+
"r"];
|
|
765
|
+
}
|
|
766
|
+
if ( "retries-max" in _argv ) {
|
|
767
|
+
retries_max =
|
|
768
|
+
_argv[
|
|
769
|
+
"retries-max"];
|
|
770
|
+
}
|
|
771
|
+
if ( "u" in _argv ) {
|
|
772
|
+
measure_unit =
|
|
773
|
+
_argv[
|
|
774
|
+
"u"];
|
|
775
|
+
}
|
|
776
|
+
if ( "measure-unit" in _argv ) {
|
|
777
|
+
measure_unit =
|
|
778
|
+
_argv[
|
|
779
|
+
"measure-unit"];
|
|
780
|
+
}
|
|
781
|
+
if ( "l" in _argv ) {
|
|
782
|
+
balance_lifespan =
|
|
783
|
+
_argv[
|
|
784
|
+
"l"];
|
|
785
|
+
}
|
|
786
|
+
if ( "balance-lifespan" in _argv ) {
|
|
787
|
+
balance_lifespan =
|
|
788
|
+
_argv[
|
|
789
|
+
"balance-lifespan"];
|
|
790
|
+
}
|
|
791
|
+
if ( "a" in _argv ) {
|
|
792
|
+
networks_all =
|
|
793
|
+
"y";
|
|
794
|
+
}
|
|
795
|
+
if ( "networks-all" in _argv ) {
|
|
796
|
+
networks_all =
|
|
797
|
+
"y";
|
|
798
|
+
}
|
|
799
|
+
if ( "P" in _argv ) {
|
|
800
|
+
tasks_parallel =
|
|
801
|
+
_argv[
|
|
802
|
+
"P"];
|
|
803
|
+
}
|
|
804
|
+
if ( "tasks-parallel" in _argv ) {
|
|
805
|
+
tasks_parallel =
|
|
806
|
+
_argv[
|
|
807
|
+
"tasks-parallel"];
|
|
808
|
+
}
|
|
809
|
+
if ( "Q" in _argv ) {
|
|
810
|
+
qr_support =
|
|
811
|
+
_argv[
|
|
812
|
+
"Q"];
|
|
813
|
+
}
|
|
814
|
+
if ( "qr-support" in _argv ) {
|
|
815
|
+
qr_support =
|
|
816
|
+
_argv[
|
|
817
|
+
"qr-support"];
|
|
818
|
+
}
|
|
819
|
+
if ( "o" in _argv ) {
|
|
820
|
+
output_type =
|
|
821
|
+
_argv[
|
|
822
|
+
"o"];
|
|
823
|
+
}
|
|
824
|
+
if ( "output-type" in _argv ) {
|
|
825
|
+
output_type =
|
|
826
|
+
_argv[
|
|
827
|
+
"output-type"];
|
|
828
|
+
}
|
|
829
|
+
if ( "t" in _argv ) {
|
|
830
|
+
currency_type =
|
|
831
|
+
_argv[
|
|
832
|
+
"t"];
|
|
833
|
+
}
|
|
834
|
+
if ( "currency-type" in _argv ) {
|
|
835
|
+
currency_type =
|
|
836
|
+
_argv[
|
|
837
|
+
"currency-type"];
|
|
838
|
+
}
|
|
839
|
+
if ( "C" in _argv ) {
|
|
840
|
+
currency_address =
|
|
841
|
+
_argv[
|
|
842
|
+
"C"];
|
|
843
|
+
}
|
|
844
|
+
if ( "currency" in _argv ) {
|
|
845
|
+
currency_address =
|
|
846
|
+
_argv[
|
|
847
|
+
"currency"];
|
|
848
|
+
}
|
|
849
|
+
_libevm_cmdline_parse(
|
|
850
|
+
_argv);
|
|
851
|
+
if ( _argv[
|
|
852
|
+
"v"] ||
|
|
853
|
+
_argv[
|
|
854
|
+
"verbose"]) {
|
|
855
|
+
verbose =
|
|
856
|
+
true;
|
|
857
|
+
}
|
|
858
|
+
if ( verbose ) {
|
|
859
|
+
quiet =
|
|
860
|
+
"n";
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
function
|
|
865
|
+
_url_parse() {
|
|
866
|
+
const
|
|
867
|
+
_argv =
|
|
868
|
+
_argv_url_get();
|
|
869
|
+
runtime_environment =
|
|
870
|
+
"browser";
|
|
871
|
+
wallet_name =
|
|
872
|
+
_argv_url_get(
|
|
873
|
+
"wallet_name")[
|
|
874
|
+
0];
|
|
875
|
+
rpc_selection =
|
|
876
|
+
_argv_url_get(
|
|
877
|
+
"rpc_selection")[
|
|
878
|
+
0];
|
|
879
|
+
explorer_selection =
|
|
880
|
+
_argv_url_get(
|
|
881
|
+
"explorer_selection")[
|
|
882
|
+
0];
|
|
883
|
+
retries_max =
|
|
884
|
+
_argv_url_get(
|
|
885
|
+
"retries_max")[
|
|
886
|
+
0];
|
|
887
|
+
measure_unit =
|
|
888
|
+
_argv_url_get(
|
|
889
|
+
"measure_unit")[
|
|
890
|
+
0];
|
|
891
|
+
balance_lifespan =
|
|
892
|
+
_argv_url_get(
|
|
893
|
+
"balance_lifespan")[
|
|
894
|
+
0];
|
|
895
|
+
networks_all =
|
|
896
|
+
_argv_url_get(
|
|
897
|
+
"networks_all")[
|
|
898
|
+
0];
|
|
899
|
+
tasks_parallel =
|
|
900
|
+
_argv_url_get(
|
|
901
|
+
"tasks_parallel")[
|
|
902
|
+
0];
|
|
903
|
+
qr_support =
|
|
904
|
+
_argv_url_get(
|
|
905
|
+
"qr_support")[
|
|
906
|
+
0];
|
|
907
|
+
output_type =
|
|
908
|
+
_argv_url_get(
|
|
909
|
+
"output_type")[
|
|
910
|
+
0];
|
|
911
|
+
currency_type =
|
|
912
|
+
_argv_url_get(
|
|
913
|
+
"currency_type")[
|
|
914
|
+
0];
|
|
915
|
+
currency_address =
|
|
916
|
+
_argv_url_get(
|
|
917
|
+
"currency_address")[
|
|
918
|
+
0];
|
|
919
|
+
config_dir =
|
|
920
|
+
_argv_url_get(
|
|
921
|
+
"config_dir")[
|
|
922
|
+
0];
|
|
923
|
+
cache_dir =
|
|
924
|
+
_argv_url_get(
|
|
925
|
+
"cache_dir")[
|
|
926
|
+
0];
|
|
927
|
+
_libevm_url_parse();
|
|
928
|
+
quiet =
|
|
929
|
+
_argv_url_get(
|
|
930
|
+
"quiet");
|
|
931
|
+
if ( quiet.length === 0 ) {
|
|
932
|
+
quiet =
|
|
933
|
+
"n";
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
async function
|
|
938
|
+
_main() {
|
|
939
|
+
let
|
|
940
|
+
_msg,
|
|
941
|
+
_result;
|
|
942
|
+
const
|
|
943
|
+
_overrides_set_up =
|
|
944
|
+
await _overrides_set();
|
|
945
|
+
_config_show();
|
|
946
|
+
const
|
|
947
|
+
app_opts = [
|
|
948
|
+
target_command,
|
|
949
|
+
wallet_name,
|
|
950
|
+
wallet_path,
|
|
951
|
+
wallet_password,
|
|
952
|
+
wallet_seed,
|
|
953
|
+
key_fingerprint,
|
|
954
|
+
config_dir,
|
|
955
|
+
cache_dir,
|
|
956
|
+
networks_all,
|
|
957
|
+
rpc_selection,
|
|
958
|
+
api_key,
|
|
959
|
+
retries_max,
|
|
960
|
+
tasks_parallel,
|
|
961
|
+
call_timeout,
|
|
962
|
+
measure_unit,
|
|
963
|
+
balance_lifespan,
|
|
964
|
+
currency_type,
|
|
965
|
+
currency_address,
|
|
966
|
+
output_type,
|
|
967
|
+
target_key,
|
|
968
|
+
target_value,
|
|
969
|
+
target_networks
|
|
970
|
+
];
|
|
971
|
+
const
|
|
972
|
+
_results =
|
|
973
|
+
await _evm_wallet.apply(
|
|
974
|
+
null,
|
|
975
|
+
app_opts);
|
|
976
|
+
const
|
|
977
|
+
_results_type =
|
|
978
|
+
typeof(
|
|
979
|
+
_results);
|
|
980
|
+
if ( _results_type == "bigint" ) {
|
|
981
|
+
console.log(
|
|
982
|
+
_results.toString());
|
|
983
|
+
}
|
|
984
|
+
else if ( _results_type == "string" ) {
|
|
985
|
+
console.log(
|
|
986
|
+
_results);
|
|
987
|
+
}
|
|
988
|
+
else if ( _results_type == "object" ) {
|
|
989
|
+
for ( _result of _results ) {
|
|
990
|
+
console.log(
|
|
991
|
+
_result);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
else if ( _results_type == "undefined" ) {
|
|
995
|
+
_msg =
|
|
996
|
+
`No results.`;
|
|
997
|
+
_msg_error(
|
|
998
|
+
_msg,
|
|
999
|
+
1);
|
|
1000
|
+
}
|
|
1001
|
+
else {
|
|
1002
|
+
_msg =
|
|
1003
|
+
"Error retrieving results for command. " +
|
|
1004
|
+
`Type of return: '${_results_type}'.`;
|
|
1005
|
+
_msg_error(
|
|
1006
|
+
_msg,
|
|
1007
|
+
1);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
_global_variables();
|
|
1012
|
+
_libevm_global_variables();
|
|
1013
|
+
if ( _cmdline_check(
|
|
1014
|
+
"evm-wallet.js") == true ||
|
|
1015
|
+
_cmdline_check(
|
|
1016
|
+
"evm-wallet") == true ) {
|
|
1017
|
+
_cmdline_parse();
|
|
1018
|
+
}
|
|
1019
|
+
else {
|
|
1020
|
+
_url_parse();
|
|
1021
|
+
}
|
|
1022
|
+
_main();
|