hodl-wallet 1.3.6 → 1.4.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 (2) hide show
  1. package/index.mjs +21 -17
  2. package/package.json +3 -3
package/index.mjs CHANGED
@@ -93,12 +93,12 @@ class Wallet {
93
93
  async loadAccount(forceReload = false) {
94
94
  let account = this.db.secureGet('account');
95
95
 
96
- const choices = ['Create New Account', 'Import Mnemonic (12 words)', 'Import private-key'];
96
+ const choices = ['Create New Account', 'Import Mnemonic (12 words)', 'Import Private-key'];
97
97
 
98
98
  if (forceReload) {
99
99
  choices.push('Export Account');
100
100
  choices.push('Switch Network');
101
- choices.push('Go back');
101
+ choices.push('Go Back');
102
102
  }
103
103
 
104
104
  if (!account || forceReload) {
@@ -109,7 +109,7 @@ class Wallet {
109
109
  choices,
110
110
  });
111
111
 
112
- if (accountAction === 'Go back') {
112
+ if (accountAction === 'Go Back') {
113
113
  return;
114
114
  }
115
115
 
@@ -166,7 +166,7 @@ class Wallet {
166
166
  }
167
167
  }
168
168
 
169
- if (accountAction === 'Import private-key') {
169
+ if (accountAction === 'Import Private-key') {
170
170
  const { privateKey } = await inquirer.prompt({
171
171
  type: 'password',
172
172
  name: 'privateKey',
@@ -289,16 +289,8 @@ class Wallet {
289
289
  }
290
290
 
291
291
  async transferFunds() {
292
- let addressBook = this.db.get('addressBook') || [];
293
-
294
- const { token } = await inquirer.prompt({
295
- type: 'list',
296
- name: 'token',
297
- message: 'Token to transfer:',
298
- choices: Object.keys(this.selectedNetwork.tokens),
299
- });
300
-
301
- const tokens = this.selectedNetwork.tokens;
292
+ const addressBook = this.db.get('addressBook') || [];
293
+ addressBook.push({ name: 'Go Back', address: '' });
302
294
 
303
295
  // Implement autocomplete for address book
304
296
  const { recipient } = await inquirer.prompt({
@@ -309,13 +301,27 @@ class Wallet {
309
301
  input = input || '';
310
302
  return addressBook
311
303
  .filter(entry => entry.name.toLowerCase().includes(input.toLowerCase()) || entry.address.toLowerCase().includes(input.toLowerCase()))
312
- .map(entry => ({ name: `${entry.name} (${entry.address})`, value: entry.address }))
304
+ .map(entry => ({
305
+ name: entry.address ? `${entry.name} (${entry.address})` : entry.name,
306
+ value: entry.address
307
+ }))
313
308
  .concat([{ name: input, value: input }]); // Add the input as a possible choice
314
309
  },
315
310
  });
316
311
 
312
+ if (!recipient) return;
313
+
317
314
  let address = recipient;
318
315
 
316
+ const { token } = await inquirer.prompt({
317
+ type: 'list',
318
+ name: 'token',
319
+ message: 'Token to transfer:',
320
+ choices: Object.keys(this.selectedNetwork.tokens),
321
+ });
322
+
323
+ const tokens = this.selectedNetwork.tokens;
324
+
319
325
  const { amount } = await inquirer.prompt({
320
326
  type: 'input',
321
327
  name: 'amount',
@@ -713,8 +719,6 @@ while (true) {
713
719
  }
714
720
  }
715
721
 
716
-
717
-
718
722
  process.on('SIGINT', () => {
719
723
  console.log('\n');
720
724
  process.exit();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hodl-wallet",
3
- "version": "1.3.6",
3
+ "version": "1.4.2",
4
4
  "description": "🧊 HODL Wallet - Fast CLI crypto wallet!",
5
5
  "author": "Martin Clasen",
6
6
  "repository": {
@@ -43,10 +43,10 @@
43
43
  "bip39": "^3.1.0",
44
44
  "cli-table3": "^0.6.5",
45
45
  "crypto-js": "^4.2.0",
46
- "deepbase": "^1.1.8",
46
+ "deepbase": "^1.2.2",
47
47
  "hdkey": "^2.1.0",
48
48
  "inquirer": "^9.3.7",
49
49
  "inquirer-autocomplete-prompt": "^3.0.1",
50
50
  "web3": "^4.13.0"
51
51
  }
52
- }
52
+ }