evm-contracts-tools 0.0.8 → 0.0.11

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.
@@ -28,49 +28,100 @@ const
28
28
  _libcrash =
29
29
  require(
30
30
  "crash-js");
31
- _cmdline_check =
32
- _libcrash._cmdline_check;
33
- _error_display =
34
- _libcrash._error_display;
35
- _file_read =
36
- _libcrash._file_read;
37
- _file_write =
38
- _libcrash._file_write;
39
- _msg_info =
40
- _libcrash._msg_info
41
- _msg_error =
42
- _libcrash._msg_error
43
- _printf =
44
- _libcrash._printf
31
+ /* global
32
+ _cmdline_check */
33
+ const
34
+ _cmdline_check =
35
+ _libcrash._cmdline_check;
36
+ /* global
37
+ _error_display */
38
+ const
39
+ _error_display =
40
+ _libcrash._error_display;
41
+ /* global
42
+ _file_read */
43
+ const
44
+ _file_read =
45
+ _libcrash._file_read;
46
+ /* global
47
+ _file_write */
48
+ const
49
+ _file_write =
50
+ _libcrash._file_write;
51
+ /* global
52
+ _msg_info */
53
+ const
54
+ _msg_info =
55
+ _libcrash._msg_info
56
+ /* global
57
+ _msg_error */
58
+ const
59
+ _msg_error =
60
+ _libcrash._msg_error
61
+ /* global
62
+ _printf */
63
+ const
64
+ _printf =
65
+ _libcrash._printf
45
66
  const
46
67
  _contract_get_module =
47
68
  require(
48
69
  './contract-get');
49
- _contract_get =
50
- _contract_get_module._contract_get
70
+ /* global
71
+ _contract_get */
72
+ const
73
+ _contract_get =
74
+ _contract_get_module._contract_get
51
75
  const
52
- _network_provider_module =
76
+ _evm_wallet_module =
53
77
  require(
54
- '../evm-wallet/network-provider');
55
- _provider_get =
56
- _network_provider_module._provider_get;
78
+ "evm-wallet.js");
79
+ /* global
80
+ _provider_get */
81
+ const
82
+ _provider_get =
83
+ _evm_wallet_module._provider_get;
57
84
 
58
85
  function
59
86
  _global_variables() {
87
+ /* global
88
+ app_name:
89
+ writable */
60
90
  app_name =
61
91
  "bytecode-runtime-get";
92
+ /* global
93
+ wallet_seed:
94
+ writable */
62
95
  wallet_seed =
63
96
  "";
97
+ /* global
98
+ retries_max:
99
+ writable */
64
100
  retries_max =
65
101
  "";
102
+ /* global
103
+ api_key_path:
104
+ writable */
66
105
  api_key_path =
67
106
  "";
107
+ /* global
108
+ target_network:
109
+ writable */
68
110
  target_network =
69
111
  "";
112
+ /* global
113
+ contract_address:
114
+ writable */
70
115
  contract_address =
71
116
  "";
117
+ /* global
118
+ contract_abi_path:
119
+ writable */
72
120
  contract_abi_path =
73
121
  "";
122
+ /* global
123
+ contract_bytecode_path:
124
+ writable */
74
125
  contract_bytecode_path =
75
126
  "";
76
127
  // contract_compiler_output_path =
@@ -79,8 +130,11 @@ function
79
130
  // "";
80
131
  // method_args =
81
132
  // [];
133
+ /* global
134
+ quiet:
135
+ writable */
82
136
  quiet =
83
- '';
137
+ "";
84
138
  }
85
139
 
86
140
  function
@@ -92,15 +146,9 @@ function
92
146
  function
93
147
  _msg_info_contract_obtained(
94
148
  _contract) {
95
- let
96
- _msg,
97
- _template;
98
- _template =
99
- "Contract '{_contract}' obtained.";
100
- _msg =
101
- _template.replaceAll(
102
- "{_contract}",
103
- _contract);
149
+ const
150
+ _msg =
151
+ `Contract '${_contract}' obtained.`;
104
152
  _msg_info(
105
153
  _msg);
106
154
  }
@@ -108,10 +156,9 @@ function
108
156
  function
109
157
  _msg_info_method_obtained(
110
158
  _method) {
111
- let
112
- _msg;
113
- _msg =
114
- "Method obtained.";
159
+ const
160
+ _msg =
161
+ "Method obtained.";
115
162
  _msg_info(
116
163
  _msg);
117
164
  }
