mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Clear warnings when exportAccount succeeds
This commit is contained in:
parent
456f2faf4f
commit
743c6e7ca4
@ -1,3 +1,4 @@
|
|||||||
|
const log = require('loglevel')
|
||||||
const Component = require('react').Component
|
const Component = require('react').Component
|
||||||
const PropTypes = require('prop-types')
|
const PropTypes = require('prop-types')
|
||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
@ -23,7 +24,13 @@ function mapStateToProps (state) {
|
|||||||
|
|
||||||
function mapDispatchToProps (dispatch) {
|
function mapDispatchToProps (dispatch) {
|
||||||
return {
|
return {
|
||||||
exportAccount: (password, address) => dispatch(actions.exportAccount(password, address)),
|
exportAccount: (password, address) => {
|
||||||
|
return dispatch(actions.exportAccount(password, address))
|
||||||
|
.then((res) => {
|
||||||
|
dispatch(actions.hideWarning())
|
||||||
|
return res
|
||||||
|
})
|
||||||
|
},
|
||||||
showAccountDetailModal: () => dispatch(actions.showModal({ name: 'ACCOUNT_DETAILS' })),
|
showAccountDetailModal: () => dispatch(actions.showModal({ name: 'ACCOUNT_DETAILS' })),
|
||||||
hideModal: () => dispatch(actions.hideModal()),
|
hideModal: () => dispatch(actions.hideModal()),
|
||||||
}
|
}
|
||||||
@ -36,6 +43,7 @@ function ExportPrivateKeyModal () {
|
|||||||
this.state = {
|
this.state = {
|
||||||
password: '',
|
password: '',
|
||||||
privateKey: null,
|
privateKey: null,
|
||||||
|
showWarning: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +58,11 @@ ExportPrivateKeyModal.prototype.exportAccountAndGetPrivateKey = function (passwo
|
|||||||
const { exportAccount } = this.props
|
const { exportAccount } = this.props
|
||||||
|
|
||||||
exportAccount(password, address)
|
exportAccount(password, address)
|
||||||
.then(privateKey => this.setState({ privateKey }))
|
.then(privateKey => this.setState({
|
||||||
|
privateKey,
|
||||||
|
showWarning: false,
|
||||||
|
}))
|
||||||
|
.catch((e) => log.error(e))
|
||||||
}
|
}
|
||||||
|
|
||||||
ExportPrivateKeyModal.prototype.renderPasswordLabel = function (privateKey) {
|
ExportPrivateKeyModal.prototype.renderPasswordLabel = function (privateKey) {
|
||||||
@ -110,7 +122,10 @@ ExportPrivateKeyModal.prototype.render = function () {
|
|||||||
} = this.props
|
} = this.props
|
||||||
const { name, address } = selectedIdentity
|
const { name, address } = selectedIdentity
|
||||||
|
|
||||||
const { privateKey } = this.state
|
const {
|
||||||
|
privateKey,
|
||||||
|
showWarning,
|
||||||
|
} = this.state
|
||||||
|
|
||||||
return h(AccountModalContainer, {
|
return h(AccountModalContainer, {
|
||||||
showBackButton: previousModalState === 'ACCOUNT_DETAILS',
|
showBackButton: previousModalState === 'ACCOUNT_DETAILS',
|
||||||
@ -134,7 +149,7 @@ ExportPrivateKeyModal.prototype.render = function () {
|
|||||||
|
|
||||||
this.renderPasswordInput(privateKey),
|
this.renderPasswordInput(privateKey),
|
||||||
|
|
||||||
!warning ? null : h('span.private-key-password-error', warning),
|
showWarning && warning ? h('span.private-key-password-error', warning) : null,
|
||||||
]),
|
]),
|
||||||
|
|
||||||
h('div.private-key-password-warning', this.context.t('privateKeyWarning')),
|
h('div.private-key-password-warning', this.context.t('privateKeyWarning')),
|
||||||
|
Loading…
Reference in New Issue
Block a user