evm-contracts-tools 0.0.13 → 0.0.16

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  // SPDX-License-Identifier: AGPL-3.0-or-later
4
4
 
5
5
  /** ----------------------------------------------------------------
6
- * evm-chains-info.js
6
+ * evm-contract-call.js
7
7
  * ----------------------------------------------------------------
8
8
  * Copyright ©
9
9
  * Pellegrino Prevete
@@ -42,9 +42,21 @@
42
42
  /* global
43
43
  target_network:
44
44
  writable */
45
+ /* global
46
+ target_networks:
47
+ writable */
45
48
  /* global
46
49
  api_key:
47
50
  writable */
51
+ /* global
52
+ wallet_path:
53
+ writable */
54
+ /* global
55
+ wallet_password:
56
+ writable */
57
+ /* global
58
+ wallet_seed:
59
+ writable */
48
60
 
49
61
  const
50
62
  _libcrash =
@@ -123,6 +135,11 @@ const
123
135
  const
124
136
  _default_artifact_path_get =
125
137
  _libevm_contract_call_module._default_artifact_path_get;
138
+ /* global
139
+ _contract_abi_auto_detect */
140
+ const
141
+ _contract_abi_auto_detect =
142
+ _libevm_contract_call_module._contract_abi_auto_detect;
126
143
  /* global
127
144
  _evm_contract_call */
128
145
  const
@@ -233,7 +250,6 @@ function
233
250
  "";
234
251
  }
235
252
 
236
-
237
253
  function
