diff --git a/common/components/WalletDecrypt/components/LedgerNano.tsx b/common/components/WalletDecrypt/components/LedgerNano.tsx index 883780e4..c622e896 100644 --- a/common/components/WalletDecrypt/components/LedgerNano.tsx +++ b/common/components/WalletDecrypt/components/LedgerNano.tsx @@ -1,21 +1,22 @@ -import './LedgerNano.scss'; import React, { PureComponent } from 'react'; -import translate from 'translations'; -import DeterministicWalletsModal from './DeterministicWalletsModal'; -import { LedgerWallet } from 'libs/wallet'; import ledger from 'ledgerco'; +import translate, { translateRaw } from 'translations'; +import DeterministicWalletsModal from './DeterministicWalletsModal'; +import UnsupportedNetwork from './UnsupportedNetwork'; +import { LedgerWallet } from 'libs/wallet'; import { Spinner, NewTabLink } from 'components/ui'; import { connect } from 'react-redux'; import { AppState } from 'reducers'; import { SecureWalletName, ledgerReferralURL } from 'config'; import { getPaths, getSingleDPath } from 'selectors/config/wallet'; +import './LedgerNano.scss'; interface OwnProps { onUnlock(param: any): void; } interface StateProps { - dPath: DPath; + dPath: DPath | undefined; dPaths: DPath[]; } @@ -34,7 +35,7 @@ class LedgerNanoSDecryptClass extends PureComponent { public state: State = { publicKey: '', chainCode: '', - dPath: this.props.dPath.value, + dPath: this.props.dPath ? this.props.dPath.value : '', error: null, isLoading: false, showTip: false @@ -48,7 +49,7 @@ class LedgerNanoSDecryptClass extends PureComponent { public componentWillReceiveProps(nextProps: Props) { if (this.props.dPath !== nextProps.dPath) { - this.setState({ dPath: nextProps.dPath.value }); + this.setState({ dPath: nextProps.dPath ? nextProps.dPath.value : '' }); } } @@ -56,6 +57,10 @@ class LedgerNanoSDecryptClass extends PureComponent { const { dPath, publicKey, chainCode, error, isLoading, showTip } = this.state; const showErr = error ? 'is-showing' : ''; + if (!dPath) { + return ; + } + if (window.location.protocol !== 'https:') { return (
@@ -167,7 +172,7 @@ class LedgerNanoSDecryptClass extends PureComponent { this.setState({ publicKey: '', chainCode: '', - dPath: this.props.dPath.value + dPath: this.props.dPath ? this.props.dPath.value : '' }); } } diff --git a/common/components/WalletDecrypt/components/Mnemonic.tsx b/common/components/WalletDecrypt/components/Mnemonic.tsx index 62f5a2d3..e78314ad 100644 --- a/common/components/WalletDecrypt/components/Mnemonic.tsx +++ b/common/components/WalletDecrypt/components/Mnemonic.tsx @@ -155,7 +155,8 @@ class MnemonicDecryptClass extends PureComponent { function mapStateToProps(state: AppState): StateProps { return { - dPath: getSingleDPath(state, InsecureWalletName.MNEMONIC_PHRASE), + // Mnemonic dPath is guaranteed to always be provided + dPath: getSingleDPath(state, InsecureWalletName.MNEMONIC_PHRASE) as DPath, dPaths: getPaths(state, InsecureWalletName.MNEMONIC_PHRASE) }; } diff --git a/common/components/WalletDecrypt/components/Trezor.tsx b/common/components/WalletDecrypt/components/Trezor.tsx index 5070d168..90621f46 100644 --- a/common/components/WalletDecrypt/components/Trezor.tsx +++ b/common/components/WalletDecrypt/components/Trezor.tsx @@ -1,14 +1,15 @@ import { TrezorWallet, TREZOR_MINIMUM_FIRMWARE } from 'libs/wallet'; import React, { PureComponent } from 'react'; -import translate from 'translations'; +import translate, { translateRaw } from 'translations'; import TrezorConnect from 'vendor/trezor-connect'; import DeterministicWalletsModal from './DeterministicWalletsModal'; -import './Trezor.scss'; +import UnsupportedNetwork from './UnsupportedNetwork'; import { Spinner, NewTabLink } from 'components/ui'; import { AppState } from 'reducers'; import { connect } from 'react-redux'; import { SecureWalletName, trezorReferralURL } from 'config'; import { getSingleDPath, getPaths } from 'selectors/config/wallet'; +import './Trezor.scss'; //todo: conflicts with comment in walletDecrypt -> onUnlock method interface OwnProps { @@ -16,7 +17,7 @@ interface OwnProps { } interface StateProps { - dPath: DPath; + dPath: DPath | undefined; dPaths: DPath[]; } @@ -35,14 +36,14 @@ class TrezorDecryptClass extends PureComponent { public state: State = { publicKey: '', chainCode: '', - dPath: this.props.dPath.value, + dPath: this.props.dPath ? this.props.dPath.value : '', error: null, isLoading: false }; public componentWillReceiveProps(nextProps: Props) { if (this.props.dPath !== nextProps.dPath) { - this.setState({ dPath: nextProps.dPath.value }); + this.setState({ dPath: nextProps.dPath ? nextProps.dPath.value : '' }); } } @@ -50,6 +51,10 @@ class TrezorDecryptClass extends PureComponent { const { dPath, publicKey, chainCode, error, isLoading } = this.state; const showErr = error ? 'is-showing' : ''; + if (!dPath) { + return ; + } + return (