@@ -128,6 +175,7 @@ async function
128
175
  let
129
176
  _api_key,
130
177
  _code,
178
+ _msg,
131
179
  _network_provider,
132
180
  _passed,
133
181
  _wallet_password;
@@ -157,8 +205,10 @@ async function
157
205
  await _network_provider.getCode(
158
206
  _contract_address);
159
207
  if ( _code != undefined ) {
208
+ _msg =
209
+ `Bytecode length: ${_code.length}`;
160
210
  _msg_info(
161
- `Bytecode length: ${_code.length}`);
211
+ _msg);
162
212
  _file_write(
163
213
  _contract_bytecode_path,
164
214
  _code);
@@ -166,9 +216,11 @@ async function
166
216
  true;
167
217
  }
168
218
  else if ( _code == undefined ) {
219
+ _msg =
220
+ "Code not retrieved."
169
221
  throw {"error": {
170
222
  "message":
171
- "Code not retrieved." } };
223
+ _msg } };
172
224
  }
173
225
  } catch (
174
226
  _error) {
@@ -176,8 +228,10 @@ async function
176
228
  _error);
177
229
  _retry =
178
230
  _retry + 1;
231
+ _msg =
232
+ "Increasing retry and waiting 3 seconds.";
179
233
  _msg_error(
180
- "Increasing retry and waiting 3 seconds.",
234
+ _msg,
181
235
  0);
182
236
  await _delay(
183
237
  3000);
@@ -193,40 +247,19 @@ function
193
247
  _config_show() {
194
248
  let
195
249
  _line,
196
- _method_args,
197
- _text;
198
- _text =
199
- [];
200
- _text.push(
201
- " bytecode-runtime-get configuration:");
202
- _text.push(
203
- " Contract address: {contract_address}".replace(
204
- "{contract_address}",
205
- contract_address));
206
- _text.push(
207
- " Contract bytecode: {contract_bytecode_path}".replace(
208
- "{contract_bytecode_path}",
209
- contract_bytecode_path));
210
- _text.push(
211
- " Max retries: {retries_max}".replace(
212
- "{retries_max}",
213
- retries_max));
214
- _text.push(
215
- " Credentials options:");
216
- _text.push(
217
- " Wallet seed: {wallet_seed}".replace(
218
- "{wallet_seed}",
219
- wallet_seed));
220
- _text.push(
221
- " API Key path: {api_key_path}".replace(
222
- "{api_key_path}",
223
- api_key_path));
224
- _text.push(
225
- " Network options:");
226
- _text.push(
227
- " Target network: {target_network}".replace(
228
- "{target_network}",
229
- target_network));
250
+ _method_args;
251
+ const
252
+ _text = [
253
+ " bytecode-runtime-get configuration:",
254
+ ` Contract address: ${contract_address}`,
255
+ ` Contract bytecode: ${contract_bytecode_path}`,
256
+ ` Max retries: ${retries_max}`,
257
+ ` Credentials options:`,
258
+ ` Wallet seed: ${wallet_seed}`,
259
+ ` API Key path: ${api_key_path}`,
260
+ ` Network options:`,
261
+ ` Target network: ${target_network}`,
262
+ ];
230
263
  for (_line of _text) {
231
264
  _msg_info(
232
265
  _line);
@@ -245,26 +278,27 @@ function
245
278
  "Usage:",
246
279
  " bytecode-runtime-get",
247
280
  " <quiet>",
248
- " <wallet_seed>",
249
- " <retries_max>",
250
- " <api_key_path>",
251
- " <target_network>",
252
- " <contract_address>",
253
- " <contract_bytecode_path>",
281
+ " <wallet-seed>",
282
+ " <retries-max>",
283
+ " <api-key-path>",
284
+ " <target-network>",
285
+ " <contract-address>",
286
+ " <contract-bytecode_path>",
254
287
  "",
255
288
  "Args:",
256
289
  " <quiet> Can be 'y' or 'n'",
257
- " Default: y",
258
- " <wallet_seed> Path of the file containing",
290
+ ` Default: ${quiet}`,
291
+ " <wallet-seed> Path of the file containing",
259
292
  " the seed phrase.",
260
- " <retries_max> Maximum number of retries before",
293
+ " <retries-max> Maximum number of retries before",
261
294
  " failing.",
262
- " <api_key_path> Path of the API key for the",
295
+ ` Default: ${retries_max}`,
296
+ " <api-key-path> Path of the API key for the",
263
297
  " contract ABI provider service",
264
- " <target_network> Network on which the contract",
298
+ " <target-network> Network on which the contract",
265
299
  " resides.",
266
- " <contract_address> Address of the contract",
267
- " <contract_bytecode_path> Path in which to save",
300
+ " <contract-address> Address of the contract",
301
+ " <contract-bytecode-path> Path in which to save",
268
302
  " the runtime bytecode.",
269
303
  "",
270
304
  " Options:",
@@ -331,11 +365,15 @@ function
331
365
  }
332
366
  );
