evm-contracts-tools 0.0.55 → 0.0.57

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.
@@ -29,8 +29,18 @@
29
29
 
30
30
  const
31
31
  _libcrash =
32
- require(
33
- "crash-js");
32
+ await import(
33
+ "libcrash-js");
34
+ /* global
35
+ _argv */
36
+ const
37
+ _argv =
38
+ _libcrash._argv;
39
+ /* global
40
+ _basename */
41
+ const
42
+ _basename =
43
+ _libcrash._basename;
34
44
  /* global
35
45
  _cmdline_check */
36
46
  const
@@ -41,6 +51,11 @@ const
41
51
  const
42
52
  _dirname =
43
53
  _libcrash._dirname;
54
+ /* global
55
+ _echo */
56
+ const
57
+ _echo =
58
+ _libcrash._echo;
44
59
  /* global
45
60
  _exit */
46
61
  const
@@ -51,6 +66,16 @@ const
51
66
  const
52
67
  _error_display =
53
68
  _libcrash._error_display;
69
+ /* global
70
+ _get */
71
+ const
72
+ _get =
73
+ _libcrash._get;
74
+ /* global
75
+ _global_get */
76
+ const
77
+ _global_get =
78
+ _libcrash._global_get;
54
79
  /* global
55
80
  _msg_info */
56
81
  const
@@ -76,6 +101,11 @@ const
76
101
  const
77
102
  _require =
78
103
  _libcrash._require;
104
+ /* global
105
+ _set */
106
+ const
107
+ _set =
108
+ _libcrash._set;
79
109
  /* global
80
110
  _sleep */
81
111
  const
@@ -111,99 +141,143 @@ const
111
141
  _evm_wallet_module._price_gas_transaction_get;
112
142
  const
113
143
  _contract_get_module =
