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,466 @@
1
+ #!/usr/bin/env node
2
+
3
+ // SPDX-License-Identifier: AGPL-3.0-or-later
4
+
5
+ /** ----------------------------------------------------------------
6
+ * libevm-contract-deployment-bytecode
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_deployment_module =
179
+ require(
180
+ "./libevm-contract-deployment");
181
+ /* global
182
+ _contract_version_auto_detect */
183
+ const
184
+ _contract_version_auto_detect =
185
+ _libevm_contract_deployment._contract_version_auto_detect;
186
+ /* global
187
+ _deployments_dir_auto_detect */
188
+ const
189
+ _deployments_dir_auto_detect =
190
+ _libevm_contract_deployment._deployments_dir_auto_detect;
191
+ /* global
192
+ _network_check */
193
+ const
194
+ _network_check =
195
+ _libevm_contract_deployment._network_check;
196
+ /* global
197
+ _networks_all_auto_detect */
198
+ const
199
+ _networks_all_auto_detect =
200
+ _libevm_contract_deployment._networks_all_auto_detect;
201
+ /* global
202
+ _target_app_auto_detect */
203
+ const
204
+ _target_app_auto_detect =
205
+ _libevm_contract_deployment._target_app_auto_detect;
206
+ /* global
207
+ _user_deployments_check */
208
+ const
209
+ _user_deployments_check =
210
+ _libevm_contract_deployment._user_deployments_check;
211
+ const
212
+ _libevm_contract_deployments_dir_module =
213
+ require(
214
+ "./libevm-contract-deployments-dir");
215
+ /* global
216
+ _evm_contract_deployments_dir */
217
+ const
218
+ _evm_contract_deployments_dir =
219
+ _libevm_contract_deployments_dir_module._evm_contract_deployments_dir;
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_bytecode_get(
241
+ _deployments,
242
+ _contract,
243
+ _network,
244
+ _network_id,
245
+ _version) {
246
+ let
247
+ _bytecode_path,
248
+ _contract_bytecode,
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
+ _bytecode_path =
262
+ _path_join([
263
+ _deployments,
264
+ _contract,
265
+ _net,
266
+ _version,
267
+ `${_contract}.bin`
268
+ ]);
269
+ if ( _file_exists(
270
+ _bytecode_path) ) {
271
+ _found =
272
+ true;
273
+ break;
274
+ }
275
+ }
276
+ if ( ! _found ) {
277
+ _msg =
278
+ `No bytecode for network '${_network}' deployment ` +
279
+ `of contract '${_contract}' ` +
280
+ `found at path '${_deployments}'.`;
281
+ _msg_error(
282
+ _msg,
283
+ 0);
284
+ throw _msg;
285
+ }
286
+ const
287
+ _contract_bytecode =
288
+ _bytecode_path;
289
+ if ( _contract_bytecode == "" ||
290
+ _contract_bytecode == null ||
291
+ typeof(
292
+ _contract_bytecode) === "undefined" ) {
293
+ _msg =
294
+ `No '${_contract}' version '${_version}' ` +
295
+ `contract deployment specified for network ` +
296
+ `'${_network}' for directory at path `+
297
+ `'${_deployments}'.`;
298
+ _msg_error(
299
+ _msg,
300
+ 0);
301
+ throw _msg;
302
+ }
303
+ return _contract_bytecode;
304
+ }
305
+
306
+ async function
307
+ _evm_contract_deployment_bytecode(
308
+ _target_networks,
309
+ _network_ids,
310
+ _networks_all,
311
+ _target_app,
312
+ _target_contract,
313
+ _contract_version,
314
+ _user_defined,
315
+ _configuration_format,
316
+ _deployments_dir) {
317
+ let
318
+ _args,
319
+ _contract_bytecode,
320
+ _network,
321
+ _network_check_args,
322
+ _target_network,
323
+ _target_network_id,
324
+ _user_deployments_dir,
325
+ _system_deployments_dir,
326
+ _msg;
327
+ const
328
+ _contracts_bytecodes =
329
+ [];
330
+ const
331
+ _contract_bytecode_get_args =
332
+ [];
333
+ if ( _user_defined == "n" ) {
334
+ if ( _target_app == "" ) {
335
+ _msg =
336
+ "A target application needs to " +
337
+ "be specified with option '-a' " +
338
+ "if not enabling user-defined " +
339
+ "deployments with '-u' and " +
340
+ "specifying a deployments directory " +
341
+ "path with '-d'.";
342
+ _msg_error(
343
+ _msg,
344
+ 1)
345
+ }
346
+ _system_deployments_dir =
347
+ await _evm_contract_deployments_dir(
348
+ _target_app,
349
+ _user_defined);
350
+ if ( _deployments_dir != _system_deployments_dir ) {
351
+ _msg =
352
+ "To set a custom deployments directory path " +
353
+ "you need to enable the user-defined " +
354
+ "deployments switch with '-u'." +
355
+ _msg_error(
356
+ _msg,
357
+ 1)
358
+ }
359
+ }
360
+ else if ( _user_defined == "y" ) {
361
+ if ( _target_app != "" ) {
362
+ _user_deployments_dir =
363
+ await _evm_contract_deployments_dir(
364
+ _target_app,
365
+ _user_defined);
366
+ }
367
+ if ( _deployments_dir != _user_deployments_dir ) {
368
+ _msg =
369
+ "Using custom deployments directory " +
370
+ `path '${_deployments_dir}'.`;
371
+ _msg_info(
372
+ _msg);
373
+ }
374
+ else {
375
+ _user_deployments_check(
376
+ _target_app,
377
+ _deployments_dir);
378
+ }
379
+ }
380
+ else {
381
+ _msg =
382
+ "The 'user-defined' switch argument " +
383
+ `can be 'y' or 'n', current value '${_user_defined}'.`;
384
+ _msg_error(
385
+ _msg,
386
+ 1);
387
+ }
388
+ if ( _networks_all == "y" ) {
389
+ _msg =
390
+ "Selecting all networks."
391
+ _msg_info(
392
+ _msg);
393
+ _target_networks =
394
+ await _evm_contract_deployment_networks(
395
+ `${_deployments_dir}/${_target_contract}`,
396
+ _networks_all);
397
+ }
398
+ for ( _network of _target_networks ) {
399
+ // _msg =
400
+ // "Info arguments for " +
401
+ // `network '${_network}'.`;
402
+ // _msg_info(
403
+ // _msg);
404
+ _target_network_id =
405
+ "";
406
+ _network_check_args = [
407
+ _deployments_dir,
408
+ _target_contract,
409
+ _network,
410
+ _target_network_id
411
+ ];
412
+ await _network_check.apply(
413
+ null,
414
+ _network_check_args);
415
+ _contract_bytecode_get_args.push( [
416
+ _deployments_dir,
417
+ _target_contract,
418
+ _network,
419
+ _target_network_id,
420
+ _contract_version,
421
+ _configuration_format
422
+ ] );
423
+ }
424
+ for ( _network of _network_ids ) {
425
+ _target_network =
426
+ "";
427
+ _network_check_args = [
428
+ _deployments_dir,
429
+ _target_contract,
430
+ _target_network,
431
+ _network
432
+ ];
433
+ await _network_check.apply(
434
+ null,
435
+ _network_check_args);
436
+ _contract_bytecode_get_args.push( [
437
+ _deployments_dir,
438
+ _target_contract,
439
+ _target_network,
440
+ _target_network_id,
441
+ _contract_version
442
+ ] );
443
+ }
444
+ for ( _args of _contract_bytecode_get_args ) {
445
+ _contract_bytecode =
446
+ _contract_bytecode_get.apply(
447
+ null,
448
+ _args);
449
+ _contracts_bytecodes.push(
450
+ _contract_bytecode);
451
+ }
452
+ return _contracts_bytecodes;
453
+ }
454
+
455
+ module.exports = {
456
+ _contract_version_auto_detect:
457
+ _contract_version_auto_detect,
458
+ _deployments_dir_auto_detect:
459
+ _deployments_dir_auto_detect,
460
+ _evm_contract_deployment_bytecode:
461
+ _evm_contract_deployment_bytecode,
462
+ _networks_all_auto_detect:
463
+ _networks_all_auto_detect,
464
+ _target_app_auto_detect:
465
+ _target_app_auto_detect
466
+ };