238
254
  _overrides_set() {
239
255
  if ( call_date == "" ) {
@@ -252,11 +268,6 @@ function
252
268
  retries_max =
253
269
  "300";
254
270
  }
255
- if ( target_network == "" ) {
256
- // to be auto-detected
257
- target_network =
258
- "1";
259
- }
260
271
  if ( rpc_selection == "" ) {
261
272
  rpc_selection =
262
273
  "kirsh";
@@ -323,7 +334,7 @@ function
323
334
  ` Call timeout: ${call_timeout}`,
324
335
  ` API key: ${api_key}`,
325
336
  ` RPC selection method: ${rpc_selection}`,
326
- ` Gas price: ${gas_price}`,
337
+ ` Gas price: ${price_gas}`,
327
338
  ` Contract options:`,
328
339
  ` Contract address: ${contract_address}`,
329
340
  ` Contract ABI: ${contract_abi}`,
@@ -348,47 +359,93 @@ function
348
359
  _line;
349
360
  const
350
361
  _text = [
351
- "Returns info about EVM blockchains.",
362
+ "Runs a smart contract function.",
352
363
  "",
353
364
  "Usage:",
354
365
  "",
355
- " evm-chains-info.js",
366
+ " evm-contract-call.js",
356
367
  " [options]",
357
- " <target-chain>",
368
+ " <contract-address>",
369
+ " <contract-method>",
370
+ " ([method-args])",
371
+ "",
372
+ " networks:",
373
+ " all those supported by",
374
+ " 'evm-chains-info' as well",
375
+ " as directly RPC addresses",
358
376
  "",
359
377
  " options:",
360
378
  "",
361
- " -C --command Target command. Can be 'get' or 'set'.",
362
- ` <target-command> Default: '${target_command}`,
379
+ " -t --call-type It can be 'static' or 'dynamic'.",
380
+ ` <call-type> Default: '${call_type}`,
381
+ "",
382
+ " call options:",
383
+ ` -V --msg-value How much '${measure_unit} to attach to the`,
384
+ ` <msg-value> transaction.`,
385
+ ` Default: '${msg_value}'`,
386
+ "",
387
+ " -u --measure-unit Measure unit for the transacion.",
388
+ ` <measure-unit> It can be 'ether' or 'wei'.`,
389
+ ` Default: '${measure_unit}'`,
390
+ "",
391
+ " -P --price-gas I dont remember. It can be 'idontknow'.",
392
+ " <price-gas>",
393
+ ` Default: '${price_gas}'`,
394
+ "",
395
+ " -r --retries-max Maximum number of retries before",
396
+ ` <retries-max> Declaring the call failed.`,
397
+ ` Default: '${retries_max}'`,
398
+ "",
399
+ " -T --call-timeout Maximum number of milliseconds before",
400
+ " <call-timeout> declaring the call failed.",
401
+ ` Default: '${call_timeout}'`,
363
402
  "",
364
- " -i --input-type Input type. It can be 'id' or 'name'.",
365
- ` <input-type> Default: '${input_type}'`,
403
+ " contract options:",
366
404
  "",
367
- " -o --output-type Output type. It can be 'id', 'name',",
368
- " <output-type> 'rpc', 'explorers'.",
369
- ` Default: '${output_type}'`,
405
+ " -A --abi Contract ABI path.",
406
+ ` <contract-abi> Default: '${contract_abi}'.`,
370
407
  "",
371
- " -m --retrieval-mode It can be 'offline'.",
372
- ` <retrieval-mode> Default: '${retrieval_mode}'`,
408
+ " -B --bytecode Contract bytecode path.",
409
+ ` <contract-bytecode> Default: '${contract_bytecode}'.`,
373
410
  "",
374
- " -u --user-level It can be 'y' or 'n'.",
375
- ` <user-level> Default: '${user_level}'`,
411
+ " -C --compiler-output Contract compiler output path",
412
+ ` <contract-bytecode> (the hardhat artifact.`,
413
+ ` Default: '${contract_compiler_output}'.`,
376
414
  "",
377
- " -d --db-path Path of the chains' info json file",
378
- " <db-path> to be used for 'offline' retrieval.",
379
- ` Default: '${db_paths}'`,
415
+ " -I --index-retrieve Enables retrieving contract's artifacts",
416
+ ` from the EVM Contracts Source Index.`,
417
+ ` Default: '${contract_compiler_output}'.`,
380
418
  "",
381
- " -s --selection-method When output type is 'rpc',",
382
- " <selection-method> selection criterion to use when",
383
- " more than one is available.",
384
- " It can be 'kirsh', 'random' or 'all'.",
385
- ` Default: '${selection_method}'`,
419
+ " credentials options:",
386
420
  "",
387
- " -k If selected, when output type is 'rpc',",
388
- " includes the ones requiring an API key.",
389
- ` Default: '${api_key}'`,
390
- " -a --all Whether to show results for all networks.",
391
- ` Default: '${networks_all}'`,
421
+ " -N --wallet-name EVM Wallet name.",
422
+ ` <wallet-name> Default: '${wallet_name}'.`,
423
+ "",
424
+ " -w --wallet-path EVM Wallet path.",
425
+ ` <wallet-path> Default: '${wallet_path}'.`,
426
+ "",
427
+ " -p --wallet-password EVM Wallet password file.",
428
+ ` <wallet-password> Default: '${wallet_password}'.`,
429
+ "",
430
+ " -s --wallet-seed EVM Wallet seed file.",
431
+ ` <wallet-seed> Default: '${wallet_seed}'.`,
432
+ "",
433
+ " -k --api-key Etherscan-like service key file.",
434
+ ` <api-key> Default: '${api_key}'.`,
435
+ "",
436
+ " libEVM options:",
437
+ "",
438
+ " -a --auth Call authentication.",
439
+ ` Default: '${call_auth}'`,
440
+ "",
441
+ " -n --network EVM network name. Accepted",
442
+ " <network> values are all those supported by",
443
+ ` 'evm-chains-info' and RPC addresses.`,
444
+ ` Default: '${target_network}'.`,
445
+ "",
446
+ " -S --rpc-selection RPC selection method. It can be",
447
+ " <rpc-selection> 'kirsh', 'random' or 'all'.",
448
+ ` Default: '${rpc_selection}'.`,
392
449
  "",
393
450
  " -h --help This message.",
394
451
  " -v --verbose Enable verbose output."
@@ -409,8 +466,12 @@ function
409
466
  const
410
467
  _argv_args = {
411
468
  "booleans": [
469
+ "a",
470
+ "auth",
412
471
  "h",
413
472
  "help",
473
+ "I",
474
+ "index-retrieve",
414
475
  "v",
415
476
  "verbose"
416
477
  ]
@@ -483,7 +544,8 @@ function
483
544
  0];
484
545
  const
485
546
  method_args =
486
- _out.slice(
547
+ _argv[
548
+ "_"].slice(
487
549
  2,
488
550
  _argv[
489
551
  "_"].length - 2);
@@ -572,26 +634,36 @@ function
572
634
  _argv[
573
635
  "A"];
574
636
  }
575
- if ( "contract-abi" in _argv ) {
637
+ if ( "abi" in _argv ) {
576
638
  contract_abi =
577
639
  _argv[
578
- "contract-abi"];
640
+ "abi"];
641
+ }
642
+ if ( "B" in _argv ) {
643
+ contract_bytecode =
644
+ _argv[
645
+ "B"];
646
+ }
647
+ if ( "bytecode" in _argv ) {
648
+ contract_bytecode =
649
+ _argv[
650
+ "bytecode"];
579
651
  }
580
652
  if ( "C" in _argv ) {
581
653
  contract_compiler_output =
582
654
  _argv[
583
655
  "C"];
584
656
  }
585
- if ( "contract-compiler-output" in _argv ) {
657
+ if ( "compiler-output" in _argv ) {
586
658
  contract_compiler_output =
587
659
  _argv[
588
- "contract-compiler-output"];
660
+ "compiler-output"];
589
661
  }
590
662
  if ( "a" in _argv ) {
591
663
  call_auth =
592
664
  "y";
593
665
  }
594
- if ( "call-auth" in _argv ) {
666
+ if ( "auth" in _argv ) {
595
667
  call_auth =
596
668
  "y";
597
669
  }
@@ -621,6 +693,9 @@ function
621
693
 
622
694
  function
623
695
  _url_parse() {
696
+ let
697
+ _method,
698
+ _network;
624
699
  runtime_environment =
625
700
  "browser";
626
701
  call_type =
@@ -657,11 +732,15 @@ function
657
732
  0];
658
733
  contract_abi =
659
734
  _argv_url_get(
660
- "contract_abi")[
735
+ "abi")[
736
+ 0];
737
+ contract_bytecode =
738
+ _argv_url_get(
739
+ "bytecode")[
661
740
  0];
662
741
  contract_compiler_output =
663
742
  _argv_url_get(
664
- "contract_compiler_output")[
743
+ "compiler_output")[
665
744
  0];
666
745
  rpc_selection =
667
746
  _argv_url_get(
package/fs-worker.js ADDED
@@ -0,0 +1 @@
1
+ (()=>{var e={816(e,o,n){function t(){let e;return"undefined"==typeof window&&void 0!==n.g&&n.g.global===n.g&&"function"!=typeof n||(e=function(){let e;try{e=n(816)}catch(e){console.log(e);const o="Error importing the '@themartiancompany/opfs' module as 'opfs'. If you got this error while bundling a webpack for a project depending on this module double check its 'webpack.config.js' file or whether the 'opfs' module is listed in developer dependencies and install them.I'm sorry for this inconvenience but Node packagement system does not currently distinguish 'development' from 'build' dependencies.";throw console.error(o),e}return e}()),e}const r=t();e.exports=r,e.exports.getModule=function(e){let o;if(""==_module_name||"undefined"==typeof _module_name)o=t();else if("opfs"==_module_name)o=n(816);else{if("fs"!=_module_name){const e="Unknown file system module "+`'${_module_name}'.`.const;throw _error={msg:e},console.error(e),_error}o=n(816)}return o}},314(e,o,n){const t=n(816);_sync_agent=t.startSyncAgent,e.exports={_sync_agent},_sync_agent()}},o={};function n(t){var r=o[t];if(void 0!==r)return r.exports;var s=o[t]={exports:{}};return e[t](s,s.exports,n),s.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n(314)})();
@@ -178,9 +178,7 @@ async function
178
178
  function
179
179
  _config_show() {
180
180
  let
181
- _line,
182
- _method_args,
183
- _text;
181
+ _line;
184
182
  const
185
183
  _text = [
186
184
  "deployer-get configuration:",
File without changes
File without changes
@@ -33,32 +33,44 @@
33
33
  /* eslint-disable
34
34
  no-useless-assignment */
35
35
 
36
+ /* libEVM global variables */
36
37
  /* global
37
- db_paths */
38
+ api_key */
38
39
  /* global
39
- input_type:
40
- writable */
40
+ contract_abi */
41
+ /* global
42
+ contract_address */
41
43
  /* global
42
- user_level */
44
+ contract_compiler_output */
43
45
  /* global
44
- target_chain */
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
- _homedir_get */
57
+ _dirname */
52
58
  /* eslint-disable-next-line
53
59
  no-global-assign */
54
- _homedir_get =
55
- _libcrash_module._homedir_get;
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
- _evm_chains_db_path_get(
111
- _user,
112
- _chain_id,
113
- _format) {
114
- let
115
- _db_name,
116
- _db_path,
117
- _msg;
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 ( _user_level == undefined ) {
331
- _user_level =
332
- true;
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
- _all_get(
408
- _filter_output_type) {
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
- _input_type_auto_detect() {
526
- if ( input_type == "" ) {
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
- _db_paths_auto_detect(
540
- _chain_id) {
150
+ _contract_abi_auto_detect() {
541
151
  let
542
- _type_primary,
543
- _type_fallback,
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
- _db =
559
- _evm_chains_db_path_get(
560
- _type_primary,
561
- "",
562
- "unified");
155
+ _network =
156
+ target_network;
563
157
  const
564
- _db_split =
565
- _evm_chains_db_path_get(
566
- _type_primary,
567
- _chain_id,
568
- "split");
158
+ _address =
159
+ contract_address;
569
160
  const
570
- _db_fallback =
571
- _evm_chains_db_path_get(
572
- _type_fallback,
573
- "",
574
- "unified");
161
+ _key =
162
+ api_key;
575
163
  const
576
- _db_fallback_split =
577
- _evm_chains_db_path_get(
578
- _type_fallback,
579
- _chain_id,
580
- "split");
581
- if ( _file_exists(
582
- _db_split) ) {
583
- db_paths.push(
584
- _db_split);
585
- _msg =
586
- `Found database ` +
587
- `'${_db_split}', ` +
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
- function
651
- _evm_chains_info_get(
652
- _target_chain,
653
- _retrieval_mode,
654
- _input_type,
655
- _output_type,
656
- _selection_method,
657
- _api_key,
658
- _networks_all,
659
- _db_paths) {
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 if ( _input_type == "amount" ) {
737
- _msg =
738
- `Found '${_networks_total}' networks.`;
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
- _evm_chains_info_set(
756
- _input_type) {
757
- const
758
- _msg =
759
- `Setting value for type '${_input_type}'.`;
760
- if ( _input_type == "id" ) {
761
- _msg_info(
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
- _networks_all,
775
- _target_chain,
776
- _db_paths) {
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 ( _target_command == "get" ) {
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 ( _target_command == "set" ) {
829
- _evm_chains_info_set(
830
- _input_type);
227
+ else if ( _call_type == "dynamic" ) {
228
+ true;
831
229
  }
832
230
  else {
833
231
  const
834
232
  _msg =
835
- `Unknown command ` +
836
- `'${_target_command}'.`;
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
- _data_get:
845
- _data_get,
846
- _db_paths_auto_detect:
847
- _db_paths_auto_detect,
848
- _evm_chains_db_path_get:
849
- _evm_chains_db_path_get,
850
- _evm_chains_info:
851
- _evm_chains_info,
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  { "name": "evm-contracts-tools",
2
2
  "version":
3
- "0.0.13",
3
+ "0.0.16",
4
4
  "description":
5
5
  "JavaScript programs and libraries to enable seamless development of native computer applications designed to interact with Ethereum Virtual Machine-compatible networks.",
6
6
  "funding": {