evm-contracts-tools 0.0.32 → 0.0.34

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/Makefile ADDED
@@ -0,0 +1,223 @@
1
+ # SPDX-License-Identifier: AGPL-3.0
2
+
3
+ # -----------------------------------------------------
4
+ # Copyright © 2024, 2025, 2026 Pellegrino Prevete
5
+ #
6
+ # All rights reserved
7
+ # -----------------------------------------------------
8
+ #
9
+ # This program is free software: you can redistribute
10
+ # it and/or modify it under the terms of the
11
+ # GNU Affero General Public License as published by
12
+ # the Free Software Foundation, either version 3 of
13
+ # the License, or (at your option) any later version.
14
+ #
15
+ # This program is distributed in the hope that it
16
+ # will be useful, but WITHOUT ANY WARRANTY;
17
+ # without even the implied warranty of
18
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
+ # See the GNU Affero General Public License for
20
+ # more details.
21
+ #
22
+ # You should have received a copy of the
23
+ # GNU Affero General Public License
24
+ # along with this program.
25
+ # If not, see <https://www.gnu.org/licenses/>.
26
+
27
+ SHELL=bash
28
+ PREFIX ?= /usr/local
29
+ _PROJECT_NPM=evm-contracts-tools
30
+ _PROJECT=$(_PROJECT_NPM).js
31
+ _NAMESPACE=themartiancompany
32
+ DOC_DIR=$(DESTDIR)$(PREFIX)/share/doc/$(_PROJECT_NPM)
33
+ USR_DIR=$(DESTDIR)$(PREFIX)
34
+ BIN_DIR=$(DESTDIR)$(PREFIX)/bin
35
+ LIB_DIR=$(DESTDIR)$(PREFIX)/lib/$(_PROJECT_NPM)
36
+ MAN_DIR?=$(DESTDIR)$(PREFIX)/share/man
37
+ NODE_DIR=$(PREFIX)/lib/node_modules/$(_PROJECT_NPM)
38
+ BUILD_NPM_DIR=build
39
+
40
+ _INSTALL_FILE=\
41
+ install \
42
+ -vDm644
43
+ _INSTALL_EXE=\
44
+ install \
45
+ -vDm755
46
+ _INSTALL_DIR=\
47
+ install \
48
+ -vdm755
49
+
50
+ DOC_FILES=\
51
+ $(wildcard \
52
+ *.rst) \
53
+ $(wildcard \
54
+ *.md)
55
+ NPM_FILES=\
56
+ "README.md" \
57
+ "COPYING" \
58
+ "AUTHORS.rst" \
59
+ "Makefile" \
60
+ "dist" \
61
+ "evm-contract-call" \
62
+ "evm-contract-call.webpack.config.cjs" \
63
+ "lib" \
64
+ "libevm-contract-call" \
65
+ "libevm-contract-call.webpack.config.cjs" \
66
+ "$(_PROJECT_NPM)" \
67
+ "eslint.config.mjs" \
68
+ "fs-worker.webpack.config.cjs" \
69
+ "package.json" \
70
+ "webpack.config.cjs"
71
+
72
+ MAN_FILES=\
73
+ evm-contract-bytecode-get \
74
+ evm-contract-call \
75
+ evm-contract-deployer-get
76
+
77
+ all: build-man build-npm build-scripts
78
+
79
+ check: eslint
80
+
81
+ eslint:
82
+
83
+ npm \
84
+ install \
85
+ --save-dev; \
86
+ npx \
87
+ eslint \
88
+ "."
89
+
90
+ install: install-scripts install-doc install-examples install-man
91
+
92
+ install-scripts:
93
+
94
+ $(_INSTALL_DIR) \
95
+ "$(LIB_DIR)/nodejs/lib"
96
+ for _file in $(NPM_FILES); do
97
+ $(_INSTALL_FILE) \
98
+ "$${_file}" \
99
+ "$(LIB_DIR)/nodejs/$${_file}"; \
100
+ ln \
101
+ -s \
102
+ "$(PREFIX)/lib/$(_PROJECT_NPM)/nodejs/$${_file}" \
103
+ "$(LIB_DIR)/$${_file}" || \
104
+ true; \
105
+ done
106
+ # ln \
107
+ # -s \
108
+ # "$(PREFIX)/lib/$(_PROJECT_NPM)/node/lib$(_PROJECT_NPM)" \
109
+ # "$(LIB_DIR)/$(_PROJECT_NPM)-js" || \
110
+ # true
111
+
112
+ build-man:
113
+
114
+ git \
115
+ submodule \
116
+ update \
117
+ --init \
118
+ "man" || \
119
+ true; \
120
+ _version="$$( \
121
+ npm \
122
+ view \
123
+ "$${PWD}" \
124
+ "version")"; \
125
+ cd \
126
+ "man"; \
127
+ make \
128
+ _VERSION="$${_version}" \
129
+ build-man
130
+ mkdir \
131
+ -p \
132
+ "build/man"
133
+ cp \
134
+ -r \
135
+ "man/build/"* \
136
+ "build/man"
137
+
138
+ build-npm:
139
+
140
+ make \
141
+ build-man
142
+ for _file in $(NPM_FILES); do \
143
+ if [[ -d "$${_file}" ]]; then \
144
+ mkdir \
145
+ -p \
146
+ "build/$${_file}"; \
147
+ cp \
148
+ -r \
149
+ "$${_file}/"* \
150
+ "build/$${_file}"; \
151
+ elif [[ -e "$${_file}" ]]; then \
152
+ cp \
153
+ "$${_file}" \
154
+ "build"; \
155
+ fi; \
156
+ done
157
+ cd \
158
+ "build"; \
159
+ _version="$$( \
160
+ npm \
161
+ view \
162
+ "$${PWD}" \
163
+ "version")"; \
164
+ npm \
165
+ install; \
166
+ npm \
167
+ run \
168
+ "build"; \
169
+ npm \
170
+ pack; \
171
+ mv \
172
+ "$(_PROJECT_NPM)-$${_version}.tgz" \
173
+ ".."
174
+
175
+ install-npm:
176
+
177
+ _npm_opts=( \
178
+ -g \
179
+ --prefix \
180
+ '$(USR_DIR)' \
181
+ ); \
182
+ _version="$$( \
183
+ npm \
184
+ view \
185
+ "$${PWD}" \
186
+ "version")"; \
187
+ npm \
188
+ install \
189
+ "$${_npm_opts[@]}" \
190
+ "$(_PROJECT_NPM)-$${_version}.tgz"; \
191
+ $(_INSTALL_DIR) \
192
+ "$(DESTDIR)$(PREFIX)/lib"; \
193
+ ln \
194
+ -s \
195
+ "$(NODE_DIR)" \
196
+ "$(LIB_DIR)" || \
197
+ true
198
+
199
+ publish-npm:
200
+
201
+ cd \
202
+ "build"; \
203
+ npm \
204
+ publish \
205
+ --access \
206
+ "public"
207
+
208
+ install-doc:
209
+
210
+ $(_INSTALL_FILE) \
211
+ $(DOC_FILES) \
212
+ -t \
213
+ $(DOC_DIR)
214
+
215
+ install-man:
216
+
217
+ $(_INSTALL_DIR) \
218
+ "$(MAN_DIR)/man1"
219
+ $(_INSTALL_FILE) \
220
+ "build/man/$(_PROJECT_NPM).1" \
221
+ "$(MAN_DIR)/man1/$(_PROJECT_NPM).1"
222
+
223
+ .PHONY: check build-man build-npm build-scripts install install-doc install-man install-npm install-scripts shellcheck
@@ -0,0 +1,24 @@
1
+ <!--
2
+ SPDX-License-Identifier: AGPL-3.0-or-later
3
+
4
+ ----------------------------------------------------------------------
5
+ Copyright © 2024, 2025, 2026 Pellegrino Prevete
6
+
7
+ All rights reserved
8
+ ----------------------------------------------------------------------
9
+
10
+ This program is free software: you can redistribute it and/or modify
11
+ it under the terms of the GNU Affero General Public License as published by
12
+ the Free Software Foundation, either version 3 of the License, or
13
+ (at your option) any later version.
14
+
15
+ This program is distributed in the hope that it will be useful,
16
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ GNU Affero General Public License for more details.
19
+
20
+ You should have received a copy of the GNU Affero General Public License
21
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
22
+ -->
23
+
24
+ <script src="evm-contract-call.js"></script>
@@ -0,0 +1,24 @@
1
+ <!--
2
+ SPDX-License-Identifier: AGPL-3.0-or-later
3
+
4
+ ----------------------------------------------------------------------
5
+ Copyright © 2024, 2025, 2026 Pellegrino Prevete
6
+
7
+ All rights reserved
8
+ ----------------------------------------------------------------------
9
+
10
+ This program is free software: you can redistribute it and/or modify
11
+ it under the terms of the GNU Affero General Public License as published by
12
+ the Free Software Foundation, either version 3 of the License, or
13
+ (at your option) any later version.
14
+
15
+ This program is distributed in the hope that it will be useful,
16
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ GNU Affero General Public License for more details.
19
+
20
+ You should have received a copy of the GNU Affero General Public License
21
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
22
+ -->
23
+
24
+ <script src="evm-contracts-tools.js"></script>
@@ -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)})();
@@ -0,0 +1,24 @@
1
+ <!--
2
+ SPDX-License-Identifier: AGPL-3.0-or-later
3
+
4
+ ----------------------------------------------------------------------
5
+ Copyright © 2024, 2025, 2026 Pellegrino Prevete
6
+
7
+ All rights reserved
8
+ ----------------------------------------------------------------------
9
+
10
+ This program is free software: you can redistribute it and/or modify
11
+ it under the terms of the GNU Affero General Public License as published by
12
+ the Free Software Foundation, either version 3 of the License, or
13
+ (at your option) any later version.
14
+
15
+ This program is distributed in the hope that it will be useful,
16
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ GNU Affero General Public License for more details.
19
+
20
+ You should have received a copy of the GNU Affero General Public License
21
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
22
+ -->
23
+
24
+ <script src="libevm-contract-call.js"></script>
package/evm-contract-call CHANGED
@@ -30,6 +30,12 @@
30
30
  /* eslint-disable
31
31
  no-unused-vars */
