hodl-wallet 1.2.6 → 1.3.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.
Files changed (3) hide show
  1. package/index.mjs +11 -5
  2. package/package.json +1 -1
  3. package/persist.js +3 -3
package/index.mjs CHANGED
@@ -10,6 +10,7 @@ import { dirname } from 'path';
10
10
  import Table from 'cli-table3';
11
11
  import bip39 from 'bip39';
12
12
  import hdkey from 'hdkey';
13
+ import os from 'os';
13
14
 
14
15
  const __filename = fileURLToPath(import.meta.url);
15
16
  const __dirname = dirname(__filename);
@@ -19,7 +20,13 @@ inquirer.registerPrompt('autocomplete', inquirerAutocomplete);
19
20
 
20
21
  class Wallet {
21
22
  constructor(encryptionKey) {
22
- this.db = new Persist(encryptionKey);
23
+ const hodlDir = path.join(os.homedir(), '.HODL');
24
+
25
+ if (!fs.existsSync(hodlDir)) {
26
+ fs.mkdirSync(hodlDir, { recursive: true });
27
+ }
28
+
29
+ this.db = new Persist({ path: hodlDir, encryptionKey });
23
30
  this.web3 = null;
24
31
  this.selectedNetwork = null;
25
32
  this.account = null;
@@ -263,7 +270,6 @@ class Wallet {
263
270
  }
264
271
 
265
272
  console.log(table.toString());
266
- console.log('');
267
273
  }
268
274
 
269
275
  async transferFunds() {
@@ -411,7 +417,7 @@ class Wallet {
411
417
  });
412
418
 
413
419
  table.push([name, address]);
414
- console.log('\n' + table.toString());
420
+ console.log(table.toString());
415
421
  }
416
422
  }
417
423
 
@@ -514,7 +520,7 @@ class Wallet {
514
520
  ]);
515
521
  table.push([{ colSpan: 4, content: this.selectedNetwork.explorer + hash }]);
516
522
 
517
- console.log('\n' + table.toString());
523
+ console.log(table.toString());
518
524
  }
519
525
 
520
526
  clearAccountData() {
@@ -545,7 +551,7 @@ class Wallet {
545
551
  table.push(['WARNING', "Please keep your private-key secure. Never share it."]);
546
552
  }
547
553
 
548
- console.log('\n' + table.toString());
554
+ console.log(table.toString());
549
555
  }
550
556
 
551
557
  async switchNetwork() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hodl-wallet",
3
- "version": "1.2.6",
3
+ "version": "1.3.2",
4
4
  "description": "🧊 HODL Wallet - Fast CLI crypto wallet!",
5
5
  "author": "Martin Clasen",
6
6
  "repository": {
package/persist.js CHANGED
@@ -3,9 +3,9 @@ const Deepbase = require('deepbase');
3
3
  const CryptoJS = require('crypto-js');
4
4
 
5
5
  class Persist extends Deepbase {
6
- constructor(encryptionKey) {
7
- super();
8
- this.encryptionKey = encryptionKey;
6
+ constructor(opts) {
7
+ super(opts);
8
+ this.encryptionKey = opts.encryptionKey;
9
9
  }
10
10
 
11
11
  encrypt(data) {