evm-contracts-tools 0.0.11 → 0.0.14
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/evm-contract-call +297 -128
- package/lib/deployer-verify +141 -98
- package/lib/evm-contract-call-dynamic +3 -3
- package/libevm-contract-call +104 -716
- package/libevm-contracts-tools +16 -0
- package/package.json +2 -2
package/libevm-contract-call
CHANGED
|
@@ -33,32 +33,44 @@
|
|
|
33
33
|
/* eslint-disable
|
|
34
34
|
no-useless-assignment */
|
|
35
35
|
|
|
36
|
+
/* libEVM global variables */
|
|
36
37
|
/* global
|
|
37
|
-
|
|
38
|
+
api_key */
|
|
38
39
|
/* global
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
contract_abi */
|
|
41
|
+
/* global
|
|
42
|
+
contract_address */
|
|
41
43
|
/* global
|
|
42
|
-
|
|
44
|
+
contract_compiler_output */
|
|
43
45
|
/* global
|
|
44
|
-
|
|
46
|
+
target_network:
|
|
47
|
+
writable */
|
|
48
|
+
/* global
|
|
49
|
+
target_networks:
|
|
50
|
+
writable */
|
|
45
51
|
|
|
46
52
|
const
|
|
47
53
|
_libcrash_module =
|
|
48
54
|
require(
|
|
49
55
|
"crash-js");
|
|
50
56
|
/* global
|
|
51
|
-
|
|
57
|
+
_dirname */
|
|
52
58
|
/* eslint-disable-next-line
|
|
53
59
|
no-global-assign */
|
|
54
|
-
|
|
55
|
-
_libcrash_module.
|
|
60
|
+
_dirname =
|
|
61
|
+
_libcrash_module._dirname;
|
|
56
62
|
/* global
|
|
57
63
|
_file_exists */
|
|
58
64
|
/* eslint-disable-next-line
|
|
59
65
|
no-global-assign */
|
|
60
66
|
_file_exists =
|
|
61
67
|
_libcrash_module._file_exists;
|
|
68
|
+
/* global
|
|
69
|
+
_homedir_get */
|
|
70
|
+
/* eslint-disable-next-line
|
|
71
|
+
no-global-assign */
|
|
72
|
+
_homedir_get =
|
|
73
|
+
_libcrash_module._homedir_get;
|
|
62
74
|
/* global
|
|
63
75
|
_json_read */
|
|
64
76
|
/* eslint-disable-next-line
|
|
@@ -107,733 +119,119 @@ const
|
|
|
107
119
|
_ethereum_data_module._data_get;
|
|
108
120
|
|
|
109
121
|
function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if ( typeof(
|
|
119
|
-
_user) == "undefined" ||
|
|
120
|
-
_user == "" ) {
|
|
121
|
-
_user =
|
|
122
|
-
"n";
|
|
123
|
-
}
|
|
124
|
-
if ( typeof(
|
|
125
|
-
_chain_id) == "undefined" ||
|
|
126
|
-
_chain_id == "" ) {
|
|
127
|
-
_chain_id =
|
|
128
|
-
"";
|
|
129
|
-
}
|
|
130
|
-
if ( typeof(
|
|
131
|
-
_format) == "undefined" ||
|
|
132
|
-
_format == "" ) {
|
|
133
|
-
if ( _chain_id != "" ) {
|
|
134
|
-
_format =
|
|
135
|
-
"split";
|
|
136
|
-
}
|
|
137
|
-
else if ( _chain_id == "" ) {
|
|
138
|
-
_format =
|
|
139
|
-
"unified";
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
_msg =
|
|
143
|
-
`Getting path for chain ` +
|
|
144
|
-
`with chain id '${_chain_id}' ` +
|
|
145
|
-
`with privilege user set to ` +
|
|
146
|
-
`'${_user}' in format '${_format}'.`;
|
|
147
|
-
_msg_info(
|
|
148
|
-
_msg);
|
|
149
|
-
if ( _format == "unified" ) {
|
|
150
|
-
_db_name =
|
|
151
|
-
"chains.json";
|
|
152
|
-
}
|
|
153
|
-
else if ( _format == "split" ) {
|
|
154
|
-
_db_name =
|
|
155
|
-
`${_chain_id}.json`;
|
|
156
|
-
}
|
|
157
|
-
if ( _user == "y" ) {
|
|
158
|
-
const
|
|
159
|
-
_home_dir =
|
|
160
|
-
_homedir_get();
|
|
161
|
-
_msg =
|
|
162
|
-
`Home directory: '${_home_dir}'`;
|
|
163
|
-
_msg_info(
|
|
164
|
-
_msg);
|
|
165
|
-
_db_path =
|
|
166
|
-
_path_join(
|
|
167
|
-
[ _home_dir,
|
|
168
|
-
".config",
|
|
169
|
-
"evm-chains",
|
|
170
|
-
_db_name ]);
|
|
171
|
-
const
|
|
172
|
-
_db_exists =
|
|
173
|
-
_file_exists(
|
|
174
|
-
_db_path);
|
|
175
|
-
if ( _db_exists == true ) {
|
|
176
|
-
_msg =
|
|
177
|
-
`Found database '${_db_path}'.`;
|
|
178
|
-
_msg_info(
|
|
179
|
-
_msg);
|
|
180
|
-
}
|
|
181
|
-
else if ( _db_exists == false ) {
|
|
182
|
-
_msg =
|
|
183
|
-
`Database '${_db_path}' ` +
|
|
184
|
-
"not found";
|
|
185
|
-
_msg_info(
|
|
186
|
-
_msg);
|
|
187
|
-
// _user =
|
|
188
|
-
// "n";
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
_msg =
|
|
192
|
-
"wat";
|
|
193
|
-
_msg_error(
|
|
194
|
-
_msg);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
else if ( _user == "n" ) {
|
|
198
|
-
const
|
|
199
|
-
_lib =
|
|
200
|
-
_lib_get();
|
|
201
|
-
_db_path =
|
|
202
|
-
_path_join(
|
|
203
|
-
[ _lib,
|
|
204
|
-
"evm-chains",
|
|
205
|
-
_db_name ]);
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
_msg =
|
|
209
|
-
"Input variable '_user' must be a boolean. " +
|
|
210
|
-
`_user value is '${_user}'.`;
|
|
211
|
-
_msg_error(
|
|
212
|
-
_msg,
|
|
213
|
-
0);
|
|
214
|
-
}
|
|
215
|
-
return _db_path;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function
|
|
219
|
-
_evm_chain_info_get(
|
|
220
|
-
_chain_id,
|
|
221
|
-
_db_path,
|
|
222
|
-
_user_level,
|
|
223
|
-
_format,
|
|
224
|
-
_db_types) {
|
|
225
|
-
let
|
|
226
|
-
_chain_info,
|
|
227
|
-
_data,
|
|
228
|
-
_msg;
|
|
229
|
-
if ( typeof(
|
|
230
|
-
_user_level) == "undefined" ) {
|
|
231
|
-
_user_level =
|
|
232
|
-
false;
|
|
233
|
-
}
|
|
234
|
-
if ( typeof(
|
|
235
|
-
_format) == "undefined" ) {
|
|
236
|
-
_format =
|
|
237
|
-
"split";
|
|
238
|
-
}
|
|
239
|
-
if ( typeof(
|
|
240
|
-
_db_path) == "undefined" ) {
|
|
241
|
-
_db_path =
|
|
242
|
-
_evm_chains_db_path_get(
|
|
243
|
-
_user_level,
|
|
244
|
-
_chain_id,
|
|
245
|
-
_format);
|
|
246
|
-
}
|
|
247
|
-
const
|
|
248
|
-
_db_exists =
|
|
249
|
-
_file_exists(
|
|
250
|
-
_db_path);
|
|
251
|
-
if ( _db_exists == false ) {
|
|
252
|
-
if ( typeof window === 'undefined' &&
|
|
253
|
-
( typeof global !== 'undefined' && global.global === global ) &&
|
|
254
|
-
typeof __webpack_require__ !== 'function' ) {
|
|
255
|
-
_data =
|
|
256
|
-
_data_get(
|
|
257
|
-
_chain_id);
|
|
258
|
-
_msg =
|
|
259
|
-
`Displaying data for ` +
|
|
260
|
-
`chain '${_chain_id}' `+
|
|
261
|
-
`of type '${_db_types}'.`;
|
|
262
|
-
_msg_info(
|
|
263
|
-
_msg);
|
|
264
|
-
console.log(
|
|
265
|
-
_data);
|
|
266
|
-
}
|
|
267
|
-
// _msg_error(
|
|
268
|
-
// "Database file does not exists.",
|
|
269
|
-
// 1);
|
|
270
|
-
}
|
|
271
|
-
const
|
|
272
|
-
_db =
|
|
273
|
-
_json_read(
|
|
274
|
-
_db_path);
|
|
275
|
-
// _data =
|
|
276
|
-
// _data_get(
|
|
277
|
-
// _chain_id);
|
|
278
|
-
_msg =
|
|
279
|
-
`Displaying data for ` +
|
|
280
|
-
`chain '${_chain_id}' `+
|
|
281
|
-
`of type '${_db_types}'.`;
|
|
282
|
-
_msg_info(
|
|
283
|
-
_msg);
|
|
284
|
-
// console.log(
|
|
285
|
-
// _db);
|
|
286
|
-
for ( _chain_info of _db) {
|
|
287
|
-
if ( _chain_info["chainId"] == _chain_id ) {
|
|
288
|
-
return _chain_info;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
_msg_error(
|
|
292
|
-
`Network '${_chain_id}' not found.`,
|
|
293
|
-
1);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
function
|
|
297
|
-
_rpc_backend_get(
|
|
298
|
-
_network_chain_id,
|
|
299
|
-
_selection_method,
|
|
300
|
-
_db_path,
|
|
301
|
-
_user_level,
|
|
302
|
-
_db_types) {
|
|
303
|
-
if ( typeof(
|
|
304
|
-
_network_chain_id) == "undefined" ) {
|
|
305
|
-
const
|
|
306
|
-
_msg =
|
|
307
|
-
"Network's ChainID not specified.";
|
|
308
|
-
_msg_error(
|
|
309
|
-
_msg,
|
|
310
|
-
1);
|
|
311
|
-
}
|
|
312
|
-
if ( typeof(
|
|
313
|
-
_selection_method) == "undefined" ) {
|
|
314
|
-
_selection_method =
|
|
315
|
-
"kirsh";
|
|
316
|
-
}
|
|
317
|
-
if ( typeof(
|
|
318
|
-
_db_path) == "undefined" ) {
|
|
319
|
-
_db_path =
|
|
320
|
-
_evm_chains_db_path_get(
|
|
321
|
-
false);
|
|
322
|
-
}
|
|
323
|
-
if ( typeof(
|
|
324
|
-
_db_types) == "undefined" ) {
|
|
325
|
-
_db_types = [
|
|
326
|
-
"node",
|
|
327
|
-
"system"
|
|
122
|
+
_target_networks_auto_detect() {
|
|
123
|
+
// TODO:
|
|
124
|
+
// _evm_wallet_module.balance-discovery
|
|
125
|
+
if ( target_networks == "" ||
|
|
126
|
+
target_networks == [] ) {
|
|
127
|
+
// to be auto-detected
|
|
128
|
+
target_networks = [
|
|
129
|
+
"1"
|
|
328
130
|
];
|
|
329
131
|
}
|
|
330
|
-
if (
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
const
|
|
335
|
-
_chain_id =
|
|
336
|
-
Number(
|
|
337
|
-
_network_chain_id);
|
|
338
|
-
const
|
|
339
|
-
_chain_info =
|
|
340
|
-
_evm_chain_info_get(
|
|
341
|
-
_chain_id,
|
|
342
|
-
_db_path,
|
|
343
|
-
_user_level,
|
|
344
|
-
_db_types);
|
|
345
|
-
if ( _selection_method == "kirsh" ) {
|
|
346
|
-
return _chain_info["rpc"][0];
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
_msg_error(
|
|
350
|
-
"Unknown selection method.",
|
|
351
|
-
1);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
function _rpc_backends_get(
|
|
356
|
-
_networks_chain_ids,
|
|
357
|
-
_selection_method,
|
|
358
|
-
_db_path) {
|
|
359
|
-
let
|
|
360
|
-
_chain_id,
|
|
361
|
-
_rpc_backend_get_opts,
|
|
362
|
-
_rpc_backend;
|
|
363
|
-
if ( _selection_method == undefined ) {
|
|
364
|
-
_selection_method =
|
|
365
|
-
"kirsh";
|
|
366
|
-
}
|
|
367
|
-
if ( _db_path == undefined ) {
|
|
368
|
-
_db_path =
|
|
369
|
-
_evm_chains_db_path_get(
|
|
370
|
-
false);
|
|
371
|
-
}
|
|
372
|
-
const
|
|
373
|
-
_rpcs =
|
|
374
|
-
[];
|
|
375
|
-
for ( _chain_id of _networks_chain_ids ) {
|
|
376
|
-
_rpc_backend_get_opts = [
|
|
377
|
-
_chain_id,
|
|
378
|
-
_selection_method,
|
|
379
|
-
_db_path
|
|
380
|
-
];
|
|
381
|
-
_rpc_backend =
|
|
382
|
-
_rpc_backend_get.apply(
|
|
383
|
-
null,
|
|
384
|
-
_rpc_backend_get_opts);
|
|
385
|
-
_rpcs.push(
|
|
386
|
-
_rpc_backend);
|
|
387
|
-
}
|
|
388
|
-
return _rpcs;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
function
|
|
392
|
-
_db_path_check(
|
|
393
|
-
_db_path) {
|
|
394
|
-
if ( ! _file_exists(
|
|
395
|
-
_db_path) ) {
|
|
396
|
-
const
|
|
397
|
-
_msg =
|
|
398
|
-
`Database at ` +
|
|
399
|
-
`'${_db_path}' does not exist.`;
|
|
400
|
-
_msg_error(
|
|
401
|
-
_msg,
|
|
402
|
-
1);
|
|
132
|
+
if ( target_network == "" ) {
|
|
133
|
+
// to be auto-detected
|
|
134
|
+
target_network =
|
|
135
|
+
"1";
|
|
403
136
|
}
|
|
404
137
|
}
|
|
405
138
|
|
|
406
139
|
function
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
console.log(
|
|
410
|
-
_filter_output_type);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
function
|
|
414
|
-
_db_get(
|
|
415
|
-
_db_path,
|
|
416
|
-
_input_type,
|
|
417
|
-
_output_type,
|
|
418
|
-
_selection_method,
|
|
419
|
-
_api_key,
|
|
420
|
-
_networks_all,
|
|
421
|
-
_target_chain) {
|
|
422
|
-
let
|
|
423
|
-
_db,
|
|
424
|
-
_entry,
|
|
425
|
-
_filter,
|
|
426
|
-
_filter_key,
|
|
427
|
-
_filter_output_type,
|
|
428
|
-
_filter_value,
|
|
429
|
-
_results,
|
|
430
|
-
_msg;
|
|
431
|
-
_filter_output_type =
|
|
432
|
-
_output_type;
|
|
433
|
-
if ( _input_type == "id" ) {
|
|
434
|
-
/* eslint-disable-next-line
|
|
435
|
-
no-useless-assignment */
|
|
436
|
-
_filter_key =
|
|
437
|
-
"chainId";
|
|
438
|
-
_filter_value =
|
|
439
|
-
_target_chain;
|
|
440
|
-
_msg =
|
|
441
|
-
`Getting data for filter ` +
|
|
442
|
-
`key: '${_filter_key}' and value ` +
|
|
443
|
-
`'${_filter_value}'.`;
|
|
444
|
-
_msg_info(
|
|
445
|
-
_msg);
|
|
446
|
-
}
|
|
447
|
-
else if ( _input_type == "testnet" ) {
|
|
448
|
-
_msg =
|
|
449
|
-
"Like I have to agg a tag.";
|
|
450
|
-
_msg_info(
|
|
451
|
-
_msg);
|
|
452
|
-
}
|
|
453
|
-
if ( _output_type == "id" ) {
|
|
454
|
-
_filter_output_type =
|
|
455
|
-
"chainId";
|
|
456
|
-
}
|
|
457
|
-
else if ( _output_type == "rpc" ) {
|
|
458
|
-
_filter_output_type =
|
|
459
|
-
_output_type;
|
|
460
|
-
}
|
|
461
|
-
if ( _networks_all == "y" ) {
|
|
462
|
-
_filter =
|
|
463
|
-
_all_get(
|
|
464
|
-
_filter_output_type);
|
|
465
|
-
_msg =
|
|
466
|
-
"Showing results for all networks " +
|
|
467
|
-
`with filter '${_filter}'.`;
|
|
468
|
-
_msg_info(
|
|
469
|
-
_msg);
|
|
470
|
-
_db =
|
|
471
|
-
_json_read(
|
|
472
|
-
_db_path);
|
|
473
|
-
_msg =
|
|
474
|
-
"Showing results for all networks " +
|
|
475
|
-
`with filter '${_filter}'.`;
|
|
476
|
-
_msg_info(
|
|
477
|
-
_msg);
|
|
478
|
-
return _db;
|
|
479
|
-
}
|
|
480
|
-
else if ( _networks_all == "n" ) {
|
|
481
|
-
_results =
|
|
482
|
-
[];
|
|
483
|
-
_msg =
|
|
484
|
-
`Showing results for chain '${_target_chain}' in ` +
|
|
485
|
-
`database '${_db_path}' with filter '${_filter_output_type}'.`;
|
|
486
|
-
_msg_info(
|
|
487
|
-
_msg);
|
|
488
|
-
// this doesnt work the same in
|
|
489
|
-
// javascript as in bash i suppose.
|
|
490
|
-
// _filter =
|
|
491
|
-
// _filter_get(
|
|
492
|
-
// _filter_key,
|
|
493
|
-
// _filter_value,
|
|
494
|
-
// _filter_output_type);
|
|
495
|
-
// _json_read(
|
|
496
|
-
// _db_path);
|
|
497
|
-
_db =
|
|
498
|
-
_json_read(
|
|
499
|
-
_db_path);
|
|
500
|
-
_msg =
|
|
501
|
-
`Database '${_db_path}' ` +
|
|
502
|
-
`contains '${_db.length}' items.`;
|
|
503
|
-
_msg_info(
|
|
504
|
-
_msg);
|
|
505
|
-
for ( _entry of _db ) {
|
|
506
|
-
if ( _entry[
|
|
507
|
-
_filter_key] == _target_chain ) {
|
|
508
|
-
_results.push(
|
|
509
|
-
_entry);
|
|
510
|
-
if ( _selection_method == "kirsh" ) {
|
|
511
|
-
break;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
_msg =
|
|
516
|
-
`Total results returned for '${_db_path}' ` +
|
|
517
|
-
`are '${_results.length}'.`;
|
|
518
|
-
_msg_info(
|
|
519
|
-
_msg);
|
|
520
|
-
return _results;
|
|
521
|
-
}
|
|
140
|
+
_default_artifact_path_get() {
|
|
141
|
+
true;
|
|
522
142
|
}
|
|
523
143
|
|
|
524
144
|
function
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
if ( isNaN(target_chain) ) {
|
|
528
|
-
input_type =
|
|
529
|
-
"name";
|
|
530
|
-
}
|
|
531
|
-
else {
|
|
532
|
-
input_type =
|
|
533
|
-
"id";
|
|
534
|
-
}
|
|
535
|
-
}
|
|
145
|
+
_contract_artifacts_retrieve() {
|
|
146
|
+
true;
|
|
536
147
|
}
|
|
537
148
|
|
|
538
149
|
function
|
|
539
|
-
|
|
540
|
-
_chain_id) {
|
|
150
|
+
_contract_abi_auto_detect() {
|
|
541
151
|
let
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
_msg;
|
|
545
|
-
if ( user_level == "y" ) {
|
|
546
|
-
_type_primary =
|
|
547
|
-
true;
|
|
548
|
-
_type_fallback =
|
|
549
|
-
false;
|
|
550
|
-
}
|
|
551
|
-
else if ( user_level == "n" ) {
|
|
552
|
-
_type_primary =
|
|
553
|
-
true;
|
|
554
|
-
_type_fallback =
|
|
555
|
-
false;
|
|
556
|
-
}
|
|
152
|
+
_abi,
|
|
153
|
+
_abi_target;
|
|
557
154
|
const
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
_type_primary,
|
|
561
|
-
"",
|
|
562
|
-
"unified");
|
|
155
|
+
_network =
|
|
156
|
+
target_network;
|
|
563
157
|
const
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
_type_primary,
|
|
567
|
-
_chain_id,
|
|
568
|
-
"split");
|
|
158
|
+
_address =
|
|
159
|
+
contract_address;
|
|
569
160
|
const
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
_type_fallback,
|
|
573
|
-
"",
|
|
574
|
-
"unified");
|
|
161
|
+
_key =
|
|
162
|
+
api_key;
|
|
575
163
|
const
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
`adding.`;
|
|
589
|
-
_msg_info(
|
|
590
|
-
_msg);
|
|
591
|
-
}
|
|
592
|
-
else if ( ! _file_exists(
|
|
593
|
-
_db_split) ) {
|
|
594
|
-
_msg =
|
|
595
|
-
`Default per-network database ` +
|
|
596
|
-
`'${_db_split}' ` +
|
|
597
|
-
`not found, trying '${_db}'.`;
|
|
598
|
-
_msg_info(
|
|
599
|
-
_msg);
|
|
600
|
-
}
|
|
601
|
-
else {
|
|
602
|
-
_msg =
|
|
603
|
-
`wat`;
|
|
604
|
-
_msg_error(
|
|
605
|
-
_msg,
|
|
606
|
-
1);
|
|
607
|
-
}
|
|
608
|
-
if ( _file_exists(
|
|
609
|
-
_db) ) {
|
|
610
|
-
db_paths.push(
|
|
611
|
-
_db);
|
|
612
|
-
}
|
|
613
|
-
else {
|
|
614
|
-
_msg =
|
|
615
|
-
`Default unified database ` +
|
|
616
|
-
`'${_db_split}' ` +
|
|
617
|
-
`not found, trying '${_db}'.`;
|
|
618
|
-
_msg_info(
|
|
619
|
-
_msg);
|
|
620
|
-
}
|
|
621
|
-
if ( _file_exists(
|
|
622
|
-
_db_fallback_split) ) {
|
|
623
|
-
db_paths.push(
|
|
624
|
-
_db_fallback_split);
|
|
625
|
-
}
|
|
626
|
-
else {
|
|
627
|
-
_msg =
|
|
628
|
-
`Fallback per-network database ` +
|
|
629
|
-
`'${_db_fallback_split}' ` +
|
|
630
|
-
`not found, trying '${_db_fallback}'.`;
|
|
631
|
-
_msg_info(
|
|
632
|
-
_msg);
|
|
633
|
-
}
|
|
634
|
-
if ( _file_exists(
|
|
635
|
-
_db_fallback) ) {
|
|
636
|
-
db_paths.push(
|
|
637
|
-
_db_fallback);
|
|
638
|
-
}
|
|
639
|
-
else {
|
|
640
|
-
_msg =
|
|
641
|
-
`Fallback database ` +
|
|
642
|
-
`'${_db_fallback_split}' ` +
|
|
643
|
-
`not found too!`;
|
|
644
|
-
_msg_error(
|
|
645
|
-
_msg,
|
|
646
|
-
1);
|
|
164
|
+
_compiler_output =
|
|
165
|
+
contract_compiler_output;
|
|
166
|
+
_abi =
|
|
167
|
+
contract_abi;
|
|
168
|
+
_abi_target =
|
|
169
|
+
_abi;
|
|
170
|
+
if ( typeof(
|
|
171
|
+
_abi_target) == "undefined" ||
|
|
172
|
+
_abi_target == "" ) {
|
|
173
|
+
_abi_target =
|
|
174
|
+
_default_artifact_path_get(
|
|
175
|
+
"abi");
|
|
647
176
|
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
let
|
|
661
|
-
_db,
|
|
662
|
-
_db_path,
|
|
663
|
-
_entry,
|
|
664
|
-
_msg,
|
|
665
|
-
_networks_total,
|
|
666
|
-
_results;
|
|
667
|
-
_networks_total =
|
|
668
|
-
0;
|
|
669
|
-
if ( _retrieval_mode == "offline" ) {
|
|
670
|
-
_msg =
|
|
671
|
-
`Getting data from databases ` +
|
|
672
|
-
`'${_db_paths}'`;
|
|
673
|
-
_msg_info(
|
|
674
|
-
_msg);
|
|
675
|
-
for ( _db_path of _db_paths ) {
|
|
676
|
-
_msg =
|
|
677
|
-
`Looking in '${_db_path}'.`;
|
|
678
|
-
_msg_info(
|
|
679
|
-
_msg);
|
|
680
|
-
_db_path_check(
|
|
681
|
-
_db_path);
|
|
682
|
-
if ( _input_type != "amount" ) {
|
|
683
|
-
_db =
|
|
684
|
-
_db_get(
|
|
685
|
-
_db_path,
|
|
686
|
-
_input_type,
|
|
687
|
-
_output_type,
|
|
688
|
-
_selection_method,
|
|
689
|
-
_api_key,
|
|
690
|
-
_networks_all,
|
|
691
|
-
_target_chain);
|
|
692
|
-
if ( _selection_method == "kirsh" ) {
|
|
693
|
-
break;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
else if ( _input_type == "amount" ) {
|
|
697
|
-
_db =
|
|
698
|
-
_json_read(
|
|
699
|
-
_db_path);
|
|
700
|
-
_networks_total =
|
|
701
|
-
_db.length;
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
if ( _input_type != "amount" ) {
|
|
705
|
-
_networks_total =
|
|
706
|
-
_db.length;
|
|
707
|
-
if ( _db.length == 0 ) {
|
|
708
|
-
_msg =
|
|
709
|
-
`No results found for network ` +
|
|
710
|
-
`'${_target_chain}'.`;
|
|
711
|
-
_msg_error(
|
|
712
|
-
_msg,
|
|
713
|
-
0);
|
|
714
|
-
}
|
|
715
|
-
const
|
|
716
|
-
_results =
|
|
717
|
-
[];
|
|
718
|
-
for ( _entry of _db ) {
|
|
719
|
-
if ( _entry['chainId'] == _target_chain ) {
|
|
720
|
-
_results.push(
|
|
721
|
-
_entry[
|
|
722
|
-
_output_type]);
|
|
723
|
-
if ( _selection_method != "all" ) {
|
|
724
|
-
break;
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
_db =
|
|
729
|
-
_results;
|
|
730
|
-
_msg =
|
|
731
|
-
`Found '${_networks_total}' ` +
|
|
732
|
-
`networks in database '${_db_path}'.`;
|
|
733
|
-
_msg_info(
|
|
734
|
-
_msg);
|
|
177
|
+
const
|
|
178
|
+
_abi_dir =
|
|
179
|
+
_dirname(
|
|
180
|
+
_abi);
|
|
181
|
+
if ( ! _file_exists(
|
|
182
|
+
_abi) &&
|
|
183
|
+
! _file_exists(
|
|
184
|
+
_compiler_output) ) {
|
|
185
|
+
if ( _file_exists(
|
|
186
|
+
_abi_target) ) {
|
|
187
|
+
_abi =
|
|
188
|
+
_abi_target;
|
|
735
189
|
}
|
|
736
|
-
else
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
_msg_info(
|
|
740
|
-
_msg);
|
|
741
|
-
return _networks_total;
|
|
190
|
+
else {
|
|
191
|
+
_contract_artifacts_retrieve(
|
|
192
|
+
_abi_dir);
|
|
742
193
|
}
|
|
743
194
|
}
|
|
744
|
-
else if ( _retrieval_mode == "online" ) {
|
|
745
|
-
_msg =
|
|
746
|
-
`About to implement it probably.`;
|
|
747
|
-
_msg_error(
|
|
748
|
-
_msg,
|
|
749
|
-
1);
|
|
750
|
-
}
|
|
751
|
-
return _db;
|
|
752
195
|
}
|
|
753
196
|
|
|
754
197
|
function
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
_msg);
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
function
|
|
767
|
-
_evm_chains_info(
|
|
768
|
-
_target_command,
|
|
769
|
-
_input_type,
|
|
770
|
-
_output_type,
|
|
771
|
-
_retrieval_mode,
|
|
772
|
-
_selection_method,
|
|
198
|
+
_evm_contract_call(
|
|
199
|
+
_call_type,
|
|
200
|
+
_call_timeout,
|
|
201
|
+
_wallet_name,
|
|
202
|
+
_wallet_path,
|
|
203
|
+
_wallet_password,
|
|
204
|
+
_wallet_seed,
|
|
773
205
|
_api_key,
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
206
|
+
_msg_value,
|
|
207
|
+
_price_gas,
|
|
208
|
+
_measure_unit,
|
|
209
|
+
_retries_max,
|
|
210
|
+
_target_networks,
|
|
211
|
+
_rpc_selection,
|
|
212
|
+
_contract_address,
|
|
213
|
+
_contract_abi,
|
|
214
|
+
_contract_bytecode,
|
|
215
|
+
_contract_compiler_output,
|
|
216
|
+
_contract_method,
|
|
217
|
+
_method_args) {
|
|
777
218
|
let
|
|
778
219
|
_explorer,
|
|
779
220
|
_result,
|
|
780
221
|
_rpc;
|
|
781
|
-
if (
|
|
222
|
+
if ( _call_type == "static" ) {
|
|
782
223
|
const
|
|
783
224
|
_infos =
|
|
784
225
|
[];
|
|
785
|
-
const
|
|
786
|
-
_results =
|
|
787
|
-
_evm_chains_info_get(
|
|
788
|
-
_target_chain,
|
|
789
|
-
_retrieval_mode,
|
|
790
|
-
_input_type,
|
|
791
|
-
_output_type,
|
|
792
|
-
_selection_method,
|
|
793
|
-
_networks_all,
|
|
794
|
-
_api_key,
|
|
795
|
-
_db_paths);
|
|
796
|
-
if ( _output_type == "rpc" ) {
|
|
797
|
-
for ( _result of _results ) {
|
|
798
|
-
for ( _rpc of _result) {
|
|
799
|
-
_infos.push(
|
|
800
|
-
_rpc);
|
|
801
|
-
if ( _selection_method == "kirsh" ) {
|
|
802
|
-
break;
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
return _infos;
|
|
807
|
-
}
|
|
808
|
-
else if ( _output_type == "name" ) {
|
|
809
|
-
return _results;
|
|
810
|
-
}
|
|
811
|
-
else if ( _output_type == "id" ) {
|
|
812
|
-
return _results;
|
|
813
|
-
}
|
|
814
|
-
else if ( _output_type == "explorers" ) {
|
|
815
|
-
for ( _result of _results ) {
|
|
816
|
-
for ( _explorer of _result ) {
|
|
817
|
-
_infos.push(
|
|
818
|
-
_explorer[
|
|
819
|
-
"url"]);
|
|
820
|
-
if ( _selection_method == "kirsh" ) {
|
|
821
|
-
break;
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
return _infos;
|
|
826
|
-
}
|
|
827
226
|
}
|
|
828
|
-
else if (
|
|
829
|
-
|
|
830
|
-
_input_type);
|
|
227
|
+
else if ( _call_type == "dynamic" ) {
|
|
228
|
+
true;
|
|
831
229
|
}
|
|
832
230
|
else {
|
|
833
231
|
const
|
|
834
232
|
_msg =
|
|
835
|
-
`Unknown
|
|
836
|
-
`'${
|
|
233
|
+
`Unknown call type ` +
|
|
234
|
+
`'${_call_type}'.`;
|
|
837
235
|
_msg_error(
|
|
838
236
|
_msg,
|
|
839
237
|
1);
|
|
@@ -841,22 +239,12 @@ function
|
|
|
841
239
|
}
|
|
842
240
|
|
|
843
241
|
module.exports = {
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
_evm_chains_info_get:
|
|
853
|
-
_evm_chains_info_get,
|
|
854
|
-
_evm_chains_info_set:
|
|
855
|
-
_evm_chains_info_set,
|
|
856
|
-
_input_type_auto_detect:
|
|
857
|
-
_input_type_auto_detect,
|
|
858
|
-
_rpc_backend_get:
|
|
859
|
-
_rpc_backend_get,
|
|
860
|
-
_rpc_backends_get:
|
|
861
|
-
_rpc_backends_get
|
|
242
|
+
_contract_abi_auto_detect:
|
|
243
|
+
_contract_abi_auto_detect,
|
|
244
|
+
_default_artifact_path_get:
|
|
245
|
+
_default_artifact_path_get,
|
|
246
|
+
_evm_contract_call:
|
|
247
|
+
_evm_contract_call,
|
|
248
|
+
_target_networks_auto_detect:
|
|
249
|
+
_target_networks_auto_detect
|
|
862
250
|
};
|