32
32
 
33
+ /* Crash Javascript global variables */
34
+ /* global
35
+ quiet:
36
+ writable */
37
+
38
+ /* LibEVM global variables */
33
39
  /* global
34
40
  call_auth:
35
41
  writable */
@@ -92,6 +98,11 @@ const
92
98
  const
93
99
  _msg_error =
94
100
  _libcrash._msg_error;
101
+ /* global
102
+ _printf */
103
+ const
104
+ _printf =
105
+ _libcrash._printf;
95
106
  /* global
96
107
  _process_exit */
97
108
  const
@@ -130,6 +141,11 @@ const
130
141
  const
131
142
  _artifact_local_auto_detect =
132
143
  _libevm_contract_call_module._artifact_local_auto_detect;
144
+ /* global
145
+ _address_check */
146
+ const
147
+ _address_check =
148
+ _libevm_contract_call_module._address_check;
133
149
  /* global
134
150
  _default_artifact_path_get */
135
151
  const
@@ -149,7 +165,7 @@ const
149
165
  _call_auth_auto_detect */
150
166
  const
151
167
  _call_auth_auto_detect =
152
- _libevm_contract_call_module._db_paths_auto_detect;
168
+ _libevm_contract_call_module._call_auth_auto_detect;
153
169
 
154
170
  function
