@yerofey/cryptowallet-cli 1.6.2 → 1.7.1

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.
@@ -1,16 +1,8 @@
1
1
  {
2
- "title": "Polygon",
3
- "network": "EVM",
4
- "startsWith": "0x",
5
- "prefixTest": "[0-9a-fA-F]",
6
- "apps": [
7
- "metamask",
8
- "trustwallet"
9
- ],
10
- "flags": [
11
- "m",
12
- "n",
13
- "p",
14
- "s"
15
- ]
16
- }
2
+ "title": "Polygon",
3
+ "network": "EVM",
4
+ "startsWith": "0x",
5
+ "prefixTest": "[0-9a-fA-F]",
6
+ "apps": ["metamask", "trustwallet"],
7
+ "flags": ["m", "n", "p", "s"]
8
+ }
@@ -1,11 +1,8 @@
1
1
  {
2
- "title": "PeerCoin",
3
- "script": "coinkey",
4
- "startsWith": "P",
5
- "prefixTest": "(?![0OI])[1-9a-zA-Z]",
6
- "rareSymbols": "[1-9]",
7
- "flags": [
8
- "p",
9
- "s"
10
- ]
11
- }
2
+ "title": "PeerCoin",
3
+ "script": "coinkey",
4
+ "startsWith": "P",
5
+ "prefixTest": "(?![0OI])[1-9a-zA-Z]",
6
+ "rareSymbols": "[1-9]",
7
+ "flags": ["p", "s"]
8
+ }
@@ -1,11 +1,8 @@
1
1
  {
2
- "title": "Qtum",
3
- "script": "coinkey",
4
- "startsWith": "Q",
5
- "prefixTest": "(?![0OI])[1-9a-zA-Z]",
6
- "rareSymbols": "[1-9]",
7
- "flags": [
8
- "p",
9
- "s"
10
- ]
11
- }
2
+ "title": "Qtum",
3
+ "script": "coinkey",
4
+ "startsWith": "Q",
5
+ "prefixTest": "(?![0OI])[1-9a-zA-Z]",
6
+ "rareSymbols": "[1-9]",
7
+ "flags": ["p", "s"]
8
+ }
@@ -1,11 +1,8 @@
1
1
  {
2
- "title": "ReddCoin",
3
- "script": "coinkey",
4
- "startsWith": "R",
5
- "prefixTest": "(?![0OI])[1-9a-zA-Z]",
6
- "rareSymbols": "[1-9]",
7
- "flags": [
8
- "p",
9
- "s"
10
- ]
11
- }
2
+ "title": "ReddCoin",
3
+ "script": "coinkey",
4
+ "startsWith": "R",
5
+ "prefixTest": "(?![0OI])[1-9a-zA-Z]",
6
+ "rareSymbols": "[1-9]",
7
+ "flags": ["p", "s"]
8
+ }
@@ -1,14 +1,8 @@
1
1
  {
2
- "title": "Tron",
3
- "startsWith": "T",
4
- "prefixTest": "(?![0OI])[1-9a-zA-Z]",
5
- "rareSymbols": "[1-9a-z]",
6
- "apps": [
7
- "tronlink",
8
- "trustwallet"
9
- ],
10
- "flags": [
11
- "p",
12
- "s"
13
- ]
14
- }
2
+ "title": "Tron",
3
+ "startsWith": "T",
4
+ "prefixTest": "(?![0OI])[1-9a-zA-Z]",
5
+ "rareSymbols": "[1-9a-z]",
6
+ "apps": ["tronlink", "trustwallet"],
7
+ "flags": ["p", "s"]
8
+ }
@@ -1,11 +1,8 @@
1
1
  {
2
- "title": "Viacoin",
3
- "script": "coinkey",
4
- "startsWith": "V",
5
- "prefixTest": "(?![0OI])[1-9a-zA-Z]",
6
- "rareSymbols": "[1-9]",
7
- "flags": [
8
- "p",
9
- "s"
10
- ]
11
- }
2
+ "title": "Viacoin",
3
+ "script": "coinkey",
4
+ "startsWith": "V",
5
+ "prefixTest": "(?![0OI])[1-9a-zA-Z]",
6
+ "rareSymbols": "[1-9]",
7
+ "flags": ["p", "s"]
8
+ }
@@ -1,11 +1,8 @@
1
1
  {
2
- "title": "Vertcoin",
3
- "script": "coinkey",
4
- "startsWith": "V",
5
- "prefixTest": "(?![0OI])[1-9a-zA-Z]",
6
- "rareSymbols": "[1-9]",
7
- "flags": [
8
- "p",
9
- "s"
10
- ]
11
- }
2
+ "title": "Vertcoin",
3
+ "script": "coinkey",
4
+ "startsWith": "V",
5
+ "prefixTest": "(?![0OI])[1-9a-zA-Z]",
6
+ "rareSymbols": "[1-9]",
7
+ "flags": ["p", "s"]
8
+ }
@@ -1,10 +1,7 @@
1
1
  {
2
- "title": "Tezos",
3
- "startsWith": "tz1",
4
- "prefixTest": "(?![0OI])[1-9a-zA-Z]",
5
- "rareSymbols": "[1-9]",
6
- "flags": [
7
- "p",
8
- "s"
9
- ]
10
- }
2
+ "title": "Tezos",
3
+ "startsWith": "tz1",
4
+ "prefixTest": "(?![0OI])[1-9a-zA-Z]",
5
+ "rareSymbols": "[1-9]",
6
+ "flags": ["p", "s"]
7
+ }
@@ -1,11 +1,8 @@
1
1
  {
2
- "title": "Zcash",
3
- "script": "coinkey",
4
- "startsWith": "t1",
5
- "prefixTest": "(?![0OI])[1-9a-zA-Z]",
6
- "rareSymbols": "[1-9]",
7
- "flags": [
8
- "p",
9
- "s"
10
- ]
11
- }
2
+ "title": "Zcash",
3
+ "script": "coinkey",
4
+ "startsWith": "t1",
5
+ "prefixTest": "(?![0OI])[1-9a-zA-Z]",
6
+ "rareSymbols": "[1-9]",
7
+ "flags": ["p", "s"]
8
+ }
package/src/utils.js CHANGED
@@ -1,25 +1,51 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
1
+ import { readdirSync, statSync } from 'fs';
2
+ import { readFile } from 'fs/promises';
3
+ import {
4
+ join,
5
+ } from 'path';
4
6
  const log = console.log;
