From 72837414fd55e779dd67a39a740d1dfdae8ba355 Mon Sep 17 00:00:00 2001 From: elaineo Date: Mon, 11 Sep 2017 10:26:56 -0700 Subject: [PATCH 1/3] components/wallet/open: hide pw --- src/components/wallet/open.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/wallet/open.js b/src/components/wallet/open.js index 484019b..6d0d821 100644 --- a/src/components/wallet/open.js +++ b/src/components/wallet/open.js @@ -145,8 +145,9 @@ class WalletForm extends React.Component { controlId="password" > From 453f288984e35ce16220fc87d81ccb1fb5a938d5 Mon Sep 17 00:00:00 2001 From: elaineo Date: Mon, 11 Sep 2017 10:45:21 -0700 Subject: [PATCH 2/3] components/wallet/open: error handling --- src/components/wallet/open.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/wallet/open.js b/src/components/wallet/open.js index 6d0d821..f50f252 100644 --- a/src/components/wallet/open.js +++ b/src/components/wallet/open.js @@ -40,20 +40,21 @@ class WalletForm extends React.Component { if (this.state.showTextKey) this.props.openWallet(this.state.privKey, this.state.password) .then((result) => { - if (typeof result === 'object') + if (!result instanceof Error) { this.setState({ showBalance: true }); - else + this.resetState(); + } else this.setState({ error: result }); }); else if (this.state.showRequirePass && this.state.showFileKey) this.props.openWalletFile(this.state.file, this.state.password) .then((result) => { - if (typeof result === 'object') + if (!result instanceof Error) { this.setState({ showBalance: true }); - else - this.setState({ error: result }); + this.resetState(); + } else + this.setState({ error: result.toString() }); }); - this.resetState(); } closeWallet = () => { From f6477e0532c55d1c6597ad44449a8e193995c816 Mon Sep 17 00:00:00 2001 From: elaineo Date: Mon, 11 Sep 2017 10:45:31 -0700 Subject: [PATCH 3/3] store/walletActions: catch file error --- src/store/walletActions.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/store/walletActions.js b/src/store/walletActions.js index d81b6b7..ccf7588 100644 --- a/src/store/walletActions.js +++ b/src/store/walletActions.js @@ -33,7 +33,12 @@ export function openWallet(key, password = null) { export function openWalletFile(file, password = null) { return (dispatch) => { - const wallet = Wallet.getWalletFromPrivKeyFile(file, password); + let wallet; + try { // TODO: Better error handling here + wallet = Wallet.getWalletFromPrivKeyFile(file, password); + } catch (e) { + return new Error(e); + } const address = wallet.getAddressString(); dispatch({ type: 'WALLET/OPEN',