From fd7a71424f9cb17ea1cc51022e02d556f760f5c4 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Fri, 23 Nov 2018 17:23:51 +0300 Subject: [PATCH] Hide export private key option for HD wallet --- old-ui/app/account-detail.js | 2 ++ old-ui/app/components/account-dropdowns.js | 33 ++++++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/old-ui/app/account-detail.js b/old-ui/app/account-detail.js index b581df38f280..ecbdc1849c11 100644 --- a/old-ui/app/account-detail.js +++ b/old-ui/app/account-detail.js @@ -22,6 +22,7 @@ function mapStateToProps (state) { return { metamask: state.metamask, identities: state.metamask.identities, + keyrings: state.metamask.keyrings, accounts: state.metamask.accounts, address: state.metamask.selectedAddress, accountDetail: state.appState.accountDetail, @@ -147,6 +148,7 @@ AccountDetailScreen.prototype.render = function () { selected, network, identities: props.identities, + keyrings: props.keyrings, enableAccountOptions: true, }, ), diff --git a/old-ui/app/components/account-dropdowns.js b/old-ui/app/components/account-dropdowns.js index 5f452d93c73e..88d1f16e6888 100644 --- a/old-ui/app/components/account-dropdowns.js +++ b/old-ui/app/components/account-dropdowns.js @@ -32,12 +32,7 @@ class AccountDropdowns extends Component { } const isSelected = identity.address === selected - const simpleAddress = identity.address.substring(2).toLowerCase() - - const keyring = keyrings.find((kr) => { - return kr.accounts.includes(simpleAddress) || - kr.accounts.includes(identity.address) - }) + const keyring = this.getCurrentKeyring(address) return h( DropdownMenuItem, @@ -109,6 +104,26 @@ class AccountDropdowns extends Component { } catch (e) { return } } + ifHardwareAcc (address) { + const keyring = this.getCurrentKeyring(address) + if (keyring && keyring.type.search('Hardware') !== -1) { + return true + } + return false + } + + getCurrentKeyring (address) { + const { identities, keyrings } = this.props + const identity = identities[address] + const simpleAddress = identity.address.substring(2).toLowerCase() + const keyring = keyrings && keyrings.find((kr) => { + return kr.accounts.includes(simpleAddress) || + kr.accounts.includes(address) + }) + + return keyring + } + indicateIfLoose (keyring) { return this.ifLooseAcc(keyring) ? h('.keyring-label', 'IMPORTED') : null } @@ -199,7 +214,7 @@ class AccountDropdowns extends Component { } renderAccountOptions () { - const { actions } = this.props + const { actions, selected } = this.props const { optionsMenuActive } = this.state return h( @@ -259,7 +274,7 @@ class AccountDropdowns extends Component { }, 'Copy address to clipboard', ), - h( + !this.ifHardwareAcc(selected) ? h( DropdownMenuItem, { closeMenu: () => {}, @@ -268,7 +283,7 @@ class AccountDropdowns extends Component { }, }, 'Export Private Key', - ), + ) : null, ] ) }