hodl-wallet 1.3.2 → 1.3.6

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 +29 -13
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -127,19 +127,35 @@ class Wallet {
127
127
  }
128
128
 
129
129
  if (accountAction === 'Create New Account') {
130
- const mnemonic = bip39.generateMnemonic();
131
- const seed = await bip39.mnemonicToSeed(mnemonic);
132
- const root = hdkey.fromMasterSeed(seed);
133
- const addrNode = root.derive("m/44'/60'/0'/0/0");
134
- const privateKey = addrNode.privateKey.toString('hex');
135
- this.account = this.web3.eth.accounts.privateKeyToAccount('0x' + privateKey);
136
- this.account.mnemonic = mnemonic;
130
+ const { createWithMnemonic } = await inquirer.prompt({
131
+ type: 'confirm',
132
+ name: 'createWithMnemonic',
133
+ message: 'Create account with mnemonic?',
134
+ default: true
135
+ });
136
+
137
+ let message = 'Do you want to display sensitive information (private key';
138
+ if (createWithMnemonic) {
139
+ const mnemonic = bip39.generateMnemonic();
140
+ const seed = await bip39.mnemonicToSeed(mnemonic);
141
+ const root = hdkey.fromMasterSeed(seed);
142
+ const addrNode = root.derive("m/44'/60'/0'/0/0");
143
+ const privateKey = addrNode.privateKey.toString('hex');
144
+ this.account = this.web3.eth.accounts.privateKeyToAccount('0x' + privateKey);
145
+ this.account.mnemonic = mnemonic;
146
+ message += ' and mnemonic';
147
+ } else {
148
+ this.account = this.web3.eth.accounts.create();
149
+ }
150
+
151
+ message += ')?';
152
+
137
153
  await this.db.secureSet('account', this.account);
138
154
 
139
155
  const { showSensitive } = await inquirer.prompt({
140
156
  type: 'confirm',
141
157
  name: 'showSensitive',
142
- message: 'Do you want to display sensitive information (private key and mnemonic)?',
158
+ message,
143
159
  default: false,
144
160
  });
145
161
 
@@ -323,10 +339,10 @@ class Wallet {
323
339
  }
324
340
 
325
341
  const receipt = await this.web3.eth.sendSignedTransaction(signedTx.rawTransaction);
326
- this.displayTransactionResult(address, token, amount, receipt);
342
+ this.displayTransactionResult(address, token, amount, receipt.transactionHash);
327
343
 
328
344
  // Add transaction to history
329
- this.addToTransactions(address, token, amount, receipt);
345
+ this.addToTransactions(address, token, amount, receipt.transactionHash);
330
346
 
331
347
  if (!addressBook.some(entry => entry.address === address)) {
332
348
  await this.addToAddressBook(address);
@@ -367,13 +383,13 @@ class Wallet {
367
383
  }).replace(/(\d{2})\/(\d{2})\/(\d{4})/, '$3-$2-$1').replace(",", "");
368
384
  }
369
385
 
370
- addToTransactions(recipient, token, amount, receipt) {
386
+ addToTransactions(recipient, token, amount, hash) {
371
387
  const transaction = {
372
388
  timestamp: new Date().toISOString(),
373
389
  recipient,
374
390
  token,
375
391
  amount,
376
- hash: receipt.transactionHash
392
+ hash
377
393
  };
378
394
  this.db.add('transactions', this.account.address, this.selectedNetwork.nativeToken, transaction);
379
395
  }
@@ -516,7 +532,7 @@ class Wallet {
516
532
  date,
517
533
  address,
518
534
  token,
519
- amount.toFixed(3)
535
+ parseFloat(amount).toFixed(3)
520
536
  ]);
521
537
  table.push([{ colSpan: 4, content: this.selectedNetwork.explorer + hash }]);
522
538
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hodl-wallet",
3
- "version": "1.3.2",
3
+ "version": "1.3.6",
4
4
  "description": "🧊 HODL Wallet - Fast CLI crypto wallet!",
5
5
  "author": "Martin Clasen",
6
6
  "repository": {