mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Enable send-v2 functionality.
This commit is contained in:
parent
7caa914223
commit
ac43872c1a
@ -137,6 +137,7 @@ var actions = {
|
||||
UPDATE_GAS_PRICE: 'UPDATE_GAS_PRICE',
|
||||
updateGasLimit,
|
||||
updateGasPrice,
|
||||
setSelectedAddress,
|
||||
// app messages
|
||||
confirmSeedWords: confirmSeedWords,
|
||||
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) {
|
||||
return (dispatch) => {
|
||||
dispatch(actions.showLoadingIndication())
|
||||
|
@ -100,9 +100,9 @@ CurrencyDisplay.prototype.render = function () {
|
||||
this.setState({ value: newValue })
|
||||
}
|
||||
},
|
||||
onBlur: event => this.handleChangeInHexWei(event.target.value.split(' ')[0]),
|
||||
onKeyUp: event => resetCaretIfPastEnd(value || initValueToRender, event),
|
||||
onClick: event => resetCaretIfPastEnd(value || initValueToRender, event),
|
||||
onBlur: event => !readOnly && this.handleChangeInHexWei(event.target.value.split(' ')[0]),
|
||||
onKeyUp: event => !readOnly && resetCaretIfPastEnd(value || initValueToRender, event),
|
||||
onClick: event => !readOnly && resetCaretIfPastEnd(value || initValueToRender, event),
|
||||
}),
|
||||
|
||||
]),
|
||||
|
@ -19,7 +19,14 @@ FromDropdown.prototype.getListItemIcon = function (currentAccount, selectedAccou
|
||||
: null
|
||||
}
|
||||
|
||||
FromDropdown.prototype.renderDropdown = function (accounts, selectedAccount, closeDropdown) {
|
||||
FromDropdown.prototype.renderDropdown = function () {
|
||||
const {
|
||||
accounts,
|
||||
selectedAccount,
|
||||
closeDropdown,
|
||||
onSelect,
|
||||
} = this.props
|
||||
|
||||
return h('div', {}, [
|
||||
|
||||
h('div.send-v2__from-dropdown__close-area', {
|
||||
@ -30,7 +37,10 @@ FromDropdown.prototype.renderDropdown = function (accounts, selectedAccount, clo
|
||||
|
||||
...accounts.map(account => h(AccountListItem, {
|
||||
account,
|
||||
handleClick: () => console.log('Select identity'),
|
||||
handleClick: () => {
|
||||
onSelect(account.address)
|
||||
closeDropdown()
|
||||
},
|
||||
icon: this.getListItemIcon(account, selectedAccount),
|
||||
}))
|
||||
|
||||
@ -43,7 +53,6 @@ FromDropdown.prototype.render = function () {
|
||||
const {
|
||||
accounts,
|
||||
selectedAccount,
|
||||
setFromField,
|
||||
openDropdown,
|
||||
closeDropdown,
|
||||
dropdownOpen,
|
||||
@ -57,7 +66,7 @@ FromDropdown.prototype.render = function () {
|
||||
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)),
|
||||
getGasPrice: () => dispatch(actions.getGasPrice()),
|
||||
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,
|
||||
showCustomizeGasModal,
|
||||
selectedAccount,
|
||||
setSelectedAddress,
|
||||
primaryCurrency = 'ETH',
|
||||
gasLimit,
|
||||
gasPrice,
|
||||
@ -150,7 +151,7 @@ SendTransactionScreen.prototype.render = function () {
|
||||
dropdownOpen,
|
||||
accounts,
|
||||
selectedAccount,
|
||||
setFromField: () => console.log('Set From Field'),
|
||||
onSelect: address => setSelectedAddress(address),
|
||||
openDropdown: () => this.setState({ dropdownOpen: true }),
|
||||
closeDropdown: () => this.setState({ dropdownOpen: false }),
|
||||
conversionRate,
|
||||
@ -235,9 +236,43 @@ SendTransactionScreen.prototype.render = function () {
|
||||
// Buttons underneath card
|
||||
h('div.send-v2__footer', [
|
||||
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…
Reference in New Issue
Block a user