evm-chains-info 0.0.11 → 0.0.13
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/evm-chains-info +11 -5
- package/evm-chains-info.js +1 -1
- package/libevm-chains-info +98 -54
- package/libevm-chains-info.js +1 -1
- package/package.json +2 -2
package/libevm-chains-info
CHANGED
|
@@ -158,10 +158,6 @@ function
|
|
|
158
158
|
const
|
|
159
159
|
_home_dir =
|
|
160
160
|
_homedir_get();
|
|
161
|
-
_msg =
|
|
162
|
-
`Home directory: '${_home_dir}'`;
|
|
163
|
-
_msg_info(
|
|
164
|
-
_msg);
|
|
165
161
|
_db_path =
|
|
166
162
|
_path_join(
|
|
167
163
|
[ _home_dir,
|
|
@@ -197,7 +193,10 @@ function
|
|
|
197
193
|
else if ( _user == "n" ) {
|
|
198
194
|
const
|
|
199
195
|
_lib =
|
|
200
|
-
|
|
196
|
+
_lib_get();
|
|
197
|
+
_msg =
|
|
198
|
+
`Found system libraries directory ` +
|
|
199
|
+
`'${_lib}'.`;
|
|
201
200
|
_db_path =
|
|
202
201
|
_path_join(
|
|
203
202
|
[ _lib,
|
|
@@ -225,11 +224,20 @@ function
|
|
|
225
224
|
let
|
|
226
225
|
_chain_info,
|
|
227
226
|
_data,
|
|
227
|
+
_db_type,
|
|
228
228
|
_msg;
|
|
229
|
+
if ( typeof(
|
|
230
|
+
_db_types) == "undefined" ||
|
|
231
|
+
_db_types == [] ) {
|
|
232
|
+
_db_types = [
|
|
233
|
+
"node",
|
|
234
|
+
"system"
|
|
235
|
+
];
|
|
236
|
+
}
|
|
229
237
|
if ( typeof(
|
|
230
238
|
_user_level) == "undefined" ) {
|
|
231
239
|
_user_level =
|
|
232
|
-
|
|
240
|
+
"n";
|
|
233
241
|
}
|
|
234
242
|
if ( typeof(
|
|
235
243
|
_format) == "undefined" ) {
|
|
@@ -244,14 +252,38 @@ function
|
|
|
244
252
|
_chain_id,
|
|
245
253
|
_format);
|
|
246
254
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
+
for ( _db_type of _db_types ) {
|
|
256
|
+
if ( _db_type == "system" ) {
|
|
257
|
+
const
|
|
258
|
+
_db_exists =
|
|
259
|
+
_file_exists(
|
|
260
|
+
_db_path);
|
|
261
|
+
const
|
|
262
|
+
_db =
|
|
263
|
+
_json_read(
|
|
264
|
+
_db_path);
|
|
265
|
+
_msg =
|
|
266
|
+
`Displaying data for ` +
|
|
267
|
+
`chain '${_chain_id}' `+
|
|
268
|
+
`of type '${_db_types}'.`;
|
|
269
|
+
_msg_info(
|
|
270
|
+
_msg);
|
|
271
|
+
for ( _chain_info of _db) {
|
|
272
|
+
if ( _chain_info["chainId"] == _chain_id ) {
|
|
273
|
+
return _chain_info;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
_msg =
|
|
277
|
+
`Network '${_chain_id}' not found.`;
|
|
278
|
+
_msg_error(
|
|
279
|
+
_msg,
|
|
280
|
+
1);
|
|
281
|
+
}
|
|
282
|
+
else if ( _db_type == "node" ) {
|
|
283
|
+
_msg =
|
|
284
|
+
`Getting data from 'ethereum-data' module.`;
|
|
285
|
+
_msg_info(
|
|
286
|
+
_msg);
|
|
255
287
|
_data =
|
|
256
288
|
_data_get(
|
|
257
289
|
_chain_id);
|
|
@@ -263,34 +295,13 @@ function
|
|
|
263
295
|
_msg);
|
|
264
296
|
console.log(
|
|
265
297
|
_data);
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
_db =
|
|
273
|
-
_json_read(
|
|
274
|
-
_db_path);
|
|
275
|
-
// _data =
|
|
276
|
-
// _data_get(
|
|
277
|
-
// _chain_id);
|
|
278
|
-
_msg =
|
|
279
|
-
`Displaying data for ` +
|
|
280
|
-
`chain '${_chain_id}' `+
|
|
281
|
-
`of type '${_db_types}'.`;
|
|
282
|
-
_msg_info(
|
|
283
|
-
_msg);
|
|
284
|
-
// console.log(
|
|
285
|
-
// _db);
|
|
286
|
-
for ( _chain_info of _db) {
|
|
287
|
-
if ( _chain_info["chainId"] == _chain_id ) {
|
|
288
|
-
return _chain_info;
|
|
298
|
+
for ( _chain_info of _data) {
|
|
299
|
+
if ( _chain_info["chainId"] == _chain_id ) {
|
|
300
|
+
return _chain_info;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
289
303
|
}
|
|
290
304
|
}
|
|
291
|
-
_msg_error(
|
|
292
|
-
`Network '${_chain_id}' not found.`,
|
|
293
|
-
1);
|
|
294
305
|
}
|
|
295
306
|
|
|
296
307
|
function
|
|
@@ -300,8 +311,11 @@ function
|
|
|
300
311
|
_db_path,
|
|
301
312
|
_user_level,
|
|
302
313
|
_db_types) {
|
|
314
|
+
let
|
|
315
|
+
_msg;
|
|
303
316
|
if ( typeof(
|
|
304
|
-
_network_chain_id) == "undefined"
|
|
317
|
+
_network_chain_id) == "undefined" ||
|
|
318
|
+
_network_chain_id == "" ) {
|
|
305
319
|
const
|
|
306
320
|
_msg =
|
|
307
321
|
"Network's ChainID not specified.";
|
|
@@ -310,15 +324,17 @@ function
|
|
|
310
324
|
1);
|
|
311
325
|
}
|
|
312
326
|
if ( typeof(
|
|
313
|
-
_selection_method) == "undefined"
|
|
327
|
+
_selection_method) == "undefined" ||
|
|
328
|
+
_selection_method == "" ) {
|
|
314
329
|
_selection_method =
|
|
315
330
|
"kirsh";
|
|
316
331
|
}
|
|
317
332
|
if ( typeof(
|
|
318
|
-
_db_path) == "undefined"
|
|
333
|
+
_db_path) == "undefined" ||
|
|
334
|
+
_db_path == "" ) {
|
|
319
335
|
_db_path =
|
|
320
336
|
_evm_chains_db_path_get(
|
|
321
|
-
|
|
337
|
+
"n");
|
|
322
338
|
}
|
|
323
339
|
if ( typeof(
|
|
324
340
|
_db_types) == "undefined" ) {
|
|
@@ -329,7 +345,7 @@ function
|
|
|
329
345
|
}
|
|
330
346
|
if ( _user_level == undefined ) {
|
|
331
347
|
_user_level =
|
|
332
|
-
|
|
348
|
+
"y";
|
|
333
349
|
}
|
|
334
350
|
const
|
|
335
351
|
_chain_id =
|
|
@@ -343,11 +359,15 @@ function
|
|
|
343
359
|
_user_level,
|
|
344
360
|
_db_types);
|
|
345
361
|
if ( _selection_method == "kirsh" ) {
|
|
346
|
-
return _chain_info[
|
|
362
|
+
return _chain_info[
|
|
363
|
+
"rpc"][
|
|
364
|
+
0];
|
|
347
365
|
}
|
|
348
366
|
else {
|
|
367
|
+
_msg =
|
|
368
|
+
"Unknown selection method.";
|
|
349
369
|
_msg_error(
|
|
350
|
-
|
|
370
|
+
_msg,
|
|
351
371
|
1);
|
|
352
372
|
}
|
|
353
373
|
}
|
|
@@ -367,7 +387,7 @@ function _rpc_backends_get(
|
|
|
367
387
|
if ( _db_path == undefined ) {
|
|
368
388
|
_db_path =
|
|
369
389
|
_evm_chains_db_path_get(
|
|
370
|
-
|
|
390
|
+
"n");
|
|
371
391
|
}
|
|
372
392
|
const
|
|
373
393
|
_rpcs =
|
|
@@ -544,15 +564,15 @@ function
|
|
|
544
564
|
_msg;
|
|
545
565
|
if ( user_level == "y" ) {
|
|
546
566
|
_type_primary =
|
|
547
|
-
|
|
567
|
+
"y";
|
|
548
568
|
_type_fallback =
|
|
549
|
-
|
|
569
|
+
"n";
|
|
550
570
|
}
|
|
551
571
|
else if ( user_level == "n" ) {
|
|
552
572
|
_type_primary =
|
|
553
|
-
|
|
573
|
+
"n";
|
|
554
574
|
_type_fallback =
|
|
555
|
-
|
|
575
|
+
"y";
|
|
556
576
|
}
|
|
557
577
|
const
|
|
558
578
|
_db =
|
|
@@ -609,6 +629,12 @@ function
|
|
|
609
629
|
_db) ) {
|
|
610
630
|
db_paths.push(
|
|
611
631
|
_db);
|
|
632
|
+
_msg =
|
|
633
|
+
`Found database ` +
|
|
634
|
+
`'${_db}', ` +
|
|
635
|
+
`adding.`;
|
|
636
|
+
_msg_info(
|
|
637
|
+
_msg);
|
|
612
638
|
}
|
|
613
639
|
else {
|
|
614
640
|
_msg =
|
|
@@ -622,6 +648,12 @@ function
|
|
|
622
648
|
_db_fallback_split) ) {
|
|
623
649
|
db_paths.push(
|
|
624
650
|
_db_fallback_split);
|
|
651
|
+
_msg =
|
|
652
|
+
`Found database ` +
|
|
653
|
+
`'${_db_fallback_split}', ` +
|
|
654
|
+
`adding.`;
|
|
655
|
+
_msg_info(
|
|
656
|
+
_msg);
|
|
625
657
|
}
|
|
626
658
|
else {
|
|
627
659
|
_msg =
|
|
@@ -635,15 +667,27 @@ function
|
|
|
635
667
|
_db_fallback) ) {
|
|
636
668
|
db_paths.push(
|
|
637
669
|
_db_fallback);
|
|
670
|
+
_msg =
|
|
671
|
+
`Found database ` +
|
|
672
|
+
`'${_db_fallback}', ` +
|
|
673
|
+
`adding.`;
|
|
674
|
+
_msg_info(
|
|
675
|
+
_msg);
|
|
638
676
|
}
|
|
639
677
|
else {
|
|
640
678
|
_msg =
|
|
641
679
|
`Fallback database ` +
|
|
642
680
|
`'${_db_fallback_split}' ` +
|
|
643
|
-
`not
|
|
681
|
+
`does not exist.`;
|
|
644
682
|
_msg_error(
|
|
645
683
|
_msg,
|
|
646
|
-
|
|
684
|
+
0);
|
|
685
|
+
}
|
|
686
|
+
if ( db_paths.length == 0 ) {
|
|
687
|
+
_msg =
|
|
688
|
+
"Found no databases!";
|
|
689
|
+
_msg_info(
|
|
690
|
+
_msg);
|
|
647
691
|
}
|
|
648
692
|
}
|
|
649
693
|
|