Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Feature) Hide export private key option for HD wallet #205

Merged
merged 1 commit into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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