evm-contracts-tools 0.0.37 → 0.0.39

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.
Files changed (30) hide show
  1. package/Makefile +12 -0
  2. package/dist/evm-contract-call/fs-worker.js +1 -0
  3. package/dist/evm-contract-deployment-address/fs-worker.js +1 -0
  4. package/dist/evm-contract-deployment-address/index.html +31 -0
  5. package/dist/evm-contract-deployment-deployment-networks +1 -0
  6. package/dist/evm-contract-deployment-networks/index.html +31 -0
  7. package/dist/evm-contract-deployment-versions/fs-worker.js +1 -0
  8. package/dist/evm-contract-deployment-versions/index.html +33 -0
  9. package/dist/evm-contract-deployments-dir/fs-worker.js +1 -0
  10. package/dist/evm-contracts-tools/fs-worker.js +1 -0
  11. package/dist/libevm-contract-call/fs-worker.js +1 -1
  12. package/dist/libevm-contract-deployment-address/fs-worker.js +1 -0
  13. package/dist/libevm-contract-deployment-address/index.html +24 -0
  14. package/dist/libevm-contract-deployment-deployment-networks +1 -0
  15. package/dist/libevm-contract-deployment-networks/index.html +24 -0
  16. package/dist/libevm-contract-deployment-versions/fs-worker.js +1 -0
  17. package/dist/libevm-contract-deployment-versions/index.html +33 -0
  18. package/dist/libevm-contract-deployments-dir/fs-worker.js +1 -0
  19. package/dist/libevm-contracts-tools +1 -0
  20. package/evm-contract-deployment-address +453 -0
  21. package/evm-contract-deployment-networks +440 -0
  22. package/evm-contract-deployment-versions +392 -0
  23. package/lib/address-check +0 -0
  24. package/lib/evm-contract-call-dynamic +0 -0
  25. package/lib/evm-contract-call-static +0 -0
  26. package/libevm-contract-deployment-address +439 -0
  27. package/libevm-contract-deployment-networks +295 -0
  28. package/libevm-contract-deployment-versions +113 -0
  29. package/libevm-contract-deployments-dir +0 -81
  30. package/package.json +73 -23
