libevm 0.0.16 → 0.0.21

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/libevm CHANGED
@@ -33,11 +33,17 @@ const
33
33
  _libcrash =
34
34
  require(
35
35
  'crash-js');
36
+ /* global
37
+ _homedir_get */
38
+ /* eslint-disable-next-line
39
+ no-global-assign */
40
+ _homedir_get =
41
+ _libcrash._homedir_get;
36
42
  /* global
37
43
  _msg_info */
38
44
  /* eslint-disable-next-line
39
45
  no-global-assign */
40
- _path_join =
46
+ _msg_info =
41
47
  _libcrash._msg_info;
42
48
  /* global
43
49
  _path_join */
@@ -228,12 +234,148 @@ function
228
234
  }
229
235
 
230
236
  function
231
- _wallet_path_get() {
237
+ _wallet_path_get(
238
+ _wallet_app,
239
+ _wallet_name,
240
+ _qr_support) {
241
+ let
242
+ _wallet_dir;
243
+ if ( typeof(
244
+ _wallet_app) == "undefined" ||
245
+ _wallet_app == "" ) {
246
+ _wallet_app =
247
+ "evm-wallet";
248
+ }
249
+ if ( typeof(
250
+ _wallet_name) == "undefined" ||
251
+ _wallet_name == "" ) {
252
+ _wallet_name =
253
+ "default";
254
+ }
255
+ if ( typeof(
256
+ _qr_support) == "undefined" ||
257
+ _qr_support == "" ) {
258
+ _qr_support =
259
+ "n";
260
+ }
261
+ const
262
+ _home =
263
+ _homedir_get();
264
+ _wallet_dir =
265
+ _path_join( [
266
+ _home,
267
+ ".config",
268
+ _wallet_app ]);
269
+ if ( _qr_support == "y" ) {
270
+ _wallet_dir =
271
+ _path_join( [
272
+ _wallet_dir,
273
+ "qr" ]);
274
+ }
275
+ const
276
+ _path =
277
+ _path_join( [
278
+ _wallet_dir,
279
+ `${_wallet_name}.dat` ]);
280
+ return _path;
281
+ }
282
+
283
+ function
284
+ _secret_path_get(
285
+ _secret,
286
+ _app,
287
+ _wallet_name,
288
+ _qr_support){
289
+ let
290
+ _config_dir;
291
+ if ( typeof(
292
+ _secret) == "undefined" ||
293
+ _secret == "" ) {
294
+ _secret =
295
+ "seed";
296
+ }
297
+ if ( typeof(
298
+ _app) == "undefined" ||
299
+ _app == "" ) {
300
+ _app =
301
+ "evm-wallet";
302
+ }
303
+ if ( typeof(
304
+ _wallet_name) == "undefined" ||
305
+ _wallet_name == "" ) {
306
+ _wallet_name =
307
+ "default";
308
+ }
309
+ if ( typeof(
310
+ _qr_support) == "undefined" ||
311
+ _qr_support == "" ) {
312
+ _qr_support =
313
+ "n";
314
+ }
315
+ _config_dir =
316
+ _path_join( [
317
+ _homedir_get(),
318
+ ".config",
319
+ _app ]);
320
+ if ( _qr_support == "y" ) {
321
+ _config_dir =
322
+ _path_join( [
323
+ _config_dir,
324
+ "qr" ]);
232
325
  }
326
+ const
327
+ _secret_path =
328
+ _path_join( [
329
+ _config_dir,
330
+ `${_wallet_name}-${_secret}.txt` ]);
331
+ return _secret_path;
332
+ }
233
333
 
234
334
  function
235
- _secret_auto_detect() {
236
- true;
335
+ _secret_get(
336
+ _secret,
337
+ _secret_type,
338
+ _wallet_app,
339
+ _wallet_name,
340
+ _qr_support) {
341
+ if ( typeof(
342
+ _secret) == "undefined" ||
343
+ _secret == "" ) {
344
+ _secret =
345
+ "seed";
346
+ }
347
+ if ( typeof(
348
+ _secret) == "undefined" ||
349
+ _secret == "" ) {
350
+ _secret_type =
351
+ "seed";
352
+ }
353
+ if ( typeof(
354
+ _wallet_app) == "undefined" ||
355
+ _wallet_app == "" ) {
356
+ _wallet_app =
357
+ "evm-wallet";
358
+ }
359
+ if ( typeof(
360
+ _wallet_name) == "undefined" ||
361
+ _wallet_name == "" ) {
362
+ _wallet_name =
363
+ "default";
364
+ }
365
+ if ( typeof(
366
+ _qr_support) == "undefined" ||
367
+ _qr_support == "" ) {
368
+ _qr_support =
369
+ "n";
370
+ }
371
+ const
372
+ _secret_path =
373
+ _secret_path_get(
374
+ _secret,
375
+ _wallet_app,
376
+ _wallet_name,
377
+ _qr_support);
378
+ return _secret_path;
237
379
  }
238
380
 
239
381
  function
@@ -289,6 +431,16 @@ function
289
431
  _argv[
290
432
  "api-key"];
291
433
  }
434
+ if ( "T" in _argv ) {
435
+ api_key =
436
+ _argv[
437
+ "T"];
438
+ }
439
+ if ( "call-timeout" in _argv ) {
440
+ call_timeout =
441
+ _argv[
442
+ "call-timeout"];
443
+ }
292
444
  if ( "n" in _argv ) {
293
445
  target_networks.push(
294
446
  _argv[
@@ -364,14 +516,14 @@ function
364
516
  0];
365
517
  }
366
518
 
367
-
368
- function
519
+ async function
369
520
  _wallet_overrides_set(
370
521
  _wallet_app,
371
522
  _wallet_name,
372
523
  _call_auth,
373
524
  _qr_support) {
374
525
  let
526
+ _msg,
375
527
  _wallet_address,
376
528
  _wallet_seed,
377
529
  _wallet_password,
@@ -409,23 +561,26 @@ function
409
561
  if ( _call_auth == "y" ) {
410
562
  // undefined
411
563
  _wallet_path =
412
- _wallet_path_get();
413
- // undefined
414
- _secret_auto_detect(
415
- "seed",
416
- "seed",
417
- _wallet_app,
418
- _wallet_name,
419
- _qr_support);
420
- // undefined
421
- _secret_auto_detect(
422
- "password",
423
- "plain",
424
- _wallet_app,
425
- _wallet_name,
426
- _qr_support);
564
+ _wallet_path_get(
565
+ _wallet_app,
566
+ _wallet_name,
567
+ _qr_support);
568
+ _wallet_seed =
569
+ _secret_get(
570
+ "seed",
571
+ "seed",
572
+ _wallet_app,
573
+ _wallet_name,
574
+ _qr_support);
575
+ _wallet_password =
576
+ _secret_get(
577
+ "password",
578
+ "plain",
579
+ _wallet_app,
580
+ _wallet_name,
581
+ _qr_support);
427
582
  _wallet_address =
428
- _address_get(
583
+ await _address_get(
429
584
  _wallet_seed,
430
585
  "", // _target_network,
431
586
  "", // _api_key,
@@ -433,12 +588,6 @@ function
433
588
  "", // _chain_name,
434
589
  "", // _output_file
435
590
  );
436
- // to be turned into _msg_debug
437
- const
438
- _msg =
439
- `Wallet address: '${_wallet_address}'`;
440
- _msg_info(
441
- _msg);
442
591
  }
443
592
  else if ( _call_auth == "n" ) {
444
593
  if ( typeof(
@@ -470,6 +619,14 @@ function
470
619
  wallet_address =
471
620
  _wallet_address;
472
621
  }
622
+ if ( typeof(
623
+ wallet_seed) == "undefined" ||
624
+ wallet_seed == "" ||
625
+ wallet_seed == [] ) {
626
+ wallet_seed =
627
+ _wallet_seed;
628
+ }
629
+ return true;
473
630
  }
474
631
 
475
632
  module.exports = {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name":
3
3
  "libevm",
4
4
  "version":
5
- "0.0.16",
5
+ "0.0.21",
6
6
  "description":
7
7
  "Library providing useful functions to write native applications interacting with EVM-compatible blockchain networks.",
8
8
  "funding": {
@@ -18,9 +18,8 @@
18
18
  "AUTHORS.rst",
19
19
  "COPYING",
20
20
  "README.md",
21
+ "dist",
21
22
  "libevm",
22
- "libevm.js",
23
- "fs-worker.js",
24
23
  "fs-worker.webpack.config.js",
25
24
  "index.html",
26
25
  "package.json",
@@ -75,11 +74,11 @@
75
74
  },
76
75
  "dependencies": {
77
76
  "crash-js":
78
- "^0.1.101",
77
+ "^0.1.107",
79
78
  "evm-chains-info":
80
- "^0.0.18",
79
+ "^0.0.21",
81
80
  "evm-wallet.js":
82
- "^0.0.31",
81
+ "^0.0.43",
83
82
  "yargs":
84
83
  "18.0.0"
85
84
  },
@@ -89,9 +88,9 @@
89
88
  "libevm",
90
89
  "scripts": {
91
90
  "build-fs-worker":
92
- "npx webpack --mode 'production' --config 'fs-worker.webpack.config.cjs' --stats-error-details",
91
+ "npx webpack --mode 'production' --config 'fs-worker.webpack.config.cjs' --stats-error-details && mkdir -p 'dist' && cp 'fs-worker.js' 'dist/libevm'",
93
92
  "build-lib":
94
- "npx webpack --mode 'production' --config 'webpack.config.cjs' --stats-error-details",
93
+ "npx webpack --mode 'production' --config 'webpack.config.cjs' --stats-error-details && mv 'libevm.js' 'dist/libevm'",
95
94
  "build":
96
95
  "npm run lint && npm run build-fs-worker && npm run build-lib",
97
96
  "lint":
@@ -99,7 +98,7 @@
99
98
  "publish-pnm":
100
99
  "npm run build && npm publish --access public",
101
100
  "start":
102
- "npx safely-serve --help # index.html --port 3000 --https --no-cache",
101
+ "npx safely-serve 'dist/libevm' --port 3000 --https --no-cache",
103
102
  "test":
104
103
  "echo \"Error: no test specified\" && exit 1"
105
104
  }
package/fs-worker.js DELETED
@@ -1 +0,0 @@
1
- (()=>{var e={816(e,o,n){function t(){let e;return"undefined"==typeof window&&void 0!==n.g&&n.g.global===n.g&&"function"!=typeof n||(e=function(){let e;try{e=n(816)}catch(e){console.log(e);const o="Error importing the '@themartiancompany/opfs' module as 'opfs'. If you got this error while bundling a webpack for a project depending on this module double check its 'webpack.config.js' file or whether the 'opfs' module is listed in developer dependencies and install them.I'm sorry for this inconvenience but Node packagement system does not currently distinguish 'development' from 'build' dependencies.";throw console.error(o),e}return e}()),e}const r=t();e.exports=r,e.exports.getModule=function(e){let o;if(""==_module_name||"undefined"==typeof _module_name)o=t();else if("opfs"==_module_name)o=n(816);else{if("fs"!=_module_name){const e="Unknown file system module "+`'${_module_name}'.`.const;throw _error={msg:e},console.error(e),_error}o=n(816)}return o}},314(e,o,n){const t=n(816);_sync_agent=t.startSyncAgent,e.exports={_sync_agent},_sync_agent()}},o={};function n(t){var r=o[t];if(void 0!==r)return r.exports;var s=o[t]={exports:{}};return e[t](s,s.exports,n),s.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n(314)})();