|
|
@ -12,6 +12,8 @@ const GasFeeDisplay = require('./components/send/gas-fee-display-v2') |
|
|
|
|
|
|
|
|
|
|
|
const { showModal } = require('./actions') |
|
|
|
const { showModal } = require('./actions') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { multiplyCurrencies } = require('./conversion-util') |
|
|
|
|
|
|
|
|
|
|
|
module.exports = SendTransactionScreen |
|
|
|
module.exports = SendTransactionScreen |
|
|
|
|
|
|
|
|
|
|
|
inherits(SendTransactionScreen, PersistentForm) |
|
|
|
inherits(SendTransactionScreen, PersistentForm) |
|
|
@ -19,13 +21,6 @@ function SendTransactionScreen () { |
|
|
|
PersistentForm.call(this) |
|
|
|
PersistentForm.call(this) |
|
|
|
|
|
|
|
|
|
|
|
this.state = { |
|
|
|
this.state = { |
|
|
|
from: '', |
|
|
|
|
|
|
|
to: '', |
|
|
|
|
|
|
|
gasPrice: null, |
|
|
|
|
|
|
|
gasLimit: null, |
|
|
|
|
|
|
|
amount: '0x0',
|
|
|
|
|
|
|
|
txData: null, |
|
|
|
|
|
|
|
memo: '', |
|
|
|
|
|
|
|
dropdownOpen: false, |
|
|
|
dropdownOpen: false, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -41,6 +36,7 @@ SendTransactionScreen.prototype.componentWillMount = function () { |
|
|
|
estimateGas, |
|
|
|
estimateGas, |
|
|
|
selectedAddress, |
|
|
|
selectedAddress, |
|
|
|
data, |
|
|
|
data, |
|
|
|
|
|
|
|
updateGasTotal, |
|
|
|
} = this.props |
|
|
|
} = this.props |
|
|
|
const { symbol } = selectedToken || {} |
|
|
|
const { symbol } = selectedToken || {} |
|
|
|
|
|
|
|
|
|
|
@ -58,13 +54,23 @@ SendTransactionScreen.prototype.componentWillMount = function () { |
|
|
|
Object.assign(estimateGasParams, { data }) |
|
|
|
Object.assign(estimateGasParams, { data }) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Promise.all([ |
|
|
|
Promise |
|
|
|
getGasPrice(), |
|
|
|
.all([ |
|
|
|
estimateGas({ |
|
|
|
getGasPrice(), |
|
|
|
from: selectedAddress, |
|
|
|
estimateGas({ |
|
|
|
gas: '746a528800', |
|
|
|
from: selectedAddress, |
|
|
|
}), |
|
|
|
gas: '746a528800', |
|
|
|
]) |
|
|
|
}), |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
.then(([gasPrice, gas]) => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const newGasTotal = multiplyCurrencies(gas, gasPrice, { |
|
|
|
|
|
|
|
toNumericBase: 'hex', |
|
|
|
|
|
|
|
multiplicandBase: 16, |
|
|
|
|
|
|
|
multiplierBase: 16, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
updateGasTotal(newGasTotal) |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SendTransactionScreen.prototype.renderHeaderIcon = function () { |
|
|
|
SendTransactionScreen.prototype.renderHeaderIcon = function () { |
|
|
@ -122,10 +128,11 @@ SendTransactionScreen.prototype.renderHeader = function () { |
|
|
|
|
|
|
|
|
|
|
|
SendTransactionScreen.prototype.renderFromRow = function () { |
|
|
|
SendTransactionScreen.prototype.renderFromRow = function () { |
|
|
|
const { |
|
|
|
const { |
|
|
|
|
|
|
|
from, |
|
|
|
fromAccounts, |
|
|
|
fromAccounts, |
|
|
|
conversionRate, |
|
|
|
conversionRate, |
|
|
|
selectedAccount, |
|
|
|
|
|
|
|
setSelectedAddress, |
|
|
|
setSelectedAddress, |
|
|
|
|
|
|
|
updateSendFrom, |
|
|
|
} = this.props |
|
|
|
} = this.props |
|
|
|
|
|
|
|
|
|
|
|
const { dropdownOpen } = this.state |
|
|
|
const { dropdownOpen } = this.state |
|
|
@ -137,8 +144,8 @@ SendTransactionScreen.prototype.renderFromRow = function () { |
|
|
|
h(FromDropdown, { |
|
|
|
h(FromDropdown, { |
|
|
|
dropdownOpen, |
|
|
|
dropdownOpen, |
|
|
|
accounts: fromAccounts, |
|
|
|
accounts: fromAccounts, |
|
|
|
selectedAccount, |
|
|
|
selectedAccount: from, |
|
|
|
onSelect: address => setSelectedAddress(address), |
|
|
|
onSelect: updateSendFrom, |
|
|
|
openDropdown: () => this.setState({ dropdownOpen: true }), |
|
|
|
openDropdown: () => this.setState({ dropdownOpen: true }), |
|
|
|
closeDropdown: () => this.setState({ dropdownOpen: false }), |
|
|
|
closeDropdown: () => this.setState({ dropdownOpen: false }), |
|
|
|
conversionRate, |
|
|
|
conversionRate, |
|
|
@ -148,12 +155,10 @@ SendTransactionScreen.prototype.renderFromRow = function () { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SendTransactionScreen.prototype.handleToChange = function (event) { |
|
|
|
SendTransactionScreen.prototype.handleToChange = function (event) { |
|
|
|
|
|
|
|
const { updateSendTo } = this.props |
|
|
|
const to = event.target.value |
|
|
|
const to = event.target.value |
|
|
|
|
|
|
|
|
|
|
|
this.setState({ |
|
|
|
updateSendTo(to) |
|
|
|
...this.state, |
|
|
|
|
|
|
|
to, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SendTransactionScreen.prototype.renderToRow = function () { |
|
|
|
SendTransactionScreen.prototype.renderToRow = function () { |
|
|
@ -174,26 +179,21 @@ SendTransactionScreen.prototype.renderToRow = function () { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SendTransactionScreen.prototype.handleAmountChange = function (value) { |
|
|
|
SendTransactionScreen.prototype.handleAmountChange = function (value) { |
|
|
|
|
|
|
|
const { updateSendAmount } = this.props |
|
|
|
const amount = value |
|
|
|
const amount = value |
|
|
|
|
|
|
|
|
|
|
|
this.setState({ |
|
|
|
updateSendAmount(amount) |
|
|
|
...this.state, |
|
|
|
|
|
|
|
amount, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SendTransactionScreen.prototype.renderAmountRow = function () { |
|
|
|
SendTransactionScreen.prototype.renderAmountRow = function () { |
|
|
|
const { |
|
|
|
const { |
|
|
|
conversionRate, |
|
|
|
|
|
|
|
tokenToUSDRate, |
|
|
|
|
|
|
|
selectedToken, |
|
|
|
selectedToken, |
|
|
|
primaryCurrency = 'ETH', |
|
|
|
primaryCurrency = 'ETH', |
|
|
|
|
|
|
|
amountConversionRate, |
|
|
|
} = this.props |
|
|
|
} = this.props |
|
|
|
|
|
|
|
|
|
|
|
const { amount } = this.state |
|
|
|
const { amount } = this.state |
|
|
|
|
|
|
|
|
|
|
|
const amountConversionRate = selectedToken ? tokenToUSDRate : conversionRate |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return h('div.send-v2__form-row', [ |
|
|
|
return h('div.send-v2__form-row', [ |
|
|
|
|
|
|
|
|
|
|
|
h('div.send-v2__form-label', 'Amount:'), |
|
|
|
h('div.send-v2__form-label', 'Amount:'), |
|
|
@ -214,8 +214,7 @@ SendTransactionScreen.prototype.renderGasRow = function () { |
|
|
|
const { |
|
|
|
const { |
|
|
|
conversionRate, |
|
|
|
conversionRate, |
|
|
|
showCustomizeGasModal, |
|
|
|
showCustomizeGasModal, |
|
|
|
gasLimit, |
|
|
|
gasTotal, |
|
|
|
gasPrice, |
|
|
|
|
|
|
|
} = this.props |
|
|
|
} = this.props |
|
|
|
|
|
|
|
|
|
|
|
return h('div.send-v2__form-row', [ |
|
|
|
return h('div.send-v2__form-row', [ |
|
|
@ -223,8 +222,7 @@ SendTransactionScreen.prototype.renderGasRow = function () { |
|
|
|
h('div.send-v2__form-label', 'Gas fee:'), |
|
|
|
h('div.send-v2__form-label', 'Gas fee:'), |
|
|
|
|
|
|
|
|
|
|
|
h(GasFeeDisplay, { |
|
|
|
h(GasFeeDisplay, { |
|
|
|
gasLimit, |
|
|
|
gasTotal, |
|
|
|
gasPrice, |
|
|
|
|
|
|
|
conversionRate, |
|
|
|
conversionRate, |
|
|
|
onClick: showCustomizeGasModal, |
|
|
|
onClick: showCustomizeGasModal, |
|
|
|
}), |
|
|
|
}), |
|
|
@ -239,6 +237,7 @@ SendTransactionScreen.prototype.renderGasRow = function () { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SendTransactionScreen.prototype.renderMemoRow = function () { |
|
|
|
SendTransactionScreen.prototype.renderMemoRow = function () { |
|
|
|
|
|
|
|
const { updateSendMemo } = this.props |
|
|
|
const { memo } = this.state |
|
|
|
const { memo } = this.state |
|
|
|
|
|
|
|
|
|
|
|
return h('div.send-v2__form-row', [ |
|
|
|
return h('div.send-v2__form-row', [ |
|
|
@ -247,12 +246,7 @@ SendTransactionScreen.prototype.renderMemoRow = function () { |
|
|
|
|
|
|
|
|
|
|
|
h(MemoTextArea, { |
|
|
|
h(MemoTextArea, { |
|
|
|
memo, |
|
|
|
memo, |
|
|
|
onChange: (event) => { |
|
|
|
onChange: (event) => updateSendMemo(event.target.value), |
|
|
|
this.setState({ |
|
|
|
|
|
|
|
...this.state, |
|
|
|
|
|
|
|
memo: event.target.value, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}), |
|
|
|
}), |
|
|
|
|
|
|
|
|
|
|
|
]) |
|
|
|
]) |
|
|
@ -313,16 +307,14 @@ SendTransactionScreen.prototype.addToAddressBookIfNew = function (newAddress) { |
|
|
|
SendTransactionScreen.prototype.onSubmit = function (event) { |
|
|
|
SendTransactionScreen.prototype.onSubmit = function (event) { |
|
|
|
event.preventDefault() |
|
|
|
event.preventDefault() |
|
|
|
const { |
|
|
|
const { |
|
|
|
|
|
|
|
from: {address: from}, |
|
|
|
to, |
|
|
|
to, |
|
|
|
amount, |
|
|
|
amount, |
|
|
|
} = this.state |
|
|
|
|
|
|
|
const { |
|
|
|
|
|
|
|
gasLimit: gas, |
|
|
|
gasLimit: gas, |
|
|
|
gasPrice, |
|
|
|
gasPrice, |
|
|
|
signTokenTx, |
|
|
|
signTokenTx, |
|
|
|
signTx, |
|
|
|
signTx, |
|
|
|
selectedToken, |
|
|
|
selectedToken, |
|
|
|
selectedAccount: { address: from }, |
|
|
|
|
|
|
|
toAccounts, |
|
|
|
toAccounts, |
|
|
|
} = this.props |
|
|
|
} = this.props |
|
|
|
|
|
|
|
|
|
|
|