Fixed conflict
This commit is contained in:
commit
ec5fac99f3
13 changed files with 138 additions and 35 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "nault",
|
||||
"version": "1.17.0",
|
||||
"lockfileVersion": 2,
|
||||
"version": "1.18.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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`;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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`);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@
|
|||
</div>
|
||||
</a>
|
||||
|
||||
<div id="unlock-wallet-modal" uk-modal>
|
||||
<div class="modal-position-bottom" id="unlock-wallet-modal" uk-modal>
|
||||
<div class="uk-modal-dialog">
|
||||
<button class="uk-modal-close-default" type="button" uk-close></button>
|
||||
<div class="uk-modal-header">
|
||||
|
|
|
|||
|
|
@ -37,11 +37,15 @@ export class WalletWidgetComponent implements OnInit {
|
|||
ngOnInit() {
|
||||
const UIkit = (window as any).UIkit;
|
||||
const modal = UIkit.modal(document.getElementById('unlock-wallet-modal'));
|
||||
UIkit.util.on('#unlock-wallet-modal', 'hidden', () => {
|
||||
this.onModalHidden();
|
||||
});
|
||||
this.modal = modal;
|
||||
|
||||
this.ledgerService.ledgerStatus$.subscribe((ledgerStatus) => {
|
||||
this.ledgerStatus = ledgerStatus;
|
||||
});
|
||||
|
||||
// Detect if a PoW is taking too long and alert
|
||||
this.powService.powAlert$.subscribe(async shouldAlert => {
|
||||
if (shouldAlert) {
|
||||
|
|
@ -50,6 +54,12 @@ export class WalletWidgetComponent implements OnInit {
|
|||
this.powAlert = false;
|
||||
}
|
||||
});
|
||||
|
||||
this.walletService.wallet.unlockModalRequested$.subscribe(async wasRequested => {
|
||||
if (wasRequested === true) {
|
||||
this.showModal();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
showModal() {
|
||||
|
|
@ -57,6 +67,11 @@ export class WalletWidgetComponent implements OnInit {
|
|||
this.modal.show();
|
||||
}
|
||||
|
||||
onModalHidden() {
|
||||
this.unlockPassword = '';
|
||||
this.walletService.wallet.unlockModalRequested$.next(false);
|
||||
}
|
||||
|
||||
async lockWallet() {
|
||||
if (this.wallet.type === 'ledger') {
|
||||
return; // No need to lock a ledger wallet, no password saved
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ export interface FullWallet {
|
|||
selectedAccount: WalletAccount|null;
|
||||
selectedAccount$: BehaviorSubject<WalletAccount|null>;
|
||||
locked: boolean;
|
||||
locked$: BehaviorSubject<boolean|false>;
|
||||
unlockModalRequested$: BehaviorSubject<boolean|false>;
|
||||
password: string;
|
||||
pendingBlocks: Block[];
|
||||
pendingBlocksUpdate$: BehaviorSubject<ReceivableBlockUpdate|null>;
|
||||
|
|
@ -111,6 +113,8 @@ export class WalletService {
|
|||
selectedAccount: null,
|
||||
selectedAccount$: new BehaviorSubject(null),
|
||||
locked: false,
|
||||
locked$: new BehaviorSubject(false),
|
||||
unlockModalRequested$: new BehaviorSubject(false),
|
||||
password: '',
|
||||
pendingBlocks: [],
|
||||
pendingBlocksUpdate$: new BehaviorSubject(null),
|
||||
|
|
@ -315,6 +319,7 @@ export class WalletService {
|
|||
this.wallet.seed = walletJson.seed;
|
||||
this.wallet.seedBytes = this.util.hex.toUint8(walletJson.seed);
|
||||
this.wallet.locked = true;
|
||||
this.wallet.locked$.next(true);
|
||||
}
|
||||
if (walletType === 'ledger') {
|
||||
// Check ledger status?
|
||||
|
|
@ -409,6 +414,7 @@ export class WalletService {
|
|||
});
|
||||
|
||||
this.wallet.locked = true;
|
||||
this.wallet.locked$.next(true);
|
||||
this.wallet.password = '';
|
||||
|
||||
this.saveWalletExport(); // Save so that a refresh gives you a locked wallet
|
||||
|
|
@ -433,6 +439,7 @@ export class WalletService {
|
|||
});
|
||||
|
||||
this.wallet.locked = false;
|
||||
this.wallet.locked$.next(false);
|
||||
this.wallet.password = password;
|
||||
|
||||
this.notifications.removeNotification('pending-locked'); // If there is a notification to unlock, remove it
|
||||
|
|
@ -448,10 +455,6 @@ export class WalletService {
|
|||
}
|
||||
}
|
||||
|
||||
walletIsLocked() {
|
||||
return this.wallet.locked;
|
||||
}
|
||||
|
||||
async createWalletFromSeed(seed: string) {
|
||||
this.resetWallet();
|
||||
|
||||
|
|
@ -632,6 +635,7 @@ export class WalletService {
|
|||
this.wallet.type = 'seed';
|
||||
this.wallet.password = '';
|
||||
this.wallet.locked = false;
|
||||
this.wallet.locked$.next(false);
|
||||
this.wallet.seed = '';
|
||||
this.wallet.seedBytes = null;
|
||||
this.wallet.accounts = [];
|
||||
|
|
@ -1109,4 +1113,45 @@ export class WalletService {
|
|||
this.wallet.refresh$.next(true);
|
||||
this.wallet.refresh$.next(false);
|
||||
}
|
||||
|
||||
requestWalletUnlock() {
|
||||
this.wallet.unlockModalRequested$.next(true);
|
||||
|
||||
return new Promise(
|
||||
(resolve, reject) => {
|
||||
let subscriptionForUnlock;
|
||||
let subscriptionForCancel;
|
||||
|
||||
const removeSubscriptions = () => {
|
||||
if (subscriptionForUnlock != null) {
|
||||
subscriptionForUnlock.unsubscribe();
|
||||
}
|
||||
|
||||
if (subscriptionForCancel != null) {
|
||||
subscriptionForCancel.unsubscribe();
|
||||
}
|
||||
};
|
||||
|
||||
subscriptionForUnlock =
|
||||
this.wallet.locked$.subscribe(async isLocked => {
|
||||
if (isLocked === false) {
|
||||
removeSubscriptions();
|
||||
|
||||
const wasUnlocked = true;
|
||||
resolve(wasUnlocked);
|
||||
}
|
||||
});
|
||||
|
||||
subscriptionForCancel =
|
||||
this.wallet.unlockModalRequested$.subscribe(async wasRequested => {
|
||||
if (wasRequested === false) {
|
||||
removeSubscriptions();
|
||||
|
||||
const wasUnlocked = false;
|
||||
resolve(wasUnlocked);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -489,6 +489,13 @@ input[type=number] {
|
|||
.uk-tooltip {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
// Menu modal
|
||||
.modal-position-bottom[style*="display: block;"] {
|
||||
display: flex !important;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 940px) {
|
||||
|
|
@ -497,13 +504,6 @@ input[type=number] {
|
|||
}
|
||||
}
|
||||
|
||||
// Menu modal
|
||||
.modal-position-bottom[style*="display: block;"] {
|
||||
display: flex !important;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.uk-modal {
|
||||
.transaction {
|
||||
padding-left: 0 !important;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue