Skip to content

Commit

Permalink
Hide export private key option for HD wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
vbaranov committed Nov 23, 2018
1 parent ce217d5 commit fd7a714
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
2 changes: 2 additions & 0 deletions old-ui/app/account-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -147,6 +148,7 @@ AccountDetailScreen.prototype.render = function () {
selected,
network,
identities: props.identities,
keyrings: props.keyrings,
enableAccountOptions: true,
},
),
Expand Down
33 changes: 24 additions & 9 deletions old-ui/app/components/account-dropdowns.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -199,7 +214,7 @@ class AccountDropdowns extends Component {
}

renderAccountOptions () {
const { actions } = this.props
const { actions, selected } = this.props
const { optionsMenuActive } = this.state

return h(
Expand Down Expand Up @@ -259,7 +274,7 @@ class AccountDropdowns extends Component {
},
'Copy address to clipboard',
),
h(
!this.ifHardwareAcc(selected) ? h(
DropdownMenuItem,
{
closeMenu: () => {},
Expand All @@ -268,7 +283,7 @@ class AccountDropdowns extends Component {
},
},
'Export Private Key',
),
) : null,
]
)
}
Expand Down

0 comments on commit fd7a714

Please sign in to comment.