114
- require(
144
+ await import(
115
145
  './contract-get');
116
146
  /* global
117
147
  _contract_get */
118
- _contract_get =
119
- _contract_get_module._contract_get;
148
+ const
149
+ _contract_get =
150
+ _contract_get_module._contract_get;
120
151
 
121
152
  function
122
153
  _global_variables() {
123
154
  /* global
124
155
  app_name:
125
156
  writable */
126
- app_name =
127
- "evm-contract-call-dynamic";
157
+ _set(
158
+ "app",
159
+ "name",
160
+ "evm-contract-call-dynamic");
161
+ /* global
162
+ app_opts:
163
+ writable */
164
+ _set(
165
+ "app",
166
+ "opts",
167
+ []);
128
168
  /* global
129
169
  retries_max:
130
170
  writable */
131
- retries_max =
132
- "";
171
+ _set(
172
+ "retries",
173
+ "max",
174
+ "");
133
175
  /* global
134
176
  call_timeout:
135
177
  writable */
136
- call_timeout =
137
- "";
178
+ _set(
179
+ "call",
180
+ "timeout",
181
+ "");
138
182
  /* global
139
183
  wallet_seed:
140
184
  writable */
141
- wallet_seed =
142
- "";
185
+ _set(
186
+ "wallet",
187
+ "seed",
188
+ "");
143
189
  /* global
144
190
  wallet_password:
145
191
  writable */
146
- wallet_password =
147
- "";
192
+ _set(
193
+ "wallet",
194
+ "password",
195
+ "");
148
196
  /* global
149
197
  api_key_path:
150
198
  writable */
151
- api_key_path =
152
- "";
199
+ _set(
200
+ "api_key",
201
+ "path",
202
+ "");
153
203
  /* global
154
204
  price_gas:
155
205
  writable */
156
- price_gas =
157
- "";
206
+ _set(
207
+ "price",
208
+ "gas",
209
+ "");
158
210
  /* global
159
211
  msg_value:
160
212
  writable */
161
- msg_value =
162
- "";
213
+ _set(
214
+ "msg",
215
+ "value",
216
+ "");
163
217
  /* global
164
218
  measure_unit:
165
219
  writable */
166
- measure_unit =
167
- "";
220
+ _set(
221
+ "measure",
222
+ "unit",
223
+ "");
168
224
  /* global
169
225
  target_network:
170
226
  writable */
171
- target_network =
172
- "";
227
+ _set(
228
+ "target",
229
+ "network",
230
+ "");
173
231
  /* global
174
232
  contract_address:
175
233
  writable */
176
- contract_address =
177
- "";
234
+ _set(
235
+ "contract",
236
+ "address",
237
+ "");
178
238
  /* global
179
239
  contract_abi_path:
180
240
  writable */
181
- contract_abi_path =
182
- "";
241
+ _set(
242
+ "contract_abi",
243
+ "path",
244
+ "");
183
245
  /* global
184
246
  contract_bytecode_path:
185
247
  writable */
186
- contract_bytecode_path =
187
- "";
248
+ _set(
249
+ "contract_bytecode",
250
+ "path",
251
+ "");
188
252
  /* global
189
253
  contract_compiler_output_path:
190
254
  writable */
191
- contract_compiler_output_path =
192
- "";
255
+ _set(
256
+ "contract_compiler_output",
257
+ "path",
258
+ "");
193
259
  /* global
194
260
  contract_method:
195
261
  writable */
196
- contract_method =
197
- "";
262
+ _set(
263
+ "contract",
264
+ "method",
265
+ "");
198
266
  /* global
199
267
  method_args:
200
268
  writable */
201
- method_args =
202
- [];
269
+ _set(
270
+ "method",
271
+ "args",
272
+ []);
273
+ const
274
+ _global =
275
+ _global_get();
203
276
  /* global
204
277
  quiet:
205
278
  writable */
206
- quiet =
279
+ _global[
280
+ "quiet"] =
207
281
  "";
208
282
  }
209
283
 
@@ -1007,85 +1081,86 @@ function
1007
1081
  _usage(
1008
1082
  _exit_code) {
1009
1083
  let
1010
- _text;
1011
- _text = [
1012
- "Execute a dynamic call to an EVM network's contract method.",
1013
- "",
1014
- "Usage:",
1015
- " evm-contract-call-dynamic",
1016
- " <quiet>",
1017
- " <retries-max>",
1018
- " <call-timeout>",
1019
- " <wallet-seed>",
1020
- " <wallet-password>",
1021
- " <api-key-path>",
1022
- " <price-gas>",
1023
- " <msg-value>",
1024
- " <measure-unit>",
1025
- " <target-network>",
1026
- " <contract-address>",
1027
- " <contract-abi_path>",
1028
- " <contract-bytecode_path>",
1029
- " <contract-compiler-output_path>",
1030
- " <contract-method>",
1031
- " [method-args]",
1032
- "",
1033
- "Args:",
1034
- "",
1035
- " <quiet> Can be 'y' or 'n'",
1036
- " Default: y",
1037
- "",
1038
- " <retries-max> Maximum number of retries before",
1039
- " failing.",
1040
- "",
1041
- " <call-timeout> How many milliseconds to wait for a return",
1042
- " before declaring the call failed.",
1043
- "",
1044
- " <wallet-seed> Path of the file containing",
1045
- " the seed phrase.",
1046
- "",
1047
- " <wallet-password> Password of the wallet.",
1048
- "",
1049
- " <api-key-path> Path of the API key for the",
1050
- " contract ABI provider service.",
1051
- "",
1052
- " <target-network> Network on which the contract",
1053
- " resides.",
1054
- "",
1055
- " <price-gas> Gas price for the transaction.",
1056
- "",
1057
- " <msg-value> How much <measure-unit> attach",
1058
- " to the transaction.",
1059
- ` Default: ${msg_value}`,
1060
- "",
1061
- " <measure-unit> Measure unit for the transaction",
1062
- " value. It can be 'wei' or 'ether'",
1063
- ` Default: ${measure_unit}`,
1064
- "",
1065
- " <contract-address> Address of the contract.",
1066
- "",
1067
- " <contract-abi_path> Contract ABI path.",
1068
- "",
1069
- " <contract-bytecode-path> Path for the contract bytecode.",
1070
- "",
1071
- " <contract-compiler-output-path> Path for the contract compiler",
1072
- " output path (the hardhat artifact).",
1073
- "",
1074
- " <contract-method> Contract method to execute.",
1075
- "",
1076
- " [method-args] Arguments to pass to the method.",
1077
- "",
1078
- " Options:",
1079
- " -h (--help) This help."
1080
- ]
1081
- for ( let
1082
- _line =
1083
- 0;
1084
- _line < _text.length;
1085
- _line++ ) {
1086
- _msg_info(
1087
- _msgs[
1088
- _line]);
1084
+ _line;
1085
+ const
1086
+ _program =
1087
+ _basename(
1088
+ _argv[
1089
+ 0]);
1090
+ const
1091
+ _text = [
1092
+ "Execute a dynamic call to an EVM network's contract method.",
1093
+ "",
1094
+ "Usage:",
1095
+ ` ${_program}`,
1096
+ " <quiet>",
1097
+ " <retries-max>",
1098
+ " <call-timeout>",
1099
+ " <wallet-seed>",
1100
+ " <wallet-password>",
1101
+ " <api-key-path>",
1102
+ " <price-gas>",
1103
+ " <msg-value>",
1104
+ " <measure-unit>",
1105
+ " <target-network>",
1106
+ " <contract-address>",
1107
+ " <contract-abi_path>",
1108
+ " <contract-bytecode_path>",
1109
+ " <contract-compiler-output_path>",
1110
+ " <contract-method>",
1111
+ " [method-args]",
1112
+ "",
1113
+ "Args:",
1114
+ "",
1115
+ " <quiet> Can be 'y' or 'n'",
1116
+ " Default: y",
1117
+ "",
1118
+ " <retries-max> Maximum number of retries before",
1119
+ " failing.",
1120
+ "",
1121
+ " <call-timeout> How many milliseconds to wait for a return",
1122
+ " before declaring the call failed.",
1123
+ "",
1124
+ " <wallet-seed> Path of the file containing",
1125
+ " the seed phrase.",
1126
+ "",
1127
+ " <wallet-password> Password of the wallet.",
1128
+ "",
1129
+ " <api-key-path> Path of the API key for the",
1130
+ " contract ABI provider service.",
1131
+ "",
1132
+ " <target-network> Network on which the contract",
1133
+ " resides.",
1134
+ "",
1135
+ " <price-gas> Gas price for the transaction.",
1136
+ "",
1137
+ " <msg-value> How much <measure-unit> attach",
1138
+ " to the transaction.",
1139
+ ` Default: ${msg_value}`,
1140
+ "",
1141
+ " <measure-unit> Measure unit for the transaction",
1142
+ " value. It can be 'wei' or 'ether'",
1143
+ ` Default: ${measure_unit}`,
1144
+ "",
1145
+ " <contract-address> Address of the contract.",
1146
+ "",
1147
+ " <contract-abi_path> Contract ABI path.",
1148
+ "",
1149
+ " <contract-bytecode-path> Path for the contract bytecode.",
1150
+ "",
1151
+ " <contract-compiler-output-path> Path for the contract compiler",
1152
+ " output path (the hardhat artifact).",
1153
+ "",
1154
+ " <contract-method> Contract method to execute.",
1155
+ "",
1156
+ " [method-args] Arguments to pass to the method.",
1157
+ "",
1158
+ " Options:",
1159
+ " -h (--help) This help."
1160
+ ]
1161
+ for ( _line of _text ) {
1162
+ _echo(
1163
+ _line);
1089
1164
  }
1090
1165
  _exit(
1091
1166
  _exit_code);
@@ -1096,8 +1171,7 @@ function
1096
1171
  let
1097
1172
  _chars_max,
1098
1173
  _line,
1099
- _method_args,
1100
- _text;
1174
+ _method_args;
1101
1175
  _chars_max =
1102
1176
  300;
1103
1177
  _method_args =
@@ -1109,28 +1183,34 @@ function
1109
1183
  0,
1110
1184
  _chars_max);
1111
1185
  }
1112
- _text = [
1113
- "Dynamic call configuration:",
1114
- ` Measure unit: ${measure_unit}`,
1115
- ` Max retries: ${retries_max}`,
1116
- ` Network settings:`,
1117
- ` Target network: ${target_network}`,
1118
- ` API Key path: ${api_key_path}`,
1119
- ` Call timeout: ${call_timeout}`,
1120
- ` Gas price: ${price_gas}`,
1121
- ` Credentials settings:`,
1122
- ` Wallet seed: ${wallet_seed}`,
1123
- ` Wallet password: ${wallet_password}`,
1124
- ` Contract settings:`,
1125
- ` Contract address: ${contract_address}`,
1126
- ` Contract ABI: ${contract_abi_path}`,
1127
- ` Contract Bytecode: ${contract_bytecode_path}`,
1128
- `Contract compiler output: ${contract_compiler_output_path}`,
1129
- ` Call settings:`,
1130
- ` Transaction value: ${msg_value}`,
1131
- ` Contract method: ${contract_method}`,
1132
- ` Method args: ${_method_args}`,
1133
- ];
1186
+ const
1187
+ _program =
1188
+ _basename(
1189
+ _argv[
1190
+ 0]);
1191
+ const
1192
+ _text = [
1193
+ `${_program} configuration:`,
1194
+ ` Measure unit: ${measure_unit}`,
1195
+ ` Max retries: ${retries_max}`,
1196
+ ` Network settings:`,
1197
+ ` Target network: ${target_network}`,
1198
+ ` API Key path: ${api_key_path}`,
1199
+ ` Call timeout: ${call_timeout}`,
1200
+ ` Gas price: ${price_gas}`,
1201
+ ` Credentials settings:`,
1202
+ ` Wallet seed: ${wallet_seed}`,
1203
+ ` Wallet password: ${wallet_password}`,
1204
+ ` Contract settings:`,
1205
+ ` Contract address: ${contract_address}`,
1206
+ ` Contract ABI: ${contract_abi_path}`,
1207
+ ` Contract Bytecode: ${contract_bytecode_path}`,
1208
+ `Contract compiler output: ${contract_compiler_output_path}`,
1209
+ ` Call settings:`,
1210
+ ` Transaction value: ${msg_value}`,
1211
+ ` Contract method: ${contract_method}`,
1212
+ ` Method args: ${_method_args}`,
1213
+ ];
1134
1214
  for (_line of _text) {
1135
1215
  _msg_info(
1136
1216
  _line);
@@ -1141,92 +1221,140 @@ function
1141
1221
  _cmdline_parse() {
1142
1222
  let
1143
1223
  _msg;
1144
- quiet =
1224
+ const
1225
+ _global =
1226
+ _global_get();
1227
+ _global[
1228
+ "quiet"] =
1145
1229
  "y";
1146
- process.argv.forEach(
1230
+ const
1231
+ _method_args =
1232
+ _get(
1233
+ "method",
1234
+ "args");
1235
+ _argv.forEach(
1147
1236
  function (
1148
1237
  _value,
1149
- _index,
1150
- _array) {
1238
+ _index) {
1151
1239
  if ( _index == 2 ) {
1152
- quiet =
1240
+ _global[
1241
+ "quiet"] =
1153
1242
  _value;
1154
1243
  }
1155
1244
  if ( _index == 3 ) {
1156
- retries_max =
1157
- _value;
1245
+ _set(
1246
+ "retries",
1247
+ "max",
1248
+ _value);
1158
1249
  }
1159
1250
  if ( _index == 4 ) {
1160
- call_timeout =
1161
- _value;
1251
+ _set(
1252
+ "call",
1253
+ "timeout",
1254
+ _value);
1162
1255
  }
1163
1256
  if ( _index == 5 ) {
1164
- wallet_seed =
1165
- _value;
1257
+ _set(
1258
+ "wallet",
1259
+ "seed",
1260
+ _value);
1166
1261
  }
1167
1262
  if ( _index == 6 ) {
1168
- wallet_password =
1169
- _value;
1263
+ _set(
1264
+ "wallet",
1265
+ "password",
1266
+ _value);
1170
1267
  }
1171
1268
  if ( _index == 7 ) {
1172
- api_key_path =
1173
- _value;
1269
+ _set(
1270
+ "api_key",
1271
+ "path",
1272
+ _value);
1174
1273
  }
1175
1274
  if ( _index == 8 ) {
1176
- price_gas =
1177
- _value;
1275
+ _set(
1276
+ "price",
1277
+ "gas",
1278
+ _value);
1178
1279
  }
1179
1280
  if ( _index == 9 ) {
1180
- msg_value =
1181
- _value;
1281
+ _set(
1282
+ "msg",
1283
+ "value",
1284
+ _value);
1182
1285
  }
1183
1286
  if ( _index == 10 ) {
1184
- measure_unit =
1185
- _value;
1287
+ _set(
1288
+ "measure",
1289
+ "unit",
1290
+ _value);
1186
1291
  }
1187
1292
  if ( _index == 11 ) {
1188
- target_network =
1189
- _value;
1293
+ _set(
1294
+ "target",
1295
+ "network",
1296
+ _value);
1190
1297
  }
1191
1298
  if ( _index == 12 ) {
1192
- contract_address =
1193
- _value;
1299
+ _set(
1300
+ "contract",
1301
+ "address",
1302
+ _value);
1194
1303
  }
1195
1304
  if ( _index == 13 ) {
1196
- contract_abi_path =
1197
- _value;
1305
+ _set(
1306
+ "contract_abi",
1307
+ "path",
1308
+ _value);
1198
1309
  }
1199
1310
  if ( _index == 14 ) {
1200
- contract_bytecode_path =
1201
- _value;
1311
+ _set(
1312
+ "contract_bytecode",
1313
+ "path",
1314
+ _value);
1202
1315
  }
1203
1316
  if ( _index == 15 ) {
1204
- contract_compiler_output_path =
1205
- _value;
1317
+ _set(
1318
+ "contract_compiler_output",
1319
+ "path",
1320
+ _value);
1206
1321
  }
1207
1322
  if ( _index == 16 ) {
1208
- contract_method =
1209
- _value;
1323
+ _set(
1324
+ "contract",
1325
+ "method",
1326
+ _value);
1210
1327
  }
1211
1328
  if ( 16 < _index ) {
1212
- method_args.push(
1329
+ _method_args.push(
1213
1330
  _value);
1214
1331
  }
1215
1332
  if ( _value == "-h" ||
1216
1333
  _value == "--help" ) {
1217
- quiet =
1334
+ _global[
1335
+ "quiet"] =
1218
1336
  "n";
1219
1337
  _usage(
1220
1338
  0);
1221
1339
  }
1222
1340
  });
1223
- if ( contract_address == "" ) {
1341
+ _set(
1342
+ "method",
1343
+ "args",
1344
+ _method_args);
1345
+ const
1346
+ _contract_address =
1347
+ _get(
1348
+ "contract",
1349
+ "address");
1350
+ if ( _contract_address == "" ) {
1224
1351
  _msg =
1225
1352
  "No contract address specified.";
1226
1353
  _msg_error(
1227
1354
  _msg,
1228
1355
  0);
1229
- quiet =
1356
+ _global[
1357
+ "quiet"] =
1230
1358
  "n";
1231
1359
  _usage(
1232
1360
  1);
@@ -1237,26 +1365,30 @@ async function
1237
1365
  _contract_run_cmdline(
1238
1366
  app_opts) {
1239
1367
  let
1240
- _receipt,
1241
- _tx;
1242
- [ _tx,
1243
- _receipt ] =
1244
- await _contract_run.apply(
1245
- null,
1246
- app_opts);
1368
+ _msg;
1369
+ const
1370
+ [ _tx,
1371
+ _receipt ] =
1372
+ await _contract_run.apply(
1373
+ null,
1374
+ app_opts);
1247
1375
  _msg =
1248
1376
  "Transaction response:"
1249
- console.log(
1377
+ _echo(
1378
+ _msg);
1379
+ _echo(
1250
1380
  _tx);
1251
1381
  _msg =
1252
1382
  "Transaction receipt:"
1253
- console.log(
1383
+ _echo(
1384
+ _msg);
1385
+ _echo(
1254
1386
  _receipt);
1255
1387
  }
1256
1388
 
1257
- if ( _cmdline_check(
1389
+ if ( await _cmdline_check(
1258
1390
  "evm-contract-call-dynamic") ||
1259
- _cmdline_check(
1391
+ await _cmdline_check(
1260
1392
  "contract-run") ) {
1261
1393
  _global_variables();
1262
1394
  _cmdline_parse();
@@ -1283,9 +1415,14 @@ if ( _cmdline_check(
1283
1415
  app_opts);
1284
1416
  }
1285
1417
 
1286
- module.exports = {
1287
- _contract_call_dynamic:
1288
- _contract_call_dynamic,
1289
- _contract_run:
1290
- _contract_run
1418
+ export {
1419
+ _contract_call_dynamic,
1420
+ _contract_run
1291
1421
  };
1422
+
1423
+ // module.exports = {
1424
+ // _contract_call_dynamic:
1425
+ // _contract_call_dynamic,
1426
+ // _contract_run:
1427
+ // _contract_run
1428
+ // };