From 4fd3330e246e62e04dc22b0dafd987fc73102ab1 Mon Sep 17 00:00:00 2001 From: Daniel Ternyak Date: Thu, 28 Dec 2017 21:54:40 -0600 Subject: [PATCH] Attempt to unlock MetaMask onClick, and provide existing flow with notification when unlock fails. --- .../WalletDecrypt/WalletDecrypt.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/common/components/WalletDecrypt/WalletDecrypt.tsx b/common/components/WalletDecrypt/WalletDecrypt.tsx index e17b258254b..ca6d145b699 100644 --- a/common/components/WalletDecrypt/WalletDecrypt.tsx +++ b/common/components/WalletDecrypt/WalletDecrypt.tsx @@ -69,6 +69,7 @@ interface BaseWalletInfo { unlock: any; helpLink?: string; isReadOnly?: boolean; + attemptUnlock?: boolean; } export interface SecureWalletInfo extends BaseWalletInfo { @@ -105,6 +106,7 @@ export class WalletDecrypt extends Component { component: Web3Decrypt, initialParams: {}, unlock: this.props.unlockWeb3, + attemptUnlock: true, helpLink: `${knowledgeBaseURL}/migration/moving-from-private-key-to-metamask` }, 'ledger-nano-s': { @@ -282,10 +284,19 @@ export class WalletDecrypt extends Component { return; } - this.setState({ - selectedWalletKey: walletType, - value: wallet.initialParams - }); + let timeout = 0; + + if (wallet.attemptUnlock) { + timeout = 250; + wallet.unlock(); + } + + setTimeout(() => { + this.setState({ + selectedWalletKey: walletType, + value: wallet.initialParams + }); + }, timeout); }; public clearWalletChoice = () => {