333
367
  if ( contract_address == "" ) {
368
+ const
369
+ _msg =
370
+ "It is required to set a contract address.";
334
371
  _msg_error(
335
- "It is required to set a contract address.",
372
+ _msg,
336
373
  0);
337
374
  quiet =
338
375
  "n";
376
+ _overrides_set();
339
377
  _usage(
340
378
  1);
341
379
  }
@@ -28,77 +28,161 @@ const
28
28
  _libcrash =
29
29
  require(
30
30
  "crash-js");
31
- _cmdline_check =
32
- _libcrash._cmdline_check;
33
- _dirname =
34
- _libcrash._dirname;
35
- _error_display =
36
- _libcrash._error_display;
37
- _msg_info =
38
- _libcrash._msg_info;
39
- _msg_error =
40
- _libcrash._msg_error;
41
- _path_join =
42
- _libcrash._path_join;
43
- _sleep =
44
- _libcrash._sleep;
31
+ /* global
32
+ _cmdline_check */
33
+ const
34
+ _cmdline_check =
35
+ _libcrash._cmdline_check;
36
+ /* global
37
+ _dirname */
38
+ const
39
+ _dirname =
40
+ _libcrash._dirname;
41
+ /* global
42
+ _error_display */
43
+ const
44
+ _error_display =
45
+ _libcrash._error_display;
46
+ /* global
47
+ _msg_info */
48
+ const
49
+ _msg_info =
50
+ _libcrash._msg_info;
51
+ /* global
52
+ _msg_error */
53
+ const
54
+ _msg_error =
55
+ _libcrash._msg_error;
56
+ /* global
57
+ _path_join */
58
+ const
59
+ _path_join =
60
+ _libcrash._path_join;
61
+ /* global
62
+ _sleep */
63
+ const
64
+ _sleep =
65
+ _libcrash._sleep;
45
66
  const
46
67
  { ethers } =
47
68
  require(
48
69
  "ethers");
49
- _ethers =
50
- ethers;
51
- _wei_to_ether =
52
- _ethers.formatEther;
53
- _parse_units =
54
- _ethers.parseUnits;
70
+ const
71
+ _ethers =
72
+ ethers;
73
+ /* global
74
+ _wei_to_ether */
75
+ const
76
+ _wei_to_ether =
77
+ _ethers.formatEther;
78
+ /* global
79
+ _parse_units */
80
+ const
81
+ _parse_units =
82
+ _ethers.parseUnits;
55
83
  const
56
84
  _price_gas_transaction_get_module =
57
85
  require(
58
86
  '../evm-wallet/price-gas-transaction-get');
59
- _price_gas_transaction_get =
60
- _price_gas_transaction_get_module._price_gas_transaction_get;
87
+ /* global
88
+ _price_gas_transaction_get */
89
+ const
90
+ _price_gas_transaction_get =
91
+ _price_gas_transaction_get_module._price_gas_transaction_get;
61
92
  const
62
93
  _contract_get_module =
63
94
  require(
64
95
  './contract-get');
96
+ /* global
97
+ _contract_get */
65
98
  _contract_get =
66
99
  _contract_get_module._contract_get;
67
100
 
68
101
  function
