evm-contracts-tools 0.0.37 → 0.0.38

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.
@@ -0,0 +1,287 @@
1
+ #!/usr/bin/env node
2
+
3
+ // SPDX-License-Identifier: AGPL-3.0-or-later
4
+
5
+ /** ----------------------------------------------------------------
6
+ * libevm-contract-deployments-dir
7
+ * ----------------------------------------------------------------
8
+ * Copyright ©
9
+ * Pellegrino Prevete
10
+ * 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
26
+ * GNU General Public License
27
+ * along with this program.
28
+ * If not, see <https://www.gnu.org/licenses/>.
29
+ */
30
+
31
+ /* eslint-disable
32
+ no-unused-vars */
33
+ /* eslint-disable
34
+ no-useless-assignment */
35
+
36
+ /* EVM Contracts tools global variables */
37
+ /* global
38
+ call_type */
39
+ /* global
40
+ call_auth:
41
+ writable */
42
+
43
+ /* libEVM global variables */
44
+ /* global
45
+ api_key */
46
+ /* global
47
+ contract_abi:
48
+ writable */
49
+ /* global
50
+ contract_address */
51
+ /* global
52
+ contract_bytecode:
53
+ writable */
54
+ /* global
55
+ contract_compiler_output:
56
+ writable */
57
+ /* global
58
+ target_network:
59
+ writable */
60
+ /* global
61
+ target_networks:
62
+ writable */
63
+
64
+ const
65
+ _libcrash_module =
66
+ require(
67
+ "crash-js");
68
+ /* global
69
+ _dirname */
70
+ /* eslint-disable-next-line
71
+ no-global-assign */
72
+ const
73
+ _dirname =
74
+ _libcrash_module._dirname;
75
+ /* global
76
+ _file_exists */
77
+ /* eslint-disable-next-line
78
+ no-global-assign */
79
+ const
80
+ _file_exists =
81
+ _libcrash_module._file_exists;
82
+ /* global
83
+ _homedir_get */
84
+ /* eslint-disable-next-line
85
+ no-global-assign */
86
+ const
87
+ _homedir_get =
88
+ _libcrash_module._homedir_get;
89
+ /* global
90
+ _json_read */
91
+ /* eslint-disable-next-line
92
+ no-global-assign */
93
+ const
94
+ _json_read =
95
+ _libcrash_module._json_read;
96
+ /* global
97
+ _lib_get */
98
+ /* eslint-disable-next-line
99
+ no-global-assign */
100
+ const
101
+ _lib_get =
102
+ _libcrash_module._lib_get;
103
+ /* global
104
+ _msg_info */
105
+ /* eslint-disable-next-line
106
+ no-global-assign */
107
+ const
108
+ _msg_info =
109
+ _libcrash_module._msg_info;
110
+ /* global
111
+ _msg_error */
112
+ /* eslint-disable-next-line
113
+ no-global-assign */
114
+ const
115
+ _msg_error =
116
+ _libcrash_module._msg_error;
117
+ /* global
118
+ _path_join */
119
+ /* eslint-disable-next-line
120
+ no-global-assign */
121
+ const
122
+ _path_join =
123
+ _libcrash_module._path_join;
124
+ /* global
125
+ _range */
126
+ /* eslint-disable-next-line
127
+ no-global-assign */
128
+ const
129
+ _range =
130
+ _libcrash_module._range;
131
+ const
132
+ _libevm_contract_deployments_dir_module =
133
+ require(
134
+ "./libevm-contract-deployments-dir");
135
+ /* global
136
+ _evm_contract_deployments_dir */
137
+ const
138
+ _evm_contract_deployments_dir =
139
+ _libevm_contract_deployments_dir_module._evm_contract_deployments_dir;
140
+ const
141
+ _evm_chains_info_module =
142
+ require(
143
+ "evm-chains-info");
144
+ /* global
145
+ _evm_chains_info */
146
+ const
147
+ _evm_chains_info =
148
+ _evm_chains_info_module._evm_chains_info;
149
+
150
+
151
+ function
152
+ _contract_address_get(
153
+ _deployments,
154
+ _contract,
155
+ _network,
156
+ _network_id,
157
+ _version) {
158
+ let
159
+ _config_path,
160
+ _address,
161
+ _found,
162
+ _msg,
163
+ _net;
164
+ const
165
+ _networks = [
166
+ _network,
167
+ _network_id
168
+ ];
169
+ _found =
170
+ false;
171
+ for ( _net of _networks ) {
172
+ _config_path =
173
+ `${_deployments}/${_contract}/${_net}/config.sh`;
174
+ if ( _file_exists(
175
+ _config_path) ) {
176
+ _found =
177
+ true;
178
+ break;
179
+ }
180
+ }
181
+ if ( ! _found ) {
182
+ _msg =
183
+ `No network '${_network}' deployment ` +
184
+ `configuration for '${_contract}' ` +
185
+ `found at path '${_deployments}'.`;
186
+ _msg_error(
187
+ _msg,
188
+ 1);
189
+ }
190
+ const
191
+ _config =
192
+ _json_read(
193
+ _config);
194
+ const
195
+ _contract_address =
196
+ _config[
197
+ "contract-address"][
198
+ _version];
199
+ if ( _contract_address == "" ||
200
+ _contract_address == null ) {
201
+ _msg =
202
+ `No '${_contract}' version '${_version}' ` +
203
+ `contract deployment specified for network ` +
204
+ `'${_network}' for directory at path `+
205
+ `'${_deployments}'.`;
206
+ _msg_error(
207
+ _msg,
208
+ 1);
209
+ }
210
+ }
211
+
212
+ function
213
+ _network_check(
214
+ _deployments,
215
+ _contract,
216
+ _target_network,
217
+ _target_network_id) {
218
+ let
219
+ _msg,
220
+ _network_id,
221
+ _networks;
222
+ _networks = [
223
+ // I need to write that first apparently
224
+ _evm_contract_deployment_networks
225
+ ];
226
+ _app_check(
227
+ _app);
228
+ if ( typeof(
229
+ _type) == "undefined" ||
230
+ _type == "" ) {
231
+ _type =
232
+ "system";
233
+ }
234
+ let
235
+ _conf_dir;
236
+ if ( _type == "system" ) {
237
+ _conf_dir =
238
+ _lib_get();
239
+ }
240
+ else if ( _type == "user" ) {
241
+ const
242
+ _homedir =
243
+ _homedir_get();
244
+ _conf_dir =
245
+ `${_homedir}/.config`;
246
+ }
247
+ return `${_conf_dir}/${_app}/deployments`;
248
+ }
249
+
250
+ function
251
+ _evm_contract_deployments_dir(
252
+ _app,
253
+ _user_level) {
254
+ let
255
+ _deployments,
256
+ _deployment_type;
257
+ _app_check(
258
+ _app);
259
+ if ( _user_level == "n" ) {
260
+ _deployment_type =
261
+ "system";
262
+ }
263
+ else if ( _user_level == "n" ) {
264
+ _deployment_type =
265
+ "system";
266
+ }
267
+ else {
268
+ _msg =
269
+ "User level argument must be " +
270
+ "can be 'y' or 'n'."
271
+ _msg_error(
272
+ _msg,
273
+ 1);
274
+ }
275
+ _deployments =
276
+ _default_deployments_dir_get(
277
+ _app,
278
+ _deployment_type);
279
+ return _deployments;
280
+ }
281
+
282
+ module.exports = {
283
+ _default_deployments_dir_get:
284
+ _default_deployments_dir_get,
285
+ _evm_contract_deployments_dir:
286
+ _evm_contract_deployments_dir,
287
+ };
@@ -33,52 +33,10 @@
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
-
43
- /* libEVM global variables */
44
- /* global
45
- api_key */
46
- /* global
47
- contract_abi:
48
- writable */
49
- /* global
50
- contract_address */
51
- /* global
52
- contract_bytecode:
53
- writable */
54
- /* global
55
- contract_compiler_output:
56
- writable */
57
- /* global
58
- target_network:
59
- writable */
60
- /* global
61
- target_networks:
62
- writable */
63
-
64
36
  const