@@ -0,0 +1,439 @@
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
+ _libevm_contract_deployment_networks =
142
+ require(
143
+ "./libevm-contract-deployment-networks");
144
+ /* global
145
+ _evm_contract_deployment_networks */
146
+ const
147
+ _evm_contract_deployment_networks =
148
+ _libevm_contract_deployment_networks_module._evm_contract_deployment_networks;
149
+ const
150
+ _evm_chains_info_module =
151
+ require(
152
+ "evm-chains-info");
153
+ /* global
154
+ _evm_chains_info */
155
+ const
156
+ _evm_chains_info =
157
+ _evm_chains_info_module._evm_chains_info;
158
+
159
+ function
160
+ _contract_address_get(
161
+ _deployments,
162
+ _contract,
163
+ _network,
164
+ _network_id,
165
+ _version,
166
+ _configuration_format) {
167
+ let
168
+ _config_file_ext,
169
+ _config_path,
170
+ _address,
171
+ _found,
172
+ _msg,
173
+ _net;
174
+ if ( typeof(
175
+ _configuration_format) === "undefined" ||
176
+ _configuration_format == "" ) {
177
+ _configuration_format =
178
+ "bash";
179
+ }
180
+ if ( _configuration_format == "bash" ) {
181
+ _config_file_ext =
182
+ "sh";
183
+ }
184
+ if ( _configuration_format == "json" ) {
185
+ _config_file_ext =
186
+ "json"
187
+ }
188
+ else {
189
+ _msg =
190
+ "Unknown configuration format " +
191
+ `${_configuration_format}'.`;
192
+ _msg_error(
193
+ _msg,
194
+ 1);
195
+ }
196
+ const
197
+ _networks = [
198
+ _network,
199
+ _network_id
200
+ ];
201
+ _found =
202
+ false;
203
+ for ( _net of _networks ) {
204
+ _config_path =
205
+ `${_deployments}/${_contract}/${_net}/config.${_config_file_ext}`;
206
+ if ( _file_exists(
207
+ _config_path) ) {
208
+ _found =
209
+ true;
210
+ break;
211
+ }
212
+ }
213
+ if ( ! _found ) {
214
+ _msg =
215
+ `No network '${_network}' deployment ` +
216
+ `configuration for contract '${_contract}' ` +
217
+ `found at path '${_deployments}'.`;
218
+ _msg_error(
219
+ _msg,
220
+ 1);
221
+ }
222
+ const
223
+ _config =
224
+ _json_read(
225
+ _config);
226
+ const
227
+ _contract_address =
228
+ _config[
229
+ "contract-address"][
230
+ _version];
231
+ if ( _contract_address == "" ||
232
+ _contract_address == null ) {
233
+ _msg =
234
+ `No '${_contract}' version '${_version}' ` +
235
+ `contract deployment specified for network ` +
236
+ `'${_network}' for directory at path `+
237
+ `'${_deployments}'.`;
238
+ _msg_error(
239
+ _msg,
240
+ 1);
241
+ }
242
+ return _contract_address;
243
+ }
244
+
245
+ function
246
+ _network_check(
247
+ _deployments,
248
+ _contract,
249
+ _target_network,
250
+ _target_network_id) {
251
+ let
252
+ _msg,
253
+ _network_id,
254
+ _networks;
255
+ _networks = [
256
+ // I need to write that first apparently
257
+ _evm_contract_deployment_networks
258
+ ];
259
+ _app_check(
260
+ _app);
261
+ if ( typeof(
262
+ _type) == "undefined" ||
263
+ _type == "" ) {
264
+ _type =
265
+ "system";
266
+ }
267
+ let
268
+ _conf_dir;
269
+ if ( _type == "system" ) {
270
+ _conf_dir =
271
+ _lib_get();
272
+ }
273
+ else if ( _type == "user" ) {
274
+ const
275
+ _homedir =
276
+ _homedir_get();
277
+ _conf_dir =
278
+ `${_homedir}/.config`;
279
+ }
280
+ return `${_conf_dir}/${_app}/deployments`;
281
+ }
282
+
283
+ function
284
+ _evm_contract_deployment_address(
285
+ _target_networks,
286
+ _network_ids,
287
+ _networks_all,
288
+ _target_app,
289
+ _contract_version,
290
+ _user_defined,
291
+ _deployments_dir) {
292
+ let
293
+ _args,
294
+ _contract_address,
295
+ _contract_address_get_args,
296
+ _contracts_addresses,
297
+ _network,
298
+ _network_check_args,
299
+ _target_network,
300
+ _target_network_id,
301
+ _user_deployments_dir,
302
+ _system_deployments_dir,
303
+ _msg;
304
+ if ( _user_defined == "n" ) {
305
+ if ( _target_app == "" ) {
306
+ _msg =
307
+ "A target application needs to " +
308
+ "be specified with option '-a' " +
309
+ "if not enabling user-defined " +
310
+ "deployments with '-u' and " +
311
+ "specifying a deployments directory " +
312
+ "path with '-d'.";
313
+ _msg_error(
314
+ _msg,
315
+ 1)
316
+ }
317
+ _system_deployments_dir =
318
+ _evm_contract_deployments_dir(
319
+ target_app);
320
+ if ( _deployments_dir != system_deployments_dir ) {
321
+ _msg =
322
+ "To set a custom deployments directory path " +
323
+ "you need to enable the user-defined " +
324
+ "deployments switch with '-u'." +
325
+ _msg_error(
326
+ _msg,
327
+ 1)
328
+ }
329
+ }
330
+ else if ( _user_defined == "y" ) {
331
+ if ( _target_app != "" ) {
332
+ _user_deployments_dir =
333
+ _evm_contract_deployments_dir(
334
+ _target_app,
335
+ _user_defined);
336
+ }
337
+ if ( _deployments_dir != _user_deployments_dir ) {
338
+ _msg =
339
+ "Using custom deployments directory " +
340
+ `path '${_deployments_dir}'.`;
341
+ _msg_info(
342
+ _msg);
343
+ }
344
+ else {
345
+ _user_deployments_check();
346
+ }
347
+ }
348
+ else {
349
+ _msg =
350
+ "The 'user-defined' switch argument must be " +
351
+ "can be 'y' or 'n'."
352
+ _msg_error(
353
+ _msg,
354
+ 1);
355
+ }
356
+ if ( _networks_all == "y" ) {
357
+ _target_networks =
358
+ _evm_contract_deployment_networks(
359
+ `${_deployments_dir}/${_target_contract}`,
360
+ _networks_all);
361
+ }
362
+ for ( _network of _target_networks ) {
363
+ _target_network_id =
364
+ "";
365
+ _network_check_args = [
366
+ _deployments_dir,
367
+ _target_contract,
368
+ _network,
369
+ _target_network_id
370
+ ];
371
+ _network_check.apply(
372
+ null,
373
+ _network_check_args);
374
+ _contract_address_get_args.push( [
375
+ _deployments_dir,
376
+ _target_contract,
377
+ _target_network,
378
+ _target_network_id,
379
+ _contract_version
380
+ ] );
381
+ }
382
+ for ( _network of _network_ids ) {
383
+ _target_network =
384
+ "";
385
+ _network_check_args = [
386
+ _deployments_dir,
387
+ _target_contract,
388
+ _target_network,
389
+ _network
390
+ ];
391
+ _network_check.apply(
392
+ null,
393
+ _network_check_args);
394
+ _contract_address_get_args.push( [
395
+ _deployments_dir,
396
+ _target_contract,
397
+ _target_network,
398
+ _target_network_id,
399
+ _contract_version
400
+ ] );
401
+ }
402
+ for ( _args of _contract_address_args ) {
403
+ _contract_address =
404
+ _contract_address_get.apply(
405
+ null,
406
+ _args);
407
+ _contract_addresses.push(
408
+ _contract_address);
409
+ }
410
+ return _contracts_addresses;
411
+ }
412
+
413
+ function
414
+ _networks_all_auto_detect() {
415
+ let
416
+ _networks_all;
417
+ _networks_all =
418
+ "n";
419
+ if ( target_networks.length < 1 &&
420
+ network_ids.length < 1 ) {
421
+ _networks_all =
422
+ "y";
423
+ }
424
+ if ( typeof(
425
+ networks_all) === "undefined" ||
426
+ networks_all == "" ) {
427
+ networks_all =
428
+ _networks_all;
429
+ }
430
+ }
431
+
432
+ module.exports = {
433
+ _default_deployments_dir_get:
434
+ _default_deployments_dir_get,
435
+ _evm_contract_deployment_address:
436
+ _evm_contract_deployment_address,
437
+ _networks_all_auto_detect:
438
+ _networks_all_auto_detect,
439
+ };
@@ -0,0 +1,295 @@
1
+ #!/usr/bin/env node
2
+
3
+ // SPDX-License-Identifier: AGPL-3.0-or-later
4
+
5
+ /** ----------------------------------------------------------------
6
+ * libevm-contract-deployments-networks
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
+ const
37
+ _libcrash_module =
38
+ require(
39
+ "crash-js");
40
+ /* global
41
+ _dirname */
42
+ /* eslint-disable-next-line
43
+ no-global-assign */
44
+ const
45
+ _dirname =
46
+ _libcrash_module._dirname;
47
+ /* global
48
+ _file_exists */
49
+ /* eslint-disable-next-line
50
+ no-global-assign */
51
+ const
52
+ _file_exists =
53
+ _libcrash_module._file_exists;
54
+ /* global
55
+ _homedir_get */
56
+ /* eslint-disable-next-line
57
+ no-global-assign */
58
+ const
59
+ _homedir_get =
60
+ _libcrash_module._homedir_get;
61
+ /* global
62
+ _json_read */
63
+ /* eslint-disable-next-line
64
+ no-global-assign */
65
+ const
66
+ _json_read =
67
+ _libcrash_module._json_read;
68
+ /* global
69
+ _lib_get */
70
+ /* eslint-disable-next-line
71
+ no-global-assign */
72
+ const
73
+ _lib_get =
74
+ _libcrash_module._lib_get;
75
+ /* global
76
+ _ls */
77
+ /* eslint-disable-next-line
78
+ no-global-assign */
79
+ const
80
+ _ls =
81
+ _libcrash_module._ls;
82
+ /* global
83
+ _msg_info */
84
+ /* eslint-disable-next-line
85
+ no-global-assign */
86
+ const
87
+ _msg_info =
88
+ _libcrash_module._msg_info;
89
+ /* global
90
+ _msg_error */
91
+ /* eslint-disable-next-line
92
+ no-global-assign */
93
+ const
94
+ _msg_error =
95
+ _libcrash_module._msg_error;
96
+ /* global
97
+ _path_join */
98
+ /* eslint-disable-next-line
99
+ no-global-assign */
100
+ const
101
+ _path_join =
102
+ _libcrash_module._path_join;
103
+ /* global
104
+ _range */
105
+ /* eslint-disable-next-line
106
+ no-global-assign */
107
+ const
108
+ _range =
109
+ _libcrash_module._range;
110
+ /* global
111
+ _stat */
112
+ /* eslint-disable-next-line
113
+ no-global-assign */
114
+ const
115
+ _stat =
116
+ _libcrash_module._stat;
117
+ const
118
+ _libevm_contract_deployments_dir_module =
119
+ require(
120
+ "./libevm-contract-deployments-dir");
121
+ /* global
122
+ _evm_contract_deployments_dir */
123
+ const
124
+ _evm_contract_deployments_dir =
125
+ _libevm_contract_deployments_dir_module._evm_contract_deployments_dir;
126
+ const
127
+ _evm_chains_info_module =
128
+ require(
129
+ "evm-chains-info");
130
+ /* global
131
+ _evm_chains_info */
132
+ const
133
+ _evm_chains_info =
134
+ _evm_chains_info_module._evm_chains_info;
135
+
136
+
137
+ function
138
+ _contract_address_get(
139
+ _deployments,
140
+ _contract,
141
+ _network,
142
+ _network_id,
143
+ _version) {
144
+ let
145
+ _config_path,
146
+ _address,
147
+ _found,
148
+ _msg,
149
+ _net;
150
+ const
151
+ _networks = [
152
+ _network,
153
+ _network_id
154
+ ];
155
+ _found =
156
+ false;
157
+ for ( _net of _networks ) {
158
+ _config_path =
159
+ `${_deployments}/${_contract}/${_net}/config.sh`;
160
+ if ( _file_exists(
161
+ _config_path) ) {
162
+ _found =
163
+ true;
164
+ break;
165
+ }
166
+ }
167
+ if ( ! _found ) {
168
+ _msg =
169
+ `No network '${_network}' deployment ` +
170
+ `configuration for '${_contract}' ` +
171
+ `found at path '${_deployments}'.`;
172
+ _msg_error(
173
+ _msg,
174
+ 1);
175
+ }
176
+ const
177
+ _config =
178
+ _json_read(
179
+ _config);
180
+ const
181
+ _contract_address =
182
+ _config[
183
+ "contract-address"][
184
+ _version];
185
+ if ( _contract_address == "" ||
186
+ _contract_address == null ) {
187
+ _msg =
188
+ `No '${_contract}' version '${_version}' ` +
189
+ `contract deployment specified for network ` +
190
+ `'${_network}' for directory at path `+
191
+ `'${_deployments}'.`;
192
+ _msg_error(
193
+ _msg,
194
+ 1);
195
+ }
196
+ }
197
+
198
+ function
199
+ _network_check(
200
+ _deployments,
201
+ _contract,
202
+ _target_network,
203
+ _target_network_id) {
204
+ let
205
+ _msg,
206
+ _network_id,
207
+ _networks;
208
+ _networks = [
209
+ // I need to write that first apparently
210
+ _evm_contract_deployment_networks
211
+ ];
212
+ _app_check(
213
+ _app);
214
+ if ( typeof(
215
+ _type) == "undefined" ||
216
+ _type == "" ) {
217
+ _type =
218
+ "system";
219
+ }
220
+ let
221
+ _conf_dir;
222
+ if ( _type == "system" ) {
223
+ _conf_dir =
224
+ _lib_get();
225
+ }
226
+ else if ( _type == "user" ) {
227
+ const
228
+ _homedir =
229
+ _homedir_get();
230
+ _conf_dir =
231
+ `${_homedir}/.config`;
232
+ }
233
+ return `${_conf_dir}/${_app}/deployments`;
234
+ }
235
+
236
+ function
237
+ _networks_find(
238
+ _deployment_dir) {
239
+ let
240
+ _file,
241
+ _file_is_dir,
242
+ _path;
243
+ const
244
+ _networks =
245
+ [];
246
+ const
247
+ _files =
248
+ _ls(
249
+ _deployment_dir);
250
+ for ( _file of _files ) {
251
+ _path =
252
+ `${_deployment_dir}/${_file}`;
253
+ _file_is_dir =
254
+ _is_dir(
255
+ _path);
256
+ if ( ! _file_is_dir ) {
257
+ const
258
+ _msg =
259
+ `there shouldn't be a file into ` +
260
+ `this directory.`;
261
+ _msg_warning(
262
+ _msg)
263
+ _stat(
264
+ _file_info);
265
+ }
266
+ else {
267
+ _networks.push(
268
+ _file);
269
+ }
270
+ }
271
+ return _networks;
272
+ }
273
+
274
+ function
275
+ _evm_contract_deployment_networks(
276
+ _deployment_dir,
277
+ _display_all,
278
+ _display_safest,
279
+ _display_cheapest) {
280
+ let
281
+ _networks;
282
+ console.log(
283
+ _deployment_dir);
284
+ _networks =
285
+ _networks_find(
286
+ _deployment_dir);
287
+ console.log(
288
+ _networks);
289
+ return _networks;
290
+ }
291
+
292
+ module.exports = {
293
+ _evm_contract_deployment_networks:
294
+ _evm_contract_deployment_networks
295
+ };