diff --git a/package-lock.json b/package-lock.json index a617bdc..2d53dcf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,7 +1,7 @@ { "name": "nault", - "version": "1.17.0", - "lockfileVersion": 2, + "version": "1.18.0", + "lockfileVersion": 1, "requires": true, "packages": { "": { diff --git a/package.json b/package.json index 9213e92..b60455c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nault", - "version": "1.17.0", + "version": "1.18.0", "license": "MIT", "description": "Wallet for interacting with nano", "author": "The Nano Community / Andrew Steele", diff --git a/src/app/components/account-details/account-details.component.ts b/src/app/components/account-details/account-details.component.ts index 92903ca..211f46e 100644 --- a/src/app/components/account-details/account-details.component.ts +++ b/src/app/components/account-details/account-details.component.ts @@ -957,9 +957,14 @@ export class AccountDetailsComponent implements OnInit, OnDestroy { async receiveReceivableBlock(receivableBlock) { const sourceBlock = receivableBlock.hash; - if (this.wallet.walletIsLocked()) { - return this.notifications.sendWarning(`Wallet must be unlocked`); + if (this.wallet.isLocked()) { + const wasUnlocked = await this.wallet.requestWalletUnlock(); + + if (wasUnlocked === false) { + return; + } } + receivableBlock.loading = true; const createdReceiveBlockHash = diff --git a/src/app/components/accounts/accounts.component.ts b/src/app/components/accounts/accounts.component.ts index a525adf..a4cde15 100644 --- a/src/app/components/accounts/accounts.component.ts +++ b/src/app/components/accounts/accounts.component.ts @@ -48,8 +48,13 @@ export class AccountsComponent implements OnInit { async createAccount() { if (this.walletService.isLocked()) { - return this.notificationService.sendError(this.translocoService.translate('accounts.wallet-is-locked')); + const wasUnlocked = await this.walletService.requestWalletUnlock(); + + if (wasUnlocked === false) { + return; + } } + if ((this.isLedgerWallet) && (this.ledger.ledger.status !== LedgerStatus.READY)) { return this.notificationService.sendWarning(this.translocoService.translate('accounts.ledger-device-must-be-ready')); } @@ -113,9 +118,14 @@ export class AccountsComponent implements OnInit { } async deleteAccount(account) { - if (this.walletService.walletIsLocked()) { - return this.notificationService.sendWarning(this.translocoService.translate('accounts.wallet-is-locked')); + if (this.walletService.isLocked()) { + const wasUnlocked = await this.walletService.requestWalletUnlock(); + + if (wasUnlocked === false) { + return; + } } + try { await this.walletService.removeWalletAccount(account.id); this.notificationService.sendSuccess( diff --git a/src/app/components/manage-wallet/manage-wallet.component.ts b/src/app/components/manage-wallet/manage-wallet.component.ts index 31f0a19..e106598 100644 --- a/src/app/components/manage-wallet/manage-wallet.component.ts +++ b/src/app/components/manage-wallet/manage-wallet.component.ts @@ -73,8 +73,12 @@ export class ManageWalletComponent implements OnInit { if (this.newPassword.length < 1) { return this.notifications.sendError(`Password cannot be empty`); } - if (this.walletService.walletIsLocked()) { - return this.notifications.sendWarning(`Wallet must be unlocked`); + if (this.walletService.isLocked()) { + const wasUnlocked = await this.walletService.requestWalletUnlock(); + + if (wasUnlocked === false) { + return; + } } this.walletService.wallet.password = this.newPassword; @@ -88,8 +92,12 @@ export class ManageWalletComponent implements OnInit { } async exportWallet() { - if (this.walletService.walletIsLocked()) { - return this.notifications.sendWarning(`Wallet must be unlocked`); + if (this.walletService.isLocked()) { + const wasUnlocked = await this.walletService.requestWalletUnlock(); + + if (wasUnlocked === false) { + return; + } } const exportUrl = this.walletService.generateExportUrl(); @@ -174,9 +182,13 @@ export class ManageWalletComponent implements OnInit { } } - exportToFile() { - if (this.walletService.walletIsLocked()) { - return this.notifications.sendWarning(`Wallet must be unlocked`); + async exportToFile() { + if (this.walletService.isLocked()) { + const wasUnlocked = await this.walletService.requestWalletUnlock(); + + if (wasUnlocked === false) { + return; + } } const fileName = `Nault-Wallet.json`; diff --git a/src/app/components/receive/receive.component.ts b/src/app/components/receive/receive.component.ts index dcdc683..352f859 100644 --- a/src/app/components/receive/receive.component.ts +++ b/src/app/components/receive/receive.component.ts @@ -311,8 +311,12 @@ export class ReceiveComponent implements OnInit, OnDestroy { throw new Error(`Unable to find receiving account in wallet`); } - if (this.walletService.walletIsLocked()) { - return this.notificationService.sendWarning(`Wallet must be unlocked`); + if (this.walletService.isLocked()) { + const wasUnlocked = await this.walletService.requestWalletUnlock(); + + if (wasUnlocked === false) { + return; + } } receivableBlock.loading = true; diff --git a/src/app/components/representatives/representatives.component.ts b/src/app/components/representatives/representatives.component.ts index 991eb0a..f8248d7 100644 --- a/src/app/components/representatives/representatives.component.ts +++ b/src/app/components/representatives/representatives.component.ts @@ -287,8 +287,12 @@ export class RepresentativesComponent implements OnInit { if (this.changingRepresentatives) { return; // Already running } - if (this.walletService.walletIsLocked()) { - return this.notifications.sendWarning(`Wallet must be unlocked`); + if (this.walletService.isLocked()) { + const wasUnlocked = await this.walletService.requestWalletUnlock(); + + if (wasUnlocked === false) { + return; + } } if (!accounts || !accounts.length) { return this.notifications.sendWarning(`You must select at least one account to change`); diff --git a/src/app/components/send/send.component.ts b/src/app/components/send/send.component.ts index 516dc2d..a6d5e7b 100644 --- a/src/app/components/send/send.component.ts +++ b/src/app/components/send/send.component.ts @@ -358,8 +358,12 @@ export class SendComponent implements OnInit { if (!walletAccount) { throw new Error(`Unable to find sending account in wallet`); } - if (this.walletService.walletIsLocked()) { - return this.notificationService.sendWarning(`Wallet must be unlocked`); + if (this.walletService.isLocked()) { + const wasUnlocked = await this.walletService.requestWalletUnlock(); + + if (wasUnlocked === false) { + return; + } } this.confirmingTransaction = true; diff --git a/src/app/components/sign/sign.component.ts b/src/app/components/sign/sign.component.ts index 0d8063b..2417888 100644 --- a/src/app/components/sign/sign.component.ts +++ b/src/app/components/sign/sign.component.ts @@ -453,8 +453,12 @@ export class SignComponent implements OnInit { // using internal wallet if (this.signTypeSelected === this.signTypes[0] && walletAccount) { - if (this.walletService.walletIsLocked()) { - return this.notificationService.sendWarning('Wallet must be unlocked for signing with it'); + if (this.walletService.isLocked()) { + const wasUnlocked = await this.walletService.requestWalletUnlock(); + + if (wasUnlocked === false) { + return; + } } } else if (this.signTypeSelected === this.signTypes[0]) { return this.notificationService.sendWarning('Could not find a matching wallet account to sign with. Make sure it\'s added under your accounts'); diff --git a/src/app/components/wallet-widget/wallet-widget.component.html b/src/app/components/wallet-widget/wallet-widget.component.html index a64d84d..c112700 100644 --- a/src/app/components/wallet-widget/wallet-widget.component.html +++ b/src/app/components/wallet-widget/wallet-widget.component.html @@ -65,7 +65,7 @@ -
+