65
37
  _libcrash_module =
66
38
  require(
67
39
  "crash-js");
68
- /* global
69
- _dirname */
70
- /* eslint-disable-next-line
71
- no-global-assign */
72
- const
73
- _dirname =
74
- _libcrash_module._dirname;
75
- /* global
76
- _file_exists */
77
- /* eslint-disable-next-line
78
- no-global-assign */
79
- const
80
- _file_exists =
81
- _libcrash_module._file_exists;
82
40
  /* global
83
41
  _homedir_get */
84
42
  /* eslint-disable-next-line
@@ -86,13 +44,6 @@ const
86
44
  const
87
45
  _homedir_get =
88
46
  _libcrash_module._homedir_get;
89
- /* global
90
- _json_read */
91
- /* eslint-disable-next-line
92
- no-global-assign */
93
- const
94
- _json_read =
95
- _libcrash_module._json_read;
96
47
  /* global
97
48
  _lib_get */
98
49
  /* eslint-disable-next-line
@@ -114,38 +65,6 @@ const
114
65
  const
115
66
  _msg_error =
116
67
  _libcrash_module._msg_error;
117
- /* global
118
- _path_join */
119
- /* eslint-disable-next-line
120
- no-global-assign */
121
- const
122
- _path_join =
123
- _libcrash_module._path_join;
124
- /* global
125
- _range */
126
- /* eslint-disable-next-line
127
- no-global-assign */
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;
139
-
140
- const
141
- _ethereum_data_module =
142
- require(
143
- "ethereum-data");
144
- /* global
145
- _data_get */
146
- const
147
- _data_get =
148
- _ethereum_data_module._data_get;
149
68
 
