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.
- package/Makefile +13 -0
- package/dist/evm-contract-call/evm-contract-call.js +1 -1
- package/dist/evm-contract-deployment-abi/evm-contract-deployment-abi.js +2 -0
- package/dist/evm-contract-deployment-abi/fs-worker.js +1 -0
- package/dist/evm-contract-deployment-abi/index.html +31 -0
- package/dist/evm-contract-deployment-address/evm-contract-deployment-address.js +1 -1
- package/dist/evm-contract-deployment-bytecode/evm-contract-deployment-bytecode.js +2 -0
- package/dist/evm-contract-deployment-bytecode/fs-worker.js +1 -0
- package/dist/evm-contract-deployment-bytecode/index.html +31 -0
- package/dist/evm-contract-deployment-compiler-output/evm-contract-deployment-compiler-output.js +2 -0
- package/dist/evm-contract-deployment-compiler-output/fs-worker.js +1 -0
- package/dist/evm-contract-deployment-compiler-output/index.html +31 -0
- package/dist/evm-contract-deployment-networks/evm-contract-deployment-networks.js +1 -1
- package/dist/evm-contract-deployment-versions/evm-contract-deployment-versions.js +1 -1
- package/dist/evm-contract-deployments-dir/evm-contract-deployments-dir.js +1 -1
- package/dist/evm-contracts-tools/evm-contracts-tools.js +1 -1
- package/dist/libevm-contract-call/libevm-contract-call.js +1 -1
- package/dist/libevm-contract-deployment-abi/fs-worker.js +1 -0
- package/dist/libevm-contract-deployment-abi/index.html +24 -0
- package/dist/libevm-contract-deployment-abi/libevm-contract-deployment-abi.js +2 -0
- package/dist/libevm-contract-deployment-address/libevm-contract-deployment-address.js +1 -1
- package/dist/libevm-contract-deployment-bytecode/fs-worker.js +1 -0
- package/dist/libevm-contract-deployment-bytecode/index.html +24 -0
- package/dist/libevm-contract-deployment-bytecode/libevm-contract-deployment-bytecode.js +2 -0
- package/dist/libevm-contract-deployment-compiler-output/fs-worker.js +1 -0
- package/dist/libevm-contract-deployment-compiler-output/index.html +24 -0
- package/dist/libevm-contract-deployment-networks/libevm-contract-deployment-networks.js +1 -1
- package/dist/libevm-contract-deployment-versions/libevm-contract-deployment-versions.js +1 -1
- package/dist/libevm-contract-deployments-dir/libevm-contract-deployments-dir.js +1 -1
- package/evm-contract-call +44 -40
- package/evm-contract-deployment-abi +538 -0
- package/evm-contract-deployment-address +34 -29
- package/evm-contract-deployment-bytecode +538 -0
- package/evm-contract-deployment-compiler-output +537 -0
- package/evm-contract-deployments-dir +24 -34
- package/lib/address-check +0 -0
- package/lib/evm-contract-call-dynamic +46 -17
- package/lib/evm-contract-call-static +0 -0
- package/libevm-contract-call +0 -18
- package/libevm-contract-deployment +650 -0
- package/libevm-contract-deployment-abi +446 -0
- package/libevm-contract-deployment-address +71 -402
- package/libevm-contract-deployment-bytecode +446 -0
- package/libevm-contract-deployment-compiler-output +446 -0
- package/libevm-contract-deployment-networks +28 -72
- package/libevm-contract-deployment-versions +26 -50
- package/libevm-contract-deployments-dir +13 -21
- 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-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
|
+
|
|
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_abi_get(
|
|
219
|
+
_deployments,
|
|
220
|
+
_contract,
|
|
221
|
+
_network,
|
|
222
|
+
_network_id,
|
|
223
|
+
_version) {
|
|
224
|
+
let
|
|
225
|
+
_abi_path,
|
|
226
|
+
_address,
|
|
227
|
+
_found,
|
|
228
|
+
_key_name,
|
|
229
|
+
_msg,
|
|
230
|
+
_net;
|
|
231
|
+
const
|
|
232
|
+
_networks = [
|
|
233
|
+
_network,
|
|
234
|
+
_network_id
|
|
235
|
+
];
|
|
236
|
+
_found =
|
|
237
|
+
false;
|
|
238
|
+
for ( _net of _networks ) {
|
|
239
|
+
_abi_path =
|
|
240
|
+
_path_join( [
|
|
241
|
+
_deployments,
|
|
242
|
+
_contract,
|
|
243
|
+
_net,
|
|
244
|
+
_version,
|
|
245
|
+
`${_contract}.abi.json` ]);
|
|
246
|
+
if ( _file_exists(
|
|
247
|
+
_abi_path) ) {
|
|
248
|
+
_found =
|
|
249
|
+
true;
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if ( ! _found ) {
|
|
254
|
+
_msg =
|
|
255
|
+
`No ABI file for '${_network}' deployment ` +
|
|
256
|
+
`of contract '${_contract}' ` +
|
|
257
|
+
`found at path '${_deployments}'.`;
|
|
258
|
+
_msg_error(
|
|
259
|
+
_msg,
|
|
260
|
+
0);
|
|
261
|
+
throw _msg;
|
|
262
|
+
}
|
|
263
|
+
const
|
|
264
|
+
_contract_abi =
|
|
265
|
+
_abi_path;
|
|
266
|
+
if ( _contract_abi == "" ||
|
|
267
|
+
typeof(
|
|
268
|
+
_contract_abi) == "undefined" ||
|
|
269
|
+
_contract_abi == null ) {
|
|
270
|
+
_msg =
|
|
271
|
+
`No '${_contract}' version '${_version}' ` +
|
|
272
|
+
`contract deployment specified for network ` +
|
|
273
|
+
`'${_network}' for directory at path `+
|
|
274
|
+
`'${_deployments}'.`;
|
|
275
|
+
_msg_error(
|
|
276
|
+
_msg,
|
|
277
|
+
0);
|
|
278
|
+
throw _msg;
|
|
279
|
+
}
|
|
280
|
+
return _contract_abi;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
async function
|
|
284
|
+
_evm_contract_deployment_abi(
|
|
285
|
+
_target_networks,
|
|
286
|
+
_network_ids,
|
|
287
|
+
_networks_all,
|
|
288
|
+
_target_app,
|
|
289
|
+
_target_contract,
|
|
290
|
+
_contract_version,
|
|
291
|
+
_user_defined,
|
|
292
|
+
_configuration_format,
|
|
293
|
+
_deployments_dir) {
|
|
294
|
+
let
|
|
295
|
+
_args,
|
|
296
|
+
_contract_abi,
|
|
297
|
+
_network,
|
|
298
|
+
_network_check_args,
|
|
299
|
+
_target_network,
|
|
300
|
+
_target_network_id,
|
|
301
|
+
_user_deployments_dir,
|
|
302
|
+
_system_deployments_dir,
|
|
303
|
+
_msg;
|
|
304
|
+
const
|
|
305
|
+
_contracts_abis =
|
|
306
|
+
[];
|
|
307
|
+
const
|
|
308
|
+
_contract_abi_get_args =
|
|
309
|
+
[];
|
|
310
|
+
if ( _user_defined == "n" ) {
|
|
311
|
+
if ( _target_app == "" ) {
|
|
312
|
+
_msg =
|
|
313
|
+
"A target application needs to " +
|
|
314
|
+
"be specified with option '-a' " +
|
|
315
|
+
"if not enabling user-defined " +
|
|
316
|
+
"deployments with '-u' and " +
|
|
317
|
+
"specifying a deployments directory " +
|
|
318
|
+
"path with '-d'.";
|
|
319
|
+
_msg_error(
|
|
320
|
+
_msg,
|
|
321
|
+
0);
|
|
322
|
+
throw _msg;
|
|
323
|
+
}
|
|
324
|
+
_system_deployments_dir =
|
|
325
|
+
await _evm_contract_deployments_dir(
|
|
326
|
+
_target_app,
|
|
327
|
+
_user_defined);
|
|
328
|
+
if ( _deployments_dir != _system_deployments_dir ) {
|
|
329
|
+
_msg =
|
|
330
|
+
"To set a custom deployments directory path " +
|
|
331
|
+
"you need to enable the user-defined " +
|
|
332
|
+
"deployments switch with '-u'." +
|
|
333
|
+
_msg_error(
|
|
334
|
+
_msg,
|
|
335
|
+
0);
|
|
336
|
+
throw _msg;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
else if ( _user_defined == "y" ) {
|
|
340
|
+
if ( _target_app != "" ) {
|
|
341
|
+
_user_deployments_dir =
|
|
342
|
+
await _evm_contract_deployments_dir(
|
|
343
|
+
_target_app,
|
|
344
|
+
_user_defined);
|
|
345
|
+
}
|
|
346
|
+
if ( _deployments_dir != _user_deployments_dir ) {
|
|
347
|
+
_msg =
|
|
348
|
+
"Using custom deployments directory " +
|
|
349
|
+
`path '${_deployments_dir}'.`;
|
|
350
|
+
_msg_info(
|
|
351
|
+
_msg);
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
_user_deployments_check(
|
|
355
|
+
_target_app,
|
|
356
|
+
_deployments_dir);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
_msg =
|
|
361
|
+
"The 'user-defined' switch argument " +
|
|
362
|
+
`can be 'y' or 'n', current value '${_user_defined}'.`;
|
|
363
|
+
_msg_error(
|
|
364
|
+
_msg,
|
|
365
|
+
1);
|
|
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_abi_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_abi_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_abi_get_args ) {
|
|
425
|
+
_contract_abi =
|
|
426
|
+
_contract_abi_get.apply(
|
|
427
|
+
null,
|
|
428
|
+
_args);
|
|
429
|
+
_contracts_abis.push(
|
|
430
|
+
_contract_abi);
|
|
431
|
+
}
|
|
432
|
+
return _contracts_abis;
|
|
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_abi:
|
|
441
|
+
_evm_contract_deployment_abi,
|
|
442
|
+
_networks_all_auto_detect:
|
|
443
|
+
_networks_all_auto_detect,
|
|
444
|
+
_target_app_auto_detect:
|
|
445
|
+
_target_app_auto_detect
|
|
446
|
+
};
|