@yerofey/cryptowallet-cli 1.17.1 → 1.17.2
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/cli.js +6 -1
- package/package.json +1 -1
- package/src/utils.js +9 -5
package/cli.js
CHANGED
|
@@ -12,7 +12,12 @@ import Method from './src/Method.js';
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
// generate mnemonic string if no argument is passed or only the mnemonic length is passed
|
|
15
|
-
if (
|
|
15
|
+
if (
|
|
16
|
+
options.mnemonic &&
|
|
17
|
+
(options.mnemonic === true ||
|
|
18
|
+
options.mnemonic === '' ||
|
|
19
|
+
options.mnemonic.split(' ').length === 1)
|
|
20
|
+
) {
|
|
16
21
|
return new Method('mnemonic').init({ mnemonic: options.mnemonic });
|
|
17
22
|
}
|
|
18
23
|
|
package/package.json
CHANGED
package/src/utils.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { readdirSync, statSync } from 'node:fs';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
4
5
|
|
|
5
6
|
const log = console.log;
|
|
6
7
|
|
|
8
|
+
const dirname = (metaUrl) => {
|
|
9
|
+
const __filename = fileURLToPath(metaUrl);
|
|
10
|
+
const __dirname = path.dirname(__filename);
|
|
11
|
+
return __dirname;
|
|
12
|
+
};
|
|
13
|
+
|
|
7
14
|
const filesList = (dir) => {
|
|
8
15
|
return readdirSync(dir).reduce((list, file) => {
|
|
9
16
|
const name = path.join(dir, file);
|
|
@@ -29,12 +36,9 @@ const objectHasAllKeys = (obj, keysArray) =>
|
|
|
29
36
|
keysArray.every((item) => obj.hasOwnProperty(item));
|
|
30
37
|
|
|
31
38
|
let supportedChains = [];
|
|
32
|
-
|
|
33
|
-
const chainsFolder = `${path.dirname(
|
|
34
|
-
decodeURIComponent(import.meta.url)
|
|
35
|
-
)}/chains/`.replace('file://', '');
|
|
39
|
+
const chainsFolder = path.join(dirname(import.meta.url), 'chains');
|
|
36
40
|
supportedChains = filesList(chainsFolder).map((item) =>
|
|
37
|
-
item.replace(chainsFolder, '').replace('.json', '')
|
|
41
|
+
item.replace(chainsFolder, '').replace('.json', '').replace('/', '')
|
|
38
42
|
);
|
|
39
43
|
|
|
40
44
|
export { log, loadFile, loadJson, objectHasAllKeys, supportedChains };
|