150
69
  function
151
70
  _app_check(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  { "name": "evm-contracts-tools",
2
2
  "version":
3
- "0.0.37",
3
+ "0.0.38",
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": {
@@ -26,12 +26,20 @@
26
26
  "dist",
27
27
  "evm-contract-call",
28
28
  "evm-contract-call.webpack.config.js",
29
+ "evm-contract-deployment-address",
30
+ "evm-contract-deployment-address.webpack.config.js",
31
+ "evm-contract-deployment-networks",
32
+ "evm-contract-deployment-networks.webpack.config.js",
29
33
  "evm-contract-deployments-dir",
30
34
  "evm-contract-deployments-dir.webpack.config.js",
31
35
  "fs-worker.webpack.config.js",
32
36
  "index.html",
33
37
  "libevm-contract-call",
34
38
  "libevm-contract-call.webpack.config.js",
39
+ "libevm-contract-deployment-address",
40
+ "libevm-contract-deployment-address.webpack.config.js",
41
+ "libevm-contract-deployment-networks",
42
+ "libevm-contract-deployment-networks.webpack.config.js",
35
43
  "libevm-contract-deployments-dir",
36
44
  "libevm-contract-deployments-dir.webpack.config.js",
37
45
  "lib",
@@ -99,7 +107,7 @@
99
107
  "evm-transactions-tools":
100
108
  "^0.0.9",
101
109
  "evm-wallet.js":
102
- "^0.0.50",
110
+ "^0.0.54",
103
111
  "libevm":
104
112
  "^0.0.27",
105
113
  "ws":
@@ -111,7 +119,7 @@
111
119
  "evm-contracts-tools":
112
120
  "^0.0.32",
113
121
  "evm-wallet.js":
114
- "^0.0.50"
122
+ "^0.0.54"
115
123
  },
116
124
  "type":
117
125
  "commonjs",
@@ -127,39 +135,68 @@
127
135
  "evm-contract-call",
128
136
  "evm-contract-call-dynamic.js":
129
137
  "lib/evm-contract-call-dynamic",
130
- "evm-contract-deployments-dir.js":
131
- "evm-contract-deployments-dir",
138
+ "evm-contract-call-dynamic":
139
+ "lib/evm-contract-call-dynamic",
140
+ "evm-contract-call-static":
141
+ "lib/evm-contract-call-static",
142
+ "evm-contract-call-static.js":
143
+ "lib/evm-contract-call-static",
144
+ "evm-contract-deployment-address":
145
+ "evm-contract-deployment-address",
146
+ "evm-contract-deployment-address.js":
147
+ "evm-contract-deployment-address",
148
+ "evm-contract-deployment-networks":
149
+ "evm-contract-deployment-networks",
150
+ "evm-contract-deployment-networks.js":
151
+ "evm-contract-deployment-networks",
152
+ "evm-contract-deployment-versions":
153
+ "evm-contract-deployment-versions",
154
+ "evm-contract-deployment-versions.js":
155
+ "evm-contract-deployment-versions",
132
156
  "evm-contract-deployments-dir":
133
157
  "evm-contract-deployments-dir",
134
- "evm-contract-call-static.js":
135
- "lib/evm-contract-call-static" },
158
+ "evm-contract-deployments-dir.js":
159
+ "evm-contract-deployments-dir"
160
+ },
136
161
  "scripts": {
137
162
  "build-fs-worker":
138
163
  "npx webpack --mode 'production' --config 'fs-worker.webpack.config.cjs' --stats-error-details && cp 'fs-worker.js' 'dist/'{'evm-contract-call','evm-contracts-tools','libevm-contract-call'}",
139
164
  "build-libevm-contract-call":
140
165
  "npx webpack --mode 'production' --config 'libevm-contract-call.webpack.config.cjs' --stats-error-details && mv 'libevm-contract-call.js' 'dist/libevm-contract-call'",
166
+ "build-libevm-contract-deployment-address":
167
+ "_app='libevm-contract-deployment-address'; npx webpack --mode 'production' --config \"${_app}.webpack.config.cjs\" --stats-error-details && mv \"${_app}.js\" \"dist/${_app}\"",
168
+ "build-libevm-contract-deployment-networks":
169
+ "_app='libevm-contract-deployment-networks'; npx webpack --mode 'production' --config \"${_app}.webpack.config.cjs\" --stats-error-details && mv \"${_app}.js\" \"dist/${_app}\"",
170
+ "build-libevm-contract-deployment-versions":
171
+ "_app='libevm-contract-deployment-versions'; npx webpack --mode 'production' --config \"${_app}.webpack.config.cjs\" --stats-error-details && mv \"${_app}.js\" \"dist/${_app}\"",
141
172
  "build-libevm-contract-deployments-dir":
142
- "npx webpack --mode 'production' --config 'libevm-contract-deployments-dir.webpack.config.cjs' --stats-error-details && mv 'libevm-contract-deployments-dir.js' 'dist/libevm-contract-deployments-dir'",
173
+ "_app='libevm-contract-deployments-dir'; npx webpack --mode 'production' --config \"${_app}.webpack.config.cjs\" --stats-error-details && mv \"${_app}.js\" \"dist/${_app}\"",
143
174
  "build-lib":
144
- "npm run build-libevm-contract-call && npm run build-libevm-contract-deployments-dir",
175
+ "for _app in evm-contract-call evm-contract-deployment-address evm-contract-deployment-deployment-networks evm-contract-deployment-versions evm-contract-deployments-dir evm-contracts-tools; do npm run \"build-lib${_app}\"; done",
145
176
  "build-evm-contract-call":
146
- "npx webpack --mode 'production' --config 'evm-contract-call.webpack.config.cjs' --stats-error-details && mv 'evm-contract-call.js' 'dist/evm-contract-call'",
177
+ "_app='evm-contract-call'; npx webpack --mode 'production' --config \"${_app}.webpack.config.cjs\" --stats-error-details && mv \"${_app}.js\" \"dist/${_app}\"",
178
+ "build-evm-contract-deployment-address":
179
+ "_app='evm-contract-deployment-address'; npx webpack --mode 'production' --config \"${_app}.webpack.config.cjs\" --stats-error-details && mv \"${_app}.js\" \"dist/${_app}\"",
180
+ "build-evm-contract-deployments-dir":
181
+ "_app='evm-contract-deployments-dir'; npx webpack --mode 'production' --config \"${_app}.webpack.config.cjs\" --stats-error-details && mv \"${_app}.js\" \"dist/${_app}\"",
182
+ "build-evm-contract-deployment-networks":
183
+ "_app='evm-contract-deployments-networks'; npx webpack --mode 'production' --config \"${_app}.webpack.config.cjs\" --stats-error-details && mv \"${_app}.js\" \"dist/${_app}\"",
184
+ "build-evm-contract-deployment-versions":
185
+ "_app='evm-contract-deployments-versions'; npx webpack --mode 'production' --config \"${_app}.webpack.config.cjs\" --stats-error-details && mv \"${_app}.js\" \"dist/${_app}\"",
147
186
  "build-evm-contracts-tools":
148
187
  "npx webpack --mode 'production' --config 'webpack.config.cjs' --stats-error-details && mv 'evm-contracts-tools.js' 'dist/evm-contracts-tools'",
149
- "build-evm-contract-deployments-dir":
150
- "npx webpack --mode 'production' --config 'evm-contract-deployments-dir.webpack.config.cjs' --stats-error-details && mv 'evm-contract-deployments-dir.js' 'dist/evm-contract-deployments-dir' && npx webpack --mode 'production' --config 'webpack.config.cjs' --stats-error-details && mv 'evm-contracts-tools.js' 'dist/evm-contracts-tools'",
151
188
  "build-bin":
152
- "npm run build-evm-contract-call && npm run build-evm-contract-deployments-dir && npm run build-evm-contracts-tools",
189
+ "for _app in evm-contract-call evm-contract-deployment-address evm-contract-deployment-deployment-networks evm-contract-deployment-versions evm-contract-deployments-dir evm-contracts-tools; do npm run \"build-${_app}\"; done",
153
190
  "build-man":
154
191
  "make build-man",
155
192
  "build":
156
- "npm run lint && npm run build-fs-worker && npm run build-lib && npm run build-bin",
193
+ "npm run lint; npm run build-fs-worker; npm run build-lib; npm run build-bin",
157
194
  "lint":
158
195
  "npx eslint .",
159
196
  "publish-npm":
160
197
  "npm run build-man && npm run build && npm publish --access public",
161
198
  "start":
162
- "npx safely-serve --help # index.html --port 3000 --https --no-cache",
199
+ "npx safely-serve dist/evm-contract-call",
163
200
  "test":
164
201
  "echo \"Error: no test specified\" && exit 1"
165
202
  }