evm-contracts-tools 0.0.46 → 0.0.48

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