69
102
  _global_variables() {
103
+ /* global
104
+ app_name:
105
+ writable */
70
106
  app_name =
71
107
  "evm-contract-call-dynamic";
108
+ /* global
109
+ retries_max:
110
+ writable */
72
111
  retries_max =
73
112
  "";
113
+ /* global
114
+ call_timeout:
115
+ writable */
74
116
  call_timeout =
75
117
  "";
118
+ /* global
119
+ wallet_seed:
120
+ writable */
76
121
  wallet_seed =
77
122
  "";
123
+ /* global
124
+ wallet_password:
125
+ writable */
78
126
  wallet_password =
79
127
  "";
128
+ /* global
129
+ api_key_path:
130
+ writable */
80
131
  api_key_path =
81
132
  "";
133
+ /* global
134
+ price_gas:
135
+ writable */
82
136
  price_gas =
83
137
  "";
138
+ /* global
139
+ msg_value:
140
+ writable */
84
141
  msg_value =
85
142
  "";
143
+ /* global
144
+ measure_unit:
145
+ writable */
86
146
  measure_unit =
87
147
  "";
148
+ /* global
149
+ target_network:
150
+ writable */
88
151
  target_network =
89
152
  "";
153
+ /* global
154
+ contract_address:
155
+ writable */
90
156
  contract_address =
91
157
  "";
158
+ /* global
159
+ contract_abi_path:
160
+ writable */
92
161
  contract_abi_path =
93
162
  "";
163
+ /* global
164
+ contract_bytecode_path:
165
+ writable */
94
166
  contract_bytecode_path =
95
167
  "";
168
+ /* global
169
+ contract_compiler_output_path:
170
+ writable */
96
171
  contract_compiler_output_path =
97
172
  "";
173
+ /* global
174
+ contract_method:
175
+ writable */
98
176
  contract_method =
99
177
  "";
178
+ /* global
179
+ method_args:
180
+ writable */
100
181
  method_args =
101
182
  [];
183
+ /* global
184
+ quiet:
185
+ writable */
102
186
  quiet =
103
187
  "";
104
188
  }
@@ -106,15 +190,9 @@ function
106
190
  function
107
191
  _msg_info_wallet_selected(
108
192
  _wallet_path) {
109
- let
110
- _msg,
111
- _template;
112
- _template =
113
- "Selecting '{_wallet_path}'.";
114
- _msg =
115
- _template.replaceAll(
116
- "{_wallet_path}",
117
- _wallet_path);
193
+ const
194
+ _msg =
195
+ `Selecting '${_wallet_path}'.`;
118
196
  _msg_info(
119
197
  _msg);
120
198
  }
@@ -122,15 +200,10 @@ function
122
200
  async function
123
201
  _msg_info_contract_obtained(
124
202
  _contract) {
125
- let
126
- _msg,
127
- _template;
128
- _template =
129
- "Contract object '{_contract}' obtained.";
130
- _msg =
131
- _template.replaceAll(
132
- "{_contract}",
133
- _contract);
203
+ const
204
+ _msg =
205
+ `Contract object obtained.`;
206
+ // `Contract object '${_contract}' obtained.`;
134
207
  _msg_info(
135
208
  _msg);
136
209
  }
@@ -138,10 +211,9 @@ async function
138
211
  function
139
212
  _msg_info_method_obtained(
140
213
  _method) {
141
- let
142
- _msg;
143
- _msg =
144
- "Method obtained.";
214
+ const
215
+ _msg =
216
+ "Method obtained.";
145
217
  _msg_info(
146
218
  _msg);
147
219
  }
@@ -149,17 +221,9 @@ function
149
221
  function
150
222
  _msg_error_transaction_undefined(
151
223
  _attempt) {
152
- let
153
- _msg,
154
- _template;
155
- _template =
156
- "Transaction undefined at attempt '{_attempt}'.";
157
- _msg =
158
- _template.replaceAll(
159
- "{_attempt}",
160
- _attempt);
161
- _msg_info(
162
- _msg);
224
+ const
225
+ _msg =
226
+ `Transaction undefined at attempt '${_attempt}'.`;
163
227
  _msg_error(
164
228
  _msg,
165
229
  0);
@@ -168,10 +232,9 @@ function
168
232
  function
169
233
  _msg_error_transaction_failed(
170
234
  _attempt) {
171
- let
172
- _msg;
173
- _msg =
174
- `Transaction failed at attempt '${_attempt}'.`;
235
+ const
236
+ _msg =
237
+ `Transaction failed at attempt '${_attempt}'.`;
175
238
  _msg_error(
176
239
  _msg,
177
240
  0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  { "name": "evm-contracts-tools",
2
2
  "version":
3
- "0.0.8",
3
+ "0.0.11",
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": {