5
7
 
6
8
  const filesList = (dir) => {
7
- return fs.readdirSync(dir).reduce((list, file) => {
8
- const name = path.join(dir, file);
9
- const isDir = fs.statSync(name).isDirectory();
10
- return list.concat(isDir ? fileList(name) : [name]);
11
- }, []);
9
+ return readdirSync(dir).reduce((list, file) => {
10
+ const name = join(dir, file);
11
+ const isDir = statSync(name).isDirectory();
12
+ return list.concat(isDir ? filesList(name) : [name]);
13
+ }, []);
14
+ };
15
+
16
+ const loadFile = async (filename, defaultValue = {}) => {
17
+ try {
18
+ return await import(filename);
19
+ } catch (error) {
20
+ return defaultValue;
21
+ }
22
+ };
23
+
24
+ const loadJson = async (filename) => {
25
+ return JSON.parse(
26
+ await readFile(
27
+ new URL(filename, import.meta.url)
28
+ )
29
+ );
12
30
  }
13
31
 
14
- const objectHasAllKeys = (obj, keysArray) => keysArray.every(item => obj.hasOwnProperty(item));
32
+ const objectHasAllKeys = (obj, keysArray) =>
33
+ // eslint-disable-next-line no-prototype-builtins
34
+ keysArray.every((item) => obj.hasOwnProperty(item));
15
35
 
16
36
  let supportedChains = [];
17
- const chainsFolder = __dirname + '/chains/';
37
+ // eslint-disable-next-line no-undef
38
+ const chainsFolder = `${process.cwd()}/src/chains/`;
18
39
  filesList(chainsFolder).forEach((item) => {
19
- const name = item.replace(chainsFolder, '').replace('.json', '');
20
- supportedChains.push(name);
40
+ const name = item.replace(chainsFolder, '').replace('.json', '');
41
+ supportedChains.push(name);
21
42
  });
22
43
 
23
- module.exports.log = log;
24
- module.exports.objectHasAllKeys = objectHasAllKeys;
25
- module.exports.supportedChains = supportedChains;
44
+ const _log = log;
45
+ export { _log as log };
46
+ export { loadFile };
47
+ export { loadJson };
48
+ const _objectHasAllKeys = objectHasAllKeys;
49
+ export { _objectHasAllKeys as objectHasAllKeys };
50
+ const _supportedChains = supportedChains;
51
+ export { _supportedChains as supportedChains };