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.
- package/index.mjs +11 -5
- package/package.json +1 -1
- 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
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
554
|
+
console.log(table.toString());
|
|
549
555
|
}
|
|
550
556
|
|
|
551
557
|
async switchNetwork() {
|
package/package.json
CHANGED
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(
|
|
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) {
|