@yerofey/cryptowallet-cli 1.7.2 → 1.7.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yerofey/cryptowallet-cli",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "type": "module",
5
5
  "homepage": "https://github.com/yerofey/cryptowallet-cli",
6
6
  "author": "Yerofey S. <pm@yerofey.dev> (https://github.com/yerofey)",
package/src/Chain.js CHANGED
@@ -1,3 +1,4 @@
1
+ import path from 'node:path';
1
2
  import { loadJson } from './utils.js';
2
3
 
3
4
  class Chain {
@@ -8,7 +9,7 @@ class Chain {
8
9
 
9
10
  async init() {
10
11
  // eslint-disable-next-line no-undef
11
- const content = await loadJson(`${process.cwd()}/src/chains/${this.chain}.json`);
12
+ const content = await loadJson(`${path.dirname(import.meta.url)}/chains/${this.chain}.json`.replace('file://', ''));
12
13
  const data = (() => {
13
14
  if (content.formats !== undefined) {
14
15
  if (this.format != '' && this.format != content.defaultFormat) {
package/src/Method.js CHANGED
@@ -1,3 +1,4 @@
1
+ import path from 'node:path';
1
2
  import chalk from 'chalk';
2
3
  const {
3
4
  blue,
@@ -18,7 +19,7 @@ import {
18
19
  } from './utils.js';
19
20
  import { generateMnemonicString } from './Wallet.js';
20
21
  import CW from './CW.js';
21
- const pkg = await loadJson('./../package.json');
22
+ const pkg = await loadJson(`${path.dirname(import.meta.url)}/../package.json`.replace('file://', ''));
22
23
  // eslint-disable-next-line no-undef
23
24
  const _version = pkg['version'] || 0;
24
25
 
@@ -36,7 +37,7 @@ class Method {
36
37
  let cryptos = {};
37
38
  for (const val of supportedChains) {
38
39
  // eslint-disable-next-line no-undef
39
- const data = await loadJson(`${process.cwd()}/src/chains/${val}.json`);
40
+ const data = await loadJson(`${path.dirname(import.meta.url)}/chains/${val}.json`.replace('file://', ''));
40
41
 
41
42
  let title = data.title || '';
42
43
  if (title == '' || val == 'ERC') {
package/src/utils.js CHANGED
@@ -1,13 +1,12 @@
1
- import { readdirSync, statSync } from 'fs';
2
- import { readFile } from 'fs/promises';
3
- import {
4
- join,
5
- } from 'path';
1
+ import { readdirSync, statSync } from 'node:fs';
2
+ import { readFile } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+
6
5
  const log = console.log;
7
6
 
8
7
  const filesList = (dir) => {
9
8
  return readdirSync(dir).reduce((list, file) => {
10
- const name = join(dir, file);
9
+ const name = path.join(dir, file);
11
10
  const isDir = statSync(name).isDirectory();
12
11
  return list.concat(isDir ? filesList(name) : [name]);
13
12
  }, []);
@@ -35,7 +34,7 @@ const objectHasAllKeys = (obj, keysArray) =>
35
34
 
36
35
  let supportedChains = [];
37
36
  // eslint-disable-next-line no-undef
38
- const chainsFolder = `${process.cwd()}/src/chains/`;
37
+ const chainsFolder = `${path.dirname(import.meta.url)}/chains/`.replace('file://', '');
39
38
  filesList(chainsFolder).forEach((item) => {
40
39
  const name = item.replace(chainsFolder, '').replace('.json', '');
41
40
  supportedChains.push(name);