evm-contracts-tools 0.0.45 → 0.0.47

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