You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.3 KiB
89 lines
2.3 KiB
8 years ago
|
const inherits = require('util').inherits
|
||
|
const Component = require('react').Component
|
||
|
const h = require('react-hyperscript')
|
||
7 years ago
|
const { withRouter } = require('react-router-dom')
|
||
|
const { compose } = require('recompose')
|
||
|
const { connect } = require('react-redux')
|
||
|
const actions = require('../../../../actions')
|
||
|
const { DEFAULT_ROUTE } = require('../../../../routes')
|
||
8 years ago
|
|
||
7 years ago
|
module.exports = compose(
|
||
|
withRouter,
|
||
|
connect(mapStateToProps, mapDispatchToProps)
|
||
|
)(PrivateKeyImportView)
|
||
8 years ago
|
|
||
|
function mapStateToProps (state) {
|
||
|
return {
|
||
|
error: state.appState.warning,
|
||
|
}
|
||
|
}
|
||
|
|
||
7 years ago
|
function mapDispatchToProps (dispatch) {
|
||
|
return {
|
||
|
importNewAccount: (strategy, [ privateKey ]) => {
|
||
7 years ago
|
return dispatch(actions.importNewAccount(strategy, [ privateKey ]))
|
||
7 years ago
|
},
|
||
|
displayWarning: () => dispatch(actions.displayWarning(null)),
|
||
|
}
|
||
|
}
|
||
|
|
||
8 years ago
|
inherits(PrivateKeyImportView, Component)
|
||
|
function PrivateKeyImportView () {
|
||
|
Component.call(this)
|
||
|
}
|
||
|
|
||
|
PrivateKeyImportView.prototype.render = function () {
|
||
7 years ago
|
const { error } = this.props
|
||
8 years ago
|
|
||
|
return (
|
||
7 years ago
|
h('div.new-account-import-form__private-key', [
|
||
8 years ago
|
|
||
7 years ago
|
h('div.new-account-import-form__private-key-password-container', [
|
||
8 years ago
|
|
||
7 years ago
|
h('span.new-account-import-form__instruction', 'Paste your private key string here:'),
|
||
|
|
||
|
h('input.new-account-import-form__input-password', {
|
||
|
type: 'password',
|
||
|
id: 'private-key-box',
|
||
|
onKeyPress: () => this.createKeyringOnEnter(),
|
||
|
}),
|
||
|
|
||
|
]),
|
||
|
|
||
|
h('div.new-account-import-form__buttons', {}, [
|
||
7 years ago
|
|
||
|
h('button.new-account-create-form__button-cancel', {
|
||
7 years ago
|
onClick: () => this.props.history.push(DEFAULT_ROUTE),
|
||
7 years ago
|
}, [
|
||
|
'CANCEL',
|
||
|
]),
|
||
|
|
||
|
h('button.new-account-create-form__button-create', {
|
||
|
onClick: () => this.createNewKeychain(),
|
||
|
}, [
|
||
|
'IMPORT',
|
||
|
]),
|
||
|
|
||
|
]),
|
||
8 years ago
|
|
||
8 years ago
|
error ? h('span.error', error) : null,
|
||
8 years ago
|
])
|
||
|
)
|
||
|
}
|
||
|
|
||
|
PrivateKeyImportView.prototype.createKeyringOnEnter = function (event) {
|
||
|
if (event.key === 'Enter') {
|
||
|
event.preventDefault()
|
||
|
this.createNewKeychain()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
PrivateKeyImportView.prototype.createNewKeychain = function () {
|
||
|
const input = document.getElementById('private-key-box')
|
||
|
const privateKey = input.value
|
||
7 years ago
|
const { importNewAccount, history } = this.props
|
||
7 years ago
|
|
||
7 years ago
|
importNewAccount('Private Key', [ privateKey ])
|
||
|
.then(() => history.push(DEFAULT_ROUTE))
|
||
8 years ago
|
}
|