evm-contracts-tools 0.0.48 → 0.0.50
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/dist/evm-contract-call/evm-contract-call.js +1 -1
- package/dist/evm-contract-deployment-abi/evm-contract-deployment-abi.js +1 -1
- package/dist/evm-contract-deployment-address/evm-contract-deployment-address.js +1 -1
- package/dist/evm-contract-deployment-bytecode/evm-contract-deployment-bytecode.js +1 -1
- package/dist/evm-contract-deployment-compiler-output/evm-contract-deployment-compiler-output.js +1 -1
- 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/libevm-contract-deployment-abi.js +1 -1
- package/dist/libevm-contract-deployment-address/libevm-contract-deployment-address.js +1 -1
- package/dist/libevm-contract-deployment-bytecode/libevm-contract-deployment-bytecode.js +1 -1
- 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/lib/address-check +16 -11
- package/lib/bytecode-creation-get +24 -14
- package/lib/bytecode-runtime-get +20 -15
- package/lib/contract-get +35 -17
- package/lib/deployer-get +47 -10
- package/lib/deployer-verify +19 -16
- package/lib/evm-contract-call-dynamic +40 -23
- package/lib/evm-contract-call-static +222 -153
- package/libevm-contract-call +10 -5
- package/package.json +11 -9
|
@@ -24,72 +24,143 @@
|
|
|
24
24
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
+
/* Crash Javascript global variables */
|
|
28
|
+
|
|
29
|
+
/* global
|
|
30
|
+
app_name:
|
|
31
|
+
writable */
|
|
32
|
+
/* global
|
|
33
|
+
app_opts:
|
|
34
|
+
writable */
|
|
35
|
+
/* global
|
|
36
|
+
quiet:
|
|
37
|
+
writable */
|
|
38
|
+
|
|
27
39
|
const
|
|
28
40
|
_libcrash =
|
|
29
41
|
require(
|
|
30
42
|
"crash-js");
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
/* global
|
|
44
|
+
_cmdline_check */
|
|
45
|
+
const
|
|
46
|
+
_cmdline_check =
|
|
47
|
+
_libcrash._cmdline_check;
|
|
48
|
+
/* global
|
|
49
|
+
_error_display */
|
|
50
|
+
const
|
|
51
|
+
_error_display =
|
|
52
|
+
_libcrash._error_display;
|
|
53
|
+
/* global
|
|
54
|
+
_exit */
|
|
55
|
+
const
|
|
56
|
+
_exit =
|
|
57
|
+
_libcrash._exit;
|
|
58
|
+
/* global
|
|
59
|
+
_msg_info */
|
|
60
|
+
const
|
|
61
|
+
_msg_info =
|
|
62
|
+
_libcrash._msg_info;
|
|
63
|
+
/* global
|
|
64
|
+
_msg_error */
|
|
65
|
+
const
|
|
66
|
+
_msg_error =
|
|
67
|
+
_libcrash._msg_error;
|
|
68
|
+
/* global
|
|
69
|
+
_override_set */
|
|
70
|
+
const
|
|
71
|
+
_override_set =
|
|
72
|
+
_libcrash._override_set;
|
|
73
|
+
/* global
|
|
74
|
+
_printf */
|
|
75
|
+
const
|
|
76
|
+
_printf =
|
|
77
|
+
_libcrash._printf;
|
|
78
|
+
/* global
|
|
79
|
+
_sleep */
|
|
80
|
+
const
|
|
81
|
+
_sleep =
|
|
82
|
+
_libcrash._sleep;
|
|
43
83
|
const
|
|
44
84
|
_contract_get_module =
|
|
45
85
|
require(
|
|
46
86
|
'./contract-get');
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
87
|
+
/* global
|
|
88
|
+
_contract_get */
|
|
89
|
+
const
|
|
90
|
+
_contract_get =
|
|
91
|
+
_contract_get_module._contract_get
|
|
50
92
|
|
|
51
93
|
function
|
|
52
94
|
_global_variables() {
|
|
53
95
|
app_name =
|
|
54
96
|
"evm-contract-call-static";
|
|
97
|
+
app_opts =
|
|
98
|
+
[];
|
|
99
|
+
/* global
|
|
100
|
+
wallet_seed:
|
|
101
|
+
writable */
|
|
55
102
|
wallet_seed =
|
|
56
|
-
|
|
103
|
+
"";
|
|
104
|
+
/* global
|
|
105
|
+
retries_max:
|
|
106
|
+
writable */
|
|
57
107
|
retries_max =
|
|
58
|
-
|
|
108
|
+
"";
|
|
109
|
+
/* global
|
|
110
|
+
api_key_path:
|
|
111
|
+
writable */
|
|
59
112
|
api_key_path =
|
|
60
|
-
|
|
113
|
+
"";
|
|
114
|
+
/* global
|
|
115
|
+
target_network:
|
|
116
|
+
writable */
|
|
61
117
|
target_network =
|
|
62
|
-
|
|
118
|
+
"";
|
|
119
|
+
/* global
|
|
120
|
+
contract_address:
|
|
121
|
+
writable */
|
|
63
122
|
contract_address =
|
|
64
|
-
|
|
123
|
+
"";
|
|
124
|
+
/* global
|
|
125
|
+
contract_abi_path:
|
|
126
|
+
writable */
|
|
65
127
|
contract_abi_path =
|
|
66
|
-
|
|
128
|
+
"";
|
|
129
|
+
/* global
|
|
130
|
+
contract_bytecode_path:
|
|
131
|
+
writable */
|
|
67
132
|
contract_bytecode_path =
|
|
68
|
-
|
|
133
|
+
"";
|
|
134
|
+
/* global
|
|
135
|
+
contract_compiler_output_path:
|
|
136
|
+
writable */
|
|
69
137
|
contract_compiler_output_path =
|
|
70
|
-
|
|
138
|
+
"";
|
|
139
|
+
/* global
|
|
140
|
+
method_object:
|
|
141
|
+
writable */
|
|
71
142
|
method_object =
|
|
72
|
-
|
|
143
|
+
"";
|
|
144
|
+
/* global
|
|
145
|
+
contract_method:
|
|
146
|
+
writable */
|
|
73
147
|
contract_method =
|
|
74
|
-
|
|
148
|
+
"";
|
|
149
|
+
/* global
|
|
150
|
+
method_args:
|
|
151
|
+
writable */
|
|
75
152
|
method_args =
|
|
76
153
|
[];
|
|
77
154
|
quiet =
|
|
78
|
-
|
|
155
|
+
"";
|
|
79
156
|
}
|
|
80
157
|
|
|
81
158
|
function
|
|
82
159
|
_msg_info_contract_obtained(
|
|
83
160
|
_contract) {
|
|
84
|
-
|
|
85
|
-
_msg
|
|
86
|
-
|
|
87
|
-
_template =
|
|
88
|
-
"Contract '{_contract}' obtained.";
|
|
89
|
-
_msg =
|
|
90
|
-
_template.replaceAll(
|
|
91
|
-
"{_contract}",
|
|
92
|
-
_contract);
|
|
161
|
+
const
|
|
162
|
+
_msg =
|
|
163
|
+
`Contract '${_contract}' obtained.`;
|
|
93
164
|
_msg_info(
|
|
94
165
|
_msg);
|
|
95
166
|
}
|
|
@@ -97,10 +168,9 @@ function
|
|
|
97
168
|
function
|
|
98
169
|
_msg_info_method_obtained(
|
|
99
170
|
_method) {
|
|
100
|
-
|
|
101
|
-
_msg
|
|
102
|
-
|
|
103
|
-
"Method obtained.";
|
|
171
|
+
const
|
|
172
|
+
_msg =
|
|
173
|
+
"Method obtained.";
|
|
104
174
|
_msg_info(
|
|
105
175
|
_msg);
|
|
106
176
|
}
|
|
@@ -122,17 +192,18 @@ async function
|
|
|
122
192
|
_contract,
|
|
123
193
|
_contract_get_opts,
|
|
124
194
|
_method,
|
|
195
|
+
_msg,
|
|
125
196
|
_passed,
|
|
126
|
-
_value
|
|
127
|
-
_wallet_password;
|
|
197
|
+
_value;
|
|
128
198
|
if ( _method_object == undefined ) {
|
|
129
199
|
_method_object =
|
|
130
200
|
"";
|
|
131
201
|
}
|
|
132
202
|
_retry =
|
|
133
203
|
1;
|
|
134
|
-
|
|
135
|
-
|
|
204
|
+
const
|
|
205
|
+
_wallet_password =
|
|
206
|
+
"";
|
|
136
207
|
_contract_get_opts = [
|
|
137
208
|
_wallet_seed,
|
|
138
209
|
_wallet_password,
|
|
@@ -148,24 +219,50 @@ async function
|
|
|
148
219
|
while ( _retry <= _retries_max &&
|
|
149
220
|
_passed == false ) {
|
|
150
221
|
try {
|
|
151
|
-
if ( _method_object
|
|
152
|
-
|
|
222
|
+
if ( _method_object === "" ||
|
|
223
|
+
typeof(
|
|
224
|
+
_method_object) === "undefined" ) {
|
|
153
225
|
_contract =
|
|
154
226
|
await _contract_get.apply(
|
|
155
227
|
null,
|
|
156
228
|
_contract_get_opts);
|
|
157
229
|
_msg_info_contract_obtained(
|
|
158
230
|
_contract);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
231
|
+
try {
|
|
232
|
+
_method =
|
|
233
|
+
await _contract.getFunction(
|
|
234
|
+
_contract_method);
|
|
235
|
+
_msg_info_method_obtained(
|
|
236
|
+
_method);
|
|
237
|
+
}
|
|
238
|
+
catch(
|
|
239
|
+
_error) {
|
|
240
|
+
const
|
|
241
|
+
_msg_no_fragment =
|
|
242
|
+
"no matching fragment";
|
|
243
|
+
const
|
|
244
|
+
_msg_short =
|
|
245
|
+
_error[
|
|
246
|
+
"shortMessage"];
|
|
247
|
+
if ( _msg_no_fragment == _msg_short ) {
|
|
248
|
+
_msg =
|
|
249
|
+
`Found no '${_contract_method}' method ` +
|
|
250
|
+
`nor contract ABI '${_contract_abi_path}' ` +
|
|
251
|
+
`nor in compiler output ` +
|
|
252
|
+
`'${_contract_compiler_output_path}'.`;
|
|
253
|
+
_msg_error(
|
|
254
|
+
_msg,
|
|
255
|
+
0);
|
|
256
|
+
}
|
|
257
|
+
throw _error;
|
|
258
|
+
}
|
|
164
259
|
}
|
|
165
260
|
else if ( _method_object != "" ||
|
|
166
261
|
_method_object != undefined ) {
|
|
262
|
+
_msg =
|
|
263
|
+
"Re-using contract method.";
|
|
167
264
|
_msg_info(
|
|
168
|
-
|
|
265
|
+
_msg);
|
|
169
266
|
_method =
|
|
170
267
|
_method_object;
|
|
171
268
|
}
|
|
@@ -209,58 +306,25 @@ async function
|
|
|
209
306
|
function
|
|
210
307
|
_config_show() {
|
|
211
308
|
let
|
|
212
|
-
_line
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
"{api_key_path}",
|
|
232
|
-
api_key_path));
|
|
233
|
-
_text.push(
|
|
234
|
-
" Target network: {target_network}".replace(
|
|
235
|
-
"{target_network}",
|
|
236
|
-
target_network));
|
|
237
|
-
_text.push(
|
|
238
|
-
" Contract ABI: {contract_abi_path}".replace(
|
|
239
|
-
"{contract_abi_path}",
|
|
240
|
-
contract_abi_path));
|
|
241
|
-
_text.push(
|
|
242
|
-
" Contract bytecode: {contract_bytecode_path}".replace(
|
|
243
|
-
"{contract_bytecode_path}",
|
|
244
|
-
contract_bytecode_path));
|
|
245
|
-
_text.push(
|
|
246
|
-
"Contract compiler output: {contract_compiler_output_path}".replace(
|
|
247
|
-
"{contract_compiler_output_path}",
|
|
248
|
-
contract_compiler_output_path));
|
|
249
|
-
_text.push(
|
|
250
|
-
" Contract address: {contract_address}".replace(
|
|
251
|
-
"{contract_address}",
|
|
252
|
-
contract_address));
|
|
253
|
-
_text.push(
|
|
254
|
-
" Contract method: {contract_method}".replace(
|
|
255
|
-
"{contract_method}",
|
|
256
|
-
contract_method));
|
|
257
|
-
_method_args =
|
|
258
|
-
method_args.join(
|
|
259
|
-
" ");
|
|
260
|
-
_text.push(
|
|
261
|
-
" Method args: {method_args}".replace(
|
|
262
|
-
"{method_args}",
|
|
263
|
-
_method_args));
|
|
309
|
+
_line;
|
|
310
|
+
const
|
|
311
|
+
_method_args =
|
|
312
|
+
method_args.join(
|
|
313
|
+
" ");
|
|
314
|
+
const
|
|
315
|
+
_text = [
|
|
316
|
+
` ${app_name} configuration:`,
|
|
317
|
+
` Wallet seed: ${wallet_seed}`,
|
|
318
|
+
` Max retries: ${retries_max}`,
|
|
319
|
+
` API Key path: ${api_key_path}`,
|
|
320
|
+
` Target network: ${target_network}`,
|
|
321
|
+
` Contract ABI: ${contract_abi_path}`,
|
|
322
|
+
` Contract bytecode: ${contract_bytecode_path}`,
|
|
323
|
+
`Contract compiler output: ${contract_compiler_output_path}`,
|
|
324
|
+
` Contract address: ${contract_address}`,
|
|
325
|
+
` Contract method: ${contract_method}`,
|
|
326
|
+
` Method args: ${_method_args}`
|
|
327
|
+
];
|
|
264
328
|
for (_line of _text) {
|
|
265
329
|
_msg_info(
|
|
266
330
|
_line);
|
|
@@ -269,63 +333,63 @@ function
|
|
|
269
333
|
|
|
270
334
|
function
|
|
271
335
|
_usage(
|
|
272
|
-
|
|
336
|
+
_exit_code) {
|
|
273
337
|
let
|
|
274
|
-
_line
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
338
|
+
_line;
|
|
339
|
+
const
|
|
340
|
+
_text = [
|
|
341
|
+
"Execute a static call to an EVM network's contract method",
|
|
342
|
+
"",
|
|
343
|
+
"Usage:",
|
|
344
|
+
" evm-contract-call-static",
|
|
345
|
+
" <quiet>",
|
|
346
|
+
" <wallet-seed>",
|
|
347
|
+
" <retries-max>",
|
|
348
|
+
" <api-key-path>",
|
|
349
|
+
" <target-network>",
|
|
350
|
+
" <contract-abi-path>",
|
|
351
|
+
" <contract-bytecode-path>",
|
|
352
|
+
" <contract-compiler-output-path>",
|
|
353
|
+
" <contract-address>",
|
|
354
|
+
" <contract-method>",
|
|
355
|
+
" <method-args>",
|
|
356
|
+
"",
|
|
357
|
+
"Args:",
|
|
358
|
+
" <quiet> Can be 'y' or 'n'",
|
|
359
|
+
" Default: y",
|
|
360
|
+
" <wallet-seed> Path of the file containing",
|
|
361
|
+
" the seed phrase.",
|
|
362
|
+
" <retries-max> Maximum number of retries before",
|
|
363
|
+
" failing.",
|
|
364
|
+
" <api-key-path> Path of the API key for the",
|
|
365
|
+
" contract ABI provider service",
|
|
366
|
+
" <target-network> Network on which the contract",
|
|
367
|
+
" resides.",
|
|
368
|
+
" <contract-abi-path> Path of the contract ABI",
|
|
369
|
+
" <contract-bytecode-path> Path for the contract bytecode",
|
|
370
|
+
" <contract-compiler-output-path> Path for the contract compiler",
|
|
371
|
+
" output path (the hardhat artifact).",
|
|
372
|
+
" <contract-address> Address of the contract",
|
|
373
|
+
" <contract-method> Contract method to execute",
|
|
374
|
+
" [method-args] Arguments to pass to the method",
|
|
375
|
+
"",
|
|
376
|
+
" Options:",
|
|
377
|
+
" -h This help."
|
|
378
|
+
];
|
|
315
379
|
for (_line of _text) {
|
|
316
380
|
_msg_info(
|
|
317
381
|
_line);
|
|
318
382
|
}
|
|
319
|
-
|
|
320
|
-
|
|
383
|
+
_exit(
|
|
384
|
+
_exit_code);
|
|
321
385
|
}
|
|
322
386
|
|
|
323
387
|
function
|
|
324
388
|
_overrides_set() {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
389
|
+
_override_set(
|
|
390
|
+
"retries",
|
|
391
|
+
"max",
|
|
392
|
+
100);
|
|
329
393
|
}
|
|
330
394
|
|
|
331
395
|
function
|
|
@@ -399,6 +463,7 @@ async function
|
|
|
399
463
|
_app_opts) {
|
|
400
464
|
let
|
|
401
465
|
_method_object,
|
|
466
|
+
_msg,
|
|
402
467
|
_value;
|
|
403
468
|
try {
|
|
404
469
|
[_value,
|
|
@@ -411,16 +476,20 @@ async function
|
|
|
411
476
|
_value.toString());
|
|
412
477
|
}
|
|
413
478
|
else {
|
|
479
|
+
_msg =
|
|
480
|
+
"Static contract call returned undefined value.";
|
|
414
481
|
throw { "error": {
|
|
415
482
|
"message":
|
|
416
|
-
|
|
483
|
+
_msg } };
|
|
417
484
|
}
|
|
418
485
|
} catch (
|
|
419
486
|
_error) {
|
|
420
487
|
_error_display(
|
|
421
488
|
_error);
|
|
489
|
+
_msg =
|
|
490
|
+
"Error while running static call.";
|
|
422
491
|
_msg_error(
|
|
423
|
-
|
|
492
|
+
_msg,
|
|
424
493
|
1);
|
|
425
494
|
}
|
|
426
495
|
}
|
package/libevm-contract-call
CHANGED
|
@@ -100,6 +100,11 @@ const
|
|
|
100
100
|
const
|
|
101
101
|
_msg_error =
|
|
102
102
|
_libcrash_module._msg_error;
|
|
103
|
+
/* global
|
|
104
|
+
_override_set */
|
|
105
|
+
const
|
|
106
|
+
_override_set =
|
|
107
|
+
_libcrash_module._override_set;
|
|
103
108
|
/* global
|
|
104
109
|
_path_join */
|
|
105
110
|
const
|
|
@@ -140,11 +145,11 @@ function
|
|
|
140
145
|
"1"
|
|
141
146
|
];
|
|
142
147
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
// to be auto-detected
|
|
149
|
+
_override_set(
|
|
150
|
+
"target",
|
|
151
|
+
"network",
|
|
152
|
+
"1");
|
|
148
153
|
}
|
|
149
154
|
|
|
150
155
|
function
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{ "name": "evm-contracts-tools",
|
|
2
2
|
"version":
|
|
3
|
-
"0.0.
|
|
3
|
+
"0.0.50",
|
|
4
4
|
"description":
|
|
5
5
|
"JavaScript programs and libraries to enable seamless development of native computer applications designed to interact with Ethereum Virtual Machine-compatible networks.",
|
|
6
6
|
"funding": {
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
103
|
"crash-js-webpack":
|
|
104
|
-
"^0.0.
|
|
104
|
+
"^0.0.46",
|
|
105
105
|
"brace-expansion":
|
|
106
106
|
"^5.0.9",
|
|
107
107
|
"eslint":
|
|
@@ -121,17 +121,17 @@
|
|
|
121
121
|
},
|
|
122
122
|
"dependencies": {
|
|
123
123
|
"crash-js":
|
|
124
|
-
"^0.
|
|
124
|
+
"^0.11111.1111111111111111",
|
|
125
125
|
"ethers":
|
|
126
126
|
"^6.13.2",
|
|
127
127
|
"evm-chains-info":
|
|
128
|
-
"^0.0.
|
|
128
|
+
"^0.0.30",
|
|
129
129
|
"evm-transactions-tools":
|
|
130
130
|
"^0.0.1111",
|
|
131
|
-
"evm-wallet
|
|
132
|
-
"
|
|
131
|
+
"evm-wallet":
|
|
132
|
+
"npm:evm-wallet.js@^0.0.75",
|
|
133
133
|
"libevm":
|
|
134
|
-
"^0.0.
|
|
134
|
+
"^0.0.33",
|
|
135
135
|
"ws":
|
|
136
136
|
"^8.21.0",
|
|
137
137
|
"yargs":
|
|
@@ -140,10 +140,12 @@
|
|
|
140
140
|
"overrides": {
|
|
141
141
|
"evm-contracts-tools":
|
|
142
142
|
"./evm-contracts-tools",
|
|
143
|
+
"evm-wallet":
|
|
144
|
+
"npm:evm-wallet.js@^0.0.75",
|
|
143
145
|
"evm-wallet.js":
|
|
144
|
-
"
|
|
146
|
+
"npm:evm-wallet.js@^0.0.75",
|
|
145
147
|
"libevm":
|
|
146
|
-
"^0.0.
|
|
148
|
+
"^0.0.33"
|
|
147
149
|
},
|
|
148
150
|
"type":
|
|
149
151
|
"commonjs",
|