evm-contracts-tools 0.0.62 → 0.0.64
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-call/fs-worker.js +1 -1
- package/dist/evm-contract-deployment-abi/evm-contract-deployment-abi.js +1 -1
- package/dist/evm-contract-deployment-abi/fs-worker.js +1 -1
- package/dist/evm-contract-deployment-address/evm-contract-deployment-address.js +1 -1
- package/dist/evm-contract-deployment-address/fs-worker.js +1 -1
- package/dist/evm-contract-deployment-bytecode/evm-contract-deployment-bytecode.js +1 -1
- package/dist/evm-contract-deployment-bytecode/fs-worker.js +1 -1
- package/dist/evm-contract-deployment-compiler-output/evm-contract-deployment-compiler-output.js +1 -1
- package/dist/evm-contract-deployment-compiler-output/fs-worker.js +1 -1
- package/dist/evm-contract-deployment-deployment-networks +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-deployment-versions/fs-worker.js +1 -1
- package/dist/evm-contract-deployments-dir/evm-contract-deployments-dir.js +1 -1
- package/dist/evm-contract-deployments-dir/fs-worker.js +1 -1
- package/dist/evm-contracts-tools/evm-contracts-tools.js +1 -1
- package/dist/evm-contracts-tools/fs-worker.js +1 -1
- package/dist/libevm-contract-call/fs-worker.js +1 -1
- package/dist/libevm-contract-call/libevm-contract-call.js +1 -1
- package/dist/libevm-contract-deployment-abi/fs-worker.js +1 -1
- package/dist/libevm-contract-deployment-abi/libevm-contract-deployment-abi.js +1 -1
- package/dist/libevm-contract-deployment-address/fs-worker.js +1 -1
- package/dist/libevm-contract-deployment-address/libevm-contract-deployment-address.js +1 -1
- package/dist/libevm-contract-deployment-bytecode/fs-worker.js +1 -1
- package/dist/libevm-contract-deployment-bytecode/libevm-contract-deployment-bytecode.js +1 -1
- package/dist/libevm-contract-deployment-compiler-output/fs-worker.js +1 -1
- package/dist/libevm-contract-deployment-compiler-output/libevm-contract-deployment-compiler-output.js +1 -1
- package/dist/libevm-contract-deployment-deployment-networks +1 -1
- package/dist/libevm-contract-deployment-networks/libevm-contract-deployment-networks.js +1 -1
- package/dist/libevm-contract-deployment-versions/fs-worker.js +1 -1
- package/dist/libevm-contract-deployment-versions/libevm-contract-deployment-versions.js +1 -1
- package/dist/libevm-contract-deployments-dir/fs-worker.js +1 -1
- package/dist/libevm-contract-deployments-dir/libevm-contract-deployments-dir.js +1 -1
- package/dist/libevm-contracts-tools +1 -1
- package/eslint.config.mjs +1 -1
- package/evm-contract-call +514 -172
- package/evm-contract-deployment-abi +16 -12
- package/evm-contract-deployment-address +15 -12
- package/evm-contract-deployment-bytecode +15 -12
- package/evm-contract-deployment-compiler-output +16 -13
- package/evm-contract-deployment-networks +15 -12
- package/evm-contract-deployment-versions +15 -12
- package/evm-contract-deployments-dir +16 -13
- package/evm-contracts-tools +14 -12
- package/lib/contract-get +169 -39
- package/lib/evm-contract-call-dynamic +1112 -361
- package/lib/evm-contract-call-static +463 -73
- package/libevm-contract-call +625 -435
- package/libevm-contract-deployment +4388 -481
- package/libevm-contract-deployment-abi +287 -91
- package/libevm-contract-deployment-address +27 -16
- package/libevm-contract-deployment-bytecode +275 -80
- package/libevm-contract-deployment-compiler-output +341 -93
- package/libevm-contract-deployments-dir +53 -50
- package/package.json +11 -11
|
@@ -2,25 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
4
|
|
|
5
|
-
/**
|
|
5
|
+
/** ----------------------------------------------------------
|
|
6
6
|
* libevm-contract-deployment
|
|
7
|
-
*
|
|
7
|
+
* ----------------------------------------------------------
|
|
8
8
|
* Copyright ©
|
|
9
9
|
* Pellegrino Prevete
|
|
10
10
|
* 2025, 2026
|
|
11
11
|
*
|
|
12
12
|
* All rights reserved
|
|
13
|
-
*
|
|
13
|
+
* ----------------------------------------------------------
|
|
14
14
|
*
|
|
15
|
-
* This program is free software: you can redistribute it
|
|
16
|
-
* modify it under the terms of the GNU General
|
|
17
|
-
* published by the Free Software
|
|
18
|
-
*
|
|
15
|
+
* This program is free software: you can redistribute it
|
|
16
|
+
* and/or modify it under the terms of the GNU General
|
|
17
|
+
* Public License as published by the Free Software
|
|
18
|
+
* Foundation, either version 3 of the License, or
|
|
19
|
+
* (at your option) any later version.
|
|
19
20
|
*
|
|
20
|
-
* This program is distributed in the hope that it will
|
|
21
|
-
* but WITHOUT ANY WARRANTY; without even the
|
|
22
|
-
* MERCHANTABILITY or FITNESS FOR A
|
|
23
|
-
*
|
|
21
|
+
* This program is distributed in the hope that it will
|
|
22
|
+
* be useful, but WITHOUT ANY WARRANTY; without even the
|
|
23
|
+
* implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
24
|
+
* PARTICULAR PURPOSE.
|
|
25
|
+
* See the GNU General Public License for more details.
|
|
24
26
|
*
|
|
25
27
|
* You should have received a copy of the
|
|
26
28
|
* GNU General Public License
|
|
@@ -80,6 +82,11 @@ const
|
|
|
80
82
|
const
|
|
81
83
|
_cp =
|
|
82
84
|
_libcrash_module._cp;
|
|
85
|
+
/* global
|
|
86
|
+
_dirname */
|
|
87
|
+
const
|
|
88
|
+
_dirname =
|
|
89
|
+
_libcrash_module._dirname;
|
|
83
90
|
/* global
|
|
84
91
|
_dir_exists */
|
|
85
92
|
const
|
|
@@ -90,6 +97,11 @@ const
|
|
|
90
97
|
const
|
|
91
98
|
_echo =
|
|
92
99
|
_libcrash_module._echo;
|
|
100
|
+
/* global
|
|
101
|
+
_echo2 */
|
|
102
|
+
const
|
|
103
|
+
_echo2 =
|
|
104
|
+
_libcrash_module._echo2;
|
|
93
105
|
/* global
|
|
94
106
|
_file_exists */
|
|
95
107
|
const
|
|
@@ -110,6 +122,11 @@ const
|
|
|
110
122
|
const
|
|
111
123
|
_get =
|
|
112
124
|
_libcrash_module._get;
|
|
125
|
+
/* global
|
|
126
|
+
_global_get */
|
|
127
|
+
const
|
|
128
|
+
_global_get =
|
|
129
|
+
_libcrash_module._global_get;
|
|
113
130
|
/* global
|
|
114
131
|
_homedir_get */
|
|
115
132
|
const
|
|
@@ -135,6 +152,11 @@ const
|
|
|
135
152
|
const
|
|
136
153
|
_msg_error =
|
|
137
154
|
_libcrash_module._msg_error;
|
|
155
|
+
/* global
|
|
156
|
+
_msg_warning */
|
|
157
|
+
const
|
|
158
|
+
_msg_warning =
|
|
159
|
+
_libcrash_module._msg_warning;
|
|
138
160
|
/* global
|
|
139
161
|
_override_set */
|
|
140
162
|
const
|
|
@@ -155,6 +177,11 @@ const
|
|
|
155
177
|
const
|
|
156
178
|
_require =
|
|
157
179
|
_libcrash_module._require;
|
|
180
|
+
/* global
|
|
181
|
+
_set */
|
|
182
|
+
const
|
|
183
|
+
_set =
|
|
184
|
+
_libcrash_module._set;
|
|
158
185
|
const
|
|
159
186
|
_evm_chains_info_module =
|
|
160
187
|
await _require(
|
|
@@ -164,595 +191,4465 @@ const
|
|
|
164
191
|
const
|
|
165
192
|
_evm_chains_info =
|
|
166
193
|
_evm_chains_info_module._evm_chains_info;
|
|
167
|
-
|
|
168
|
-
|
|
194
|
+
/* global
|
|
195
|
+
_evm_contract_deployments_dir */
|
|
169
196
|
/* global
|
|
170
197
|
_evm_contract_deployment_networks */
|
|
171
198
|
/* global
|
|
172
199
|
_evm_contract_deployment_versions */
|
|
200
|
+
const
|
|
201
|
+
_evm_contracts_tools_module =
|
|
202
|
+
await import(
|
|
203
|
+
"./evm-contracts-tools");
|
|
204
|
+
/* global
|
|
205
|
+
_address_check */
|
|
206
|
+
const
|
|
207
|
+
_address_check =
|
|
208
|
+
_evm_contracts_tools_module._address_check;
|
|
173
209
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
_contract,
|
|
178
|
-
_target_network,
|
|
179
|
-
_target_network_id) {
|
|
210
|
+
function
|
|
211
|
+
_configuration_format_check(
|
|
212
|
+
_configuration_format) {
|
|
180
213
|
let
|
|
181
|
-
|
|
182
|
-
_error_flag,
|
|
183
|
-
_evm_contract_deployment_networks,
|
|
184
|
-
_evm_chains_info_args,
|
|
185
|
-
_msg,
|
|
186
|
-
_network_id;
|
|
187
|
-
_msg =
|
|
188
|
-
"Network check for deployments " +
|
|
189
|
-
`'${_deployments}', contract '${_contract}', ` +
|
|
190
|
-
`network '${_target_network}' and network with ID ` +
|
|
191
|
-
`'${_target_network_id}'.`;
|
|
192
|
-
_msg_info(
|
|
193
|
-
_msg);
|
|
194
|
-
_evm_contract_deployment_networks =
|
|
195
|
-
_get(
|
|
196
|
-
"_evm_contract",
|
|
197
|
-
"deployment_networks");
|
|
214
|
+
_msg;
|
|
198
215
|
const
|
|
199
|
-
|
|
216
|
+
_configuration_format_type =
|
|
200
217
|
typeof(
|
|
201
|
-
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
218
|
+
_configuration_format);
|
|
219
|
+
if ( _configuration_format_type === "undefined" ) {
|
|
220
|
+
_msg =
|
|
221
|
+
"Configuration format not set, " +
|
|
222
|
+
"setting default (bash).";
|
|
223
|
+
_msg_info(
|
|
224
|
+
_msg);
|
|
225
|
+
_configuration_format =
|
|
226
|
+
"bash";
|
|
210
227
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
_contract_deployments_path =
|
|
214
|
-
_path_join( [
|
|
215
|
-
_deployments,
|
|
216
|
-
_contract ]);
|
|
217
|
-
const
|
|
218
|
-
_evm_contract_deployment_networks_args = [
|
|
219
|
-
_contract_deployments_path,
|
|
220
|
-
"y", // Display all
|
|
221
|
-
"n", // Display safest
|
|
222
|
-
"n" // Display cheapest
|
|
223
|
-
];
|
|
224
|
-
const
|
|
225
|
-
_networks =
|
|
226
|
-
await _evm_contract_deployment_networks.apply(
|
|
227
|
-
null,
|
|
228
|
-
_evm_contract_deployment_networks_args);
|
|
229
|
-
if ( _target_network_id != "" ) {
|
|
230
|
-
if ( ! _networks.includes(
|
|
231
|
-
_target_network_id) ) {
|
|
228
|
+
else if ( _configuration_format_type === "string" ) {
|
|
229
|
+
if ( _configuration_format.length < 1 ) {
|
|
232
230
|
_msg =
|
|
233
|
-
"
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
231
|
+
"Configuration format not set, " +
|
|
232
|
+
"setting default (bash).";
|
|
233
|
+
_msg_info(
|
|
234
|
+
_msg);
|
|
235
|
+
_configuration_format =
|
|
236
|
+
"bash";
|
|
237
237
|
}
|
|
238
|
-
|
|
239
|
-
else if ( _target_network != "" ) {
|
|
240
|
-
if ( ! _networks.includes(
|
|
241
|
-
_target_network) ) {
|
|
238
|
+
else {
|
|
242
239
|
_msg =
|
|
243
|
-
"
|
|
244
|
-
`
|
|
245
|
-
_error_flag =
|
|
246
|
-
true;
|
|
240
|
+
"Setting configuration format " +
|
|
241
|
+
`'${_configuration_format}'.`;
|
|
247
242
|
}
|
|
248
243
|
}
|
|
249
244
|
else {
|
|
250
245
|
_msg =
|
|
251
|
-
"
|
|
252
|
-
"
|
|
253
|
-
_error_flag =
|
|
254
|
-
true;
|
|
255
|
-
}
|
|
256
|
-
if ( _error_flag ) {
|
|
246
|
+
"Type of variable " +
|
|
247
|
+
"'configuration format' must be string.";
|
|
257
248
|
_msg_error(
|
|
258
249
|
_msg,
|
|
259
250
|
0);
|
|
260
251
|
throw _msg;
|
|
261
252
|
}
|
|
262
|
-
if (
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
"
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
"n", // api keys
|
|
272
|
-
"n", // query all networks
|
|
273
|
-
_target_network,
|
|
274
|
-
[] // database paths
|
|
275
|
-
];
|
|
276
|
-
try {
|
|
277
|
-
_network_id =
|
|
278
|
-
await _evm_chains_info.apply(
|
|
279
|
-
null,
|
|
280
|
-
_evm_chains_info_args);
|
|
281
|
-
}
|
|
282
|
-
catch(
|
|
283
|
-
_error) {
|
|
284
|
-
_msg =
|
|
285
|
-
"Error while running '_evm_chains_info' " +
|
|
286
|
-
`with arguments '${_evm_chains_info_args}'.`;
|
|
287
|
-
_msg_error(
|
|
288
|
-
_msg,
|
|
289
|
-
0);
|
|
290
|
-
_msg_error(
|
|
291
|
-
_error,
|
|
292
|
-
0);
|
|
293
|
-
throw _error;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
else if ( _target_network == "" ) {
|
|
297
|
-
_network_id =
|
|
298
|
-
_target_network_id;
|
|
299
|
-
_evm_chains_info_args = [
|
|
300
|
-
"get", // target command
|
|
301
|
-
"id" , // input type
|
|
302
|
-
"name", // output type
|
|
303
|
-
"offline",
|
|
304
|
-
[ "system", // db types
|
|
305
|
-
"node" ],
|
|
306
|
-
"kirsh", // selection method, first
|
|
307
|
-
"n", // api keys
|
|
308
|
-
"n", // query all networks
|
|
309
|
-
_target_network_id,
|
|
310
|
-
[] // database paths
|
|
311
|
-
];
|
|
312
|
-
try {
|
|
313
|
-
_target_network =
|
|
314
|
-
await _evm_chains_info.apply(
|
|
315
|
-
null,
|
|
316
|
-
_evm_chains_info_args);
|
|
317
|
-
}
|
|
318
|
-
catch(
|
|
319
|
-
_error) {
|
|
320
|
-
_msg =
|
|
321
|
-
"Error while running '_evm_chains_info' " +
|
|
322
|
-
`with arguments '${_evm_chains_info_args}'.`;
|
|
323
|
-
_msg_error(
|
|
324
|
-
_msg,
|
|
325
|
-
0);
|
|
326
|
-
_msg_error(
|
|
327
|
-
_error,
|
|
328
|
-
0);
|
|
329
|
-
throw _error;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
if ( _target_network_id != "" ) {
|
|
333
|
-
if ( _target_network_id != _network_id ) {
|
|
334
|
-
_msg =
|
|
335
|
-
"Requested target network ID " +
|
|
336
|
-
`'${_target_network_id}' does ` +
|
|
337
|
-
`not correspond to '${_target_network}' ` +
|
|
338
|
-
`known ID '${_network_id}'.`;
|
|
339
|
-
_msg_error(
|
|
340
|
-
_msg,
|
|
341
|
-
0);
|
|
342
|
-
throw _msg;
|
|
343
|
-
}
|
|
253
|
+
if ( _configuration_format !== "bash" &&
|
|
254
|
+
_configuration_format !== "json" ) {
|
|
255
|
+
_msg =
|
|
256
|
+
"Unknown configuration format " +
|
|
257
|
+
`'${_configuration_format}'.`
|
|
258
|
+
_msg_error(
|
|
259
|
+
_msg,
|
|
260
|
+
0);
|
|
261
|
+
throw _msg;
|
|
344
262
|
}
|
|
345
|
-
|
|
346
|
-
"Network check for deployments " +
|
|
347
|
-
`'${_deployments}', contract '${_contract}', ` +
|
|
348
|
-
`network '${_target_network}' and network with ID ` +
|
|
349
|
-
`'${_target_network_id}' completed.`;
|
|
350
|
-
_msg_info(
|
|
351
|
-
_msg);
|
|
263
|
+
return _configuration_format;
|
|
352
264
|
}
|
|
353
265
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
266
|
+
function
|
|
267
|
+
_default_artifact_path_get(
|
|
268
|
+
_type,
|
|
269
|
+
_target_network,
|
|
270
|
+
_contract_address) {
|
|
358
271
|
let
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
_user_defined =
|
|
362
|
-
"y";
|
|
363
|
-
_evm_contract_deployments_dir =
|
|
364
|
-
_get(
|
|
365
|
-
"_evm_contract",
|
|
366
|
-
"deployments_dir");
|
|
272
|
+
_file_name;
|
|
367
273
|
const
|
|
368
|
-
|
|
274
|
+
_network_type =
|
|
369
275
|
typeof(
|
|
370
|
-
|
|
371
|
-
if (
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
_evm_contract_deployments_dir =
|
|
378
|
-
_libevm_contract_deployments_dir_module._evm_contract_deployments_dir;
|
|
276
|
+
_target_network);
|
|
277
|
+
if ( _network_type === "undefined" ||
|
|
278
|
+
_target_network === "" ) {
|
|
279
|
+
_target_network =
|
|
280
|
+
_get(
|
|
281
|
+
"target",
|
|
282
|
+
"network");
|
|
379
283
|
}
|
|
380
284
|
const
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
285
|
+
_contract_address_type =
|
|
286
|
+
typeof(
|
|
287
|
+
_contract_address);
|
|
288
|
+
if ( _contract_address_type === "undefined" ||
|
|
289
|
+
_contract_address === "" ) {
|
|
290
|
+
_contract_address =
|
|
291
|
+
_get(
|
|
292
|
+
"contract",
|
|
293
|
+
"address");
|
|
294
|
+
}
|
|
385
295
|
const
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
null,
|
|
389
|
-
_evm_contract_deployments_dir_args);
|
|
390
|
-
_chmod(
|
|
391
|
-
_deployments_dir,
|
|
392
|
-
"0700");
|
|
296
|
+
_home =
|
|
297
|
+
_homedir_get();
|
|
393
298
|
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
299
|
+
_data_dir =
|
|
300
|
+
_path_join( [
|
|
301
|
+
_home,
|
|
302
|
+
".local",
|
|
303
|
+
"share",
|
|
304
|
+
"evm-contract-call" ]);
|
|
305
|
+
if ( _type == "abi" ) {
|
|
306
|
+
_file_name =
|
|
307
|
+
`${_contract_address}.abi.json`;
|
|
401
308
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
const
|
|
412
|
-
_user_deployments_init_args = [
|
|
413
|
-
_app,
|
|
414
|
-
_deployments_dir
|
|
415
|
-
];
|
|
309
|
+
else if ( _type == "bytecode" ) {
|
|
310
|
+
_file_name =
|
|
311
|
+
`${_contract_address}.bin`;
|
|
312
|
+
}
|
|
313
|
+
else if ( _type == "compiler_output" ) {
|
|
314
|
+
_file_name =
|
|
315
|
+
`${_contract_address}.json`;
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
416
318
|
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
319
|
+
_msg =
|
|
320
|
+
`Unknown artifact type '${_type}'.`;
|
|
321
|
+
_msg_error(
|
|
322
|
+
_msg,
|
|
323
|
+
0);
|
|
324
|
+
throw _msg;
|
|
421
325
|
}
|
|
326
|
+
const
|
|
327
|
+
_artifact =
|
|
328
|
+
_path_join( [
|
|
329
|
+
_data_dir,
|
|
330
|
+
_target_network,
|
|
331
|
+
_file_name ]);
|
|
332
|
+
return _artifact;
|
|
422
333
|
}
|
|
423
334
|
|
|
424
335
|
async function
|
|
425
|
-
|
|
336
|
+
_contract_abi_check(
|
|
337
|
+
_abi,
|
|
338
|
+
_network,
|
|
339
|
+
_address,
|
|
340
|
+
_api_key,
|
|
341
|
+
_compiler_output,
|
|
342
|
+
_app,
|
|
343
|
+
_contract,
|
|
344
|
+
_configuration_format,
|
|
345
|
+
_deployments_dir,
|
|
346
|
+
_user_defined,
|
|
347
|
+
_local) {
|
|
426
348
|
let
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
349
|
+
_abi_get,
|
|
350
|
+
_abi_target,
|
|
351
|
+
_abi_targets,
|
|
352
|
+
_evm_contract_deployment_abi,
|
|
353
|
+
_msg;
|
|
354
|
+
_abi_get =
|
|
355
|
+
false;
|
|
356
|
+
_local =
|
|
357
|
+
_local_check(
|
|
358
|
+
_local);
|
|
434
359
|
const
|
|
435
|
-
|
|
360
|
+
_abi_type =
|
|
436
361
|
typeof(
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
362
|
+
_abi);
|
|
363
|
+
_user_defined =
|
|
364
|
+
_user_defined_check(
|
|
365
|
+
_user_defined);
|
|
366
|
+
if ( _abi_type === "undefined" ) {
|
|
367
|
+
_msg =
|
|
368
|
+
"ABI undefined, setting default.";
|
|
369
|
+
_msg_info(
|
|
370
|
+
_msg);
|
|
371
|
+
_abi_get =
|
|
372
|
+
true;
|
|
373
|
+
}
|
|
374
|
+
else if ( _abi_type === "string" ) {
|
|
375
|
+
if ( _abi.length < 1 ) {
|
|
376
|
+
_abi_get =
|
|
377
|
+
true;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
_msg =
|
|
382
|
+
"ABI path must be a string.";
|
|
383
|
+
_msg_error(
|
|
384
|
+
_msg,
|
|
385
|
+
0);
|
|
386
|
+
throw _msg;
|
|
387
|
+
}
|
|
388
|
+
if ( _abi_get ) {
|
|
389
|
+
if ( ! _local ) {
|
|
390
|
+
_abi =
|
|
391
|
+
_get(
|
|
392
|
+
"contract",
|
|
393
|
+
"abi");
|
|
394
|
+
_msg =
|
|
395
|
+
"Variable '_abi' not defined, " +
|
|
396
|
+
"defaulting to global variable " +
|
|
397
|
+
"'contract_abi', which has value " +
|
|
398
|
+
`'${_abi}'.`;
|
|
399
|
+
_msg_info(
|
|
400
|
+
_msg);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
const
|
|
404
|
+
_network_type =
|
|
405
|
+
typeof(
|
|
406
|
+
_network);
|
|
407
|
+
if ( _network_type === "undefined" ) {
|
|
408
|
+
_network =
|
|
409
|
+
_get(
|
|
410
|
+
"target",
|
|
411
|
+
"network");
|
|
412
|
+
_msg =
|
|
413
|
+
"Variable '_network' not defined, " +
|
|
414
|
+
"defaulting to global variable " +
|
|
415
|
+
"'target_network', which has value " +
|
|
416
|
+
`'${_network}'.`;
|
|
417
|
+
_msg_info(
|
|
418
|
+
_msg);
|
|
419
|
+
}
|
|
420
|
+
const
|
|
421
|
+
_api_key_type =
|
|
422
|
+
typeof(
|
|
423
|
+
_api_key);
|
|
424
|
+
if ( _api_key_type == "undefined" ) {
|
|
425
|
+
_api_key =
|
|
426
|
+
_get(
|
|
427
|
+
"api",
|
|
428
|
+
"key");
|
|
429
|
+
_msg =
|
|
430
|
+
"Variable '_api_key' not defined, " +
|
|
431
|
+
"defaulting to global variable " +
|
|
432
|
+
"'api_key', which has value " +
|
|
433
|
+
`'${_api_key}'.`;
|
|
434
|
+
_msg_info(
|
|
435
|
+
_msg);
|
|
436
|
+
}
|
|
437
|
+
const
|
|
438
|
+
_compiler_output_type =
|
|
439
|
+
typeof(
|
|
440
|
+
_compiler_output);
|
|
441
|
+
if ( _compiler_output_type == "undefined" ) {
|
|
442
|
+
_compiler_output =
|
|
443
|
+
_get(
|
|
444
|
+
"contract",
|
|
445
|
+
"compiler_output");
|
|
446
|
+
_msg =
|
|
447
|
+
"Variable '_compiler_output' not defined, " +
|
|
448
|
+
"defaulting to global variable " +
|
|
449
|
+
"'contract_compiler_output', which has value " +
|
|
450
|
+
`'${_compiler_output}'.`;
|
|
451
|
+
_msg_info(
|
|
452
|
+
_msg);
|
|
453
|
+
}
|
|
454
|
+
_app =
|
|
455
|
+
_app_check(
|
|
456
|
+
_app);
|
|
457
|
+
const
|
|
458
|
+
_contract_type =
|
|
459
|
+
typeof(
|
|
460
|
+
_contract);
|
|
461
|
+
if ( _contract_type == "undefined" ) {
|
|
462
|
+
_contract =
|
|
463
|
+
_get(
|
|
464
|
+
"target",
|
|
465
|
+
"contract");
|
|
466
|
+
_msg =
|
|
467
|
+
"Variable '_contract' not defined, " +
|
|
468
|
+
"defaulting to global variable " +
|
|
469
|
+
"'target_contract', which has value " +
|
|
470
|
+
`'${_contract}'.`;
|
|
471
|
+
_msg_info(
|
|
472
|
+
_msg);
|
|
473
|
+
}
|
|
474
|
+
const
|
|
475
|
+
_address_type =
|
|
476
|
+
typeof(
|
|
477
|
+
_address);
|
|
478
|
+
if ( _address_type == "undefined" ) {
|
|
479
|
+
_address =
|
|
480
|
+
_get(
|
|
481
|
+
"contract",
|
|
482
|
+
"address");
|
|
483
|
+
_msg =
|
|
484
|
+
"Variable '_address' not defined, " +
|
|
485
|
+
"defaulting to global variable " +
|
|
486
|
+
"'contract_address', which has value " +
|
|
487
|
+
`'${_address}'.`;
|
|
488
|
+
_msg_info(
|
|
489
|
+
_msg);
|
|
490
|
+
}
|
|
491
|
+
_abi_target =
|
|
492
|
+
_abi;
|
|
493
|
+
_abi_target =
|
|
494
|
+
_default_artifact_path_get(
|
|
495
|
+
"abi");
|
|
496
|
+
const
|
|
497
|
+
_abi_target_exists =
|
|
498
|
+
_file_exists(
|
|
499
|
+
_abi_target);
|
|
500
|
+
if ( ! _abi_target_exists ) {
|
|
501
|
+
if ( _app !== "" &&
|
|
502
|
+
_contract !== "" ) {
|
|
503
|
+
_evm_contract_deployment_abi =
|
|
504
|
+
_get(
|
|
505
|
+
"_evm_contract_deployment",
|
|
506
|
+
"abi");
|
|
507
|
+
try {
|
|
508
|
+
_evm_contract_deployment_abi =
|
|
509
|
+
await _evm_contract_deployment_abi_check.apply(
|
|
510
|
+
null,
|
|
511
|
+
_evm_contract_deployment_abi);
|
|
512
|
+
}
|
|
513
|
+
catch(
|
|
514
|
+
_error) {
|
|
515
|
+
_msg =
|
|
516
|
+
"Error running " +
|
|
517
|
+
"'_evm_contract_deployment_abi_check' " +
|
|
518
|
+
"with parameters:";
|
|
519
|
+
_msg_error(
|
|
520
|
+
_msg,
|
|
521
|
+
0);
|
|
522
|
+
_echo2(
|
|
523
|
+
_evm_contract_deployment_abi);
|
|
524
|
+
_echo2(
|
|
525
|
+
_error);
|
|
526
|
+
throw _error;
|
|
527
|
+
}
|
|
528
|
+
const
|
|
529
|
+
_configuration_format_check_args = [
|
|
530
|
+
_configuration_format
|
|
531
|
+
];
|
|
532
|
+
_configuration_format =
|
|
533
|
+
_configuration_format_check.apply(
|
|
534
|
+
null,
|
|
535
|
+
_configuration_format_check_args);
|
|
536
|
+
const
|
|
537
|
+
_deployments_dir_check_args = [
|
|
538
|
+
_deployments_dir,
|
|
539
|
+
_app,
|
|
540
|
+
_user_defined
|
|
541
|
+
];
|
|
542
|
+
try {
|
|
543
|
+
_deployments_dir =
|
|
544
|
+
await _deployments_dir_check.apply(
|
|
545
|
+
null,
|
|
546
|
+
_deployments_dir_check_args);
|
|
547
|
+
}
|
|
548
|
+
catch(
|
|
549
|
+
_error) {
|
|
550
|
+
_msg =
|
|
551
|
+
"Error running '_deployments_dir_check' " +
|
|
552
|
+
"with parameters:";
|
|
553
|
+
_msg_error(
|
|
554
|
+
_msg,
|
|
555
|
+
0);
|
|
556
|
+
_echo2(
|
|
557
|
+
_deployments_dir_check_args);
|
|
558
|
+
_echo2(
|
|
559
|
+
_error);
|
|
560
|
+
throw _error;
|
|
561
|
+
}
|
|
562
|
+
_msg =
|
|
563
|
+
`Getting LibEVM app '${_app}' ` +
|
|
564
|
+
`ABI for contract '${_contract}' for ` +
|
|
565
|
+
`network '${_network}' in format ` +
|
|
566
|
+
`'${_configuration_format}' at deployments ` +
|
|
567
|
+
`directory '${_deployments_dir}'.`;
|
|
568
|
+
_msg_info(
|
|
569
|
+
_msg);
|
|
570
|
+
const
|
|
571
|
+
_evm_contract_deployment_abi_args = [
|
|
572
|
+
[ _network ] ,
|
|
573
|
+
[ _network ],
|
|
574
|
+
"n",
|
|
575
|
+
_app,
|
|
576
|
+
_contract,
|
|
577
|
+
"", // version
|
|
578
|
+
"n", // user level
|
|
579
|
+
_configuration_format,
|
|
580
|
+
_deployments_dir
|
|
581
|
+
];
|
|
582
|
+
try {
|
|
583
|
+
_abi_targets =
|
|
584
|
+
await _evm_contract_deployment_abi.apply(
|
|
585
|
+
null,
|
|
586
|
+
_evm_contract_deployment_abi_args);
|
|
587
|
+
}
|
|
588
|
+
catch(
|
|
589
|
+
_error) {
|
|
590
|
+
_msg =
|
|
591
|
+
`Error retrieving LibEVM app '${_app}' ` +
|
|
592
|
+
`ABI for contract '${_contract}'.`;
|
|
593
|
+
_msg_error(
|
|
594
|
+
_msg,
|
|
595
|
+
0);
|
|
596
|
+
throw _error;
|
|
597
|
+
}
|
|
598
|
+
if ( 0 < _abi_target.length ) {
|
|
599
|
+
_abi_target =
|
|
600
|
+
_abi_targets[
|
|
601
|
+
0];
|
|
602
|
+
}
|
|
603
|
+
else if ( _abi_target.length < 1 ) {
|
|
604
|
+
_msg =
|
|
605
|
+
"Got no results.";
|
|
606
|
+
_msg_warning(
|
|
607
|
+
_msg);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
else {
|
|
612
|
+
_msg =
|
|
613
|
+
"Selecting abi target " +
|
|
614
|
+
`'${_abi_target}' for auto-detection.`;
|
|
615
|
+
_msg_info(
|
|
616
|
+
_msg);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
if ( ! _file_exists(
|
|
621
|
+
_abi) &&
|
|
622
|
+
! _file_exists(
|
|
623
|
+
_compiler_output) ) {
|
|
624
|
+
if ( _file_exists(
|
|
625
|
+
_abi_target) ) {
|
|
626
|
+
_abi =
|
|
627
|
+
_abi_target;
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
_msg =
|
|
631
|
+
`ABI '${_abi}' does not ` +
|
|
632
|
+
`exist and '${_abi_target}' neither.`;
|
|
633
|
+
_msg_info(
|
|
634
|
+
_msg);
|
|
635
|
+
const
|
|
636
|
+
_abi_dir =
|
|
637
|
+
_dirname(
|
|
638
|
+
_abi);
|
|
639
|
+
_contract_artifacts_retrieve(
|
|
640
|
+
_abi_dir);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return _abi;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
async function
|
|
647
|
+
_contract_bytecode_check(
|
|
648
|
+
_bytecode,
|
|
649
|
+
_network,
|
|
650
|
+
_address,
|
|
651
|
+
_api_key,
|
|
652
|
+
_compiler_output,
|
|
653
|
+
_app,
|
|
654
|
+
_contract,
|
|
655
|
+
_configuration_format,
|
|
656
|
+
_deployments_dir,
|
|
657
|
+
_user_defined,
|
|
658
|
+
_local) {
|
|
659
|
+
let
|
|
660
|
+
_bytecode_get,
|
|
661
|
+
_bytecode_target,
|
|
662
|
+
_bytecode_targets,
|
|
663
|
+
_evm_contract_deployment_bytecode,
|
|
664
|
+
_msg;
|
|
665
|
+
_bytecode_get =
|
|
666
|
+
false;
|
|
667
|
+
_local =
|
|
668
|
+
_local_check(
|
|
669
|
+
_local);
|
|
670
|
+
const
|
|
671
|
+
_bytecode_type =
|
|
672
|
+
typeof(
|
|
673
|
+
_bytecode);
|
|
674
|
+
_user_defined =
|
|
675
|
+
_user_defined_check(
|
|
676
|
+
_user_defined);
|
|
677
|
+
if ( _bytecode_type === "undefined" ) {
|
|
678
|
+
_msg =
|
|
679
|
+
"Bytecode undefined, setting default.";
|
|
680
|
+
_msg_info(
|
|
681
|
+
_msg);
|
|
682
|
+
_bytecode_get =
|
|
683
|
+
true;
|
|
684
|
+
}
|
|
685
|
+
else if ( _bytecode_type === "string" ) {
|
|
686
|
+
if ( _bytecode.length < 1 ) {
|
|
687
|
+
_bytecode_get =
|
|
688
|
+
true;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
_msg =
|
|
693
|
+
"Bytecode path must be a string.";
|
|
694
|
+
_msg_error(
|
|
695
|
+
_msg,
|
|
696
|
+
0);
|
|
697
|
+
throw _msg;
|
|
698
|
+
}
|
|
699
|
+
if ( _bytecode_get ) {
|
|
700
|
+
if ( ! _local ) {
|
|
701
|
+
_bytecode =
|
|
702
|
+
_get(
|
|
703
|
+
"contract",
|
|
704
|
+
"bytecode");
|
|
705
|
+
_msg =
|
|
706
|
+
"Variable '_bytecode' not defined, " +
|
|
707
|
+
"defaulting to global variable " +
|
|
708
|
+
"'contract_bytecode', which has value " +
|
|
709
|
+
`'${_bytecode}'.`;
|
|
710
|
+
_msg_info(
|
|
711
|
+
_msg);
|
|
712
|
+
}
|
|
713
|
+
else {
|
|
714
|
+
const
|
|
715
|
+
_network_type =
|
|
716
|
+
typeof(
|
|
717
|
+
_network);
|
|
718
|
+
if ( _network_type === "undefined" ) {
|
|
719
|
+
_network =
|
|
720
|
+
_get(
|
|
721
|
+
"target",
|
|
722
|
+
"network");
|
|
723
|
+
_msg =
|
|
724
|
+
"Variable '_network' not defined, " +
|
|
725
|
+
"defaulting to global variable " +
|
|
726
|
+
"'target_network', which has value " +
|
|
727
|
+
`'${_network}'.`;
|
|
728
|
+
_msg_info(
|
|
729
|
+
_msg);
|
|
730
|
+
}
|
|
731
|
+
const
|
|
732
|
+
_api_key_type =
|
|
733
|
+
typeof(
|
|
734
|
+
_api_key);
|
|
735
|
+
if ( _api_key_type == "undefined" ) {
|
|
736
|
+
_api_key =
|
|
737
|
+
_get(
|
|
738
|
+
"api",
|
|
739
|
+
"key");
|
|
740
|
+
_msg =
|
|
741
|
+
"Variable '_api_key' not defined, " +
|
|
742
|
+
"defaulting to global variable " +
|
|
743
|
+
"'api_key', which has value " +
|
|
744
|
+
`'${_api_key}'.`;
|
|
745
|
+
_msg_info(
|
|
746
|
+
_msg);
|
|
747
|
+
}
|
|
748
|
+
const
|
|
749
|
+
_compiler_output_type =
|
|
750
|
+
typeof(
|
|
751
|
+
_compiler_output);
|
|
752
|
+
if ( _compiler_output_type == "undefined" ) {
|
|
753
|
+
_compiler_output =
|
|
754
|
+
_get(
|
|
755
|
+
"contract",
|
|
756
|
+
"compiler_output");
|
|
757
|
+
_msg =
|
|
758
|
+
"Variable '_compiler_output' not defined, " +
|
|
759
|
+
"defaulting to global variable " +
|
|
760
|
+
"'contract_compiler_output', which has value " +
|
|
761
|
+
`'${_compiler_output}'.`;
|
|
762
|
+
_msg_info(
|
|
763
|
+
_msg);
|
|
764
|
+
}
|
|
765
|
+
_app =
|
|
766
|
+
_app_check(
|
|
767
|
+
_app);
|
|
768
|
+
const
|
|
769
|
+
_contract_type =
|
|
770
|
+
typeof(
|
|
771
|
+
_contract);
|
|
772
|
+
if ( _contract_type == "undefined" ) {
|
|
773
|
+
_contract =
|
|
774
|
+
_get(
|
|
775
|
+
"target",
|
|
776
|
+
"contract");
|
|
777
|
+
_msg =
|
|
778
|
+
"Variable '_contract' not defined, " +
|
|
779
|
+
"defaulting to global variable " +
|
|
780
|
+
"'target_contract', which has value " +
|
|
781
|
+
`'${_contract}'.`;
|
|
782
|
+
_msg_info(
|
|
783
|
+
_msg);
|
|
784
|
+
}
|
|
785
|
+
const
|
|
786
|
+
_address_type =
|
|
787
|
+
typeof(
|
|
788
|
+
_address);
|
|
789
|
+
if ( _address_type == "undefined" ) {
|
|
790
|
+
_address =
|
|
791
|
+
_get(
|
|
792
|
+
"contract",
|
|
793
|
+
"address");
|
|
794
|
+
_msg =
|
|
795
|
+
"Variable '_address' not defined, " +
|
|
796
|
+
"defaulting to global variable " +
|
|
797
|
+
"'contract_address', which has value " +
|
|
798
|
+
`'${_address}'.`;
|
|
799
|
+
_msg_info(
|
|
800
|
+
_msg);
|
|
801
|
+
}
|
|
802
|
+
_bytecode_target =
|
|
803
|
+
_bytecode;
|
|
804
|
+
_bytecode_target =
|
|
805
|
+
_default_artifact_path_get(
|
|
806
|
+
"bytecode");
|
|
807
|
+
const
|
|
808
|
+
_bytecode_target_exists =
|
|
809
|
+
_file_exists(
|
|
810
|
+
_bytecode_target);
|
|
811
|
+
if ( ! _bytecode_target_exists ) {
|
|
812
|
+
if ( _app !== "" &&
|
|
813
|
+
_contract !== "" ) {
|
|
814
|
+
_evm_contract_deployment_bytecode =
|
|
815
|
+
_get(
|
|
816
|
+
"_evm_contract_deployment",
|
|
817
|
+
"bytecode");
|
|
818
|
+
try {
|
|
819
|
+
_evm_contract_deployment_bytecode =
|
|
820
|
+
await _evm_contract_deployment_bytecode_check.apply(
|
|
821
|
+
null,
|
|
822
|
+
_evm_contract_deployment_bytecode);
|
|
823
|
+
}
|
|
824
|
+
catch(
|
|
825
|
+
_error) {
|
|
826
|
+
_msg =
|
|
827
|
+
"Error running " +
|
|
828
|
+
"'_evm_contract_deployment_bytecode_check' " +
|
|
829
|
+
"with parameters:";
|
|
830
|
+
_msg_error(
|
|
831
|
+
_msg,
|
|
832
|
+
0);
|
|
833
|
+
_echo2(
|
|
834
|
+
_evm_contract_deployment_bytecode);
|
|
835
|
+
_echo2(
|
|
836
|
+
_error);
|
|
837
|
+
throw _error;
|
|
838
|
+
}
|
|
839
|
+
const
|
|
840
|
+
_configuration_format_check_args = [
|
|
841
|
+
_configuration_format
|
|
842
|
+
];
|
|
843
|
+
_configuration_format =
|
|
844
|
+
_configuration_format_check.apply(
|
|
845
|
+
null,
|
|
846
|
+
_configuration_format_check_args);
|
|
847
|
+
const
|
|
848
|
+
_deployments_dir_check_args = [
|
|
849
|
+
_deployments_dir,
|
|
850
|
+
_app,
|
|
851
|
+
_user_defined
|
|
852
|
+
];
|
|
853
|
+
try {
|
|
854
|
+
_deployments_dir =
|
|
855
|
+
await _deployments_dir_check.apply(
|
|
856
|
+
null,
|
|
857
|
+
_deployments_dir_check_args);
|
|
858
|
+
}
|
|
859
|
+
catch(
|
|
860
|
+
_error) {
|
|
861
|
+
_msg =
|
|
862
|
+
"Error running '_deployments_dir_check' " +
|
|
863
|
+
"with parameters:";
|
|
864
|
+
_msg_error(
|
|
865
|
+
_msg,
|
|
866
|
+
0);
|
|
867
|
+
_echo2(
|
|
868
|
+
_deployments_dir_check_args);
|
|
869
|
+
_echo2(
|
|
870
|
+
_error);
|
|
871
|
+
throw _error;
|
|
872
|
+
}
|
|
873
|
+
_msg =
|
|
874
|
+
`Getting LibEVM app '${_app}' ` +
|
|
875
|
+
`bytecode for contract '${_contract}' for ` +
|
|
876
|
+
`network '${_network}' in format ` +
|
|
877
|
+
`'${_configuration_format}' at deployments ` +
|
|
878
|
+
`directory '${_deployments_dir}'.`;
|
|
879
|
+
_msg_info(
|
|
880
|
+
_msg);
|
|
881
|
+
const
|
|
882
|
+
_evm_contract_deployment_bytecode_args = [
|
|
883
|
+
[ _network ] ,
|
|
884
|
+
[ _network ],
|
|
885
|
+
"n",
|
|
886
|
+
_app,
|
|
887
|
+
_contract,
|
|
888
|
+
"", // version
|
|
889
|
+
"n", // user level
|
|
890
|
+
_configuration_format,
|
|
891
|
+
_deployments_dir
|
|
892
|
+
];
|
|
893
|
+
try {
|
|
894
|
+
_bytecode_targets =
|
|
895
|
+
await _evm_contract_deployment_bytecode.apply(
|
|
896
|
+
null,
|
|
897
|
+
_evm_contract_deployment_bytecode_args);
|
|
898
|
+
}
|
|
899
|
+
catch(
|
|
900
|
+
_error) {
|
|
901
|
+
_msg =
|
|
902
|
+
`Error retrieving LibEVM app '${_app}' ` +
|
|
903
|
+
`bytecode for contract '${_contract}'.`;
|
|
904
|
+
_msg_error(
|
|
905
|
+
_msg,
|
|
906
|
+
0);
|
|
907
|
+
throw _error;
|
|
908
|
+
}
|
|
909
|
+
if ( 0 < _bytecode_target.length ) {
|
|
910
|
+
_bytecode_target =
|
|
911
|
+
_bytecode_targets[
|
|
912
|
+
0];
|
|
913
|
+
}
|
|
914
|
+
else if ( _bytecode_target.length < 1 ) {
|
|
915
|
+
_msg =
|
|
916
|
+
"Got no results.";
|
|
917
|
+
_msg_warning(
|
|
918
|
+
_msg);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
else {
|
|
923
|
+
_msg =
|
|
924
|
+
"Selecting abi target " +
|
|
925
|
+
`'${_bytecode_target}' for auto-detection.`;
|
|
926
|
+
_msg_info(
|
|
927
|
+
_msg);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
if ( ! _file_exists(
|
|
932
|
+
_bytecode) &&
|
|
933
|
+
! _file_exists(
|
|
934
|
+
_compiler_output) ) {
|
|
935
|
+
if ( _file_exists(
|
|
936
|
+
_bytecode_target) ) {
|
|
937
|
+
_bytecode =
|
|
938
|
+
_bytecode_target;
|
|
939
|
+
}
|
|
940
|
+
else {
|
|
941
|
+
_msg =
|
|
942
|
+
`Bytecode '${_bytecode}' does not ` +
|
|
943
|
+
`exist and '${_bytecode_target}' neither.`;
|
|
944
|
+
_msg_info(
|
|
945
|
+
_msg);
|
|
946
|
+
const
|
|
947
|
+
_bytecode_dir =
|
|
948
|
+
_dirname(
|
|
949
|
+
_bytecode);
|
|
950
|
+
_contract_artifacts_retrieve(
|
|
951
|
+
_bytecode_dir);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
return _bytecode;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
async function
|
|
958
|
+
_contract_compiler_output_check(
|
|
959
|
+
_compiler_output,
|
|
960
|
+
_network,
|
|
961
|
+
_address,
|
|
962
|
+
_api_key,
|
|
963
|
+
_app,
|
|
964
|
+
_contract,
|
|
965
|
+
_configuration_format,
|
|
966
|
+
_deployments_dir,
|
|
967
|
+
_user_defined,
|
|
968
|
+
_local) {
|
|
969
|
+
let
|
|
970
|
+
_compiler_output_get,
|
|
971
|
+
_compiler_output_target,
|
|
972
|
+
_compiler_output_targets,
|
|
973
|
+
_evm_contract_deployment_compiler_output,
|
|
974
|
+
_msg;
|
|
975
|
+
_compiler_output_get =
|
|
976
|
+
false;
|
|
977
|
+
_local =
|
|
978
|
+
_local_check(
|
|
979
|
+
_local);
|
|
980
|
+
const
|
|
981
|
+
_compiler_output_type =
|
|
982
|
+
typeof(
|
|
983
|
+
_compiler_output);
|
|
984
|
+
_user_defined =
|
|
985
|
+
_user_defined_check(
|
|
986
|
+
_user_defined);
|
|
987
|
+
if ( _compiler_output_type === "undefined" ) {
|
|
988
|
+
_msg =
|
|
989
|
+
"Compiler output undefined, setting default.";
|
|
990
|
+
_msg_info(
|
|
991
|
+
_msg);
|
|
992
|
+
_compiler_output_get =
|
|
993
|
+
true;
|
|
994
|
+
}
|
|
995
|
+
else if ( _compiler_output_type === "string" ) {
|
|
996
|
+
if ( _compiler_output.length < 1 ) {
|
|
997
|
+
_compiler_output_get =
|
|
998
|
+
true;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
else {
|
|
1002
|
+
_msg =
|
|
1003
|
+
"Compiler output path must be a string.";
|
|
1004
|
+
_msg_error(
|
|
1005
|
+
_msg,
|
|
1006
|
+
0);
|
|
1007
|
+
throw _msg;
|
|
1008
|
+
}
|
|
1009
|
+
if ( _compiler_output_get ) {
|
|
1010
|
+
if ( ! _local ) {
|
|
1011
|
+
_compiler_output =
|
|
1012
|
+
_get(
|
|
1013
|
+
"contract",
|
|
1014
|
+
"compiler_output");
|
|
1015
|
+
_msg =
|
|
1016
|
+
"Variable '_compiler_output' not defined, " +
|
|
1017
|
+
"defaulting to global variable " +
|
|
1018
|
+
"'contract_compiler_output', which has value " +
|
|
1019
|
+
`'${_compiler_output}'.`;
|
|
1020
|
+
_msg_info(
|
|
1021
|
+
_msg);
|
|
1022
|
+
}
|
|
1023
|
+
else {
|
|
1024
|
+
const
|
|
1025
|
+
_network_type =
|
|
1026
|
+
typeof(
|
|
1027
|
+
_network);
|
|
1028
|
+
if ( _network_type === "undefined" ) {
|
|
1029
|
+
_network =
|
|
1030
|
+
_get(
|
|
1031
|
+
"target",
|
|
1032
|
+
"network");
|
|
1033
|
+
_msg =
|
|
1034
|
+
"Variable '_network' not defined, " +
|
|
1035
|
+
"defaulting to global variable " +
|
|
1036
|
+
"'target_network', which has value " +
|
|
1037
|
+
`'${_network}'.`;
|
|
1038
|
+
_msg_info(
|
|
1039
|
+
_msg);
|
|
1040
|
+
}
|
|
1041
|
+
const
|
|
1042
|
+
_api_key_type =
|
|
1043
|
+
typeof(
|
|
1044
|
+
_api_key);
|
|
1045
|
+
if ( _api_key_type == "undefined" ) {
|
|
1046
|
+
_api_key =
|
|
1047
|
+
_get(
|
|
1048
|
+
"api",
|
|
1049
|
+
"key");
|
|
1050
|
+
_msg =
|
|
1051
|
+
"Variable '_api_key' not defined, " +
|
|
1052
|
+
"defaulting to global variable " +
|
|
1053
|
+
"'api_key', which has value " +
|
|
1054
|
+
`'${_api_key}'.`;
|
|
1055
|
+
_msg_info(
|
|
1056
|
+
_msg);
|
|
1057
|
+
}
|
|
1058
|
+
_app =
|
|
1059
|
+
_app_check(
|
|
1060
|
+
_app);
|
|
1061
|
+
const
|
|
1062
|
+
_contract_type =
|
|
1063
|
+
typeof(
|
|
1064
|
+
_contract);
|
|
1065
|
+
if ( _contract_type == "undefined" ) {
|
|
1066
|
+
_contract =
|
|
1067
|
+
_get(
|
|
1068
|
+
"target",
|
|
1069
|
+
"contract");
|
|
1070
|
+
_msg =
|
|
1071
|
+
"Variable '_contract' not defined, " +
|
|
1072
|
+
"defaulting to global variable " +
|
|
1073
|
+
"'target_contract', which has value " +
|
|
1074
|
+
`'${_contract}'.`;
|
|
1075
|
+
_msg_info(
|
|
1076
|
+
_msg);
|
|
1077
|
+
}
|
|
1078
|
+
const
|
|
1079
|
+
_address_type =
|
|
1080
|
+
typeof(
|
|
1081
|
+
_address);
|
|
1082
|
+
if ( _address_type == "undefined" ) {
|
|
1083
|
+
_address =
|
|
1084
|
+
_get(
|
|
1085
|
+
"contract",
|
|
1086
|
+
"address");
|
|
1087
|
+
_msg =
|
|
1088
|
+
"Variable '_address' not defined, " +
|
|
1089
|
+
"defaulting to global variable " +
|
|
1090
|
+
"'contract_address', which has value " +
|
|
1091
|
+
`'${_address}'.`;
|
|
1092
|
+
_msg_info(
|
|
1093
|
+
_msg);
|
|
1094
|
+
}
|
|
1095
|
+
_compiler_output_target =
|
|
1096
|
+
_compiler_output;
|
|
1097
|
+
_compiler_output_target =
|
|
1098
|
+
_default_artifact_path_get(
|
|
1099
|
+
"compiler_output");
|
|
1100
|
+
const
|
|
1101
|
+
_compiler_output_target_exists =
|
|
1102
|
+
_file_exists(
|
|
1103
|
+
_compiler_output_target);
|
|
1104
|
+
if ( ! _compiler_output_target_exists ) {
|
|
1105
|
+
if ( _app !== "" &&
|
|
1106
|
+
_contract !== "" ) {
|
|
1107
|
+
_evm_contract_deployment_compiler_output =
|
|
1108
|
+
_get(
|
|
1109
|
+
"_evm_contract_deployment",
|
|
1110
|
+
"compiler_output");
|
|
1111
|
+
try {
|
|
1112
|
+
_evm_contract_deployment_compiler_output =
|
|
1113
|
+
await _evm_contract_deployment_compiler_output_check.apply(
|
|
1114
|
+
null,
|
|
1115
|
+
_evm_contract_deployment_compiler_output);
|
|
1116
|
+
}
|
|
1117
|
+
catch(
|
|
1118
|
+
_error) {
|
|
1119
|
+
_msg =
|
|
1120
|
+
"Error importing " +
|
|
1121
|
+
"'_evm_contract_deployment_compiler_output' " +
|
|
1122
|
+
"function by running " +
|
|
1123
|
+
"'_evm_contract_deployment_compiler_output_check' " +
|
|
1124
|
+
"with parameters:";
|
|
1125
|
+
_msg_error(
|
|
1126
|
+
_msg,
|
|
1127
|
+
0);
|
|
1128
|
+
_echo2(
|
|
1129
|
+
_evm_contract_deployment_compiler_output);
|
|
1130
|
+
_echo2(
|
|
1131
|
+
_error);
|
|
1132
|
+
throw _error;
|
|
1133
|
+
}
|
|
1134
|
+
const
|
|
1135
|
+
_configuration_format_check_args = [
|
|
1136
|
+
_configuration_format
|
|
1137
|
+
];
|
|
1138
|
+
_configuration_format =
|
|
1139
|
+
_configuration_format_check.apply(
|
|
1140
|
+
null,
|
|
1141
|
+
_configuration_format_check_args);
|
|
1142
|
+
const
|
|
1143
|
+
_deployments_dir_check_args = [
|
|
1144
|
+
_deployments_dir,
|
|
1145
|
+
_app,
|
|
1146
|
+
_user_defined
|
|
1147
|
+
];
|
|
1148
|
+
try {
|
|
1149
|
+
_deployments_dir =
|
|
1150
|
+
await _deployments_dir_check.apply(
|
|
1151
|
+
null,
|
|
1152
|
+
_deployments_dir_check_args);
|
|
1153
|
+
}
|
|
1154
|
+
catch(
|
|
1155
|
+
_error) {
|
|
1156
|
+
_msg =
|
|
1157
|
+
"Error running '_deployments_dir_check' " +
|
|
1158
|
+
"with parameters:";
|
|
1159
|
+
_msg_error(
|
|
1160
|
+
_msg,
|
|
1161
|
+
0);
|
|
1162
|
+
_echo2(
|
|
1163
|
+
_deployments_dir_check_args);
|
|
1164
|
+
_echo2(
|
|
1165
|
+
_error);
|
|
1166
|
+
throw _error;
|
|
1167
|
+
}
|
|
1168
|
+
_msg =
|
|
1169
|
+
`Getting LibEVM app '${_app}' ` +
|
|
1170
|
+
`compiler output for contract '${_contract}' for ` +
|
|
1171
|
+
`network '${_network}' in format ` +
|
|
1172
|
+
`'${_configuration_format}' at deployments ` +
|
|
1173
|
+
`directory '${_deployments_dir}'.`;
|
|
1174
|
+
_msg_info(
|
|
1175
|
+
_msg);
|
|
1176
|
+
const
|
|
1177
|
+
_evm_contract_deployment_compiler_output_args = [
|
|
1178
|
+
[ _network ] ,
|
|
1179
|
+
[ _network ],
|
|
1180
|
+
"n",
|
|
1181
|
+
_app,
|
|
1182
|
+
_contract,
|
|
1183
|
+
"", // version
|
|
1184
|
+
"n", // user level
|
|
1185
|
+
_configuration_format,
|
|
1186
|
+
_deployments_dir
|
|
1187
|
+
];
|
|
1188
|
+
try {
|
|
1189
|
+
_compiler_output_targets =
|
|
1190
|
+
await _evm_contract_deployment_compiler_output.apply(
|
|
1191
|
+
null,
|
|
1192
|
+
_evm_contract_deployment_compiler_output_args);
|
|
1193
|
+
}
|
|
1194
|
+
catch(
|
|
1195
|
+
_error) {
|
|
1196
|
+
_msg =
|
|
1197
|
+
`Error retrieving LibEVM app '${_app}' ` +
|
|
1198
|
+
`compiler output for contract '${_contract}'.`;
|
|
1199
|
+
_msg_error(
|
|
1200
|
+
_msg,
|
|
1201
|
+
0);
|
|
1202
|
+
throw _error;
|
|
1203
|
+
}
|
|
1204
|
+
if ( 0 < _compiler_output_target.length ) {
|
|
1205
|
+
_compiler_output_target =
|
|
1206
|
+
_compiler_output_targets[
|
|
1207
|
+
0];
|
|
1208
|
+
}
|
|
1209
|
+
else if ( _compiler_output_target.length < 1 ) {
|
|
1210
|
+
_msg =
|
|
1211
|
+
"Got no results.";
|
|
1212
|
+
_msg_warning(
|
|
1213
|
+
_msg);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
else {
|
|
1218
|
+
_msg =
|
|
1219
|
+
"Selecting compiler output target " +
|
|
1220
|
+
`'${_compiler_output_target}' for auto-detection.`;
|
|
1221
|
+
_msg_info(
|
|
1222
|
+
_msg);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
const
|
|
1227
|
+
_abi =
|
|
1228
|
+
_get(
|
|
1229
|
+
"contract",
|
|
1230
|
+
"abi");
|
|
1231
|
+
const
|
|
1232
|
+
_bytecode =
|
|
1233
|
+
_get(
|
|
1234
|
+
"contract",
|
|
1235
|
+
"bytecode");
|
|
1236
|
+
if ( ! _file_exists(
|
|
1237
|
+
_compiler_output) &&
|
|
1238
|
+
( ! _file_exists(
|
|
1239
|
+
_abi) &&
|
|
1240
|
+
! _file_exists(
|
|
1241
|
+
_bytecode) ) ) {
|
|
1242
|
+
if ( _file_exists(
|
|
1243
|
+
_compiler_output_target) ) {
|
|
1244
|
+
_compiler_output =
|
|
1245
|
+
_compiler_output_target;
|
|
1246
|
+
}
|
|
1247
|
+
else {
|
|
1248
|
+
_msg =
|
|
1249
|
+
`Compiler output '${_compiler_output}' does not ` +
|
|
1250
|
+
`exist and '${_compiler_output_target}' neither.`;
|
|
1251
|
+
_msg_info(
|
|
1252
|
+
_msg);
|
|
1253
|
+
const
|
|
1254
|
+
_compiler_output_dir =
|
|
1255
|
+
_dirname(
|
|
1256
|
+
_compiler_output);
|
|
1257
|
+
_contract_artifacts_retrieve(
|
|
1258
|
+
_compiler_output_dir);
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
return _compiler_output;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
async function
|
|
1265
|
+
_network_check(
|
|
1266
|
+
_deployments_dir,
|
|
1267
|
+
_contract,
|
|
1268
|
+
_target_network,
|
|
1269
|
+
_target_network_id,
|
|
1270
|
+
_app,
|
|
1271
|
+
_user_defined) {
|
|
1272
|
+
let
|
|
1273
|
+
_contract_deployments_dir,
|
|
1274
|
+
_error_flag,
|
|
1275
|
+
_evm_contract_deployment_networks,
|
|
1276
|
+
_evm_chains_info_args,
|
|
1277
|
+
_msg,
|
|
1278
|
+
_network_id,
|
|
1279
|
+
_networks;
|
|
1280
|
+
_error_flag =
|
|
1281
|
+
false;
|
|
1282
|
+
_app =
|
|
1283
|
+
_app_check(
|
|
1284
|
+
_app,
|
|
1285
|
+
false);
|
|
1286
|
+
_user_defined =
|
|
1287
|
+
_user_defined_check(
|
|
1288
|
+
_user_defined);
|
|
1289
|
+
const
|
|
1290
|
+
_deployments_dir_check_args = [
|
|
1291
|
+
_deployments_dir,
|
|
1292
|
+
_app,
|
|
1293
|
+
_user_defined
|
|
1294
|
+
];
|
|
1295
|
+
try {
|
|
1296
|
+
_deployments_dir =
|
|
1297
|
+
await _deployments_dir_check.apply(
|
|
1298
|
+
null,
|
|
1299
|
+
_deployments_dir_check_args);
|
|
1300
|
+
}
|
|
1301
|
+
catch(
|
|
1302
|
+
_error) {
|
|
1303
|
+
_msg =
|
|
1304
|
+
"Error checking '_deployments_dir' " +
|
|
1305
|
+
"variable in '_network_check' function:";
|
|
1306
|
+
_msg_error(
|
|
1307
|
+
_msg,
|
|
1308
|
+
0);
|
|
1309
|
+
throw _error;
|
|
1310
|
+
}
|
|
1311
|
+
_msg =
|
|
1312
|
+
"Network check for deployments " +
|
|
1313
|
+
`'${_deployments_dir}', contract '${_contract}', ` +
|
|
1314
|
+
`network '${_target_network}' and network with ID ` +
|
|
1315
|
+
`'${_target_network_id}'.`;
|
|
1316
|
+
_msg_info(
|
|
1317
|
+
_msg);
|
|
1318
|
+
_evm_contract_deployment_networks =
|
|
1319
|
+
_get(
|
|
1320
|
+
"_evm_contract_deployment",
|
|
1321
|
+
"networks");
|
|
1322
|
+
try {
|
|
1323
|
+
_evm_contract_deployment_networks =
|
|
1324
|
+
await _evm_contract_deployment_networks_check(
|
|
1325
|
+
_evm_contract_deployment_networks);
|
|
1326
|
+
}
|
|
1327
|
+
catch(
|
|
1328
|
+
_error) {
|
|
1329
|
+
_msg =
|
|
1330
|
+
"Error importing '_evm_contract_deployment_networks'.";
|
|
1331
|
+
_msg_error(
|
|
1332
|
+
_msg,
|
|
1333
|
+
0);
|
|
1334
|
+
_echo2(
|
|
1335
|
+
_error);
|
|
1336
|
+
throw _error;
|
|
1337
|
+
}
|
|
1338
|
+
_contract_deployments_dir =
|
|
1339
|
+
_path_join( [
|
|
1340
|
+
_deployments_dir,
|
|
1341
|
+
_contract ]);
|
|
1342
|
+
const
|
|
1343
|
+
_evm_contract_deployment_networks_args = [
|
|
1344
|
+
_contract_deployments_dir,
|
|
1345
|
+
"y", // Display all
|
|
1346
|
+
"n", // Display safest
|
|
1347
|
+
"n" // Display cheapest
|
|
1348
|
+
];
|
|
1349
|
+
try {
|
|
1350
|
+
_networks =
|
|
1351
|
+
await _evm_contract_deployment_networks.apply(
|
|
1352
|
+
null,
|
|
1353
|
+
_evm_contract_deployment_networks_args);
|
|
1354
|
+
}
|
|
1355
|
+
catch(
|
|
1356
|
+
_error) {
|
|
1357
|
+
_msg =
|
|
1358
|
+
"Error running '_evm_contract_deployment_networks' " +
|
|
1359
|
+
`with parameters:`;
|
|
1360
|
+
_msg_error(
|
|
1361
|
+
_msg,
|
|
1362
|
+
0);
|
|
1363
|
+
_echo2(
|
|
1364
|
+
_evm_contract_deployment_networks_args);
|
|
1365
|
+
_echo2(
|
|
1366
|
+
_error);
|
|
1367
|
+
throw _error;
|
|
1368
|
+
}
|
|
1369
|
+
if ( _target_network_id != "" ) {
|
|
1370
|
+
if ( ! _networks.includes(
|
|
1371
|
+
_target_network_id) ) {
|
|
1372
|
+
_msg =
|
|
1373
|
+
`The contract '${_contract}' ` +
|
|
1374
|
+
`does not result deployed on ` +
|
|
1375
|
+
`network with id '${_target_network_id}'.`;
|
|
1376
|
+
_error_flag =
|
|
1377
|
+
true;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
else if ( _target_network != "" ) {
|
|
1381
|
+
if ( ! _networks.includes(
|
|
1382
|
+
_target_network) ) {
|
|
1383
|
+
_msg =
|
|
1384
|
+
"The contract does not result deployed on " +
|
|
1385
|
+
`network '${_target_network}'.`;
|
|
1386
|
+
_error_flag =
|
|
1387
|
+
true;
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
else {
|
|
1391
|
+
_msg =
|
|
1392
|
+
"Provide one between a target network name " +
|
|
1393
|
+
"or ID.";
|
|
1394
|
+
_error_flag =
|
|
1395
|
+
true;
|
|
1396
|
+
}
|
|
1397
|
+
if ( _error_flag ) {
|
|
1398
|
+
_msg_error(
|
|
1399
|
+
_msg,
|
|
1400
|
+
0);
|
|
1401
|
+
throw _msg;
|
|
1402
|
+
}
|
|
1403
|
+
if ( _target_network_id == "" ) {
|
|
1404
|
+
_evm_chains_info_args = [
|
|
1405
|
+
"get", // target command
|
|
1406
|
+
"name", // input type
|
|
1407
|
+
"id", // output type
|
|
1408
|
+
"offline",
|
|
1409
|
+
[ "system", // db types
|
|
1410
|
+
"node" ],
|
|
1411
|
+
"kirsh", // selection method, first
|
|
1412
|
+
"n", // api keys
|
|
1413
|
+
"n", // query all networks
|
|
1414
|
+
_target_network,
|
|
1415
|
+
[] // database paths
|
|
1416
|
+
];
|
|
1417
|
+
try {
|
|
1418
|
+
_network_id =
|
|
1419
|
+
await _evm_chains_info.apply(
|
|
1420
|
+
null,
|
|
1421
|
+
_evm_chains_info_args);
|
|
1422
|
+
}
|
|
1423
|
+
catch(
|
|
1424
|
+
_error) {
|
|
1425
|
+
_msg =
|
|
1426
|
+
"Error while running '_evm_chains_info' " +
|
|
1427
|
+
`with arguments '${_evm_chains_info_args}'.`;
|
|
1428
|
+
_msg_error(
|
|
1429
|
+
_msg,
|
|
1430
|
+
0);
|
|
1431
|
+
_msg_error(
|
|
1432
|
+
_error,
|
|
1433
|
+
0);
|
|
1434
|
+
throw _error;
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
else if ( _target_network == "" ) {
|
|
1438
|
+
_network_id =
|
|
1439
|
+
_target_network_id;
|
|
1440
|
+
_evm_chains_info_args = [
|
|
1441
|
+
"get", // target command
|
|
1442
|
+
"id" , // input type
|
|
1443
|
+
"name", // output type
|
|
1444
|
+
"offline",
|
|
1445
|
+
[ "system", // db types
|
|
1446
|
+
"node" ],
|
|
1447
|
+
"kirsh", // selection method, first
|
|
1448
|
+
"n", // api keys
|
|
1449
|
+
"n", // query all networks
|
|
1450
|
+
_target_network_id,
|
|
1451
|
+
[] // database paths
|
|
1452
|
+
];
|
|
1453
|
+
try {
|
|
1454
|
+
_target_network =
|
|
1455
|
+
await _evm_chains_info.apply(
|
|
1456
|
+
null,
|
|
1457
|
+
_evm_chains_info_args);
|
|
1458
|
+
}
|
|
1459
|
+
catch(
|
|
1460
|
+
_error) {
|
|
1461
|
+
_msg =
|
|
1462
|
+
"Error while running '_evm_chains_info' " +
|
|
1463
|
+
`with arguments '${_evm_chains_info_args}'.`;
|
|
1464
|
+
_msg_error(
|
|
1465
|
+
_msg,
|
|
1466
|
+
0);
|
|
1467
|
+
_msg_error(
|
|
1468
|
+
_error,
|
|
1469
|
+
0);
|
|
1470
|
+
throw _error;
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
if ( _target_network_id != "" ) {
|
|
1474
|
+
if ( _target_network_id != _network_id ) {
|
|
1475
|
+
_msg =
|
|
1476
|
+
"Requested target network ID " +
|
|
1477
|
+
`'${_target_network_id}' does ` +
|
|
1478
|
+
`not correspond to '${_target_network}' ` +
|
|
1479
|
+
`known ID '${_network_id}'.`;
|
|
1480
|
+
_msg_error(
|
|
1481
|
+
_msg,
|
|
1482
|
+
0);
|
|
1483
|
+
throw _msg;
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
_msg =
|
|
1487
|
+
"Network check for deployments " +
|
|
1488
|
+
`'${_deployments_dir}', contract '${_contract}', ` +
|
|
1489
|
+
`network '${_target_network}' and network with ID ` +
|
|
1490
|
+
`'${_target_network_id}' completed.`;
|
|
1491
|
+
_msg_info(
|
|
1492
|
+
_msg);
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
async function
|
|
1496
|
+
_user_deployments_init(
|
|
1497
|
+
_app,
|
|
1498
|
+
_deployments_dir) {
|
|
1499
|
+
let
|
|
1500
|
+
_evm_contract_deployments_dir;
|
|
1501
|
+
const
|
|
1502
|
+
_user_defined =
|
|
1503
|
+
"n";
|
|
1504
|
+
_evm_contract_deployments_dir =
|
|
1505
|
+
_get(
|
|
1506
|
+
"_evm_contract",
|
|
1507
|
+
"deployments_dir");
|
|
1508
|
+
try {
|
|
1509
|
+
_evm_contract_deployments_dir =
|
|
1510
|
+
await _evm_contract_deployments_dir_check(
|
|
1511
|
+
_evm_contract_deployments_dir);
|
|
1512
|
+
}
|
|
1513
|
+
catch(
|
|
1514
|
+
_error) {
|
|
1515
|
+
_msg =
|
|
1516
|
+
"Error getting '_evm_cotract_deployments_dir' " +
|
|
1517
|
+
"function.";
|
|
1518
|
+
_msg_error(
|
|
1519
|
+
_msg,
|
|
1520
|
+
0);
|
|
1521
|
+
_echo2(
|
|
1522
|
+
_error);
|
|
1523
|
+
throw _error;
|
|
1524
|
+
}
|
|
1525
|
+
const
|
|
1526
|
+
_evm_contract_deployments_dir_args = [
|
|
1527
|
+
_app,
|
|
1528
|
+
_user_defined
|
|
1529
|
+
];
|
|
1530
|
+
const
|
|
1531
|
+
_system_deployments =
|
|
1532
|
+
await _evm_contract_deployments_dir.apply(
|
|
1533
|
+
null,
|
|
1534
|
+
_evm_contract_deployments_dir_args);
|
|
1535
|
+
_chmod(
|
|
1536
|
+
_deployments_dir,
|
|
1537
|
+
"0700");
|
|
1538
|
+
const
|
|
1539
|
+
_files =
|
|
1540
|
+
await _ls(
|
|
1541
|
+
_system_deployments);
|
|
1542
|
+
for ( _file of _files ) {
|
|
1543
|
+
_cp(
|
|
1544
|
+
_file,
|
|
1545
|
+
_deployments_dir);
|
|
1546
|
+
}
|
|
1547
|
+
return true;
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
async function
|
|
1551
|
+
_user_deployments_check(
|
|
1552
|
+
_app,
|
|
1553
|
+
_deployments_dir) {
|
|
1554
|
+
if ( ! _file_exists(
|
|
1555
|
+
_deployments_dir) ) {
|
|
1556
|
+
const
|
|
1557
|
+
_user_deployments_init_args = [
|
|
1558
|
+
_app,
|
|
1559
|
+
_deployments_dir
|
|
1560
|
+
];
|
|
1561
|
+
const
|
|
1562
|
+
_initialized =
|
|
1563
|
+
await _user_deployments_init.apply(
|
|
1564
|
+
null,
|
|
1565
|
+
_user_deployments_init_args);
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
function
|
|
1570
|
+
_user_defined_check(
|
|
1571
|
+
_user_defined) {
|
|
1572
|
+
let
|
|
1573
|
+
_msg;
|
|
1574
|
+
const
|
|
1575
|
+
_user_defined_type =
|
|
1576
|
+
typeof(
|
|
1577
|
+
_user_defined);
|
|
1578
|
+
if ( _user_defined_type === "undefined" ) {
|
|
1579
|
+
_msg =
|
|
1580
|
+
"Variable '_user_defined' undefined, " +
|
|
1581
|
+
"setting default value 'n'.";
|
|
1582
|
+
_msg_info(
|
|
1583
|
+
_msg);
|
|
1584
|
+
_user_defined =
|
|
1585
|
+
"n";
|
|
1586
|
+
}
|
|
1587
|
+
else if ( _user_defined_type === "string" ) {
|
|
1588
|
+
if ( _user_defined.length < 1 ) {
|
|
1589
|
+
_msg =
|
|
1590
|
+
"Variable '_user_defined' not set, " +
|
|
1591
|
+
"setting default value 'n'.";
|
|
1592
|
+
_msg_info(
|
|
1593
|
+
_msg);
|
|
1594
|
+
_user_defined =
|
|
1595
|
+
"n";
|
|
1596
|
+
}
|
|
1597
|
+
else if ( _user_defined.length > 1 ||
|
|
1598
|
+
( _user_defined !== "n" &&
|
|
1599
|
+
_user_defined !== "y" ) ) {
|
|
1600
|
+
_msg =
|
|
1601
|
+
"Variable '_user_defined' can have " +
|
|
1602
|
+
"value 'y' or 'n'.";
|
|
1603
|
+
_msg_error(
|
|
1604
|
+
_msg,
|
|
1605
|
+
0);
|
|
1606
|
+
throw _msg;
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
else {
|
|
1610
|
+
_msg =
|
|
1611
|
+
"Variable '_user_defined' must be of type " +
|
|
1612
|
+
"string and have value 'y' or 'n'.";
|
|
1613
|
+
_msg_error(
|
|
1614
|
+
_msg,
|
|
1615
|
+
0);
|
|
1616
|
+
throw _msg;
|
|
1617
|
+
}
|
|
1618
|
+
return _user_defined;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
function
|
|
1622
|
+
_user_level_check(
|
|
1623
|
+
_user_level) {
|
|
1624
|
+
let
|
|
1625
|
+
_msg;
|
|
1626
|
+
const
|
|
1627
|
+
_user_level_type =
|
|
1628
|
+
typeof(
|
|
1629
|
+
_user_level);
|
|
1630
|
+
if ( _user_level_type === "undefined" ) {
|
|
1631
|
+
_msg =
|
|
1632
|
+
"Variable '_user_level' undefined, " +
|
|
1633
|
+
"setting default value 'n'.";
|
|
1634
|
+
_msg_info(
|
|
1635
|
+
_msg);
|
|
1636
|
+
_user_level =
|
|
1637
|
+
"n";
|
|
1638
|
+
}
|
|
1639
|
+
else if ( _user_level_type === "string" ) {
|
|
1640
|
+
if ( _user_level.length < 1 ) {
|
|
1641
|
+
_msg =
|
|
1642
|
+
"Variable '_user_level' not set, " +
|
|
1643
|
+
"setting default value 'n'.";
|
|
1644
|
+
_msg_info(
|
|
1645
|
+
_msg);
|
|
1646
|
+
_user_level =
|
|
1647
|
+
"n";
|
|
1648
|
+
}
|
|
1649
|
+
else if ( _user_level.length > 1 ||
|
|
1650
|
+
( _user_level !== "n" &&
|
|
1651
|
+
_user_level !== "y" ) ) {
|
|
1652
|
+
_msg =
|
|
1653
|
+
"Variable '_user_level' can have " +
|
|
1654
|
+
"value 'y' or 'n' (current value " +
|
|
1655
|
+
`'${_user_level}'.`;
|
|
1656
|
+
_msg_error(
|
|
1657
|
+
_msg,
|
|
1658
|
+
0);
|
|
1659
|
+
throw _msg;
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
else {
|
|
1663
|
+
_msg =
|
|
1664
|
+
"Variable '_user_level' must be of type " +
|
|
1665
|
+
"string and have value 'y' or 'n'.";
|
|
1666
|
+
_msg_error(
|
|
1667
|
+
_msg,
|
|
1668
|
+
0);
|
|
1669
|
+
throw _msg;
|
|
1670
|
+
}
|
|
1671
|
+
return _user_level;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
async function
|
|
1675
|
+
_deployments_dir_check(
|
|
1676
|
+
_deployments,
|
|
1677
|
+
_app,
|
|
1678
|
+
_user_defined) {
|
|
1679
|
+
let
|
|
1680
|
+
_evm_contract_deployments_dir,
|
|
1681
|
+
_msg;
|
|
1682
|
+
_evm_contract_deployments_dir =
|
|
1683
|
+
_get(
|
|
1684
|
+
"_evm_contract",
|
|
1685
|
+
"deployments_dir");
|
|
1686
|
+
try {
|
|
1687
|
+
_evm_contract_deployments_dir =
|
|
1688
|
+
await _evm_contract_deployments_dir_check(
|
|
1689
|
+
_evm_contract_deployments_dir);
|
|
1690
|
+
}
|
|
1691
|
+
catch(
|
|
1692
|
+
_error) {
|
|
1693
|
+
_msg =
|
|
1694
|
+
"Error getting '_evm_contract_deployments_dir' " +
|
|
1695
|
+
"function.";
|
|
1696
|
+
_msg_error(
|
|
1697
|
+
_msg,
|
|
1698
|
+
0);
|
|
1699
|
+
_echo2(
|
|
1700
|
+
_error);
|
|
1701
|
+
throw _error;
|
|
1702
|
+
}
|
|
1703
|
+
_app =
|
|
1704
|
+
_app_check(
|
|
1705
|
+
_app);
|
|
1706
|
+
_user_defined =
|
|
1707
|
+
_user_defined_check(
|
|
1708
|
+
_user_defined);
|
|
1709
|
+
const
|
|
1710
|
+
_evm_contract_deployments_dir_args = [
|
|
1711
|
+
_app,
|
|
1712
|
+
_user_defined
|
|
1713
|
+
];
|
|
1714
|
+
try {
|
|
1715
|
+
_deployments =
|
|
1716
|
+
await _evm_contract_deployments_dir.apply(
|
|
1717
|
+
null,
|
|
1718
|
+
_evm_contract_deployments_dir_args);
|
|
1719
|
+
}
|
|
1720
|
+
catch(
|
|
1721
|
+
_error) {
|
|
1722
|
+
_msg =
|
|
1723
|
+
"Error running '_evm_contract_deployments_dir' " +
|
|
1724
|
+
"function with arguments:";
|
|
1725
|
+
_msg_error(
|
|
1726
|
+
_msg,
|
|
1727
|
+
0);
|
|
1728
|
+
_echo2(
|
|
1729
|
+
_evm_contract_deployments_dir_args);
|
|
1730
|
+
_echo2(
|
|
1731
|
+
_error);
|
|
1732
|
+
throw _error;
|
|
1733
|
+
}
|
|
1734
|
+
return _deployments;
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
async function
|
|
1738
|
+
_deployments_dir_auto_detect() {
|
|
1739
|
+
let
|
|
1740
|
+
_app,
|
|
1741
|
+
_deployments_dir,
|
|
1742
|
+
_evm_contract_deployments_dir,
|
|
1743
|
+
_msg,
|
|
1744
|
+
_user_defined;
|
|
1745
|
+
_deployments_dir =
|
|
1746
|
+
_get(
|
|
1747
|
+
"deployments",
|
|
1748
|
+
"dir");
|
|
1749
|
+
_app =
|
|
1750
|
+
_get(
|
|
1751
|
+
"target",
|
|
1752
|
+
"app");
|
|
1753
|
+
_app =
|
|
1754
|
+
_app_check(
|
|
1755
|
+
_app);
|
|
1756
|
+
if ( _app != "" ) {
|
|
1757
|
+
_user_defined =
|
|
1758
|
+
_get(
|
|
1759
|
+
"user",
|
|
1760
|
+
"defined");
|
|
1761
|
+
_user_defined =
|
|
1762
|
+
_user_defined_check(
|
|
1763
|
+
_user_defined);
|
|
1764
|
+
const
|
|
1765
|
+
_deployments_dir_check_args = [
|
|
1766
|
+
_deployments_dir,
|
|
1767
|
+
_app,
|
|
1768
|
+
_user_defined
|
|
1769
|
+
];
|
|
1770
|
+
try {
|
|
1771
|
+
_deployments_dir =
|
|
1772
|
+
await _deployments_dir_check.apply(
|
|
1773
|
+
null,
|
|
1774
|
+
_deployments_dir_check_args);
|
|
1775
|
+
}
|
|
1776
|
+
catch(
|
|
1777
|
+
_error) {
|
|
1778
|
+
_msg =
|
|
1779
|
+
"Error checking '_deployments_dir' " +
|
|
1780
|
+
"variable."
|
|
1781
|
+
_msg_error(
|
|
1782
|
+
_msg,
|
|
1783
|
+
0);
|
|
1784
|
+
_echo2(
|
|
1785
|
+
_error);
|
|
1786
|
+
throw _error;
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
_override_set(
|
|
1790
|
+
"deployments",
|
|
1791
|
+
"dir",
|
|
1792
|
+
_deployments_dir);
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
function
|
|
1796
|
+
_local_check(
|
|
1797
|
+
_local) {
|
|
1798
|
+
let
|
|
1799
|
+
_msg;
|
|
1800
|
+
const
|
|
1801
|
+
_local_type =
|
|
1802
|
+
typeof(
|
|
1803
|
+
_local);
|
|
1804
|
+
if ( _local_type === "undefined" ) {
|
|
1805
|
+
_msg =
|
|
1806
|
+
"Local not specified, setting default " +
|
|
1807
|
+
"value 'true'.";
|
|
1808
|
+
_msg_info(
|
|
1809
|
+
_msg);
|
|
1810
|
+
_local =
|
|
1811
|
+
true;
|
|
1812
|
+
}
|
|
1813
|
+
else if ( _local_type === "string" ) {
|
|
1814
|
+
if ( _local.length < 1 ) {
|
|
1815
|
+
_msg =
|
|
1816
|
+
"Local not specified, setting default " +
|
|
1817
|
+
"value 'true'.";
|
|
1818
|
+
_msg_info(
|
|
1819
|
+
_msg);
|
|
1820
|
+
_local =
|
|
1821
|
+
true;
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
else if ( _local_type !== "boolean" ) {
|
|
1825
|
+
_msg =
|
|
1826
|
+
"Variable '_local' must be a boolean.";
|
|
1827
|
+
_msg_error(
|
|
1828
|
+
_msg,
|
|
1829
|
+
0);
|
|
1830
|
+
throw _msg;
|
|
1831
|
+
}
|
|
1832
|
+
return _local;
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
function
|
|
1836
|
+
_app_check(
|
|
1837
|
+
_app,
|
|
1838
|
+
_local) {
|
|
1839
|
+
let
|
|
1840
|
+
_undefined_flag,
|
|
1841
|
+
_msg;
|
|
1842
|
+
_local =
|
|
1843
|
+
_local_check(
|
|
1844
|
+
_local);
|
|
1845
|
+
const
|
|
1846
|
+
_app_type =
|
|
1847
|
+
typeof(
|
|
1848
|
+
_app);
|
|
1849
|
+
if ( _app_type === "undefined" ) {
|
|
1850
|
+
_msg =
|
|
1851
|
+
"No application specified.";
|
|
1852
|
+
_undefined_flag =
|
|
1853
|
+
true;
|
|
1854
|
+
}
|
|
1855
|
+
else if ( _app_type === "string" ) {
|
|
1856
|
+
if ( _app.length < 1 ) {
|
|
1857
|
+
_msg =
|
|
1858
|
+
"No application specified.";
|
|
1859
|
+
_undefined_flag =
|
|
1860
|
+
true;
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
else {
|
|
1864
|
+
_msg =
|
|
1865
|
+
"Application argument must be of " +
|
|
1866
|
+
`type string (current type: '${_app_type}').`;
|
|
1867
|
+
_msg_error(
|
|
1868
|
+
_msg,
|
|
1869
|
+
0);
|
|
1870
|
+
throw _msg;
|
|
1871
|
+
}
|
|
1872
|
+
if ( _undefined_flag ) {
|
|
1873
|
+
if ( _local ) {
|
|
1874
|
+
_msg_error(
|
|
1875
|
+
_msg,
|
|
1876
|
+
0);
|
|
1877
|
+
throw _msg;
|
|
1878
|
+
}
|
|
1879
|
+
else {
|
|
1880
|
+
_msg =
|
|
1881
|
+
"Local option disabled, " +
|
|
1882
|
+
"getting '_app' variable from " +
|
|
1883
|
+
"global variable 'target_app'.";
|
|
1884
|
+
_msg_info(
|
|
1885
|
+
_msg);
|
|
1886
|
+
const
|
|
1887
|
+
_global =
|
|
1888
|
+
_global_get();
|
|
1889
|
+
const
|
|
1890
|
+
_target_app =
|
|
1891
|
+
_get(
|
|
1892
|
+
"target",
|
|
1893
|
+
"app");
|
|
1894
|
+
const
|
|
1895
|
+
_target_app_type =
|
|
1896
|
+
typeof(
|
|
1897
|
+
_target_app);
|
|
1898
|
+
if ( _target_app_type === "string" ) {
|
|
1899
|
+
if ( 0 < _target_app.length ) {
|
|
1900
|
+
_msg =
|
|
1901
|
+
"Getting '_app' variable value from " +
|
|
1902
|
+
"global variable 'target_app'.";
|
|
1903
|
+
_msg_info(
|
|
1904
|
+
_msg);
|
|
1905
|
+
_app =
|
|
1906
|
+
_target_app;
|
|
1907
|
+
}
|
|
1908
|
+
else {
|
|
1909
|
+
_msg =
|
|
1910
|
+
"Error while auto-detecting '_app' variable " +
|
|
1911
|
+
"value, global variable 'target_app' " +
|
|
1912
|
+
"also not set.";
|
|
1913
|
+
_msg_error(
|
|
1914
|
+
_msg,
|
|
1915
|
+
0);
|
|
1916
|
+
throw _msg;
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
else {
|
|
1920
|
+
_msg =
|
|
1921
|
+
"Global variable 'target_app' has " +
|
|
1922
|
+
"the wrong type for the local " +
|
|
1923
|
+
`variable '_app' ('${_target_app_variable}')`;
|
|
1924
|
+
_msg_error(
|
|
1925
|
+
_msg,
|
|
1926
|
+
0);
|
|
1927
|
+
throw _msg;
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
return _app;
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
async function
|
|
1935
|
+
_contract_version_auto_detect() {
|
|
1936
|
+
let
|
|
1937
|
+
_config,
|
|
1938
|
+
_config_ext,
|
|
1939
|
+
_contract,
|
|
1940
|
+
_deployments_dir,
|
|
1941
|
+
_evm_contracts_deployment_versions,
|
|
1942
|
+
_found,
|
|
1943
|
+
_net,
|
|
1944
|
+
_network,
|
|
1945
|
+
_network_id,
|
|
1946
|
+
_networks,
|
|
1947
|
+
_version,
|
|
1948
|
+
_msg;
|
|
1949
|
+
_networks =
|
|
1950
|
+
[];
|
|
1951
|
+
_contract =
|
|
1952
|
+
_get(
|
|
1953
|
+
"target",
|
|
1954
|
+
"contract");
|
|
1955
|
+
_deployments_dir =
|
|
1956
|
+
_get(
|
|
1957
|
+
"deployments",
|
|
1958
|
+
"dir");
|
|
1959
|
+
_found =
|
|
1960
|
+
false;
|
|
1961
|
+
if ( configuration_format == "bash" ) {
|
|
1962
|
+
_config_ext =
|
|
1963
|
+
"sh";
|
|
1964
|
+
}
|
|
1965
|
+
else if ( configuration_format == "bash" ) {
|
|
1966
|
+
_config_ext =
|
|
1967
|
+
"json";
|
|
1968
|
+
}
|
|
1969
|
+
const
|
|
1970
|
+
_contract_type =
|
|
1971
|
+
typeof(
|
|
1972
|
+
_contract);
|
|
1973
|
+
if ( _contract != "" &&
|
|
1974
|
+
_contract_type != "undefined" ) {
|
|
1975
|
+
const
|
|
1976
|
+
_deployments_dir_type =
|
|
1977
|
+
typeof(
|
|
1978
|
+
_deployments_dir);
|
|
1979
|
+
if ( _deployments_dir_type !== "undefined" &&
|
|
1980
|
+
deployments_dir !== "" ) {
|
|
1981
|
+
_deployments =
|
|
1982
|
+
deployments_dir;
|
|
1983
|
+
if ( 0 < target_networks.length ) {
|
|
1984
|
+
_network =
|
|
1985
|
+
target_networks[
|
|
1986
|
+
0];
|
|
1987
|
+
}
|
|
1988
|
+
if ( 0 < network_ids.length ) {
|
|
1989
|
+
_network_id =
|
|
1990
|
+
_network_ids[
|
|
1991
|
+
0];
|
|
1992
|
+
}
|
|
1993
|
+
const
|
|
1994
|
+
_deployments_path =
|
|
1995
|
+
_path_join( [
|
|
1996
|
+
_deployments,
|
|
1997
|
+
_contract ] );
|
|
1998
|
+
if ( networks_all == "n" ) {
|
|
1999
|
+
_networks.push(
|
|
2000
|
+
_network,
|
|
2001
|
+
_network_id);
|
|
2002
|
+
}
|
|
2003
|
+
else if ( networks_all == "y" ) {
|
|
2004
|
+
const
|
|
2005
|
+
_evm_contract_deployment_networks_args = [
|
|
2006
|
+
_deployments_path,
|
|
2007
|
+
"y", // Display all
|
|
2008
|
+
"n", // Display safest
|
|
2009
|
+
"n" // Display cheapest
|
|
2010
|
+
];
|
|
2011
|
+
_networks_new =
|
|
2012
|
+
await _evm_contract_deployment_networks.apply(
|
|
2013
|
+
null,
|
|
2014
|
+
_evm_contract_deployment_networks_args);
|
|
2015
|
+
_networks =
|
|
2016
|
+
_networks.concat(
|
|
2017
|
+
_networks_new);
|
|
2018
|
+
}
|
|
2019
|
+
for ( _net of _networks ) {
|
|
2020
|
+
_config =
|
|
2021
|
+
_path_join( [
|
|
2022
|
+
_deployments_path,
|
|
2023
|
+
_net,
|
|
2024
|
+
`config.${_config_ext}`
|
|
2025
|
+
]);
|
|
2026
|
+
if ( _file_exists(
|
|
2027
|
+
_config) ) {
|
|
2028
|
+
_found =
|
|
2029
|
+
true;
|
|
2030
|
+
_msg =
|
|
2031
|
+
`Found deployment configuration ` +
|
|
2032
|
+
`at location '${_config}'.`;
|
|
2033
|
+
_msg_info(
|
|
2034
|
+
_msg);
|
|
2035
|
+
break;
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
if ( ! _found ) {
|
|
2039
|
+
_msg =
|
|
2040
|
+
"No deployment configuration " +
|
|
2041
|
+
"file found for network " +
|
|
2042
|
+
`'${_network}' with ID ` +
|
|
2043
|
+
`'${_network_id}'.`;
|
|
2044
|
+
_msg_error(
|
|
2045
|
+
_msg,
|
|
2046
|
+
1);
|
|
2047
|
+
}
|
|
2048
|
+
_evm_contract_deployment_versions =
|
|
2049
|
+
_get(
|
|
2050
|
+
"_evm_contract_deployment",
|
|
2051
|
+
"versions");
|
|
2052
|
+
try {
|
|
2053
|
+
_evm_contract_deployment_versions =
|
|
2054
|
+
await _evm_contract_deployment_versions_check(
|
|
2055
|
+
_evm_contract_deployment_versions);
|
|
2056
|
+
}
|
|
2057
|
+
catch(
|
|
2058
|
+
_error) {
|
|
2059
|
+
_msg =
|
|
2060
|
+
"Error checking '_evm_contract_deployment_versions'.";
|
|
2061
|
+
_msg_error(
|
|
2062
|
+
_msg,
|
|
2063
|
+
0);
|
|
2064
|
+
throw _msg;
|
|
2065
|
+
}
|
|
2066
|
+
const
|
|
2067
|
+
_evm_contract_deployment_versions_args = [
|
|
2068
|
+
_config,
|
|
2069
|
+
"y", // display highest
|
|
2070
|
+
"n", // display lowest
|
|
2071
|
+
configuration_format
|
|
2072
|
+
];
|
|
2073
|
+
_version =
|
|
2074
|
+
await _evm_contract_deployment_versions.apply(
|
|
2075
|
+
null,
|
|
2076
|
+
_evm_contract_deployment_versions_args);
|
|
2077
|
+
}
|
|
2078
|
+
else if ( _deployments_dir_type == "undefined" ||
|
|
2079
|
+
deployments_dir == "" ) {
|
|
2080
|
+
const
|
|
2081
|
+
_msg =
|
|
2082
|
+
"If no target application is specified " +
|
|
2083
|
+
"then the user-defined deployments " +
|
|
2084
|
+
"switch must be enabled with '-u' and " +
|
|
2085
|
+
"a deployments directory must be specified " +
|
|
2086
|
+
"with '-d'.";
|
|
2087
|
+
_msg_error(
|
|
2088
|
+
_msg,
|
|
2089
|
+
1);
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
_override_set(
|
|
2093
|
+
"contract",
|
|
2094
|
+
"version",
|
|
2095
|
+
_version);
|
|
2096
|
+
return true;
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
function
|
|
2100
|
+
_networks_all_auto_detect() {
|
|
2101
|
+
let
|
|
2102
|
+
_networks_all;
|
|
2103
|
+
_networks_all =
|
|
2104
|
+
"n";
|
|
2105
|
+
if ( target_networks.length < 1 &&
|
|
2106
|
+
network_ids.length < 1 ) {
|
|
2107
|
+
_networks_all =
|
|
2108
|
+
"y";
|
|
2109
|
+
}
|
|
2110
|
+
_override_set(
|
|
2111
|
+
"networks",
|
|
2112
|
+
"all",
|
|
2113
|
+
_networks_all);
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
async function
|
|
2117
|
+
_evm_contract_deployment_abi_check(
|
|
2118
|
+
_evm_contract_deployment_abi) {
|
|
2119
|
+
let
|
|
2120
|
+
_import,
|
|
2121
|
+
_msg;
|
|
2122
|
+
_import =
|
|
2123
|
+
false;
|
|
2124
|
+
const
|
|
2125
|
+
_evm_contract_deployment_abi_type =
|
|
2126
|
+
typeof(
|
|
2127
|
+
_evm_contract_deployment_abi);
|
|
2128
|
+
if ( _evm_contract_deployment_abi_type === "undefined" ) {
|
|
2129
|
+
_msg =
|
|
2130
|
+
"Function '_evm_contract_deployment_abi' " +
|
|
2131
|
+
"undefined, importing.";
|
|
2132
|
+
_import =
|
|
2133
|
+
true;
|
|
2134
|
+
}
|
|
2135
|
+
else if ( _evm_contract_deployment_abi_type === "string" ) {
|
|
2136
|
+
if ( _evm_contract_deployment_abi.length < 1 ) {
|
|
2137
|
+
_msg =
|
|
2138
|
+
"Function '_evm_contract_deployment_abi' " +
|
|
2139
|
+
"undefined, importing.";
|
|
2140
|
+
_import =
|
|
2141
|
+
true;
|
|
2142
|
+
}
|
|
2143
|
+
else {
|
|
2144
|
+
_msg =
|
|
2145
|
+
"Function '_evm_contract_deployment_abi' " +
|
|
2146
|
+
"is a string.";
|
|
2147
|
+
_msg_error(
|
|
2148
|
+
_msg,
|
|
2149
|
+
0);
|
|
2150
|
+
throw _msg;
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
if ( _import ) {
|
|
2154
|
+
try {
|
|
2155
|
+
const
|
|
2156
|
+
_libevm_contract_deployment_abi_module =
|
|
2157
|
+
await import(
|
|
2158
|
+
"./libevm-contract-deployment-abi");
|
|
2159
|
+
_evm_contract_deployment_abi =
|
|
2160
|
+
_libevm_contract_deployment_abi_module._evm_contract_deployment_abi;
|
|
2161
|
+
}
|
|
2162
|
+
catch(
|
|
2163
|
+
_error) {
|
|
2164
|
+
_msg =
|
|
2165
|
+
"Error importing './libevm-contract-deployment-abi'.";
|
|
2166
|
+
_msg_error(
|
|
2167
|
+
_msg,
|
|
2168
|
+
0);
|
|
2169
|
+
throw _msg;
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
return _evm_contract_deployment_abi;
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
async function
|
|
2176
|
+
_evm_contract_deployment_address_check(
|
|
2177
|
+
_evm_contract_deployment_address) {
|
|
2178
|
+
let
|
|
2179
|
+
_import,
|
|
2180
|
+
_msg;
|
|
2181
|
+
_import =
|
|
2182
|
+
false;
|
|
2183
|
+
const
|
|
2184
|
+
_evm_contract_deployment_address_type =
|
|
2185
|
+
typeof(
|
|
2186
|
+
_evm_contract_deployment_address);
|
|
2187
|
+
if ( _evm_contract_deployment_address_type === "undefined" ) {
|
|
2188
|
+
_msg =
|
|
2189
|
+
"Function '_evm_contract_deployment_address' " +
|
|
2190
|
+
"undefined, importing.";
|
|
2191
|
+
_import =
|
|
2192
|
+
true;
|
|
2193
|
+
}
|
|
2194
|
+
else if ( _evm_contract_deployment_address_type === "string" ) {
|
|
2195
|
+
if ( _evm_contract_deployment_address.length < 1 ) {
|
|
2196
|
+
_msg =
|
|
2197
|
+
"Function '_evm_contract_deployment_address' " +
|
|
2198
|
+
"undefined, importing.";
|
|
2199
|
+
_import =
|
|
2200
|
+
true;
|
|
2201
|
+
}
|
|
2202
|
+
else {
|
|
2203
|
+
_msg =
|
|
2204
|
+
"Function '_evm_contract_deployment_address' " +
|
|
2205
|
+
"is a string.";
|
|
2206
|
+
_msg_error(
|
|
2207
|
+
_msg,
|
|
2208
|
+
0);
|
|
2209
|
+
throw _msg;
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
if ( _import ) {
|
|
2213
|
+
try {
|
|
2214
|
+
const
|
|
2215
|
+
_libevm_contract_deployment_address_module =
|
|
2216
|
+
await import(
|
|
2217
|
+
"./libevm-contract-deployment-address");
|
|
2218
|
+
_evm_contract_deployment_address =
|
|
2219
|
+
_libevm_contract_deployment_address_module._evm_contract_deployment_address;
|
|
2220
|
+
}
|
|
2221
|
+
catch(
|
|
2222
|
+
_error) {
|
|
2223
|
+
_msg =
|
|
2224
|
+
"Error importing './libevm-contract-deployment-address'.";
|
|
2225
|
+
_msg_error(
|
|
2226
|
+
_msg,
|
|
2227
|
+
0);
|
|
2228
|
+
throw _msg;
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
return _evm_contract_deployment_address;
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
async function
|
|
2235
|
+
_evm_contract_deployment_bytecode_check(
|
|
2236
|
+
_evm_contract_deployment_bytecode) {
|
|
2237
|
+
let
|
|
2238
|
+
_import,
|
|
2239
|
+
_msg;
|
|
2240
|
+
_import =
|
|
2241
|
+
false;
|
|
2242
|
+
const
|
|
2243
|
+
_evm_contract_deployment_bytecode_type =
|
|
2244
|
+
typeof(
|
|
2245
|
+
_evm_contract_deployment_bytecode);
|
|
2246
|
+
if ( _evm_contract_deployment_bytecode_type === "undefined" ) {
|
|
2247
|
+
_msg =
|
|
2248
|
+
"Function '_evm_contract_deployment_bytecode' " +
|
|
2249
|
+
"undefined, importing.";
|
|
2250
|
+
_import =
|
|
2251
|
+
true;
|
|
2252
|
+
}
|
|
2253
|
+
else if ( _evm_contract_deployment_bytecode_type === "string" ) {
|
|
2254
|
+
if ( _evm_contract_deployment_bytecode.length < 1 ) {
|
|
2255
|
+
_msg =
|
|
2256
|
+
"Function '_evm_contract_deployment_bytecode' " +
|
|
2257
|
+
"is an empty string, importing.";
|
|
2258
|
+
_import =
|
|
2259
|
+
true;
|
|
2260
|
+
}
|
|
2261
|
+
else {
|
|
2262
|
+
_msg =
|
|
2263
|
+
"Function '_evm_contract_deployment_bytecode' " +
|
|
2264
|
+
"is a string.";
|
|
2265
|
+
_msg_error(
|
|
2266
|
+
_msg,
|
|
2267
|
+
0);
|
|
2268
|
+
throw _msg;
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
if ( _import ) {
|
|
2272
|
+
try {
|
|
2273
|
+
const
|
|
2274
|
+
_libevm_contract_deployment_bytecode_module =
|
|
2275
|
+
await import(
|
|
2276
|
+
"./libevm-contract-deployment-bytecode");
|
|
2277
|
+
_evm_contract_deployment_bytecode =
|
|
2278
|
+
_libevm_contract_deployment_bytecode_module._evm_contract_deployment_bytecode;
|
|
2279
|
+
}
|
|
2280
|
+
catch(
|
|
2281
|
+
_error) {
|
|
2282
|
+
_msg =
|
|
2283
|
+
"Error importing './libevm-contract-deployment-bytecode'.";
|
|
2284
|
+
_msg_error(
|
|
2285
|
+
_msg,
|
|
2286
|
+
0);
|
|
2287
|
+
throw _msg;
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
return _evm_contract_deployment_bytecode;
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
async function
|
|
2294
|
+
_evm_contract_deployment_compiler_output_check(
|
|
2295
|
+
_evm_contract_deployment_compiler_output) {
|
|
2296
|
+
let
|
|
2297
|
+
_import,
|
|
2298
|
+
_msg;
|
|
2299
|
+
_import =
|
|
2300
|
+
false;
|
|
2301
|
+
const
|
|
2302
|
+
_evm_contract_deployment_compiler_output_type =
|
|
2303
|
+
typeof(
|
|
2304
|
+
_evm_contract_deployment_compiler_output);
|
|
2305
|
+
if ( _evm_contract_deployment_compiler_output_type === "undefined" ) {
|
|
2306
|
+
_msg =
|
|
2307
|
+
"Function '_evm_contract_deployment_compiler_output' " +
|
|
2308
|
+
"undefined, importing.";
|
|
2309
|
+
_import =
|
|
2310
|
+
true;
|
|
2311
|
+
}
|
|
2312
|
+
else if ( _evm_contract_deployment_compiler_output_type === "string" ) {
|
|
2313
|
+
if ( _evm_contract_deployment_compiler_output.length < 1 ) {
|
|
2314
|
+
_msg =
|
|
2315
|
+
"Function '_evm_contract_deployment_compiler_output' " +
|
|
2316
|
+
"is an empty string, importing.";
|
|
2317
|
+
_import =
|
|
2318
|
+
true;
|
|
2319
|
+
}
|
|
2320
|
+
else {
|
|
2321
|
+
_msg =
|
|
2322
|
+
"Function '_evm_contract_deployment_compiler_output' " +
|
|
2323
|
+
"is a string.";
|
|
2324
|
+
_msg_error(
|
|
2325
|
+
_msg,
|
|
2326
|
+
0);
|
|
2327
|
+
throw _msg;
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
if ( _import ) {
|
|
2331
|
+
try {
|
|
2332
|
+
const
|
|
2333
|
+
_libevm_contract_deployment_compiler_output_module =
|
|
2334
|
+
await import(
|
|
2335
|
+
"./libevm-contract-deployment-compiler-output");
|
|
2336
|
+
_evm_contract_deployment_compiler_output =
|
|
2337
|
+
_libevm_contract_deployment_compiler_output_module._evm_contract_deployment_compiler_output;
|
|
2338
|
+
}
|
|
2339
|
+
catch(
|
|
2340
|
+
_error) {
|
|
2341
|
+
_msg =
|
|
2342
|
+
"Error importing './libevm-contract-deployment-compiler-output'.";
|
|
2343
|
+
_msg_error(
|
|
2344
|
+
_msg,
|
|
2345
|
+
0);
|
|
2346
|
+
throw _msg;
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
return _evm_contract_deployment_compiler_output;
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
async function
|
|
2353
|
+
_evm_contract_deployment_networks_check(
|
|
2354
|
+
_evm_contract_deployment_networks) {
|
|
2355
|
+
let
|
|
2356
|
+
_import,
|
|
2357
|
+
_msg;
|
|
2358
|
+
_import =
|
|
2359
|
+
false;
|
|
2360
|
+
const
|
|
2361
|
+
_evm_contract_deployment_networks_type =
|
|
2362
|
+
typeof(
|
|
2363
|
+
_evm_contract_deployment_networks);
|
|
2364
|
+
if ( _evm_contract_deployment_networks_type === "undefined" ) {
|
|
2365
|
+
_msg =
|
|
2366
|
+
"Function '_evm_contract_deployment_networks' " +
|
|
2367
|
+
"undefined, importing.";
|
|
2368
|
+
_import =
|
|
2369
|
+
true;
|
|
2370
|
+
}
|
|
2371
|
+
else if ( _evm_contract_deployment_networks_type === "string" ) {
|
|
2372
|
+
if ( _evm_contract_deployment_networks.length < 1 ) {
|
|
2373
|
+
_msg =
|
|
2374
|
+
"Function '_evm_contract_deployment_networks' " +
|
|
2375
|
+
"undefined, importing.";
|
|
2376
|
+
_import =
|
|
2377
|
+
true;
|
|
2378
|
+
}
|
|
2379
|
+
else {
|
|
2380
|
+
_msg =
|
|
2381
|
+
"Function '_evm_contract_deployment_networks' " +
|
|
2382
|
+
"is a string.";
|
|
2383
|
+
_msg_error(
|
|
2384
|
+
_msg,
|
|
2385
|
+
0);
|
|
2386
|
+
throw _msg;
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
if ( _import ) {
|
|
2390
|
+
try {
|
|
2391
|
+
const
|
|
2392
|
+
_libevm_contract_deployment_networks_module =
|
|
2393
|
+
await import(
|
|
2394
|
+
"./libevm-contract-deployment-networks");
|
|
2395
|
+
_evm_contract_deployment_networks =
|
|
2396
|
+
_libevm_contract_deployment_networks_module._evm_contract_deployment_networks;
|
|
2397
|
+
}
|
|
2398
|
+
catch(
|
|
2399
|
+
_error) {
|
|
2400
|
+
_msg =
|
|
2401
|
+
"Error importing './libevm-contract-deployment-networks'.";
|
|
2402
|
+
_msg_error(
|
|
2403
|
+
_msg,
|
|
2404
|
+
0);
|
|
2405
|
+
throw _msg;
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
return _evm_contract_deployment_networks;
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
async function
|
|
2412
|
+
_evm_contract_deployment_versions_check(
|
|
2413
|
+
_evm_contract_deployment_versions) {
|
|
2414
|
+
let
|
|
2415
|
+
_import,
|
|
2416
|
+
_msg;
|
|
2417
|
+
_import =
|
|
2418
|
+
false;
|
|
2419
|
+
const
|
|
2420
|
+
_evm_contract_deployment_versions_type =
|
|
2421
|
+
typeof(
|
|
2422
|
+
_evm_contract_deployment_versions);
|
|
2423
|
+
if ( _evm_contract_deployment_versions_type === "undefined" ) {
|
|
2424
|
+
_msg =
|
|
2425
|
+
"Function '_evm_contract_deployment_versions' " +
|
|
2426
|
+
"undefined, importing.";
|
|
2427
|
+
_import =
|
|
2428
|
+
true;
|
|
2429
|
+
}
|
|
2430
|
+
else if ( _evm_contract_deployment_versions_type === "string" ) {
|
|
2431
|
+
if ( _evm_contract_deployment_versions.length < 1 ) {
|
|
2432
|
+
_msg =
|
|
2433
|
+
"Function '_evm_contract_deployment_versions' " +
|
|
2434
|
+
"undefined, importing.";
|
|
2435
|
+
_import =
|
|
2436
|
+
true;
|
|
2437
|
+
}
|
|
2438
|
+
else {
|
|
2439
|
+
_msg =
|
|
2440
|
+
"Function '_evm_contract_deployment_versions' " +
|
|
2441
|
+
"is a string.";
|
|
2442
|
+
_msg_error(
|
|
2443
|
+
_msg,
|
|
2444
|
+
0);
|
|
2445
|
+
throw _msg;
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
if ( _import ) {
|
|
2449
|
+
try {
|
|
2450
|
+
const
|
|
2451
|
+
_libevm_contract_deployment_versions_module =
|
|
2452
|
+
await import(
|
|
2453
|
+
"./libevm-contract-deployment-versions");
|
|
2454
|
+
_evm_contract_deployment_versions =
|
|
2455
|
+
_libevm_contract_deployment_versions_module._evm_contract_deployment_versions;
|
|
2456
|
+
}
|
|
2457
|
+
catch(
|
|
2458
|
+
_error) {
|
|
2459
|
+
_msg =
|
|
2460
|
+
"Error importing './libevm-contract-deployment-versions'.";
|
|
2461
|
+
_msg_error(
|
|
2462
|
+
_msg,
|
|
2463
|
+
0);
|
|
2464
|
+
throw _msg;
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
return _evm_contract_deployment_versions;
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
async function
|
|
2471
|
+
_evm_contract_deployments_dir_check(
|
|
2472
|
+
_evm_contract_deployments_dir) {
|
|
2473
|
+
let
|
|
2474
|
+
_import,
|
|
2475
|
+
_msg;
|
|
2476
|
+
_import =
|
|
2477
|
+
false;
|
|
2478
|
+
const
|
|
2479
|
+
_evm_contract_deployments_dir_type =
|
|
2480
|
+
typeof(
|
|
2481
|
+
_evm_contract_deployments_dir);
|
|
2482
|
+
if ( _evm_contract_deployments_dir_type === "undefined" ) {
|
|
2483
|
+
_msg =
|
|
2484
|
+
"Function '_evm_contract_deployments_dir' " +
|
|
2485
|
+
"undefined, importing.";
|
|
2486
|
+
_import =
|
|
2487
|
+
true;
|
|
2488
|
+
}
|
|
2489
|
+
else if ( _evm_contract_deployments_dir_type === "string" ) {
|
|
2490
|
+
if ( _evm_contract_deployments_dir.length < 1 ) {
|
|
2491
|
+
_msg =
|
|
2492
|
+
"Function '_evm_contract_deployments_dir' " +
|
|
2493
|
+
"undefined, importing.";
|
|
2494
|
+
_import =
|
|
2495
|
+
true;
|
|
2496
|
+
}
|
|
2497
|
+
else {
|
|
2498
|
+
_msg =
|
|
2499
|
+
"Function '_evm_contract_deployments_dir' " +
|
|
2500
|
+
"is a string.";
|
|
2501
|
+
_msg_error(
|
|
2502
|
+
_msg,
|
|
2503
|
+
0);
|
|
2504
|
+
throw _msg;
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
if ( _import ) {
|
|
2508
|
+
try {
|
|
2509
|
+
const
|
|
2510
|
+
_libevm_contract_deployments_dir_module =
|
|
2511
|
+
await import(
|
|
2512
|
+
"./libevm-contract-deployments-dir");
|
|
2513
|
+
_evm_contract_deployments_dir =
|
|
2514
|
+
_libevm_contract_deployments_dir_module._evm_contract_deployments_dir;
|
|
2515
|
+
}
|
|
2516
|
+
catch(
|
|
2517
|
+
_error) {
|
|
2518
|
+
_msg =
|
|
2519
|
+
"Error importing './libevm-contract-deployments-dir'.";
|
|
2520
|
+
_msg_error(
|
|
2521
|
+
_msg,
|
|
2522
|
+
0);
|
|
2523
|
+
throw _msg;
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
return _evm_contract_deployments_dir;
|
|
2527
|
+
}
|
|
2528
|
+
|
|
2529
|
+
async function
|
|
2530
|
+
_target_app_auto_detect() {
|
|
2531
|
+
let
|
|
2532
|
+
_address_missing,
|
|
2533
|
+
_app,
|
|
2534
|
+
_evm_contract_deployments_dir;
|
|
2535
|
+
const
|
|
2536
|
+
_contract_address =
|
|
2537
|
+
_get(
|
|
2538
|
+
"contract",
|
|
2539
|
+
"address");
|
|
2540
|
+
const
|
|
2541
|
+
_contract_address_type =
|
|
2542
|
+
typeof(
|
|
2543
|
+
_contract_address);
|
|
2544
|
+
if ( _contract_address_type === "undefined" ) {
|
|
2545
|
+
_msg =
|
|
2546
|
+
"Contract address undefined, skipping ",
|
|
2547
|
+
"application auto-detection.";
|
|
2548
|
+
_msg_info(
|
|
2549
|
+
_msg);
|
|
2550
|
+
_address_missing =
|
|
2551
|
+
true;
|
|
2552
|
+
}
|
|
2553
|
+
else if ( _contract_address_type === "string" ) {
|
|
2554
|
+
if ( _contract_address.length < 1 ) {
|
|
2555
|
+
_msg =
|
|
2556
|
+
"Contract address undefined, skipping ",
|
|
2557
|
+
"application auto-detection.";
|
|
2558
|
+
_msg_info(
|
|
2559
|
+
_msg);
|
|
2560
|
+
_address_missing =
|
|
2561
|
+
true;
|
|
2562
|
+
}
|
|
2563
|
+
else {
|
|
2564
|
+
_msg =
|
|
2565
|
+
"Contract address correctly detected, auto-detecting " +
|
|
2566
|
+
"application.";
|
|
2567
|
+
_msg_info(
|
|
2568
|
+
_msg);
|
|
2569
|
+
_address_missing =
|
|
2570
|
+
false;
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
else {
|
|
2574
|
+
_msg =
|
|
2575
|
+
`Unknown type '${_contract_address_type}' ` +
|
|
2576
|
+
`for global variable 'contract_address':`;
|
|
2577
|
+
_msg_info(
|
|
2578
|
+
_msg);
|
|
2579
|
+
_echo2(
|
|
2580
|
+
_contract_address);
|
|
2581
|
+
throw _msg;
|
|
2582
|
+
}
|
|
2583
|
+
_app =
|
|
2584
|
+
"";
|
|
2585
|
+
if ( ! _address_missing ) {
|
|
2586
|
+
const
|
|
2587
|
+
_dir_current_name =
|
|
2588
|
+
_basename(
|
|
2589
|
+
_pwd());
|
|
2590
|
+
const
|
|
2591
|
+
_user_defined =
|
|
2592
|
+
_get(
|
|
2593
|
+
"user",
|
|
2594
|
+
"defined");
|
|
2595
|
+
_user_defined =
|
|
2596
|
+
_user_defined_check(
|
|
2597
|
+
_user_defined);
|
|
2598
|
+
_evm_contract_deployments_dir =
|
|
2599
|
+
_get(
|
|
2600
|
+
"_evm_contract",
|
|
2601
|
+
"deployments_dir");
|
|
2602
|
+
try {
|
|
2603
|
+
_evm_contract_deployments_dir =
|
|
2604
|
+
await _evm_contract_deployments_dir_check(
|
|
2605
|
+
_evm_contract_deployments_dir);
|
|
2606
|
+
}
|
|
2607
|
+
catch(
|
|
2608
|
+
_error) {
|
|
2609
|
+
_msg =
|
|
2610
|
+
"Error getting '_evm_contract_deployments_dir' " +
|
|
2611
|
+
"function.";
|
|
2612
|
+
_msg_error(
|
|
2613
|
+
_msg,
|
|
2614
|
+
0);
|
|
2615
|
+
_echo2(
|
|
2616
|
+
_error);
|
|
2617
|
+
throw _error;
|
|
2618
|
+
}
|
|
2619
|
+
const
|
|
2620
|
+
_evm_contract_deployments_dir_args = [
|
|
2621
|
+
_dir_current_name,
|
|
2622
|
+
_user_defined
|
|
2623
|
+
];
|
|
2624
|
+
try {
|
|
2625
|
+
const
|
|
2626
|
+
_target_dir =
|
|
2627
|
+
await _evm_contract_deployments_dir.apply(
|
|
2628
|
+
null,
|
|
2629
|
+
_evm_contract_deployments_dir_args);
|
|
2630
|
+
}
|
|
2631
|
+
catch(
|
|
2632
|
+
_error) {
|
|
2633
|
+
_msg =
|
|
2634
|
+
"Error running '_evm_contract_deployments_dir' " +
|
|
2635
|
+
"with arguments:";
|
|
2636
|
+
_echo2(
|
|
2637
|
+
_evm_contract_deployments_dir_args);
|
|
2638
|
+
_echo2(
|
|
2639
|
+
_error);
|
|
2640
|
+
throw _error;
|
|
2641
|
+
}
|
|
2642
|
+
if ( _dir_exists(
|
|
2643
|
+
_target_dir) ) {
|
|
2644
|
+
_msg =
|
|
2645
|
+
"Found existing directory " +
|
|
2646
|
+
`'${_target_dir}', setting ` +
|
|
2647
|
+
`'${_dir_current_name}' as application name.`;
|
|
2648
|
+
_msg_info(
|
|
2649
|
+
_msg);
|
|
2650
|
+
_app =
|
|
2651
|
+
_dir_current_name;
|
|
2652
|
+
}
|
|
2653
|
+
else {
|
|
2654
|
+
_msg =
|
|
2655
|
+
`Directory '${_target_dir}' ` +
|
|
2656
|
+
"not found, impossible auto-detecting " +
|
|
2657
|
+
"application name for given contract.";
|
|
2658
|
+
_msg_info(
|
|
2659
|
+
_msg);
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
_override_set(
|
|
2663
|
+
"target",
|
|
2664
|
+
"app",
|
|
2665
|
+
_app);
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2668
|
+
async function
|
|
2669
|
+
_config_file_path_check(
|
|
2670
|
+
_config_file_path,
|
|
2671
|
+
_app,
|
|
2672
|
+
_deployments_dir,
|
|
2673
|
+
_contract,
|
|
2674
|
+
_network,
|
|
2675
|
+
_network_id,
|
|
2676
|
+
_configuration_format,
|
|
2677
|
+
_user_defined) {
|
|
2678
|
+
let
|
|
2679
|
+
_config_file_ext,
|
|
2680
|
+
_config_file_path_get,
|
|
2681
|
+
_found,
|
|
2682
|
+
_msg,
|
|
2683
|
+
_net;
|
|
2684
|
+
const
|
|
2685
|
+
_config_file_path_type =
|
|
2686
|
+
typeof(
|
|
2687
|
+
_config_file_path);
|
|
2688
|
+
_config_file_path_get =
|
|
2689
|
+
false;
|
|
2690
|
+
if ( _config_file_path_type == "undefined" ) {
|
|
2691
|
+
_msg =
|
|
2692
|
+
"Configuration file path undefined, " +
|
|
2693
|
+
"auto-detecting.";
|
|
2694
|
+
_msg_info(
|
|
2695
|
+
_msg);
|
|
2696
|
+
_config_file_path_get =
|
|
2697
|
+
true;
|
|
2698
|
+
}
|
|
2699
|
+
else if ( _config_file_path_type == "string" ) {
|
|
2700
|
+
if ( _config_file_path.length < 1 ) {
|
|
2701
|
+
_msg =
|
|
2702
|
+
"Configuration file path not set, " +
|
|
2703
|
+
"auto-detecting.";
|
|
2704
|
+
_msg_info(
|
|
2705
|
+
_msg);
|
|
2706
|
+
_config_file_path_get =
|
|
2707
|
+
true;
|
|
2708
|
+
}
|
|
2709
|
+
else {
|
|
2710
|
+
if ( ! _file_exists(
|
|
2711
|
+
_config_file_path) ) {
|
|
2712
|
+
_msg =
|
|
2713
|
+
`File at location '${_config_file_path}' ` +
|
|
2714
|
+
`does not exist.`;
|
|
2715
|
+
_msg_error(
|
|
2716
|
+
_msg,
|
|
2717
|
+
0);
|
|
2718
|
+
throw _msg;
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
else {
|
|
2723
|
+
_msg =
|
|
2724
|
+
`Unknown type '${_config_file_path_type}' ` +
|
|
2725
|
+
`for '_config_file_path' variable (correct ` +
|
|
2726
|
+
`type: string).`;
|
|
2727
|
+
_msg_error(
|
|
2728
|
+
_msg,
|
|
2729
|
+
0);
|
|
2730
|
+
}
|
|
2731
|
+
const
|
|
2732
|
+
_global =
|
|
2733
|
+
_global_get();
|
|
2734
|
+
const
|
|
2735
|
+
_quiet =
|
|
2736
|
+
_global[
|
|
2737
|
+
"quiet"];
|
|
2738
|
+
if ( _config_file_path_get ) {
|
|
2739
|
+
const
|
|
2740
|
+
_contract_type =
|
|
2741
|
+
typeof(
|
|
2742
|
+
_contract);
|
|
2743
|
+
if ( _contract_type === "undefined" ) {
|
|
2744
|
+
_msg =
|
|
2745
|
+
"A contract name must be specified a contract name."
|
|
2746
|
+
}
|
|
2747
|
+
_user_defined =
|
|
2748
|
+
await _user_defined_check(
|
|
2749
|
+
_user_defined);
|
|
2750
|
+
_configuration_format =
|
|
2751
|
+
_configuration_format_check(
|
|
2752
|
+
_configuration_format);
|
|
2753
|
+
if ( _configuration_format == "bash" ) {
|
|
2754
|
+
_config_file_ext =
|
|
2755
|
+
"sh";
|
|
2756
|
+
}
|
|
2757
|
+
else if ( _configuration_format == "json" ) {
|
|
2758
|
+
_config_file_ext =
|
|
2759
|
+
"json";
|
|
2760
|
+
}
|
|
2761
|
+
else {
|
|
2762
|
+
_msg =
|
|
2763
|
+
"Unknown configuration format " +
|
|
2764
|
+
`${_configuration_format}'.`;
|
|
2765
|
+
_msg_error(
|
|
2766
|
+
_msg,
|
|
2767
|
+
0);
|
|
2768
|
+
throw _msg;
|
|
2769
|
+
}
|
|
2770
|
+
const
|
|
2771
|
+
_deployments_dir_check_args = [
|
|
2772
|
+
_deployments_dir,
|
|
2773
|
+
_app,
|
|
2774
|
+
_user_defined
|
|
2775
|
+
];
|
|
2776
|
+
try {
|
|
2777
|
+
_deployments_dir =
|
|
2778
|
+
await _deployments_dir_check.apply(
|
|
2779
|
+
null,
|
|
2780
|
+
_deployments_dir_check_args);
|
|
2781
|
+
}
|
|
2782
|
+
catch(
|
|
2783
|
+
_error) {
|
|
2784
|
+
_msg =
|
|
2785
|
+
"Error checking '_deployments_dir' " +
|
|
2786
|
+
"variable."
|
|
2787
|
+
_msg_error(
|
|
2788
|
+
_msg,
|
|
2789
|
+
0);
|
|
2790
|
+
_echo2(
|
|
2791
|
+
_error);
|
|
2792
|
+
throw _error;
|
|
2793
|
+
}
|
|
2794
|
+
const
|
|
2795
|
+
_networks = [
|
|
2796
|
+
_network,
|
|
2797
|
+
_network_id
|
|
2798
|
+
];
|
|
2799
|
+
_found =
|
|
2800
|
+
false;
|
|
2801
|
+
for ( _net of _networks ) {
|
|
2802
|
+
_config_file_path =
|
|
2803
|
+
_path_join( [
|
|
2804
|
+
_deployments_dir,
|
|
2805
|
+
_contract,
|
|
2806
|
+
_net,
|
|
2807
|
+
`config.${_config_file_ext}` ]);
|
|
2808
|
+
if ( _file_exists(
|
|
2809
|
+
_config_file_path) ) {
|
|
2810
|
+
_found =
|
|
2811
|
+
true;
|
|
2812
|
+
break;
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
return _config_file_path;
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
function
|
|
2820
|
+
_configuration_format_get(
|
|
2821
|
+
_config_file) {
|
|
2822
|
+
let
|
|
2823
|
+
_configuration_format,
|
|
2824
|
+
_msg;
|
|
2825
|
+
_msg =
|
|
2826
|
+
"Getting configuration format " +
|
|
2827
|
+
`for configuration file '${_config_file}'.`;
|
|
2828
|
+
_msg_info(
|
|
2829
|
+
_msg);
|
|
2830
|
+
if ( _config_file.endsWith(
|
|
2831
|
+
".sh") ) {
|
|
2832
|
+
_configuration_format =
|
|
2833
|
+
"bash";
|
|
2834
|
+
}
|
|
2835
|
+
else if ( _config_file.endsWith(
|
|
2836
|
+
".json") ) {
|
|
2837
|
+
_configuration_format =
|
|
2838
|
+
"json";
|
|
2839
|
+
}
|
|
2840
|
+
else {
|
|
2841
|
+
_msg =
|
|
2842
|
+
"Impossible determining " +
|
|
2843
|
+
"configuration format from file " +
|
|
2844
|
+
"extension, defaulting to 'json'.";
|
|
2845
|
+
_msg_error(
|
|
2846
|
+
_msg,
|
|
2847
|
+
0);
|
|
2848
|
+
throw _msg;
|
|
2849
|
+
}
|
|
2850
|
+
return _configuration_format;
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
async function
|
|
2854
|
+
_configuration_format_auto_detect() {
|
|
2855
|
+
let
|
|
2856
|
+
_config_file_path,
|
|
2857
|
+
_configuration_format,
|
|
2858
|
+
_msg;
|
|
2859
|
+
_configuration_format =
|
|
2860
|
+
_get(
|
|
2861
|
+
"configuration",
|
|
2862
|
+
"format");
|
|
2863
|
+
_config_file_path =
|
|
2864
|
+
_get(
|
|
2865
|
+
"config",
|
|
2866
|
+
"file");
|
|
2867
|
+
const
|
|
2868
|
+
_app =
|
|
2869
|
+
_get(
|
|
2870
|
+
"target",
|
|
2871
|
+
"app");
|
|
2872
|
+
const
|
|
2873
|
+
_deployments_dir =
|
|
2874
|
+
_get(
|
|
2875
|
+
"deployments",
|
|
2876
|
+
"dir");
|
|
2877
|
+
const
|
|
2878
|
+
_target_contract =
|
|
2879
|
+
_get(
|
|
2880
|
+
"target",
|
|
2881
|
+
"contract");
|
|
2882
|
+
const
|
|
2883
|
+
_target_network =
|
|
2884
|
+
_get(
|
|
2885
|
+
"target",
|
|
2886
|
+
"network");
|
|
2887
|
+
const
|
|
2888
|
+
_user_defined =
|
|
2889
|
+
_get(
|
|
2890
|
+
"user",
|
|
2891
|
+
"defined");
|
|
2892
|
+
const
|
|
2893
|
+
_config_file_path_check_args = [
|
|
2894
|
+
_config_file_path,
|
|
2895
|
+
_app,
|
|
2896
|
+
_deployments_dir,
|
|
2897
|
+
_contract,
|
|
2898
|
+
_target_network,
|
|
2899
|
+
_target_network,
|
|
2900
|
+
_configuration_format,
|
|
2901
|
+
_user_defined
|
|
2902
|
+
];
|
|
2903
|
+
try {
|
|
2904
|
+
_config_file_path =
|
|
2905
|
+
await _config_file_path_check.apply(
|
|
2906
|
+
null,
|
|
2907
|
+
_config_file_path_check_args);
|
|
2908
|
+
}
|
|
2909
|
+
catch(
|
|
2910
|
+
_error) {
|
|
2911
|
+
_msg =
|
|
2912
|
+
"Error checking 'config_file' variable.";
|
|
2913
|
+
_msg_error(
|
|
2914
|
+
_msg,
|
|
2915
|
+
0);
|
|
2916
|
+
echo2(
|
|
2917
|
+
_error);
|
|
2918
|
+
throw _error;
|
|
2919
|
+
}
|
|
2920
|
+
_configuration_format =
|
|
2921
|
+
_configuration_format_get(
|
|
2922
|
+
_config_file);
|
|
2923
|
+
_override_set(
|
|
2924
|
+
"configuration",
|
|
2925
|
+
"format",
|
|
2926
|
+
_configuration_format);
|
|
2927
|
+
}
|
|
2928
|
+
|
|
2929
|
+
async function
|
|
2930
|
+
_version_check(
|
|
2931
|
+
_version,
|
|
2932
|
+
_app,
|
|
2933
|
+
_contract,
|
|
2934
|
+
_address,
|
|
2935
|
+
_network,
|
|
2936
|
+
_user_defined,
|
|
2937
|
+
_deployments_dir,
|
|
2938
|
+
_config_file,
|
|
2939
|
+
_configuration_format) {
|
|
2940
|
+
let
|
|
2941
|
+
_evm_contract_deployment_versions,
|
|
2942
|
+
_msg,
|
|
2943
|
+
_version_get;
|
|
2944
|
+
_configuration_format =
|
|
2945
|
+
_configuration_format_check(
|
|
2946
|
+
_configuration_format);
|
|
2947
|
+
const
|
|
2948
|
+
_version_type =
|
|
2949
|
+
typeof(
|
|
2950
|
+
_version);
|
|
2951
|
+
_version_get =
|
|
2952
|
+
false;
|
|
2953
|
+
if ( _version_type === "undefined" ) {
|
|
2954
|
+
_msg =
|
|
2955
|
+
"Variable 'version' undefined, " +
|
|
2956
|
+
"auto-detecting.";
|
|
2957
|
+
_version_get =
|
|
2958
|
+
true;
|
|
2959
|
+
}
|
|
2960
|
+
if ( _version_type === "string" ) {
|
|
2961
|
+
if ( _version.length < 1 ) {
|
|
2962
|
+
_msg =
|
|
2963
|
+
"Variable 'version' not specified, " +
|
|
2964
|
+
"auto-detecting.";
|
|
2965
|
+
_version_get =
|
|
2966
|
+
true;
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
if ( _version_get ) {
|
|
2970
|
+
_app =
|
|
2971
|
+
_app_check(
|
|
2972
|
+
_app,
|
|
2973
|
+
false);
|
|
2974
|
+
_user_defined =
|
|
2975
|
+
_user_defined_check(
|
|
2976
|
+
_user_defined);
|
|
2977
|
+
const
|
|
2978
|
+
_deployments_dir_check_args = [
|
|
2979
|
+
_deployments_dir,
|
|
2980
|
+
_app,
|
|
2981
|
+
_user_defined
|
|
2982
|
+
];
|
|
2983
|
+
try {
|
|
2984
|
+
_deployments_dir =
|
|
2985
|
+
await _deployments_dir_check.apply(
|
|
2986
|
+
null,
|
|
2987
|
+
_deployments_dir_check_args);
|
|
2988
|
+
_msg_info(
|
|
2989
|
+
`Got '${_deployments_dir}'`);
|
|
2990
|
+
}
|
|
2991
|
+
catch(
|
|
2992
|
+
_error) {
|
|
2993
|
+
_msg =
|
|
2994
|
+
"Error checking variable " +
|
|
2995
|
+
"'_deployments_dir'.";
|
|
2996
|
+
_msg_error(
|
|
2997
|
+
_msg,
|
|
2998
|
+
0);
|
|
2999
|
+
throw _error;
|
|
3000
|
+
}
|
|
3001
|
+
_evm_contract_deployment_versions =
|
|
444
3002
|
_get(
|
|
445
|
-
"
|
|
446
|
-
"
|
|
3003
|
+
"_evm_contract_deployment",
|
|
3004
|
+
"versions");
|
|
3005
|
+
try {
|
|
3006
|
+
_evm_contract_deployment_versions =
|
|
3007
|
+
await _evm_contract_deployment_versions_check(
|
|
3008
|
+
_evm_contract_deployment_versions);
|
|
3009
|
+
}
|
|
3010
|
+
catch(
|
|
3011
|
+
_error) {
|
|
3012
|
+
_msg =
|
|
3013
|
+
"Error importing '_evm-contract-deployment-versions'.";
|
|
3014
|
+
_msg_error(
|
|
3015
|
+
_msg,
|
|
3016
|
+
0);
|
|
3017
|
+
throw _error;
|
|
3018
|
+
}
|
|
3019
|
+
const
|
|
3020
|
+
_target_contract_check_args = [
|
|
3021
|
+
_contract,
|
|
3022
|
+
_address,
|
|
3023
|
+
_app,
|
|
3024
|
+
_deployments_dir
|
|
3025
|
+
];
|
|
3026
|
+
try {
|
|
3027
|
+
_contract =
|
|
3028
|
+
await _target_contract_check.apply(
|
|
3029
|
+
null,
|
|
3030
|
+
_target_contract_check_args);
|
|
3031
|
+
}
|
|
3032
|
+
catch(
|
|
3033
|
+
_error) {
|
|
3034
|
+
_msg =
|
|
3035
|
+
"Error running '_target_contract_check' " +
|
|
3036
|
+
"with arguments:";
|
|
3037
|
+
_msg_error(
|
|
3038
|
+
_msg,
|
|
3039
|
+
0);
|
|
3040
|
+
_echo2(
|
|
3041
|
+
_target_contract_check_args);
|
|
3042
|
+
_echo2(
|
|
3043
|
+
_error);
|
|
3044
|
+
throw _error;
|
|
3045
|
+
}
|
|
3046
|
+
const
|
|
3047
|
+
_config_file_path_check_args = [
|
|
3048
|
+
_config_file,
|
|
3049
|
+
_app,
|
|
3050
|
+
_deployments_dir,
|
|
3051
|
+
_contract,
|
|
3052
|
+
_network,
|
|
3053
|
+
_network,
|
|
3054
|
+
_configuration_format,
|
|
3055
|
+
_user_defined
|
|
3056
|
+
];
|
|
3057
|
+
try {
|
|
3058
|
+
_config_file =
|
|
3059
|
+
await _config_file_path_check.apply(
|
|
3060
|
+
null,
|
|
3061
|
+
_config_file_path_check_args);
|
|
3062
|
+
}
|
|
3063
|
+
catch(
|
|
3064
|
+
_error) {
|
|
3065
|
+
_msg =
|
|
3066
|
+
"Error running '_config_file_path_check' " +
|
|
3067
|
+
"with arguments:";
|
|
3068
|
+
_msg_error(
|
|
3069
|
+
_msg,
|
|
3070
|
+
0);
|
|
3071
|
+
_echo2(
|
|
3072
|
+
_config_file_path_check_args);
|
|
3073
|
+
_echo2(
|
|
3074
|
+
_error);
|
|
3075
|
+
throw _error;
|
|
3076
|
+
}
|
|
447
3077
|
const
|
|
448
|
-
|
|
3078
|
+
_evm_contract_deployment_versions_args = [
|
|
3079
|
+
_config_file,
|
|
3080
|
+
"y", // display highest version
|
|
3081
|
+
"n", // display lowest version
|
|
3082
|
+
_configuration_format
|
|
3083
|
+
];
|
|
3084
|
+
try {
|
|
3085
|
+
_version =
|
|
3086
|
+
await _evm_contract_deployment_versions.apply(
|
|
3087
|
+
null,
|
|
3088
|
+
_evm_contract_deployment_versions_args);
|
|
3089
|
+
}
|
|
3090
|
+
catch(
|
|
3091
|
+
_error) {
|
|
3092
|
+
_msg =
|
|
3093
|
+
"Error auto-retrieving version.";
|
|
3094
|
+
_msg_error(
|
|
3095
|
+
_msg,
|
|
3096
|
+
0);
|
|
3097
|
+
throw _error;
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
return _version;
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3103
|
+
async function
|
|
3104
|
+
_target_networks_check(
|
|
3105
|
+
_target_networks,
|
|
3106
|
+
_local) {
|
|
3107
|
+
let
|
|
3108
|
+
_msg,
|
|
3109
|
+
_target_networks_get,
|
|
3110
|
+
_target_networks_type;
|
|
3111
|
+
_local =
|
|
3112
|
+
_local_check(
|
|
3113
|
+
_local);
|
|
3114
|
+
_target_networks_get =
|
|
3115
|
+
false;
|
|
3116
|
+
_target_networks_type =
|
|
3117
|
+
typeof(
|
|
3118
|
+
_target_networks);
|
|
3119
|
+
if ( _target_networks_type === "undefined" ) {
|
|
3120
|
+
_msg =
|
|
3121
|
+
"Variable '_target_networks' undefined, " +
|
|
3122
|
+
"auto-detecting.";
|
|
3123
|
+
_msg_info(
|
|
3124
|
+
_msg);
|
|
3125
|
+
_target_networks_get =
|
|
3126
|
+
true;
|
|
3127
|
+
}
|
|
3128
|
+
else if ( _target_networks_type === "string" ) {
|
|
3129
|
+
_msg =
|
|
3130
|
+
"Variable '_target_networks' must be of type " +
|
|
3131
|
+
"'array'.";
|
|
3132
|
+
_msg_error(
|
|
3133
|
+
_msg,
|
|
3134
|
+
0);
|
|
3135
|
+
throw _msg;
|
|
3136
|
+
}
|
|
3137
|
+
else if ( _target_networks_type === "array" ||
|
|
3138
|
+
_target_networks_type === "object" ) {
|
|
3139
|
+
if ( _target_networks.length < 1 ) {
|
|
3140
|
+
_msg =
|
|
3141
|
+
"Variable '_target_networks' not " +
|
|
3142
|
+
"specified, auto-detecting.";
|
|
3143
|
+
_msg_info(
|
|
3144
|
+
_msg);
|
|
3145
|
+
_target_networks_get =
|
|
3146
|
+
true;
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
else {
|
|
3150
|
+
_msg =
|
|
3151
|
+
"Variable '_target_networks' must be of type " +
|
|
3152
|
+
`'array' (current type: '${_target_networks_type}'):`;
|
|
3153
|
+
_msg_error(
|
|
3154
|
+
_msg,
|
|
3155
|
+
0);
|
|
3156
|
+
_echo2(
|
|
3157
|
+
_target_networks);
|
|
3158
|
+
throw _msg;
|
|
3159
|
+
}
|
|
3160
|
+
if ( _target_networks_get ) {
|
|
3161
|
+
if ( _local ) {
|
|
3162
|
+
true;
|
|
3163
|
+
// _networks_check
|
|
3164
|
+
}
|
|
3165
|
+
else {
|
|
3166
|
+
_target_networks =
|
|
3167
|
+
_get(
|
|
3168
|
+
"target",
|
|
3169
|
+
"networks");
|
|
3170
|
+
_target_networks_type =
|
|
449
3171
|
typeof(
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
3172
|
+
_target_networks);
|
|
3173
|
+
if ( _target_networks_type === "array" ||
|
|
3174
|
+
_target_networks_type === "object" ) {
|
|
3175
|
+
if ( _target_networks.length < 1 ) {
|
|
3176
|
+
_msg =
|
|
3177
|
+
"Global variable 'target_networks' " +
|
|
3178
|
+
"empty.";
|
|
3179
|
+
_msg_error(
|
|
3180
|
+
_msg,
|
|
3181
|
+
0);
|
|
3182
|
+
throw _msg;
|
|
3183
|
+
}
|
|
3184
|
+
else {
|
|
3185
|
+
_msg =
|
|
3186
|
+
"Variable '_target_networks'." +
|
|
3187
|
+
"set from public global variable " +
|
|
3188
|
+
"'target_networks'.";
|
|
3189
|
+
_msg_info(
|
|
3190
|
+
_msg);
|
|
3191
|
+
}
|
|
3192
|
+
}
|
|
3193
|
+
else if ( _target_networks_type === "undefined" ) {
|
|
3194
|
+
_msg =
|
|
3195
|
+
"Global variable 'target_networks' " +
|
|
3196
|
+
"undefined.";
|
|
3197
|
+
_msg_error(
|
|
3198
|
+
_msg,
|
|
3199
|
+
0);
|
|
3200
|
+
throw _msg;
|
|
3201
|
+
}
|
|
3202
|
+
else {
|
|
3203
|
+
_msg =
|
|
3204
|
+
`Unknown type '${_target_networks_type}' for` +
|
|
3205
|
+
"global variable 'target_networks':";
|
|
3206
|
+
_msg_error(
|
|
3207
|
+
_msg,
|
|
3208
|
+
0);
|
|
3209
|
+
_echo2(
|
|
3210
|
+
_target_networks);
|
|
3211
|
+
throw _msg;
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
return _target_networks;
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3218
|
+
async function
|
|
3219
|
+
_contract_address_check(
|
|
3220
|
+
_contract_address,
|
|
3221
|
+
_deployments_dir,
|
|
3222
|
+
_app,
|
|
3223
|
+
_user_defined,
|
|
3224
|
+
_networks) {
|
|
3225
|
+
let
|
|
3226
|
+
_address_valid,
|
|
3227
|
+
_contract,
|
|
3228
|
+
_contract_address_get,
|
|
3229
|
+
_evm_contract_deployment_address,
|
|
3230
|
+
_msg;
|
|
3231
|
+
_contract_address_get =
|
|
3232
|
+
false;
|
|
3233
|
+
_user_defined =
|
|
3234
|
+
_user_defined_check(
|
|
3235
|
+
_user_defined);
|
|
3236
|
+
const
|
|
3237
|
+
_contract_address_type =
|
|
3238
|
+
typeof(
|
|
3239
|
+
_contract_address);
|
|
3240
|
+
if ( _contract_address_type === "undefined" ) {
|
|
3241
|
+
_msg =
|
|
3242
|
+
"Contract address not set, " +
|
|
3243
|
+
"auto-detecting given input data.";
|
|
3244
|
+
_msg_info(
|
|
3245
|
+
_msg);
|
|
3246
|
+
_contract_address_get =
|
|
3247
|
+
true;
|
|
3248
|
+
}
|
|
3249
|
+
else if ( _contract_address_type === "string" ) {
|
|
3250
|
+
if ( _contract_address.length < 1 ) {
|
|
3251
|
+
_msg =
|
|
3252
|
+
"Contract address not set, " +
|
|
3253
|
+
"auto-detecting given input data.";
|
|
3254
|
+
_msg_info(
|
|
3255
|
+
_msg);
|
|
3256
|
+
_contract_address_get =
|
|
3257
|
+
true;
|
|
3258
|
+
}
|
|
3259
|
+
else {
|
|
3260
|
+
try {
|
|
3261
|
+
const
|
|
3262
|
+
_address_valid =
|
|
3263
|
+
await _address_check(
|
|
3264
|
+
_contract_address);
|
|
3265
|
+
}
|
|
3266
|
+
catch(
|
|
3267
|
+
_error) {
|
|
3268
|
+
_msg =
|
|
3269
|
+
"Error verifying validity of " +
|
|
3270
|
+
`address '${_contract_address}'.`;
|
|
3271
|
+
_msg_error(
|
|
3272
|
+
_msg,
|
|
3273
|
+
0);
|
|
3274
|
+
throw _msg;
|
|
3275
|
+
}
|
|
3276
|
+
if ( ! _address_valid ) {
|
|
3277
|
+
_msg =
|
|
3278
|
+
"Address not valid, getting " +
|
|
3279
|
+
"contract address.";
|
|
3280
|
+
_contract_address_get =
|
|
3281
|
+
true;
|
|
3282
|
+
_contract =
|
|
3283
|
+
_get(
|
|
3284
|
+
"target",
|
|
3285
|
+
"contract");
|
|
3286
|
+
const
|
|
3287
|
+
_target_contract_check_args = [
|
|
3288
|
+
_contract_address
|
|
3289
|
+
];
|
|
3290
|
+
try {
|
|
3291
|
+
_contract =
|
|
3292
|
+
await _target_contract_check.apply(
|
|
3293
|
+
null,
|
|
3294
|
+
_target_contract_check_args);
|
|
3295
|
+
_override_set(
|
|
3296
|
+
"target",
|
|
3297
|
+
"contract",
|
|
3298
|
+
_contract);
|
|
3299
|
+
}
|
|
3300
|
+
catch(
|
|
3301
|
+
_error) {
|
|
3302
|
+
_msg =
|
|
3303
|
+
"Error running '_target_contract_check' " +
|
|
3304
|
+
`with parameters:`;
|
|
3305
|
+
_msg_error(
|
|
3306
|
+
_msg,
|
|
3307
|
+
0);
|
|
3308
|
+
_echo2(
|
|
3309
|
+
_target_contract_check_args);
|
|
3310
|
+
_echo2(
|
|
3311
|
+
_error);
|
|
3312
|
+
throw _error;
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
else {
|
|
3316
|
+
_msg =
|
|
3317
|
+
`Address '${_contract_address}' ` +
|
|
3318
|
+
`valid.`;
|
|
3319
|
+
_msg_info(
|
|
3320
|
+
_msg);
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
else {
|
|
3325
|
+
_msg =
|
|
3326
|
+
"Invalid type for variable " +
|
|
3327
|
+
`'_contract_address' (${_contract_address_type}):`;
|
|
3328
|
+
_msg_error(
|
|
3329
|
+
_msg,
|
|
3330
|
+
0);
|
|
3331
|
+
_echo2(
|
|
3332
|
+
_contract_address);
|
|
3333
|
+
throw _msg;
|
|
3334
|
+
}
|
|
3335
|
+
if ( _contract_address_get ) {
|
|
3336
|
+
_app =
|
|
3337
|
+
_app_check(
|
|
3338
|
+
_app,
|
|
3339
|
+
false);
|
|
3340
|
+
const
|
|
3341
|
+
_deployments_dir_check_args = [
|
|
3342
|
+
_deployments_dir,
|
|
3343
|
+
_app,
|
|
3344
|
+
_user_defined
|
|
3345
|
+
];
|
|
3346
|
+
try {
|
|
3347
|
+
_deployments_dir =
|
|
3348
|
+
await _deployments_dir_check.apply(
|
|
3349
|
+
null,
|
|
3350
|
+
_deployments_dir_check_args);
|
|
3351
|
+
_msg_info(
|
|
3352
|
+
`Got '${_deployments_dir}'`);
|
|
3353
|
+
}
|
|
3354
|
+
catch(
|
|
3355
|
+
_error) {
|
|
3356
|
+
_msg =
|
|
3357
|
+
"Error checking variable " +
|
|
3358
|
+
"'_deployments_dir'.";
|
|
3359
|
+
_msg_error(
|
|
3360
|
+
_msg,
|
|
3361
|
+
0);
|
|
3362
|
+
throw _error;
|
|
3363
|
+
}
|
|
3364
|
+
const
|
|
3365
|
+
_target_networks_check_args = [
|
|
3366
|
+
_networks,
|
|
3367
|
+
false
|
|
3368
|
+
];
|
|
3369
|
+
try {
|
|
3370
|
+
_networks =
|
|
3371
|
+
await _target_networks_check.apply(
|
|
3372
|
+
null,
|
|
3373
|
+
_target_networks_check_args);
|
|
3374
|
+
}
|
|
3375
|
+
catch(
|
|
3376
|
+
_error) {
|
|
3377
|
+
_msg =
|
|
3378
|
+
"Error running '_target_networks_check' " +
|
|
3379
|
+
"with parameters:";
|
|
3380
|
+
_msg_error(
|
|
3381
|
+
_msg,
|
|
3382
|
+
0);
|
|
3383
|
+
_echo2(
|
|
3384
|
+
_target_networks_check_args);
|
|
3385
|
+
_echo2(
|
|
3386
|
+
_error);
|
|
3387
|
+
throw _error;
|
|
3388
|
+
}
|
|
3389
|
+
_contract =
|
|
3390
|
+
_get(
|
|
3391
|
+
"target",
|
|
3392
|
+
"contract");
|
|
3393
|
+
_msg =
|
|
3394
|
+
"Looking for address " +
|
|
3395
|
+
"corresponding to contract " +
|
|
3396
|
+
`'${_contract}' for the ` +
|
|
3397
|
+
`'${_app}' ` +
|
|
3398
|
+
"libEVM application on networks " +
|
|
3399
|
+
`'${_networks}' at deployments ` +
|
|
3400
|
+
`directory '${_deployments_dir}'.`;
|
|
3401
|
+
_msg_info(
|
|
3402
|
+
_msg);
|
|
3403
|
+
try {
|
|
3404
|
+
_evm_contract_deployment_address =
|
|
3405
|
+
await _evm_contract_deployment_address_check(
|
|
3406
|
+
_evm_contract_deployment_address);
|
|
3407
|
+
}
|
|
3408
|
+
catch(
|
|
3409
|
+
_error) {
|
|
3410
|
+
_msg =
|
|
3411
|
+
"Error running '_evm_contract_deployment_address_check'.";
|
|
3412
|
+
_msg_error(
|
|
3413
|
+
_msg,
|
|
3414
|
+
0);
|
|
3415
|
+
throw _error;
|
|
3416
|
+
}
|
|
3417
|
+
const
|
|
3418
|
+
_evm_contract_deployment_address_args = [
|
|
3419
|
+
_networks, // target networks
|
|
3420
|
+
_networks, // target chain ids
|
|
3421
|
+
"n", // all networks
|
|
3422
|
+
_app,
|
|
3423
|
+
_contract,
|
|
3424
|
+
"", // contract version
|
|
3425
|
+
"n", // user-level
|
|
3426
|
+
"", // configuration format
|
|
3427
|
+
_deployments_dir
|
|
3428
|
+
];
|
|
3429
|
+
try {
|
|
453
3430
|
const
|
|
454
|
-
|
|
455
|
-
await
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
3431
|
+
_contract_addresses =
|
|
3432
|
+
await _evm_contract_deployment_address.apply(
|
|
3433
|
+
null,
|
|
3434
|
+
_evm_contract_deployment_address_args);
|
|
3435
|
+
_contract_address =
|
|
3436
|
+
_contract_addresses[
|
|
3437
|
+
0];
|
|
3438
|
+
}
|
|
3439
|
+
catch(
|
|
3440
|
+
_error) {
|
|
3441
|
+
_msg =
|
|
3442
|
+
"Error while looking for contract " +
|
|
3443
|
+
"address from local libEVM applications " +
|
|
3444
|
+
"deployments directories.";
|
|
3445
|
+
_msg_error(
|
|
3446
|
+
_msg,
|
|
3447
|
+
0);
|
|
3448
|
+
_msg_error(
|
|
3449
|
+
_error,
|
|
3450
|
+
0);
|
|
3451
|
+
throw _error;
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
return _contract_address;
|
|
3455
|
+
}
|
|
3456
|
+
|
|
3457
|
+
async function
|
|
3458
|
+
_contract_address_auto_detect() {
|
|
3459
|
+
let
|
|
3460
|
+
_contract_address,
|
|
3461
|
+
_contract_addresses,
|
|
3462
|
+
_evm_contract_deployment_address,
|
|
3463
|
+
_evm_contract_deployment_address_args,
|
|
3464
|
+
_msg,
|
|
3465
|
+
_network,
|
|
3466
|
+
_target_contract;
|
|
3467
|
+
const
|
|
3468
|
+
_target_networks_index =
|
|
3469
|
+
{};
|
|
3470
|
+
_contract_address =
|
|
3471
|
+
_get(
|
|
3472
|
+
"contract",
|
|
3473
|
+
"address");
|
|
3474
|
+
const
|
|
3475
|
+
_target_app =
|
|
3476
|
+
_get(
|
|
3477
|
+
"target",
|
|
3478
|
+
"app");
|
|
3479
|
+
const
|
|
3480
|
+
_target_networks =
|
|
3481
|
+
_get(
|
|
3482
|
+
"target",
|
|
3483
|
+
"networks");
|
|
3484
|
+
const
|
|
3485
|
+
_deployments_dir =
|
|
3486
|
+
_get(
|
|
3487
|
+
"deployments",
|
|
3488
|
+
"dir");
|
|
3489
|
+
for ( _network of _target_networks ) {
|
|
3490
|
+
_target_networks_index[
|
|
3491
|
+
_network] =
|
|
3492
|
+
1;
|
|
3493
|
+
}
|
|
3494
|
+
const
|
|
3495
|
+
_target_networks_set =
|
|
3496
|
+
Object.keys(
|
|
3497
|
+
_target_networks_index);
|
|
3498
|
+
_msg =
|
|
3499
|
+
"Auto-detecting address " +
|
|
3500
|
+
`for contract '${_contract_address}' ` +
|
|
3501
|
+
`on network '${_target_networks_set}' ` +
|
|
3502
|
+
`for application '${_target_app}'.`;
|
|
3503
|
+
_msg_info(
|
|
3504
|
+
_msg);
|
|
3505
|
+
if ( _contract_address != "" ) {
|
|
3506
|
+
const
|
|
3507
|
+
_address_valid =
|
|
3508
|
+
await _address_check(
|
|
3509
|
+
_contract_address);
|
|
3510
|
+
if ( _address_valid ) {
|
|
3511
|
+
_msg =
|
|
3512
|
+
`Address '${_contract_address}' ` +
|
|
3513
|
+
`is valid.`;
|
|
3514
|
+
_msg_info(
|
|
3515
|
+
_msg);
|
|
3516
|
+
}
|
|
3517
|
+
else {
|
|
3518
|
+
_target_contract =
|
|
3519
|
+
_get(
|
|
3520
|
+
"target",
|
|
3521
|
+
"contract");
|
|
3522
|
+
const
|
|
3523
|
+
_target_contract_check_args = [
|
|
3524
|
+
_target_contract,
|
|
3525
|
+
_contract_address,
|
|
3526
|
+
_target_app,
|
|
3527
|
+
_deployments_dir
|
|
3528
|
+
];
|
|
3529
|
+
try {
|
|
3530
|
+
_target_contract =
|
|
3531
|
+
await _target_contract_check.apply(
|
|
3532
|
+
null,
|
|
3533
|
+
_target_contract_check_args);
|
|
3534
|
+
}
|
|
3535
|
+
catch(
|
|
3536
|
+
_error) {
|
|
3537
|
+
_msg =
|
|
3538
|
+
"Error running '_target_contract_check' " +
|
|
3539
|
+
`with parameters:`;
|
|
3540
|
+
_msg_error(
|
|
3541
|
+
_msg,
|
|
3542
|
+
0);
|
|
3543
|
+
_echo2(
|
|
3544
|
+
_target_contract_check_args);
|
|
3545
|
+
_echo2(
|
|
3546
|
+
_error);
|
|
3547
|
+
throw _error;
|
|
3548
|
+
}
|
|
3549
|
+
if ( _target_app != "" &&
|
|
3550
|
+
0 < _target_networks.length &&
|
|
3551
|
+
_target_contract != "" ) {
|
|
3552
|
+
_msg =
|
|
3553
|
+
"Looking for address " +
|
|
3554
|
+
"corresponding to contract " +
|
|
3555
|
+
`'${_target_contract}' for the ` +
|
|
3556
|
+
`'${_target_app}' ` +
|
|
3557
|
+
"libEVM application on network " +
|
|
3558
|
+
`'${_target_networks}' at deployments ` +
|
|
3559
|
+
`directory '${_deployments_dir}'.`;
|
|
3560
|
+
_msg_info(
|
|
3561
|
+
_msg);
|
|
3562
|
+
try {
|
|
3563
|
+
_evm_contract_deployment_address =
|
|
3564
|
+
await _evm_contract_deployment_address_check(
|
|
3565
|
+
_evm_contract_deployment_address);
|
|
3566
|
+
}
|
|
3567
|
+
catch(
|
|
3568
|
+
_error) {
|
|
3569
|
+
_msg =
|
|
3570
|
+
"Error running '_evm_contract_deployment_address_check'.";
|
|
3571
|
+
_msg_error(
|
|
3572
|
+
_msg,
|
|
3573
|
+
0);
|
|
3574
|
+
throw _error;
|
|
3575
|
+
}
|
|
3576
|
+
_evm_contract_deployment_address_args = [
|
|
3577
|
+
_target_networks_set, // target networks
|
|
3578
|
+
_target_networks_set, // target chain ids
|
|
3579
|
+
"n", // all networks
|
|
3580
|
+
_target_app,
|
|
3581
|
+
_target_contract,
|
|
3582
|
+
"", // contract version
|
|
3583
|
+
"n", // user-level
|
|
3584
|
+
"", // configuration format
|
|
3585
|
+
_deployments_dir
|
|
3586
|
+
];
|
|
3587
|
+
try {
|
|
3588
|
+
_contract_addresses =
|
|
3589
|
+
await _evm_contract_deployment_address.apply(
|
|
3590
|
+
null,
|
|
3591
|
+
_evm_contract_deployment_address_args);
|
|
3592
|
+
_contract_address =
|
|
3593
|
+
_contract_addresses[
|
|
3594
|
+
0];
|
|
3595
|
+
}
|
|
3596
|
+
catch(
|
|
3597
|
+
_error) {
|
|
3598
|
+
_msg =
|
|
3599
|
+
"Error while looking for contract " +
|
|
3600
|
+
"address from local libEVM applications " +
|
|
3601
|
+
"deployments directories.";
|
|
3602
|
+
_msg_error(
|
|
3603
|
+
_msg,
|
|
3604
|
+
0);
|
|
3605
|
+
_msg_error(
|
|
3606
|
+
_error,
|
|
3607
|
+
0);
|
|
3608
|
+
throw _error;
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
else {
|
|
3612
|
+
_msg =
|
|
3613
|
+
"One between the " +
|
|
3614
|
+
`application '${_target_app}', ` +
|
|
3615
|
+
`the network '${_target_networks_set}' ` +
|
|
3616
|
+
`or the contract '${_target_contract}' ` +
|
|
3617
|
+
`has not been specified.`;
|
|
3618
|
+
_msg_info(
|
|
3619
|
+
_msg);
|
|
3620
|
+
}
|
|
3621
|
+
}
|
|
3622
|
+
}
|
|
3623
|
+
_set(
|
|
3624
|
+
"contract",
|
|
3625
|
+
"address",
|
|
3626
|
+
_contract_address);
|
|
3627
|
+
}
|
|
3628
|
+
|
|
3629
|
+
async function
|
|
3630
|
+
_target_contract_check(
|
|
3631
|
+
_target_contract,
|
|
3632
|
+
_contract_address,
|
|
3633
|
+
_target_app,
|
|
3634
|
+
_deployments_dir,
|
|
3635
|
+
_user_defined,
|
|
3636
|
+
_networks) {
|
|
3637
|
+
let
|
|
3638
|
+
_msg,
|
|
3639
|
+
_target_contract_get;
|
|
3640
|
+
const
|
|
3641
|
+
_target_contract_type =
|
|
3642
|
+
typeof(
|
|
3643
|
+
_target_contract);
|
|
3644
|
+
if ( _target_contract_type === "undefined" ) {
|
|
3645
|
+
_msg =
|
|
3646
|
+
"Target contract undefined, auto-detecting.";
|
|
3647
|
+
_msg_info(
|
|
3648
|
+
_msg);
|
|
3649
|
+
_target_contract_get =
|
|
3650
|
+
true;
|
|
3651
|
+
}
|
|
3652
|
+
else if ( _target_contract_type === "string" ) {
|
|
3653
|
+
if ( _target_contract.length < 1 ) {
|
|
3654
|
+
_msg =
|
|
3655
|
+
"Target contract not set, auto-detecting.";
|
|
3656
|
+
_msg_info(
|
|
3657
|
+
_msg);
|
|
3658
|
+
_target_contract_get =
|
|
3659
|
+
true;
|
|
459
3660
|
}
|
|
3661
|
+
}
|
|
3662
|
+
else {
|
|
3663
|
+
_msg =
|
|
3664
|
+
"Target contract must have type 'string'.";
|
|
3665
|
+
_msg_error(
|
|
3666
|
+
_msg,
|
|
3667
|
+
0);
|
|
3668
|
+
throw _msg;
|
|
3669
|
+
}
|
|
3670
|
+
if ( _target_contract_get ) {
|
|
3671
|
+
_user_defined =
|
|
3672
|
+
_user_defined_check(
|
|
3673
|
+
_user_defined);
|
|
460
3674
|
const
|
|
461
|
-
|
|
462
|
-
|
|
3675
|
+
_deployments_dir_check_args = [
|
|
3676
|
+
_deployments_dir,
|
|
3677
|
+
_target_app,
|
|
463
3678
|
_user_defined
|
|
464
3679
|
];
|
|
465
|
-
|
|
466
|
-
|
|
3680
|
+
try {
|
|
3681
|
+
_deployments_dir =
|
|
3682
|
+
await _deployments_dir_check.apply(
|
|
3683
|
+
null,
|
|
3684
|
+
_deployments_dir_check_args);
|
|
3685
|
+
}
|
|
3686
|
+
catch(
|
|
3687
|
+
_error) {
|
|
3688
|
+
_msg =
|
|
3689
|
+
"Error running '_deployments_dir_check' " +
|
|
3690
|
+
"with arguments:";
|
|
3691
|
+
_msg_error(
|
|
3692
|
+
_msg,
|
|
3693
|
+
0);
|
|
3694
|
+
_echo2(
|
|
3695
|
+
_deployments_dir_check_args);
|
|
3696
|
+
_echo2(
|
|
3697
|
+
_error);
|
|
3698
|
+
throw _error;
|
|
3699
|
+
}
|
|
3700
|
+
const
|
|
3701
|
+
_target_networks_check_args = [
|
|
3702
|
+
_networks,
|
|
3703
|
+
false
|
|
3704
|
+
];
|
|
3705
|
+
try {
|
|
3706
|
+
_networks =
|
|
3707
|
+
await _target_networks_check.apply(
|
|
3708
|
+
null,
|
|
3709
|
+
_target_networks_check_args);
|
|
3710
|
+
}
|
|
3711
|
+
catch(
|
|
3712
|
+
_error) {
|
|
3713
|
+
_msg =
|
|
3714
|
+
"Error running '_target_networks_check' " +
|
|
3715
|
+
"with arguments:";
|
|
3716
|
+
_msg_error(
|
|
3717
|
+
_msg,
|
|
3718
|
+
0);
|
|
3719
|
+
_echo2(
|
|
3720
|
+
_target_networks_check_args);
|
|
3721
|
+
_echo2(
|
|
3722
|
+
_error);
|
|
3723
|
+
throw _error;
|
|
3724
|
+
}
|
|
3725
|
+
const
|
|
3726
|
+
_contract_address_check_args = [
|
|
3727
|
+
_contract_address,
|
|
3728
|
+
_deployments_dir,
|
|
3729
|
+
_target_app,
|
|
3730
|
+
_user_defined,
|
|
3731
|
+
_networks
|
|
3732
|
+
];
|
|
3733
|
+
try {
|
|
3734
|
+
_contract_address =
|
|
3735
|
+
await _contract_address_check.apply(
|
|
3736
|
+
null,
|
|
3737
|
+
_contract_address_check_args);
|
|
3738
|
+
}
|
|
3739
|
+
catch(
|
|
3740
|
+
_error) {
|
|
3741
|
+
_msg =
|
|
3742
|
+
"Error running '_contract_address_check' " +
|
|
3743
|
+
"with arguments:";
|
|
3744
|
+
_msg_error(
|
|
3745
|
+
_msg,
|
|
3746
|
+
0);
|
|
3747
|
+
_echo2(
|
|
3748
|
+
_contract_address_check_args);
|
|
3749
|
+
_echo2(
|
|
3750
|
+
_error);
|
|
3751
|
+
throw _error;
|
|
3752
|
+
}
|
|
3753
|
+
const
|
|
3754
|
+
_address_valid =
|
|
3755
|
+
await _address_check(
|
|
3756
|
+
_contract_address);
|
|
3757
|
+
if ( ! _address_valid ) {
|
|
3758
|
+
_target_contract =
|
|
3759
|
+
_contract_address;
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
return _target_contract;
|
|
3763
|
+
}
|
|
3764
|
+
|
|
3765
|
+
async function
|
|
3766
|
+
_target_contract_auto_detect() {
|
|
3767
|
+
let
|
|
3768
|
+
_contract_address,
|
|
3769
|
+
_msg,
|
|
3770
|
+
_target_contract;
|
|
3771
|
+
_target_contract =
|
|
3772
|
+
_get(
|
|
3773
|
+
"target",
|
|
3774
|
+
"contract");
|
|
3775
|
+
const
|
|
3776
|
+
_target_app =
|
|
3777
|
+
_get(
|
|
3778
|
+
"target",
|
|
3779
|
+
"app");
|
|
3780
|
+
const
|
|
3781
|
+
_deployments_dir =
|
|
3782
|
+
_get(
|
|
3783
|
+
"deployments",
|
|
3784
|
+
"dir");
|
|
3785
|
+
_contract_address =
|
|
3786
|
+
_get(
|
|
3787
|
+
"contract",
|
|
3788
|
+
"address");
|
|
3789
|
+
const
|
|
3790
|
+
_contract_address_check_args = [
|
|
3791
|
+
_contract_address,
|
|
3792
|
+
_deployments_dir,
|
|
3793
|
+
_target_app
|
|
3794
|
+
];
|
|
3795
|
+
try {
|
|
3796
|
+
_contract_address =
|
|
3797
|
+
await _contract_address_check.apply(
|
|
467
3798
|
null,
|
|
468
|
-
|
|
3799
|
+
_contract_address_check_args);
|
|
3800
|
+
}
|
|
3801
|
+
catch(
|
|
3802
|
+
_error) {
|
|
3803
|
+
_msg =
|
|
3804
|
+
"Error running '_contract_address_check' " +
|
|
3805
|
+
"with arguments:";
|
|
3806
|
+
_msg_error(
|
|
3807
|
+
_msg,
|
|
3808
|
+
0);
|
|
3809
|
+
_echo2(
|
|
3810
|
+
_contract_address_check_args);
|
|
3811
|
+
_echo2(
|
|
3812
|
+
_error);
|
|
3813
|
+
throw _error;
|
|
3814
|
+
}
|
|
3815
|
+
const
|
|
3816
|
+
_target_contract_check_args = [
|
|
3817
|
+
_target_contract,
|
|
3818
|
+
_contract_address,
|
|
3819
|
+
_target_app,
|
|
3820
|
+
_deployments_dir
|
|
3821
|
+
];
|
|
3822
|
+
try {
|
|
3823
|
+
_target_contract =
|
|
3824
|
+
await _target_contract_check.apply(
|
|
3825
|
+
null,
|
|
3826
|
+
_target_contract_check_args);
|
|
3827
|
+
}
|
|
3828
|
+
catch(
|
|
3829
|
+
_error) {
|
|
3830
|
+
_msg =
|
|
3831
|
+
"Error running '_target_contract_check' " +
|
|
3832
|
+
"with arguments:";
|
|
3833
|
+
_msg_error(
|
|
3834
|
+
_msg,
|
|
3835
|
+
0);
|
|
3836
|
+
_echo2(
|
|
3837
|
+
_target_contract_check_args);
|
|
3838
|
+
_echo2(
|
|
3839
|
+
_error);
|
|
3840
|
+
throw _error;
|
|
469
3841
|
}
|
|
470
3842
|
_override_set(
|
|
471
|
-
"
|
|
472
|
-
"
|
|
473
|
-
|
|
3843
|
+
"target",
|
|
3844
|
+
"contract",
|
|
3845
|
+
_target_contract);
|
|
474
3846
|
}
|
|
475
3847
|
|
|
476
3848
|
async function
|
|
477
|
-
|
|
3849
|
+
_contract_abi_auto_detect() {
|
|
478
3850
|
let
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
_network_id,
|
|
487
|
-
_networks,
|
|
488
|
-
_version,
|
|
489
|
-
_msg;
|
|
490
|
-
_networks =
|
|
491
|
-
[];
|
|
3851
|
+
_abi,
|
|
3852
|
+
_abi_retrieve,
|
|
3853
|
+
_contract_address,
|
|
3854
|
+
_configuration_format,
|
|
3855
|
+
_deployments_dir,
|
|
3856
|
+
_msg,
|
|
3857
|
+
_target_contract;
|
|
492
3858
|
const
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
3859
|
+
_global =
|
|
3860
|
+
_global_get();
|
|
3861
|
+
const
|
|
3862
|
+
_quiet =
|
|
3863
|
+
_global[
|
|
3864
|
+
"quiet"];
|
|
3865
|
+
const
|
|
3866
|
+
_target_app =
|
|
3867
|
+
_get(
|
|
3868
|
+
"target",
|
|
3869
|
+
"app");
|
|
3870
|
+
const
|
|
3871
|
+
_user_defined =
|
|
3872
|
+
"n";
|
|
3873
|
+
_deployments_dir =
|
|
3874
|
+
_get(
|
|
3875
|
+
"deployments",
|
|
3876
|
+
"dir");
|
|
3877
|
+
_target_contract =
|
|
3878
|
+
_get(
|
|
3879
|
+
"target",
|
|
3880
|
+
"contract");
|
|
3881
|
+
_msg_info(
|
|
3882
|
+
`Target app '${_target_app}'.`);
|
|
3883
|
+
_msg_info(
|
|
3884
|
+
`Target contract '${_target_contract}'.`);
|
|
3885
|
+
_contract_address =
|
|
3886
|
+
_get(
|
|
3887
|
+
"contract",
|
|
3888
|
+
"address");
|
|
3889
|
+
const
|
|
3890
|
+
_target_networks =
|
|
3891
|
+
_get(
|
|
3892
|
+
"target",
|
|
3893
|
+
"networks");
|
|
3894
|
+
const
|
|
3895
|
+
_deployments_dir_check_args = [
|
|
3896
|
+
_deployments_dir,
|
|
3897
|
+
_target_app,
|
|
3898
|
+
_user_defined
|
|
3899
|
+
];
|
|
3900
|
+
_msg =
|
|
3901
|
+
"Running '_deployments_dir_check' " +
|
|
3902
|
+
`with arguments:`;
|
|
3903
|
+
_msg_info(
|
|
3904
|
+
_msg);
|
|
3905
|
+
if ( _quiet == "n" ) {
|
|
3906
|
+
_echo(
|
|
3907
|
+
_deployments_dir_check_args);
|
|
3908
|
+
}
|
|
3909
|
+
try {
|
|
3910
|
+
_deployments_dir =
|
|
3911
|
+
await _deployments_dir_check.apply(
|
|
3912
|
+
null,
|
|
3913
|
+
_deployments_dir_check_args);
|
|
3914
|
+
}
|
|
3915
|
+
catch(
|
|
3916
|
+
_error) {
|
|
3917
|
+
_msg =
|
|
3918
|
+
"Error running '_deployments_dir_check' " +
|
|
3919
|
+
`with arguments:`;
|
|
3920
|
+
_msg_error(
|
|
3921
|
+
_msg,
|
|
3922
|
+
0);
|
|
3923
|
+
_echo2(
|
|
3924
|
+
_deployments_dir_check_args);
|
|
3925
|
+
_echo2(
|
|
3926
|
+
_error);
|
|
3927
|
+
throw _error;
|
|
3928
|
+
}
|
|
3929
|
+
const
|
|
3930
|
+
_target_contract_check_args = [
|
|
3931
|
+
_target_contract,
|
|
3932
|
+
_contract_address,
|
|
3933
|
+
_target_app,
|
|
3934
|
+
_deployments_dir
|
|
3935
|
+
];
|
|
3936
|
+
try {
|
|
3937
|
+
_target_contract =
|
|
3938
|
+
await _target_contract_check.apply(
|
|
3939
|
+
null,
|
|
3940
|
+
_target_contract_check_args);
|
|
3941
|
+
}
|
|
3942
|
+
catch(
|
|
3943
|
+
_error) {
|
|
3944
|
+
_msg =
|
|
3945
|
+
"Error running '_target_contract_check' " +
|
|
3946
|
+
"with parameters:";
|
|
3947
|
+
_echo2(
|
|
3948
|
+
_target_contract_check_args);
|
|
3949
|
+
_echo2(
|
|
3950
|
+
_error);
|
|
3951
|
+
throw _error;
|
|
3952
|
+
}
|
|
3953
|
+
const
|
|
3954
|
+
_contract_address_check_args = [
|
|
3955
|
+
_contract_address,
|
|
3956
|
+
_deployments_dir,
|
|
3957
|
+
_target_app
|
|
3958
|
+
];
|
|
3959
|
+
try {
|
|
3960
|
+
_contract_address =
|
|
3961
|
+
await _contract_address_check.apply(
|
|
3962
|
+
null,
|
|
3963
|
+
_contract_address_check_args);
|
|
3964
|
+
}
|
|
3965
|
+
catch(
|
|
3966
|
+
_error) {
|
|
3967
|
+
_msg =
|
|
3968
|
+
"Error running '_contract_address_check' " +
|
|
3969
|
+
"with parameters:";
|
|
3970
|
+
_echo2(
|
|
3971
|
+
_contract_address_check_args);
|
|
3972
|
+
_echo2(
|
|
3973
|
+
_error);
|
|
3974
|
+
throw _error;
|
|
3975
|
+
}
|
|
3976
|
+
const
|
|
3977
|
+
_api_key =
|
|
3978
|
+
_get(
|
|
3979
|
+
"api",
|
|
3980
|
+
"key");
|
|
3981
|
+
const
|
|
3982
|
+
_compiler_output =
|
|
3983
|
+
_get(
|
|
3984
|
+
"contract",
|
|
3985
|
+
"compiler_output");
|
|
3986
|
+
_abi =
|
|
3987
|
+
_get(
|
|
3988
|
+
"contract",
|
|
3989
|
+
"abi");
|
|
3990
|
+
const
|
|
3991
|
+
_abi_type =
|
|
3992
|
+
typeof(
|
|
3993
|
+
_abi);
|
|
3994
|
+
_abi_retrieve =
|
|
496
3995
|
false;
|
|
497
|
-
if (
|
|
498
|
-
|
|
499
|
-
|
|
3996
|
+
if ( _abi_type === "undefined" ) {
|
|
3997
|
+
_abi_retrieve =
|
|
3998
|
+
true;
|
|
500
3999
|
}
|
|
501
|
-
else if (
|
|
502
|
-
|
|
503
|
-
|
|
4000
|
+
else if ( _abi_type === "string" ) {
|
|
4001
|
+
if ( _abi.length < 1 ) {
|
|
4002
|
+
_abi_retrieve =
|
|
4003
|
+
true;
|
|
4004
|
+
}
|
|
4005
|
+
}
|
|
4006
|
+
if ( _abi_retrieve ) {
|
|
4007
|
+
if ( 1 < _target_networks.length ) {
|
|
4008
|
+
_msg =
|
|
4009
|
+
"You can't currently retrieve " +
|
|
4010
|
+
"ABI for more than a contract.";
|
|
4011
|
+
_msg_error(
|
|
4012
|
+
_msg,
|
|
4013
|
+
0);
|
|
4014
|
+
throw _msg;
|
|
4015
|
+
}
|
|
4016
|
+
else if ( 1 == _target_networks.length ) {
|
|
4017
|
+
const
|
|
4018
|
+
_network =
|
|
4019
|
+
_target_networks[
|
|
4020
|
+
0];
|
|
4021
|
+
_configuration_format =
|
|
4022
|
+
_configuration_format_check(
|
|
4023
|
+
_configuration_format);
|
|
4024
|
+
const
|
|
4025
|
+
_contract_abi_check_args = [
|
|
4026
|
+
_abi,
|
|
4027
|
+
_network,
|
|
4028
|
+
_contract_address,
|
|
4029
|
+
_api_key,
|
|
4030
|
+
_compiler_output,
|
|
4031
|
+
_target_app,
|
|
4032
|
+
_target_contract,
|
|
4033
|
+
_configuration_format,
|
|
4034
|
+
_deployments_dir,
|
|
4035
|
+
_user_defined,
|
|
4036
|
+
true // local
|
|
4037
|
+
];
|
|
4038
|
+
_msg =
|
|
4039
|
+
"Running '_contract_abi_check' with " +
|
|
4040
|
+
"parameters:";
|
|
4041
|
+
_msg_info(
|
|
4042
|
+
_msg);
|
|
4043
|
+
if ( _quiet == "n" ) {
|
|
4044
|
+
_echo(
|
|
4045
|
+
_contract_abi_check_args);
|
|
4046
|
+
}
|
|
4047
|
+
try {
|
|
4048
|
+
_abi =
|
|
4049
|
+
await _contract_abi_check.apply(
|
|
4050
|
+
null,
|
|
4051
|
+
_contract_abi_check_args);
|
|
4052
|
+
}
|
|
4053
|
+
catch(
|
|
4054
|
+
_error) {
|
|
4055
|
+
_msg =
|
|
4056
|
+
"Error running '_contract_abi_check' with " +
|
|
4057
|
+
"parameters:";
|
|
4058
|
+
_msg_error(
|
|
4059
|
+
_msg,
|
|
4060
|
+
0);
|
|
4061
|
+
_echo2(
|
|
4062
|
+
_contract_abi_check_args);
|
|
4063
|
+
_echo2(
|
|
4064
|
+
_error);
|
|
4065
|
+
throw _error;
|
|
4066
|
+
}
|
|
4067
|
+
}
|
|
4068
|
+
else {
|
|
4069
|
+
_msg =
|
|
4070
|
+
"You must currently select a network " +
|
|
4071
|
+
"to auto-detect the abi for " +
|
|
4072
|
+
"a libevm application contract.";
|
|
4073
|
+
_msg_error(
|
|
4074
|
+
_msg,
|
|
4075
|
+
0);
|
|
4076
|
+
throw _msg;
|
|
4077
|
+
}
|
|
4078
|
+
}
|
|
4079
|
+
_override_set(
|
|
4080
|
+
"contract",
|
|
4081
|
+
"abi",
|
|
4082
|
+
_abi);
|
|
4083
|
+
}
|
|
4084
|
+
|
|
4085
|
+
async function
|
|
4086
|
+
_contract_bytecode_auto_detect() {
|
|
4087
|
+
let
|
|
4088
|
+
_bytecode,
|
|
4089
|
+
_bytecode_retrieve,
|
|
4090
|
+
_contract_address,
|
|
4091
|
+
_configuration_format,
|
|
4092
|
+
_deployments_dir,
|
|
4093
|
+
_msg,
|
|
4094
|
+
_target_contract;
|
|
4095
|
+
const
|
|
4096
|
+
_global =
|
|
4097
|
+
_global_get();
|
|
4098
|
+
const
|
|
4099
|
+
_quiet =
|
|
4100
|
+
_global[
|
|
4101
|
+
"quiet"];
|
|
4102
|
+
const
|
|
4103
|
+
_target_app =
|
|
4104
|
+
_get(
|
|
4105
|
+
"target",
|
|
4106
|
+
"app");
|
|
4107
|
+
const
|
|
4108
|
+
_user_defined =
|
|
4109
|
+
"n";
|
|
4110
|
+
_deployments_dir =
|
|
4111
|
+
_get(
|
|
4112
|
+
"deployments",
|
|
4113
|
+
"dir");
|
|
4114
|
+
_target_contract =
|
|
4115
|
+
_get(
|
|
4116
|
+
"target",
|
|
4117
|
+
"contract");
|
|
4118
|
+
_msg_info(
|
|
4119
|
+
`Target app '${_target_app}'.`);
|
|
4120
|
+
_msg_info(
|
|
4121
|
+
`Target contract '${_target_contract}'.`);
|
|
4122
|
+
_contract_address =
|
|
4123
|
+
_get(
|
|
4124
|
+
"contract",
|
|
4125
|
+
"address");
|
|
4126
|
+
const
|
|
4127
|
+
_target_networks =
|
|
4128
|
+
_get(
|
|
4129
|
+
"target",
|
|
4130
|
+
"networks");
|
|
4131
|
+
const
|
|
4132
|
+
_deployments_dir_check_args = [
|
|
4133
|
+
_deployments_dir,
|
|
4134
|
+
_target_app,
|
|
4135
|
+
_user_defined
|
|
4136
|
+
];
|
|
4137
|
+
_msg =
|
|
4138
|
+
"Running '_deployments_dir_check' " +
|
|
4139
|
+
`with arguments:`;
|
|
4140
|
+
_msg_info(
|
|
4141
|
+
_msg);
|
|
4142
|
+
if ( _quiet == "n" ) {
|
|
4143
|
+
_echo(
|
|
4144
|
+
_deployments_dir_check_args);
|
|
4145
|
+
}
|
|
4146
|
+
try {
|
|
4147
|
+
_deployments_dir =
|
|
4148
|
+
await _deployments_dir_check.apply(
|
|
4149
|
+
null,
|
|
4150
|
+
_deployments_dir_check_args);
|
|
4151
|
+
}
|
|
4152
|
+
catch(
|
|
4153
|
+
_error) {
|
|
4154
|
+
_msg =
|
|
4155
|
+
"Error running '_deployments_dir_check' " +
|
|
4156
|
+
`with arguments:`;
|
|
4157
|
+
_msg_error(
|
|
4158
|
+
_msg,
|
|
4159
|
+
0);
|
|
4160
|
+
_echo2(
|
|
4161
|
+
_deployments_dir_check_args);
|
|
4162
|
+
_echo2(
|
|
4163
|
+
_error);
|
|
4164
|
+
throw _error;
|
|
4165
|
+
}
|
|
4166
|
+
const
|
|
4167
|
+
_target_contract_check_args = [
|
|
4168
|
+
_target_contract,
|
|
4169
|
+
_contract_address,
|
|
4170
|
+
_target_app,
|
|
4171
|
+
_deployments_dir
|
|
4172
|
+
];
|
|
4173
|
+
try {
|
|
4174
|
+
_target_contract =
|
|
4175
|
+
await _target_contract_check.apply(
|
|
4176
|
+
null,
|
|
4177
|
+
_target_contract_check_args);
|
|
4178
|
+
}
|
|
4179
|
+
catch(
|
|
4180
|
+
_error) {
|
|
4181
|
+
_msg =
|
|
4182
|
+
"Error running '_target_contract_check' " +
|
|
4183
|
+
"with parameters:";
|
|
4184
|
+
_echo2(
|
|
4185
|
+
_target_contract_check_args);
|
|
4186
|
+
_echo2(
|
|
4187
|
+
_error);
|
|
4188
|
+
throw _error;
|
|
4189
|
+
}
|
|
4190
|
+
const
|
|
4191
|
+
_contract_address_check_args = [
|
|
4192
|
+
_contract_address,
|
|
4193
|
+
_deployments_dir,
|
|
4194
|
+
_target_app
|
|
4195
|
+
];
|
|
4196
|
+
try {
|
|
4197
|
+
_contract_address =
|
|
4198
|
+
await _contract_address_check.apply(
|
|
4199
|
+
null,
|
|
4200
|
+
_contract_address_check_args);
|
|
4201
|
+
}
|
|
4202
|
+
catch(
|
|
4203
|
+
_error) {
|
|
4204
|
+
_msg =
|
|
4205
|
+
"Error running '_contract_address_check' " +
|
|
4206
|
+
"with parameters:";
|
|
4207
|
+
_echo2(
|
|
4208
|
+
_contract_address_check_args);
|
|
4209
|
+
_echo2(
|
|
4210
|
+
_error);
|
|
4211
|
+
throw _error;
|
|
504
4212
|
}
|
|
505
4213
|
const
|
|
506
|
-
|
|
4214
|
+
_api_key =
|
|
4215
|
+
_get(
|
|
4216
|
+
"api",
|
|
4217
|
+
"key");
|
|
4218
|
+
const
|
|
4219
|
+
_compiler_output =
|
|
4220
|
+
_get(
|
|
4221
|
+
"contract",
|
|
4222
|
+
"compiler_output");
|
|
4223
|
+
_bytecode =
|
|
4224
|
+
_get(
|
|
4225
|
+
"contract",
|
|
4226
|
+
"bytecode");
|
|
4227
|
+
const
|
|
4228
|
+
_bytecode_type =
|
|
507
4229
|
typeof(
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
4230
|
+
_bytecode);
|
|
4231
|
+
_bytecode_retrieve =
|
|
4232
|
+
false;
|
|
4233
|
+
if ( _bytecode_type === "undefined" ) {
|
|
4234
|
+
_bytecode_retrieve =
|
|
4235
|
+
true;
|
|
4236
|
+
}
|
|
4237
|
+
else if ( _bytecode_type === "string" ) {
|
|
4238
|
+
if ( _bytecode.length < 1 ) {
|
|
4239
|
+
_bytecode_retrieve =
|
|
4240
|
+
true;
|
|
4241
|
+
}
|
|
4242
|
+
}
|
|
4243
|
+
if ( _bytecode_retrieve ) {
|
|
4244
|
+
if ( 1 < _target_networks.length ) {
|
|
4245
|
+
_msg =
|
|
4246
|
+
"You can't currently retrieve " +
|
|
4247
|
+
"bytecode for more than a contract.";
|
|
4248
|
+
_msg_error(
|
|
4249
|
+
_msg,
|
|
4250
|
+
0);
|
|
4251
|
+
throw _msg;
|
|
4252
|
+
}
|
|
4253
|
+
else if ( 1 == _target_networks.length ) {
|
|
4254
|
+
const
|
|
520
4255
|
_network =
|
|
521
|
-
|
|
522
|
-
0];
|
|
523
|
-
}
|
|
524
|
-
if ( 0 < network_ids.length ) {
|
|
525
|
-
_network_id =
|
|
526
|
-
_network_ids[
|
|
4256
|
+
_target_networks[
|
|
527
4257
|
0];
|
|
528
|
-
|
|
4258
|
+
_configuration_format =
|
|
4259
|
+
_configuration_format_check(
|
|
4260
|
+
_configuration_format);
|
|
529
4261
|
const
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
_deployments,
|
|
533
|
-
_contract ] );
|
|
534
|
-
if ( networks_all == "n" ) {
|
|
535
|
-
_networks.push(
|
|
4262
|
+
_contract_bytecode_check_args = [
|
|
4263
|
+
_bytecode,
|
|
536
4264
|
_network,
|
|
537
|
-
|
|
4265
|
+
_contract_address,
|
|
4266
|
+
_api_key,
|
|
4267
|
+
_compiler_output,
|
|
4268
|
+
_target_app,
|
|
4269
|
+
_target_contract,
|
|
4270
|
+
_configuration_format,
|
|
4271
|
+
_deployments_dir,
|
|
4272
|
+
_user_defined,
|
|
4273
|
+
true // local
|
|
4274
|
+
];
|
|
4275
|
+
_msg =
|
|
4276
|
+
"Running '_contract_bytecode_check' with " +
|
|
4277
|
+
"parameters:";
|
|
4278
|
+
_msg_info(
|
|
4279
|
+
_msg);
|
|
4280
|
+
if ( _quiet == "n" ) {
|
|
4281
|
+
_echo(
|
|
4282
|
+
_contract_bytecode_check_args);
|
|
538
4283
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
_deployments_path,
|
|
543
|
-
"y", // Display all
|
|
544
|
-
"n", // Display safest
|
|
545
|
-
"n" // Display cheapest
|
|
546
|
-
];
|
|
547
|
-
_networks_new =
|
|
548
|
-
await _evm_contract_deployment_networks.apply(
|
|
4284
|
+
try {
|
|
4285
|
+
_bytecode =
|
|
4286
|
+
await _contract_bytecode_check.apply(
|
|
549
4287
|
null,
|
|
550
|
-
|
|
551
|
-
_networks =
|
|
552
|
-
_networks.concat(
|
|
553
|
-
_networks_new);
|
|
554
|
-
}
|
|
555
|
-
for ( _net of _networks ) {
|
|
556
|
-
_config =
|
|
557
|
-
_path_join( [
|
|
558
|
-
_deployments_path,
|
|
559
|
-
_net,
|
|
560
|
-
`config.${_config_ext}`
|
|
561
|
-
]);
|
|
562
|
-
if ( _file_exists(
|
|
563
|
-
_config) ) {
|
|
564
|
-
_found =
|
|
565
|
-
true;
|
|
566
|
-
_msg =
|
|
567
|
-
`Found deployment configuration ` +
|
|
568
|
-
`at location '${_config}'.`;
|
|
569
|
-
_msg_info(
|
|
570
|
-
_msg);
|
|
571
|
-
break;
|
|
572
|
-
}
|
|
4288
|
+
_contract_bytecode_check_args);
|
|
573
4289
|
}
|
|
574
|
-
|
|
4290
|
+
catch(
|
|
4291
|
+
_error) {
|
|
575
4292
|
_msg =
|
|
576
|
-
"
|
|
577
|
-
"
|
|
578
|
-
`'${_network}' with ID ` +
|
|
579
|
-
`'${_network_id}'.`;
|
|
4293
|
+
"Error running '_contract_bytecode_check' with " +
|
|
4294
|
+
"parameters:";
|
|
580
4295
|
_msg_error(
|
|
581
4296
|
_msg,
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
_evm_contract_deployment_versions =
|
|
589
|
-
_get(
|
|
590
|
-
"_evm_contract",
|
|
591
|
-
"deployment_versions");
|
|
592
|
-
const
|
|
593
|
-
_evm_contract_deployment_versions_type =
|
|
594
|
-
typeof(
|
|
595
|
-
_evm_contract_deployment_versions_dir);
|
|
596
|
-
if ( _evm_contract_deployment_versions_type == "undefined" ||
|
|
597
|
-
_evm_contract_deployment_versions == "" ) {
|
|
598
|
-
const
|
|
599
|
-
_libevm_contract_deployment_versions_module =
|
|
600
|
-
await import(
|
|
601
|
-
"./libevm-contract-deployment-versions");
|
|
602
|
-
_evm_contract_deployment_versions =
|
|
603
|
-
_libevm_contract_deployment_versions_module._evm_contract_deployment_versions;
|
|
4297
|
+
0);
|
|
4298
|
+
_echo2(
|
|
4299
|
+
_contract_bytecode_check_args);
|
|
4300
|
+
_echo2(
|
|
4301
|
+
_error);
|
|
4302
|
+
throw _error;
|
|
604
4303
|
}
|
|
605
|
-
const
|
|
606
|
-
_evm_contract_deployment_versions_args = [
|
|
607
|
-
_config,
|
|
608
|
-
"y", // display highest
|
|
609
|
-
"n", // display lowest
|
|
610
|
-
configuration_format
|
|
611
|
-
];
|
|
612
|
-
_version =
|
|
613
|
-
await _evm_contract_deployment_versions.apply(
|
|
614
|
-
null,
|
|
615
|
-
_evm_contract_deployment_versions_args);
|
|
616
4304
|
}
|
|
617
|
-
else
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
"then the user-defined deployments " +
|
|
623
|
-
"switch must be enabled with '-u' and " +
|
|
624
|
-
"a deployments directory must be specified " +
|
|
625
|
-
"with '-d'.";
|
|
4305
|
+
else {
|
|
4306
|
+
_msg =
|
|
4307
|
+
"You must currently select a network " +
|
|
4308
|
+
"to auto-detect the bytecode for " +
|
|
4309
|
+
"a libevm application contract.";
|
|
626
4310
|
_msg_error(
|
|
627
4311
|
_msg,
|
|
628
|
-
|
|
4312
|
+
0);
|
|
4313
|
+
throw _msg;
|
|
629
4314
|
}
|
|
630
4315
|
}
|
|
631
4316
|
_override_set(
|
|
632
4317
|
"contract",
|
|
633
|
-
"
|
|
634
|
-
|
|
635
|
-
return true;
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
function
|
|
639
|
-
_networks_all_auto_detect() {
|
|
640
|
-
let
|
|
641
|
-
_networks_all;
|
|
642
|
-
_networks_all =
|
|
643
|
-
"n";
|
|
644
|
-
if ( target_networks.length < 1 &&
|
|
645
|
-
network_ids.length < 1 ) {
|
|
646
|
-
_networks_all =
|
|
647
|
-
"y";
|
|
648
|
-
}
|
|
649
|
-
_override_set(
|
|
650
|
-
"networks",
|
|
651
|
-
"all",
|
|
652
|
-
_networks_all);
|
|
4318
|
+
"bytecode",
|
|
4319
|
+
_bytecode);
|
|
653
4320
|
}
|
|
654
4321
|
|
|
655
4322
|
async function
|
|
656
|
-
|
|
4323
|
+
_contract_compiler_output_auto_detect() {
|
|
657
4324
|
let
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
4325
|
+
_compiler_output,
|
|
4326
|
+
_compiler_output_retrieve,
|
|
4327
|
+
_contract_address,
|
|
4328
|
+
_configuration_format,
|
|
4329
|
+
_deployments_dir,
|
|
4330
|
+
_msg,
|
|
4331
|
+
_target_contract;
|
|
4332
|
+
const
|
|
4333
|
+
_global =
|
|
4334
|
+
_global_get();
|
|
661
4335
|
const
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
4336
|
+
_quiet =
|
|
4337
|
+
_global[
|
|
4338
|
+
"quiet"];
|
|
4339
|
+
const
|
|
4340
|
+
_target_app =
|
|
4341
|
+
_get(
|
|
4342
|
+
"target",
|
|
4343
|
+
"app");
|
|
665
4344
|
const
|
|
666
4345
|
_user_defined =
|
|
667
|
-
|
|
668
|
-
|
|
4346
|
+
"n";
|
|
4347
|
+
_deployments_dir =
|
|
4348
|
+
_get(
|
|
4349
|
+
"deployments",
|
|
4350
|
+
"dir");
|
|
4351
|
+
_target_contract =
|
|
4352
|
+
_get(
|
|
4353
|
+
"target",
|
|
4354
|
+
"contract");
|
|
4355
|
+
_msg_info(
|
|
4356
|
+
`Target app '${_target_app}'.`);
|
|
4357
|
+
_msg_info(
|
|
4358
|
+
`Target contract '${_target_contract}'.`);
|
|
4359
|
+
_contract_address =
|
|
4360
|
+
_get(
|
|
4361
|
+
"contract",
|
|
4362
|
+
"address");
|
|
669
4363
|
const
|
|
670
|
-
|
|
671
|
-
|
|
4364
|
+
_target_networks =
|
|
4365
|
+
_get(
|
|
4366
|
+
"target",
|
|
4367
|
+
"networks");
|
|
4368
|
+
const
|
|
4369
|
+
_deployments_dir_check_args = [
|
|
4370
|
+
_deployments_dir,
|
|
4371
|
+
_target_app,
|
|
672
4372
|
_user_defined
|
|
673
4373
|
];
|
|
4374
|
+
_msg =
|
|
4375
|
+
"Running '_deployments_dir_check' " +
|
|
4376
|
+
`with arguments:`;
|
|
4377
|
+
_msg_info(
|
|
4378
|
+
_msg);
|
|
4379
|
+
if ( _quiet == "n" ) {
|
|
4380
|
+
_echo(
|
|
4381
|
+
_deployments_dir_check_args);
|
|
4382
|
+
}
|
|
4383
|
+
try {
|
|
4384
|
+
_deployments_dir =
|
|
4385
|
+
await _deployments_dir_check.apply(
|
|
4386
|
+
null,
|
|
4387
|
+
_deployments_dir_check_args);
|
|
4388
|
+
}
|
|
4389
|
+
catch(
|
|
4390
|
+
_error) {
|
|
4391
|
+
_msg =
|
|
4392
|
+
"Error running '_deployments_dir_check' " +
|
|
4393
|
+
`with arguments:`;
|
|
4394
|
+
_msg_error(
|
|
4395
|
+
_msg,
|
|
4396
|
+
0);
|
|
4397
|
+
_echo2(
|
|
4398
|
+
_deployments_dir_check_args);
|
|
4399
|
+
_echo2(
|
|
4400
|
+
_error);
|
|
4401
|
+
throw _error;
|
|
4402
|
+
}
|
|
674
4403
|
const
|
|
675
|
-
|
|
676
|
-
|
|
4404
|
+
_target_contract_check_args = [
|
|
4405
|
+
_target_contract,
|
|
4406
|
+
_contract_address,
|
|
4407
|
+
_target_app,
|
|
4408
|
+
_deployments_dir
|
|
4409
|
+
];
|
|
4410
|
+
try {
|
|
4411
|
+
_target_contract =
|
|
4412
|
+
await _target_contract_check.apply(
|
|
677
4413
|
null,
|
|
678
|
-
|
|
679
|
-
if ( _dir_exists(
|
|
680
|
-
_target_dir) ) {
|
|
681
|
-
_app =
|
|
682
|
-
_dir_current_name;
|
|
4414
|
+
_target_contract_check_args);
|
|
683
4415
|
}
|
|
684
|
-
|
|
4416
|
+
catch(
|
|
4417
|
+
_error) {
|
|
685
4418
|
_msg =
|
|
686
|
-
|
|
687
|
-
"
|
|
688
|
-
|
|
689
|
-
|
|
4419
|
+
"Error running '_target_contract_check' " +
|
|
4420
|
+
"with parameters:";
|
|
4421
|
+
_echo2(
|
|
4422
|
+
_target_contract_check_args);
|
|
4423
|
+
_echo2(
|
|
4424
|
+
_error);
|
|
4425
|
+
throw _error;
|
|
690
4426
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
if ( _config_file.endsWith(
|
|
703
|
-
".sh") ) {
|
|
704
|
-
_configuration_format =
|
|
705
|
-
"bash";
|
|
4427
|
+
const
|
|
4428
|
+
_contract_address_check_args = [
|
|
4429
|
+
_contract_address,
|
|
4430
|
+
_deployments_dir,
|
|
4431
|
+
_target_app
|
|
4432
|
+
];
|
|
4433
|
+
try {
|
|
4434
|
+
_contract_address =
|
|
4435
|
+
await _contract_address_check.apply(
|
|
4436
|
+
null,
|
|
4437
|
+
_contract_address_check_args);
|
|
706
4438
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
"
|
|
4439
|
+
catch(
|
|
4440
|
+
_error) {
|
|
4441
|
+
_msg =
|
|
4442
|
+
"Error running '_contract_address_check' " +
|
|
4443
|
+
"with parameters:";
|
|
4444
|
+
_echo2(
|
|
4445
|
+
_contract_address_check_args);
|
|
4446
|
+
_echo2(
|
|
4447
|
+
_error);
|
|
4448
|
+
throw _error;
|
|
711
4449
|
}
|
|
712
|
-
|
|
713
|
-
|
|
4450
|
+
const
|
|
4451
|
+
_api_key =
|
|
4452
|
+
_get(
|
|
4453
|
+
"api",
|
|
4454
|
+
"key");
|
|
4455
|
+
_compiler_output =
|
|
4456
|
+
_get(
|
|
4457
|
+
"contract",
|
|
4458
|
+
"compiler_output");
|
|
4459
|
+
const
|
|
4460
|
+
_compiler_output_type =
|
|
4461
|
+
typeof(
|
|
4462
|
+
_compiler_output);
|
|
4463
|
+
_compiler_output_retrieve =
|
|
4464
|
+
false;
|
|
4465
|
+
if ( _compiler_output_type === "undefined" ) {
|
|
4466
|
+
_compiler_output_retrieve =
|
|
4467
|
+
true;
|
|
4468
|
+
}
|
|
4469
|
+
else if ( _compiler_output_type === "string" ) {
|
|
4470
|
+
if ( _compiler_output.length < 1 ) {
|
|
4471
|
+
_compiler_output_retrieve =
|
|
4472
|
+
true;
|
|
4473
|
+
}
|
|
4474
|
+
}
|
|
4475
|
+
if ( _compiler_output_retrieve ) {
|
|
4476
|
+
if ( 1 < _target_networks.length ) {
|
|
714
4477
|
_msg =
|
|
715
|
-
"
|
|
716
|
-
"
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
4478
|
+
"You can't currently retrieve " +
|
|
4479
|
+
"compiler output for more than a contract.";
|
|
4480
|
+
_msg_error(
|
|
4481
|
+
_msg,
|
|
4482
|
+
0);
|
|
4483
|
+
throw _msg;
|
|
4484
|
+
}
|
|
4485
|
+
else if ( 1 == _target_networks.length ) {
|
|
4486
|
+
const
|
|
4487
|
+
_network =
|
|
4488
|
+
_target_networks[
|
|
4489
|
+
0];
|
|
4490
|
+
_configuration_format =
|
|
4491
|
+
_configuration_format_check(
|
|
4492
|
+
_configuration_format);
|
|
4493
|
+
const
|
|
4494
|
+
_contract_compiler_output_check_args = [
|
|
4495
|
+
_compiler_output,
|
|
4496
|
+
_network,
|
|
4497
|
+
_contract_address,
|
|
4498
|
+
_api_key,
|
|
4499
|
+
_target_app,
|
|
4500
|
+
_target_contract,
|
|
4501
|
+
_configuration_format,
|
|
4502
|
+
_deployments_dir,
|
|
4503
|
+
_user_defined,
|
|
4504
|
+
true // local
|
|
4505
|
+
];
|
|
4506
|
+
_msg =
|
|
4507
|
+
"Running '_contract_compiler_output_check' with " +
|
|
4508
|
+
"parameters:";
|
|
4509
|
+
_msg_info(
|
|
4510
|
+
_msg);
|
|
4511
|
+
if ( _quiet == "n" ) {
|
|
4512
|
+
_echo(
|
|
4513
|
+
_contract_compiler_output_check_args);
|
|
4514
|
+
}
|
|
4515
|
+
try {
|
|
4516
|
+
_compiler_output =
|
|
4517
|
+
await _contract_compiler_output_check.apply(
|
|
4518
|
+
null,
|
|
4519
|
+
_contract_compiler_output_check_args);
|
|
4520
|
+
}
|
|
4521
|
+
catch(
|
|
4522
|
+
_error) {
|
|
4523
|
+
let
|
|
4524
|
+
_error_info;
|
|
4525
|
+
_msg =
|
|
4526
|
+
"Error running '_contract_compiler_output_check' with " +
|
|
4527
|
+
"parameters:";
|
|
4528
|
+
_error_info =
|
|
4529
|
+
false;
|
|
4530
|
+
const
|
|
4531
|
+
_contract_abi =
|
|
4532
|
+
_get(
|
|
4533
|
+
"contract",
|
|
4534
|
+
"abi");
|
|
4535
|
+
const
|
|
4536
|
+
_contract_bytecode =
|
|
4537
|
+
_get(
|
|
4538
|
+
"contract",
|
|
4539
|
+
"bytecode");
|
|
4540
|
+
const
|
|
4541
|
+
_contract_abi_type =
|
|
4542
|
+
typeof(
|
|
4543
|
+
_contract_abi);
|
|
4544
|
+
const
|
|
4545
|
+
_contract_bytecode_type =
|
|
4546
|
+
typeof(
|
|
4547
|
+
_contract_bytecode);
|
|
4548
|
+
if ( _contract_abi_type == "string" &&
|
|
4549
|
+
_contract_bytecode_type == "string" ) {
|
|
4550
|
+
if ( 0 < _contract_abi.length &&
|
|
4551
|
+
0 < _contract_bytecode.length ) {
|
|
4552
|
+
if ( _file_exists(
|
|
4553
|
+
_contract_abi) &&
|
|
4554
|
+
_file_exists(
|
|
4555
|
+
_contract_bytecode) ) {
|
|
4556
|
+
_error_info =
|
|
4557
|
+
true;
|
|
4558
|
+
}
|
|
4559
|
+
}
|
|
4560
|
+
}
|
|
4561
|
+
if ( _error_info ) {
|
|
4562
|
+
_msg_info(
|
|
4563
|
+
_msg);
|
|
4564
|
+
}
|
|
4565
|
+
else {
|
|
4566
|
+
_msg_error(
|
|
4567
|
+
_msg,
|
|
4568
|
+
0);
|
|
4569
|
+
_echo2(
|
|
4570
|
+
_contract_compiler_output_check_args);
|
|
4571
|
+
}
|
|
4572
|
+
throw _error;
|
|
4573
|
+
}
|
|
4574
|
+
}
|
|
4575
|
+
else {
|
|
4576
|
+
_msg =
|
|
4577
|
+
"You must currently select a network " +
|
|
4578
|
+
"to auto-detect the compiler output for " +
|
|
4579
|
+
"a libevm application contract.";
|
|
4580
|
+
_msg_error(
|
|
4581
|
+
_msg,
|
|
4582
|
+
0);
|
|
4583
|
+
throw _msg;
|
|
4584
|
+
}
|
|
722
4585
|
}
|
|
723
|
-
return _configuration_format;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
function
|
|
727
|
-
_configuration_format_auto_detect() {
|
|
728
|
-
const
|
|
729
|
-
_configuration_format =
|
|
730
|
-
_configuration_format_get(
|
|
731
|
-
config_file);
|
|
732
4586
|
_override_set(
|
|
733
|
-
"
|
|
734
|
-
"
|
|
735
|
-
|
|
4587
|
+
"contract",
|
|
4588
|
+
"compiler_output",
|
|
4589
|
+
_compiler_output);
|
|
736
4590
|
}
|
|
737
4591
|
|
|
738
4592
|
export {
|
|
4593
|
+
_app_check,
|
|
4594
|
+
_config_file_path_check,
|
|
739
4595
|
_configuration_format_auto_detect,
|
|
4596
|
+
_configuration_format_check,
|
|
740
4597
|
_configuration_format_get,
|
|
4598
|
+
_contract_abi_auto_detect,
|
|
4599
|
+
_contract_address_auto_detect,
|
|
4600
|
+
_contract_address_check,
|
|
4601
|
+
_contract_bytecode_auto_detect,
|
|
4602
|
+
_contract_bytecode_check,
|
|
4603
|
+
_contract_compiler_output_auto_detect,
|
|
4604
|
+
_contract_compiler_output_check,
|
|
741
4605
|
_contract_version_auto_detect,
|
|
4606
|
+
_default_artifact_path_get,
|
|
742
4607
|
_deployments_dir_auto_detect,
|
|
4608
|
+
_deployments_dir_check,
|
|
743
4609
|
_network_check,
|
|
744
4610
|
_networks_all_auto_detect,
|
|
745
4611
|
_target_app_auto_detect,
|
|
4612
|
+
_target_contract_auto_detect,
|
|
4613
|
+
_target_contract_check,
|
|
746
4614
|
_user_deployments_check,
|
|
4615
|
+
_user_defined_check,
|
|
4616
|
+
_user_level_check,
|
|
4617
|
+
_version_check
|
|
747
4618
|
};
|
|
748
4619
|
|
|
749
4620
|
// module.exports = {
|
|
4621
|
+
// _app_check:
|
|
4622
|
+
// _app_check,
|
|
4623
|
+
// _config_file_path_check:
|
|
4624
|
+
// _config_file_path_check,
|
|
750
4625
|
// _configuration_format_auto_detect:
|
|
751
4626
|
// _configuration_format_auto_detect,
|
|
4627
|
+
// _configuration_format_check:
|
|
4628
|
+
// _configuration_format_check,
|
|
752
4629
|
// _configuration_format_get:
|
|
753
4630
|
// _configuration_format_get,
|
|
4631
|
+
// _contract_abi_auto_detect:
|
|
4632
|
+
// _contract_abi_auto_detect,
|
|
4633
|
+
// _contract_abi_check:
|
|
4634
|
+
// _contract_abi_check,
|
|
4635
|
+
// _contract_address_auto_detect:
|
|
4636
|
+
// _contract_address_auto_detect,
|
|
4637
|
+
// _contract_address_check:
|
|
4638
|
+
// _contract_address_check,
|
|
4639
|
+
// _contract_bytecode_check:
|
|
4640
|
+
// _contract_bytecode_check,
|
|
4641
|
+
// _contract_bytecode_auto_detect:
|
|
4642
|
+
// _contract_bytecode_auto_detect,
|
|
4643
|
+
// _contract_compiler_output_auto_detect:
|
|
4644
|
+
// _contract_compiler_output_auto_detect,
|
|
4645
|
+
// _contract_compiler_output_check:
|
|
4646
|
+
// _contract_compiler_output_check,
|
|
754
4647
|
// _contract_version_auto_detect:
|
|
755
4648
|
// _contract_version_auto_detect,
|
|
4649
|
+
// _default_artifact_path_get:
|
|
4650
|
+
// _default_artifact_path_get,
|
|
4651
|
+
// _deployments_dir_check:
|
|
4652
|
+
// _deployments_dir_check,
|
|
756
4653
|
// _deployments_dir_auto_detect:
|
|
757
4654
|
// _deployments_dir_auto_detect,
|
|
758
4655
|
// _network_check:
|
|
@@ -761,6 +4658,16 @@ export {
|
|
|
761
4658
|
// _networks_all_auto_detect,
|
|
762
4659
|
// _target_app_auto_detect:
|
|
763
4660
|
// _target_app_auto_detect,
|
|
4661
|
+
// _target_contract_auto_detect:
|
|
4662
|
+
// _target_contract_auto_detect,
|
|
4663
|
+
// _target_contract_check:
|
|
4664
|
+
// _target_contract_check,
|
|
764
4665
|
// _user_deployments_check:
|
|
765
4666
|
// _user_deployments_check,
|
|
4667
|
+
// _user_defined_check:
|
|
4668
|
+
// _user_defined_check,
|
|
4669
|
+
// _user_level_check:
|
|
4670
|
+
// _user_level_check,
|
|
4671
|
+
// _version_check:
|
|
4672
|
+
// _version_check,
|
|
766
4673
|
// };
|