|
|
@ -1,17 +1,88 @@ |
|
|
|
const Component = require('react').Component |
|
|
|
const { Component } = require('react') |
|
|
|
|
|
|
|
const PropTypes = require('prop-types') |
|
|
|
const h = require('react-hyperscript') |
|
|
|
const h = require('react-hyperscript') |
|
|
|
const inherits = require('util').inherits |
|
|
|
const { connect } = require('react-redux') |
|
|
|
const connect = require('react-redux').connect |
|
|
|
|
|
|
|
const actions = require('../../actions') |
|
|
|
const actions = require('../../actions') |
|
|
|
|
|
|
|
|
|
|
|
function mapStateToProps (state) { |
|
|
|
class NewAccountModal extends Component { |
|
|
|
|
|
|
|
constructor (props) { |
|
|
|
|
|
|
|
super(props) |
|
|
|
|
|
|
|
const { numberOfExistingAccounts = 0 } = props |
|
|
|
|
|
|
|
const newAccountNumber = numberOfExistingAccounts + 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.state = { |
|
|
|
|
|
|
|
newAccountName: `Account ${newAccountNumber}`, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render () { |
|
|
|
|
|
|
|
const { newAccountName } = this.state |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return h('div', [ |
|
|
|
|
|
|
|
h('div.new-account-modal-wrapper', { |
|
|
|
|
|
|
|
}, [ |
|
|
|
|
|
|
|
h('div.new-account-modal-header', {}, [ |
|
|
|
|
|
|
|
'New Account', |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
h('div.modal-close-x', { |
|
|
|
|
|
|
|
onClick: this.props.hideModal, |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
h('div.new-account-modal-content', {}, [ |
|
|
|
|
|
|
|
'Account Name', |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
h('div.new-account-input-wrapper', {}, [ |
|
|
|
|
|
|
|
h('input.new-account-input', { |
|
|
|
|
|
|
|
value: this.state.newAccountName, |
|
|
|
|
|
|
|
placeholder: 'E.g. My new account', |
|
|
|
|
|
|
|
onChange: event => this.setState({ newAccountName: event.target.value }), |
|
|
|
|
|
|
|
}, []), |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
h('div.new-account-modal-content.after-input', {}, [ |
|
|
|
|
|
|
|
'or', |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
h('div.new-account-modal-content.after-input.pointer', { |
|
|
|
|
|
|
|
onClick: () => { |
|
|
|
|
|
|
|
this.props.hideModal() |
|
|
|
|
|
|
|
this.props.showImportPage() |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, 'Import an account'), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
h('div.new-account-modal-content.button', {}, [ |
|
|
|
|
|
|
|
h('button.btn-clear', { |
|
|
|
|
|
|
|
onClick: () => this.props.createAccount(newAccountName), |
|
|
|
|
|
|
|
}, [ |
|
|
|
|
|
|
|
'SAVE', |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NewAccountModal.propTypes = { |
|
|
|
|
|
|
|
hideModal: PropTypes.func, |
|
|
|
|
|
|
|
showImportPage: PropTypes.func, |
|
|
|
|
|
|
|
createAccount: PropTypes.func, |
|
|
|
|
|
|
|
numberOfExistingAccounts: PropTypes.number, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = state => { |
|
|
|
|
|
|
|
const { metamask: { network, selectedAddress, identities = {} } } = state |
|
|
|
|
|
|
|
const numberOfExistingAccounts = Object.keys(identities).length |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
network: state.metamask.network, |
|
|
|
network, |
|
|
|
address: state.metamask.selectedAddress, |
|
|
|
address: selectedAddress, |
|
|
|
|
|
|
|
numberOfExistingAccounts, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function mapDispatchToProps (dispatch) { |
|
|
|
const mapDispatchToProps = dispatch => { |
|
|
|
return { |
|
|
|
return { |
|
|
|
toCoinbase: (address) => { |
|
|
|
toCoinbase: (address) => { |
|
|
|
dispatch(actions.buyEth({ network: '1', address, amount: 0 })) |
|
|
|
dispatch(actions.buyEth({ network: '1', address, amount: 0 })) |
|
|
@ -32,60 +103,4 @@ function mapDispatchToProps (dispatch) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inherits(NewAccountModal, Component) |
|
|
|
|
|
|
|
function NewAccountModal () { |
|
|
|
|
|
|
|
Component.call(this) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.state = { |
|
|
|
|
|
|
|
newAccountName: '', |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(NewAccountModal) |
|
|
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(NewAccountModal) |
|
|
|
|
|
|
|
|
|
|
|
NewAccountModal.prototype.render = function () { |
|
|
|
|
|
|
|
const { newAccountName } = this.state |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return h('div', {}, [ |
|
|
|
|
|
|
|
h('div.new-account-modal-wrapper', { |
|
|
|
|
|
|
|
}, [ |
|
|
|
|
|
|
|
h('div.new-account-modal-header', {}, [ |
|
|
|
|
|
|
|
'New Account', |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
h('div.modal-close-x', { |
|
|
|
|
|
|
|
onClick: this.props.hideModal, |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
h('div.new-account-modal-content', {}, [ |
|
|
|
|
|
|
|
'Account Name', |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
h('div.new-account-input-wrapper', {}, [ |
|
|
|
|
|
|
|
h('input.new-account-input', { |
|
|
|
|
|
|
|
placeholder: 'E.g. My new account', |
|
|
|
|
|
|
|
onChange: event => this.setState({ newAccountName: event.target.value }), |
|
|
|
|
|
|
|
}, []), |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
h('div.new-account-modal-content.after-input', {}, [ |
|
|
|
|
|
|
|
'or', |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
h('div.new-account-modal-content.after-input.pointer', { |
|
|
|
|
|
|
|
onClick: () => { |
|
|
|
|
|
|
|
this.props.hideModal() |
|
|
|
|
|
|
|
this.props.showImportPage() |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, 'Import an account'), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
h('div.new-account-modal-content.button', {}, [ |
|
|
|
|
|
|
|
h('button.btn-clear', { |
|
|
|
|
|
|
|
onClick: () => this.props.createAccount(newAccountName), |
|
|
|
|
|
|
|
}, [ |
|
|
|
|
|
|
|
'SAVE', |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|