155
171
  _global_variables() {
@@ -238,9 +254,6 @@ function
238
254
  writable */
239
255
  measure_unit =
240
256
  "";
241
- /* global
242
- quiet:
243
- writable */
244
257
  quiet =
245
258
  "";
246
259
  /* global
@@ -250,9 +263,13 @@ function
250
263
  "";
251
264
  }
252
265
 
253
- function
266
+ async function
254
267
  _overrides_set() {
255
- if ( call_date == "" ) {
268
+ _address_check(
269
+ contract_address);
270
+ if ( call_date == "" ||
271
+ typeof(
272
+ call_date) == "undefined" ) {
256
273
  call_date =
257
274
  _get_date_human();
258
275
  }
@@ -293,19 +310,20 @@ function
293
310
  if ( contract_address != "" ) {
294
311
  if ( contract_abi == "" ) {
295
312
  contract_abi =
296
- _default_artifact_path_get();
313
+ _default_artifact_path_get(
314
+ "abi");
297
315
  _artifact_local_auto_detect(
298
316
  "bytecode");
299
317
  _artifact_local_auto_detect(
300
318
  "compiler_output");
301
319
  if ( contract_abi == "" ||
302
320
  _default_artifact_path_get(
303
- "abi") == contract_abi ) {
321
+ "abi") == contract_abi ) {
304
322
  _contract_abi_auto_detect();
305
323
  }
306
324
  }
307
325
  }
308
- _wallet_overrides_set(
326
+ await _wallet_overrides_set(
309
327
  "evm-wallet",
310
328
  wallet_name,
311
329
  call_auth);
@@ -458,7 +476,7 @@ function
458
476
  _exit_code);
459
477
  }
460
478
 
461
- function
479
+ async function
462
480
  _cmdline_parse() {
463
481
  let
464
482
  _help_display,
@@ -506,7 +524,7 @@ function
506
524
  if ( _help_display ) {
507
525
  quiet =
508
526
  "n";
509
- _overrides_set();
527
+ await _overrides_set();
510
528
  _usage(
511
529
  0);
512
530
  }
@@ -677,15 +695,12 @@ function
677
695
  _argv[
678
696
  "network"]);
679
697
  }
680
- if ( "v" in _argv ) {
681
- verbose =
682
- true;
683
- }
684
- if ( "verbose" in _argv ) {
685
- verbose =
686
- true;
687
- }
688
- if ( verbose ) {
698
+ _libevm_cmdline_parse(
699
+ _argv);
700
+ if ( _argv[
701
+ "v"] ||
702
+ _argv[
703
+ "verbose"] ) {
689
704
  quiet =
690
705
  "n";
691
706
  }
@@ -765,20 +780,61 @@ function
765
780
  }
766
781
  }
767
782
 
768
- function
783
+ async function
769
784
  _evm_contract_call_cmdline(
770
785
  _app_opts) {
771
786
  let
772
787
  _result;
773
788
  const
774
789
  _results =
775
- _evm_contract_call.apply(
790
+ await _evm_contract_call.apply(
776
791
  null,
777
792
  app_opts);
778
- for ( _result of _results ) {
779
- console.log(
780
- _result);
793
+ const
794
+ _results_type =
795
+ typeof(
796
+ _results);
797
+ if ( _results_type == "object" ) {
798
+ for ( _result of _results ) {
799
+ console.log(
800
+ _result);
801
+ }
781
802
  }
803
+ else if ( _results_type == "string" ) {
804
+ _printf(
805
+ _results);
806
+ }
807
+ }
808
+
809
+ async function
810
+ _main() {
811
+ const
812
+ _overrides_set_up =
813
+ await _overrides_set();
814
+ _config_show();
815
+ app_opts = [
816
+ call_type,
817
+ call_timeout,
818
+ wallet_name,
819
+ wallet_path,
820
+ wallet_password,
821
+ wallet_seed,
822
+ api_key,
823
+ msg_value,
824
+ price_gas,
825
+ measure_unit,
826
+ retries_max,
827
+ target_network,
828
+ rpc_selection,
829
+ contract_address,
830
+ contract_abi,
831
+ contract_bytecode,
832
+ contract_compiler_output,
833
+ contract_method,
834
+ method_args
835
+ ];
836
+ await _evm_contract_call_cmdline(
837
+ app_opts);
782
838
  }
783
839
 
784
840
  _global_variables();
@@ -786,36 +842,12 @@ _libevm_global_variables();
786
842
  if ( _cmdline_check(
787
843
  "evm-contract-call.js") == true ||
788
844
  _cmdline_check(
789
- "evm-contract-call") == true ) {
845
+ "evm-contract-call") == true ) {
790
846
  _cmdline_parse();
791
- _libevm_cmdline_parse();
847
+ console.log("quiet", quiet);
792
848
  }
793
849
  else{
794
850
  _url_parse();
795
851
  _libevm_url_parse();
796
852
  }
797
- _overrides_set();
798
- _config_show();
799
- app_opts = [
800
- call_type,
801
- call_timeout,
802
- wallet_name,
803
- wallet_path,
804
- wallet_password,
805
- wallet_seed,
806
- api_key,
807
- msg_value,
808
- price_gas,
809
- measure_unit,
810
- retries_max,
811
- target_network,
812
- rpc_selection,
813
- contract_address,
814
- contract_abi,
815
- contract_bytecode,
816
- contract_compiler_output,
817
- contract_method,
818
- method_args
819
- ];
820
- _evm_contract_call_cmdline(
821
- app_opts);
853
+ _main();
@@ -36,6 +36,15 @@ const
36
36
  _libcrash_module =
37
37
  require(
38
38
  "crash-js");
39
+ const
40
+ _address_check_module =
41
+ require(
42
+ "./lib/address-check");
43
+ /* global
44
+ _address_check */
45
+ const
46
+ _address_check =
47
+ _address_check_module._address_check;
39
48
  const
40
49
  _bytecode_creation_get_module =
41
50
  require(
@@ -107,10 +116,6 @@ const
107
116
  _evm_contract_call_static_module._contract_call_static;
108
117
 
109
118
 
110
- function
111
- _default_artifact_path_get() {
112
- true;
113
- }
114
119
 
115
120
 
116
121
  function
@@ -119,12 +124,16 @@ function
119
124
  }
120
125
 
121
126
  module.exports = {
127
+ _address_check:
128
+ _address_check,
122
129
  _artifact_local_auto_detect:
123
130
  _artifact_local_auto_detect,
124
131
  _bytecode_creation_get:
125
132
  _bytecode_creation_get,
126
133
  _bytecode_runtime_get:
127
134
  _bytecode_runtime_get,
135
+ _call_auth_auto_detect:
136
+ _call_auth_auto_detect,
128
137
  _contract_call_dynamic:
129
138
  _contract_call_dynamic,
130
139
  _contract_call_static:
@@ -133,8 +142,6 @@ module.exports = {
133
142
  _contract_get,
134
143
  _contract_run:
135
144
  _contract_run,
136
- _default_artifact_path_get:
137
- _default_artifact_path_get,
138
145
  _deployer_get:
139
146
  _deployer_get,
140
147
  _deployer_verify:
@@ -0,0 +1,253 @@
1
+ #!/usr/bin/env node
2
+
3
+ // SPDX-License-Identifier: AGPL-3.0-or-later
4
+
5
+ /** ----------------------------------------------------------------------
6
+ * address-check
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 modify
16
+ * it under the terms of the GNU General Public License as published by
17
+ * the Free Software Foundation, either version 3 of the License, or
18
+ * (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. If not, see <https://www.gnu.org/licenses/>.
27
+ */
28
+
29
+ const
30
+ _libcrash =
31
+ require(
32
+ "crash-js");
33
+ /* global
34
+ _argv_get */
35
+ const
36
+ _argv_get =
37
+ _libcrash._argv_get;
38
+ /* global
39
+ _basename */
40
+ const
41
+ _basename =
42
+ _libcrash._basename;
43
+ /* global
44
+ _cmdline_check */
45
+ const
46
+ _cmdline_check =
47
+ _libcrash._cmdline_check;
48
+ /* global
49
+ _msg_info */
50
+ const
51
+ _msg_info =
52
+ _libcrash._msg_info;
53
+ /* global
54
+ _msg_error */
55
+ const
56
+ _msg_error =
57
+ _libcrash._msg_error;
58
+ /* global
59
+ _process_exit */
60
+ const
61
+ _process_exit =
62
+ _libcrash._process_exit;
63
+ const
64
+ { ethers } =
65
+ require(
66
+ "ethers");
67
+ const
68
+ _ethers =
69
+ ethers;
70
+ /* global
71
+ _address_check */
72
+ const
73
+ _address_check =
74
+ _ethers.isAddress;
75
+
76
+ function
77
+ _global_variables() {
78
+ app_name =
79
+ "address-check";
80
+ /* global
81
+ target_address:
82
+ writable */
83
+ target_address =
84
+ "";
85
+ /* global
86
+ quiet:
87
+ writable */
88
+ quiet =
89
+ "";
90
+ }
91
+
92
+ function
93
+ _config_show() {
94
+ let
95
+ _line;
96
+ const
97
+ _argv =
98
+ _argv_get();
99
+ const
100
+ _program =
101
+ _basename(
102
+ _argv[
103
+ "$0"]);
104
+ const
105
+ _text = [
106
+ `${_program} configuration:`,
107
+ ` Target address: ${target_address}`,
108
+ ];
109
+ for (_line of _text) {
110
+ _msg_info(
111
+ _line);
112
+ }
113
+ }
114
+
115
+ function
116
+ _usage(
117
+ _exit) {
118
+ let
119
+ _display_fun,
120
+ _line;
121
+ const
122
+ _argv =
123
+ _argv_get();
124
+ const
125
+ _program =
126
+ _basename(
127
+ _argv[
128
+ "$0"]);
129
+ const
130
+ _text = [
131
+ "Checks whether an address is valid.",
132
+ "",
133
+ "usage:",
134
+ ` ${_program}`,
135
+ " <target-address>",
136
+ " [options]",
137
+ "",
138
+ "args:",
139
+ " <target-address> Address to check.",
140
+ "",
141
+ " options:",
142
+ " -v --verbose Extended output.",
143
+ " -h --help This help."
144
+ ];
145
+ for (_line of _text) {
146
+ _msg_info(
147
+ _line);
148
+ }
149
+ _process_exit(
150
+ _exit);
151
+ }
152
+
153
+ function
154
+ _overrides_set() {
155
+ true;
156
+ }
157
+
158
+ function
159
+ _cmdline_parse() {
160
+ quiet =
161
+ "y";
162
+ process.argv.forEach(
163
+ function (
164
+ _value,
165
+ _index,
166
+ _array) {
167
+ if ( _index == 2 ) {
168
+ target_address =
169
+ _value;
170
+ }
171
+ else if ( _value == "-v" ||
172
+ _value == "--verbose" ) {
173
+ quiet =
174
+ "n";
175
+ }
176
+ else if ( _value == "-h" ||
177
+ _value == "--help" ) {
178
+ quiet =
179
+ "n";
180
+ _usage(
181
+ 0);
182
+ }
183
+ }
184
+ );
185
+ if ( target_address == "" ) {
186
+ const
187
+ _msg =
188
+ "No target address specified.";
189
+ _msg_error(
190
+ _msg,
191
+ 0);
192
+ quiet =
193
+ "n";
194
+ _usage(
195
+ 1);
196
+ }
197
+ }
198
+ async function
199
+ _address_check_cmdline(
200
+ _app_opts) {
201
+ let
202
+ _is_address,
203
+ _msg;
204
+ try {
205
+ _is_address =
206
+ await _address_check.apply(
207
+ null,
208
+ _app_opts);
209
+ const
210
+ _return_type =
211
+ typeof(
212
+ _is_address);
213
+ if ( _return_type == "undefined" ) {
214
+ _msg =
215
+ "Big error.";
216
+ _msg_error(
217
+ _msg,
218
+ 1);
219
+ }
220
+ else {
221
+ if ( ! _is_address ) {
222
+ _msg =
223
+ `Address '${target_address}' not is valid.'`;
224
+ throw _msg;
225
+ }
226
+ }
227
+ } catch (
228
+ _error) {
229
+ _msg_error(
230
+ _error,
231
+ 1);
232
+ }
233
+ }
234
+
235
+ if ( _cmdline_check(
236
+ "address-check") ||
237
+ _cmdline_check(
238
+ "ethereum-address-validate") ) {
239
+ _global_variables();
240
+ _cmdline_parse();
241
+ _overrides_set();
242
+ _config_show();
243
+ app_opts = [
244
+ target_address,
245
+ ];
246
+ _address_check_cmdline(
247
+ app_opts);
248
+ }
249
+
250
+ module.exports = {
251
+ _address_check:
252
+ _address_check
253
+ };
@@ -28,21 +28,36 @@ const
28
28
  _libcrash =
29
29
  require(
30
30
  "crash-js");
31
+ /* global
32
+ _cmdline_check */
31
33
  const
32
34
  _cmdline_check =
33
35
  _libcrash._cmdline_check;
36
+ /* global
37
+ _error_display */
34
38
  const
35
39
  _error_display =
36
40
  _libcrash._error_display;
41
+ /* global
42
+ _msg_info */
37
43
  const
38
44
  _msg_info =
39
45
  _libcrash._msg_info;
46
+ /* global
47
+ _msg_error */
40
48
  const
41
49
  _msg_error =
42
50
  _libcrash._msg_error;
51
+ /* global
52
+ _printf */
43
53
  const
44
54
  _printf =
45
55
  _libcrash._printf;
56
+ /* global
57
+ _process_exit */
58
+ const
59
+ _process_exit =
60
+ _libcrash._process_exit;
46
61
  const
47
62
  { ethers } =
48
63
  require(
@@ -50,6 +65,8 @@ const
50
65
  const
51
66
  _ethers =
52
67
  ethers;
68
+ /* global
69
+ _wei_to_ether */
53
70
  const
54
71
  _wei_to_ether =
55
72
  _ethers.formatEther;
@@ -57,9 +74,13 @@ const
57
74
  _evm_transactions_tools_module =
58
75
  require(
59
76
  "evm-transactions-tools");
77
+ /* global
78
+ _transaction_get */
60
79
  const
61
80
  _transaction_get =
62
81
  _evm_transactions_tools_module._transaction_get;
82
+ /* global
83
+ _transaction_receipt_get */
63
84
  const
64
85
  _transaction_receipt_get =
65
86
  _evm_transactions_tools_module._transaction_receipt_get;
@@ -67,6 +88,8 @@ const
67
88
  _deployer_get_module =
68
89
  require(
69
90
  './deployer-get');
91
+ /* global
92
+ _deployer_get */
70
93
  const
71
94
  _deployer_get =
72
95
  _deployer_get_module._deployer_get;
@@ -327,7 +350,7 @@ function
327
350
  _msg_info(
328
351
  _line);
329
352
  }
330
- process.exit(
353
+ _process_exit(
331
354
  _exit);
332
355
  }
333
356
 
@@ -341,6 +364,9 @@ function
341
364
 
342
365
  function
343
366
  _cmdline_parse() {
367
+ let
368
+ _error,
369
+ _msg;
344
370
  quiet =
345
371
  "y";
346
372
  process.argv.forEach(
@@ -397,18 +423,23 @@ function
397
423
  }
398
424
  }
399
425
  );
426
+ _error =
427
+ false;
400
428
  if ( transaction_deployment == "" ) {
401
- _msg_error(
402
- "No deployment transaction specified.",
403
- 0);
404
- quiet =
405
- "n";
406
- _usage(
407
- 1);
429
+ _msg =
430
+ "No deployment transaction specified.";
431
+ _error =
432
+ true;
408
433
  }
409
434
  if ( contract_bytecode_path == "" ) {
435
+ _msg =
436
+ "No contract bytecode path specified.";
437
+ _error =
438
+ true;
439
+ }
440
+ if ( _error ) {
410
441
  _msg_error(
411
- "No contract bytecode path specified.",
442
+ _msg,
412
443
  0);
413
444
  quiet =
414
445
  "n";
@@ -52,17 +52,22 @@ const
52
52
  _msg_info */
53
53
  const
54
54
  _msg_info =
55
- _libcrash._msg_info
55
+ _libcrash._msg_info;
56
56
  /* global
57
57
  _msg_error */
58
58
  const
59
59
  _msg_error =
60
- _libcrash._msg_error
60
+ _libcrash._msg_error;
61
61
  /* global
62
62
  _printf */
63
63
  const
64
64
  _printf =
65
- _libcrash._printf
65
+ _libcrash._printf;
66
+ /* global
67
+ _process_exit */
68
+ const
69
+ _process_exit =
70
+ _libcrash._process_exit;
66
71
  const
67
72
  _contract_get_module =
68
73
  require(
@@ -71,7 +76,7 @@ const
71
76
  _contract_get */
72
77
  const
73
78
  _contract_get =
74
- _contract_get_module._contract_get
79
+ _contract_get_module._contract_get;
75
80
  const
76
81
  _evm_wallet_module =
77
82
  require(
File without changes
File without changes
@@ -33,15 +33,27 @@
33
33
  /* eslint-disable
34
34
  no-useless-assignment */
35
35
 
36
+ /* EVM Contracts tools global variables */
37
+ /* global
38
+ call_type */
39
+ /* global
40
+ call_auth:
41
+ writable */
42
+
36
43
  /* libEVM global variables */
37
44
  /* global
38
45
  api_key */
39
46
  /* global
40
- contract_abi */
47
+ contract_abi:
48
+ writable */
41
49
  /* global
42
50
  contract_address */
43
51
  /* global
44
- contract_compiler_output */
52
+ contract_bytecode:
53
+ writable */
54
+ /* global
55
+ contract_compiler_output:
56
+ writable */
45
57
  /* global
46
58
  target_network:
47
59
  writable */
@@ -57,56 +69,73 @@ const
57
69
  _dirname */
58
70
  /* eslint-disable-next-line
59
71
  no-global-assign */
60
- _dirname =
61
- _libcrash_module._dirname;
72
+ const
73
+ _dirname =
74
+ _libcrash_module._dirname;
62
75
  /* global
63
76
  _file_exists */
64
77
  /* eslint-disable-next-line
65
78
  no-global-assign */
66
- _file_exists =
67
- _libcrash_module._file_exists;
79
+ const
80
+ _file_exists =
81
+ _libcrash_module._file_exists;
68
82
  /* global
69
83
  _homedir_get */
70
84
  /* eslint-disable-next-line
71
85
  no-global-assign */
72
- _homedir_get =
73
- _libcrash_module._homedir_get;
86
+ const
87
+ _homedir_get =
88
+ _libcrash_module._homedir_get;
74
89
  /* global
75
90
  _json_read */
76
91
  /* eslint-disable-next-line
77
92
  no-global-assign */
78
- _json_read =
79
- _libcrash_module._json_read;
93
+ const
94
+ _json_read =
95
+ _libcrash_module._json_read;
80
96
  /* global
81
97
  _lib_get */
82
98
  /* eslint-disable-next-line
83
99
  no-global-assign */
84
- _lib_get =
85
- _libcrash_module._lib_get;
100
+ const
101
+ _lib_get =
102
+ _libcrash_module._lib_get;
86
103
  /* global
87
104
  _msg_info */
88
105
  /* eslint-disable-next-line
89
106
  no-global-assign */
90
- _msg_info =
91
- _libcrash_module._msg_info;
107
+ const
108
+ _msg_info =
109
+ _libcrash_module._msg_info;
92
110
  /* global
93
111
  _msg_error */
94
112
  /* eslint-disable-next-line
95
113
  no-global-assign */
96
- _msg_error =
97
- _libcrash_module._msg_error;
114
+ const
115
+ _msg_error =
116
+ _libcrash_module._msg_error;
98
117
  /* global
99
118
  _path_join */
100
119
  /* eslint-disable-next-line
101
120
  no-global-assign */
102
- _path_join =
103
- _libcrash_module._path_join;
121
+ const
122
+ _path_join =
123
+ _libcrash_module._path_join;
104
124
  /* global
105
125
  _range */
106
126
  /* eslint-disable-next-line
107
127
  no-global-assign */
108
- _range =
109
- _libcrash_module._range;
128
+ const
129
+ _range =
130
+ _libcrash_module._range;
131
+ const
132
+ _evm_contracts_tools_module =
133
+ require("./evm-contracts-tools");
134
+ /* global
135
+ _address_check */
136
+ const
137
+ _address_check =
138
+ _evm_contracts_tools_module._address_check;
110
139
 
111
140
  const
112
141
  _ethereum_data_module =
@@ -137,8 +166,47 @@ function
137
166
  }
138
167
 
139
168
  function
140
- _default_artifact_path_get() {
141
- true;
169
+ _default_artifact_path_get(
170
+ _type) {
171
+ let
172
+ _file_name;
173
+ const
174
+ _home =
175
+ _homedir_get();
176
+ const
177
+ _data_dir =
178
+ _path_join( [
179
+ _home,
180
+ ".local",
181
+ "share",
182
+ "evm-contract-call" ]);
183
+ if ( _type == "abi" ) {
184
+ _file_name =
185
+ `${contract_address}.abi.json`;
186
+ }
187
+ else if ( _type == "bytecode" ) {
188
+ _file_name =
189
+ `${contract_address}.bin`;
190
+ }
191
+ else if ( _type == "compiler_output" ) {
192
+ _file_name =
193
+ `${contract_address}.json`;
194
+ }
195
+ else {
196
+ const
197
+ _msg =
198
+ `Unknown artifact type '${_type}'.`;
199
+ _msg_error(
200
+ _msg,
201
+ 1);
202
+ }
203
+ const
204
+ _artifact =
205
+ _path_join( [
206
+ _data_dir,
207
+ target_network,
208
+ _file_name ]);
209
+ return _artifact;
142
210
  }
143
211
 
144
212
  function
@@ -194,6 +262,26 @@ function
194
262
  }
195
263
  }
196
264
 
265
+ function
266
+ _call_auth_auto_detect() {
267
+ if ( call_type == "static" ) {
268
+ call_auth =
269
+ "n";
270
+ }
271
+ else if ( call_type == "dynamic" ) {
272
+ call_auth =
273
+ "y";
274
+ }
275
+ else {
276
+ const
277
+ _msg =
278
+ `Unknown call type '${call_type}'.`;
279
+ _msg_error(
280
+ _msg,
281
+ 1);
282
+ }
283
+ }
284
+
197
285
  function
198
286
  _evm_contract_call(
199
287
  _call_type,
@@ -217,15 +305,20 @@ function
217
305
  _method_args) {
218
306
  let
219
307
  _explorer,
308
+ _out,
220
309
  _result,
221
310
  _rpc;
222
311
  if ( _call_type == "static" ) {
223
312
  const
224
313
  _infos =
225
314
  [];
315
+ _out =
316
+ "";
317
+
226
318
  }
227
319
  else if ( _call_type == "dynamic" ) {
228
- true;
320
+ _out =
321
+ "";
229
322
  }
230
323
  else {
231
324
  const
@@ -236,9 +329,37 @@ function
236
329
  _msg,
237
330
  1);
238
331
  }
332
+ return _out;
333
+ }
334
+
335
+ function
336
+ _artifact_local_auto_detect(
337
+ _type) {
338
+ const
339
+ _artifact =
340
+ _default_artifact_path_get(
341
+ _type);
342
+ if ( _type == "abi" ) {
343
+ contract_abi =
344
+ _artifact;
345
+ }
346
+ else if ( _type == "bytecode" ) {
347
+ contract_bytecode =
348
+ _artifact;
349
+ }
350
+ else if ( _type == "compiler_output" ) {
351
+ contract_compiler_output =
352
+ _artifact;
353
+ }
239
354
  }
240
355
 
241
356
  module.exports = {
357
+ _address_check:
358
+ _address_check,
359
+ _artifact_local_auto_detect:
360
+ _artifact_local_auto_detect,
361
+ _call_auth_auto_detect:
362
+ _call_auth_auto_detect,
242
363
  _contract_abi_auto_detect:
243
364
  _contract_abi_auto_detect,
244
365
  _default_artifact_path_get:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  { "name": "evm-contracts-tools",
2
2
  "version":
3
- "0.0.32",
3
+ "0.0.34",
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": {
@@ -10,11 +10,17 @@
10
10
  "https://patreon.com/tallero"
11
11
  },
12
12
  "man": [
13
+ "./man/ethereum-address-validate.1",
14
+ "./man/evm-contract-bytecode-get.1",
15
+ "./man/evm-contract-deployer-get.1",
16
+ "./man/evm-contract-deployment-address.1",
17
+ "./man/evm-contract-call.1",
13
18
  "./man/evm-contract-call-dynamic.1"
14
19
  ],
15
20
  "files": [
16
21
  "AUTHORS.rst",
17
22
  "COPYING",
23
+ "Makefile",
18
24
  "README.md",
19
25
  "dist",
20
26
  "evm-contract-call",
@@ -86,17 +92,17 @@
86
92
  "evm-transactions-tools":
87
93
  "^0.0.9",
88
94
  "evm-wallet.js":
89
- "^0.0.44",
95
+ "^0.0.50",
90
96
  "libevm":
91
- "^0.0.26",
97
+ "^0.0.27",
92
98
  "yargs":
93
99
  "18.0.0"
94
100
  },
95
101
  "overrides": {
96
102
  "evm-contracts-tools":
97
- "^0.0.31",
103
+ "^0.0.32",
98
104
  "evm-wallet.js":
99
- "^0.0.44"
105
+ "^0.0.50"
100
106
  },
101
107
  "type":
102
108
  "commonjs",
@@ -104,6 +110,8 @@
104
110
  "evm-contracts-tools",
105
111
  "bin":
106
112
  {
113
+ "ethereum-address-validate":
114
+ "lib/address-check",
107
115
  "evm-contract-call":
108
116
  "evm-contract-call",
109
117
  "evm-contract-call.js":
@@ -119,12 +127,14 @@
119
127
  "npx webpack --mode 'production' --config 'libevm-contract-call.webpack.config.cjs' --stats-error-details && mv 'libevm-contract-call.js' 'dist/libevm-contract-call'",
120
128
  "build-bin":
121
129
  "npx webpack --mode 'production' --config 'evm-contract-call.webpack.config.cjs' --stats-error-details && mv 'evm-contract-call.js' 'dist/evm-contract-call' && npx webpack --mode 'production' --config 'webpack.config.cjs' --stats-error-details && mv 'evm-contracts-tools.js' 'dist/evm-contracts-tools'",
130
+ "build-man":
131
+ "make build-man",
122
132
  "build":
123
- "npm run lint && npm run build-fs-worker && npm run build-lib",
133
+ "npm run lint && npm run build-fs-worker && npm run build-lib && npm run build-bin",
124
134
  "lint":
125
135
  "npx eslint .",
126
- "publish-pnm":
127
- "npm run build && npm publish --access public",
136
+ "publish-npm":
137
+ "npm run build-man && npm run build && npm publish --access public",
128
138
  "start":
129
139
  "npx safely-serve --help # index.html --port 3000 --https --no-cache",
130
140
  "test":