Enable send-v2 functionality.

feature/default_network_editable
Dan 7 years ago committed by Chi Kei Chan
parent 7caa914223
commit ac43872c1a
  1. 14
      ui/app/actions.js
  2. 6
      ui/app/components/send/currency-display.js
  3. 17
      ui/app/components/send/from-dropdown.js
  4. 5
      ui/app/components/send/send-v2-container.js
  5. 39
      ui/app/send-v2.js

@ -137,6 +137,7 @@ var actions = {
UPDATE_GAS_PRICE: 'UPDATE_GAS_PRICE', UPDATE_GAS_PRICE: 'UPDATE_GAS_PRICE',
updateGasLimit, updateGasLimit,
updateGasPrice, updateGasPrice,
setSelectedAddress,
// app messages // app messages
confirmSeedWords: confirmSeedWords, confirmSeedWords: confirmSeedWords,
showAccountDetail: showAccountDetail, showAccountDetail: showAccountDetail,
@ -699,6 +700,19 @@ function setSelectedToken (tokenAddress) {
} }
} }
function setSelectedAddress (address) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
log.debug(`background.setSelectedAddress`)
background.setSelectedAddress(address, (err) => {
dispatch(actions.hideLoadingIndication())
if (err) {
return dispatch(actions.displayWarning(err.message))
}
})
}
}
function showAccountDetail (address) { function showAccountDetail (address) {
return (dispatch) => { return (dispatch) => {
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())

@ -100,9 +100,9 @@ CurrencyDisplay.prototype.render = function () {
this.setState({ value: newValue }) this.setState({ value: newValue })
} }
}, },
onBlur: event => this.handleChangeInHexWei(event.target.value.split(' ')[0]), onBlur: event => !readOnly && this.handleChangeInHexWei(event.target.value.split(' ')[0]),
onKeyUp: event => resetCaretIfPastEnd(value || initValueToRender, event), onKeyUp: event => !readOnly && resetCaretIfPastEnd(value || initValueToRender, event),
onClick: event => resetCaretIfPastEnd(value || initValueToRender, event), onClick: event => !readOnly && resetCaretIfPastEnd(value || initValueToRender, event),
}), }),
]), ]),

@ -19,7 +19,14 @@ FromDropdown.prototype.getListItemIcon = function (currentAccount, selectedAccou
: null : null
} }
FromDropdown.prototype.renderDropdown = function (accounts, selectedAccount, closeDropdown) { FromDropdown.prototype.renderDropdown = function () {
const {
accounts,
selectedAccount,
closeDropdown,
onSelect,
} = this.props
return h('div', {}, [ return h('div', {}, [
h('div.send-v2__from-dropdown__close-area', { h('div.send-v2__from-dropdown__close-area', {
@ -30,7 +37,10 @@ FromDropdown.prototype.renderDropdown = function (accounts, selectedAccount, clo
...accounts.map(account => h(AccountListItem, { ...accounts.map(account => h(AccountListItem, {
account, account,
handleClick: () => console.log('Select identity'), handleClick: () => {
onSelect(account.address)
closeDropdown()
},
icon: this.getListItemIcon(account, selectedAccount), icon: this.getListItemIcon(account, selectedAccount),
})) }))
@ -43,7 +53,6 @@ FromDropdown.prototype.render = function () {
const { const {
accounts, accounts,
selectedAccount, selectedAccount,
setFromField,
openDropdown, openDropdown,
closeDropdown, closeDropdown,
dropdownOpen, dropdownOpen,
@ -57,7 +66,7 @@ FromDropdown.prototype.render = function () {
icon: h(`i.fa.fa-caret-down.fa-lg`, { style: { color: '#dedede' } }) icon: h(`i.fa.fa-caret-down.fa-lg`, { style: { color: '#dedede' } })
}), }),
dropdownOpen && this.renderDropdown(accounts, selectedAccount, closeDropdown), dropdownOpen && this.renderDropdown(),
]) ])

@ -62,5 +62,10 @@ function mapDispatchToProps (dispatch) {
estimateGas: params => dispatch(actions.estimateGas(params)), estimateGas: params => dispatch(actions.estimateGas(params)),
getGasPrice: () => dispatch(actions.getGasPrice()), getGasPrice: () => dispatch(actions.getGasPrice()),
updateTokenExchangeRate: token => dispatch(actions.updateTokenExchangeRate(token)), updateTokenExchangeRate: token => dispatch(actions.updateTokenExchangeRate(token)),
signTokenTx: (tokenAddress, toAddress, amount, txData) => (
dispatch(actions.signTokenTx(tokenAddress, toAddress, amount, txData))
),
signTx: txParams => dispatch(actions.signTx(txParams)),
setSelectedAddress: address => dispatch(actions.setSelectedAddress(address))
} }
} }

@ -105,6 +105,7 @@ SendTransactionScreen.prototype.render = function () {
selectedToken, selectedToken,
showCustomizeGasModal, showCustomizeGasModal,
selectedAccount, selectedAccount,
setSelectedAddress,
primaryCurrency = 'ETH', primaryCurrency = 'ETH',
gasLimit, gasLimit,
gasPrice, gasPrice,
@ -150,7 +151,7 @@ SendTransactionScreen.prototype.render = function () {
dropdownOpen, dropdownOpen,
accounts, accounts,
selectedAccount, selectedAccount,
setFromField: () => console.log('Set From Field'), onSelect: address => setSelectedAddress(address),
openDropdown: () => this.setState({ dropdownOpen: true }), openDropdown: () => this.setState({ dropdownOpen: true }),
closeDropdown: () => this.setState({ dropdownOpen: false }), closeDropdown: () => this.setState({ dropdownOpen: false }),
conversionRate, conversionRate,
@ -235,9 +236,43 @@ SendTransactionScreen.prototype.render = function () {
// Buttons underneath card // Buttons underneath card
h('div.send-v2__footer', [ h('div.send-v2__footer', [
h('button.send-v2__cancel-btn', {}, 'Cancel'), h('button.send-v2__cancel-btn', {}, 'Cancel'),
h('button.send-v2__next-btn', {}, 'Next'), h('button.send-v2__next-btn', {
onClick: event => this.onSubmit(event),
}, 'Next'),
]), ]),
]) ])
) )
} }
SendTransactionScreen.prototype.onSubmit = function (event) {
event.preventDefault()
const {
to,
amount,
} = this.state
const {
gasLimit: gas,
gasPrice,
signTokenTx,
signTx,
selectedToken,
selectedAccount: { address: from },
} = this.props
const txParams = {
from,
value: '0',
gas,
gasPrice,
}
if (!selectedToken) {
txParams.value = amount
txParams.to = to
}
selectedToken
? signTokenTx(selectedToken.address, to, amount, txParams)
: signTx(txParams)
}

Loading…
Cancel
Save