|
|
@ -2,6 +2,7 @@ const { inherits } = require('util') |
|
|
|
const PersistentForm = require('../lib/persistent-form') |
|
|
|
const PersistentForm = require('../lib/persistent-form') |
|
|
|
const h = require('react-hyperscript') |
|
|
|
const h = require('react-hyperscript') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ethAbi = require('ethereumjs-abi') |
|
|
|
const ethUtil = require('ethereumjs-util') |
|
|
|
const ethUtil = require('ethereumjs-util') |
|
|
|
|
|
|
|
|
|
|
|
const Identicon = require('./components/identicon') |
|
|
|
const Identicon = require('./components/identicon') |
|
|
@ -13,6 +14,7 @@ const GasFeeDisplay = require('./components/send/gas-fee-display-v2') |
|
|
|
|
|
|
|
|
|
|
|
const { |
|
|
|
const { |
|
|
|
MIN_GAS_TOTAL, |
|
|
|
MIN_GAS_TOTAL, |
|
|
|
|
|
|
|
TOKEN_TRANSFER_FUNCTION_SIGNATURE, |
|
|
|
} = require('./components/send/send-constants') |
|
|
|
} = require('./components/send/send-constants') |
|
|
|
|
|
|
|
|
|
|
|
const { |
|
|
|
const { |
|
|
@ -552,6 +554,48 @@ SendTransactionScreen.prototype.addToAddressBookIfNew = function (newAddress) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SendTransactionScreen.prototype.getEditedTx = function () { |
|
|
|
|
|
|
|
const { |
|
|
|
|
|
|
|
from: {address: from}, |
|
|
|
|
|
|
|
to, |
|
|
|
|
|
|
|
amount, |
|
|
|
|
|
|
|
gasLimit: gas, |
|
|
|
|
|
|
|
gasPrice, |
|
|
|
|
|
|
|
selectedToken, |
|
|
|
|
|
|
|
editingTransactionId, |
|
|
|
|
|
|
|
unapprovedTxs, |
|
|
|
|
|
|
|
} = this.props |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const editingTx = { |
|
|
|
|
|
|
|
...unapprovedTxs[editingTransactionId], |
|
|
|
|
|
|
|
txParams: { |
|
|
|
|
|
|
|
from: ethUtil.addHexPrefix(from), |
|
|
|
|
|
|
|
gas: ethUtil.addHexPrefix(gas), |
|
|
|
|
|
|
|
gasPrice: ethUtil.addHexPrefix(gasPrice), |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedToken) { |
|
|
|
|
|
|
|
const data = TOKEN_TRANSFER_FUNCTION_SIGNATURE + Array.prototype.map.call( |
|
|
|
|
|
|
|
ethAbi.rawEncode(['address', 'uint256'], [to, ethUtil.addHexPrefix(amount)]), |
|
|
|
|
|
|
|
x => ('00' + x.toString(16)).slice(-2) |
|
|
|
|
|
|
|
).join('') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.assign(editingTx.txParams, { |
|
|
|
|
|
|
|
value: ethUtil.addHexPrefix('0'), |
|
|
|
|
|
|
|
to: ethUtil.addHexPrefix(selectedToken.address), |
|
|
|
|
|
|
|
data, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Object.assign(editingTx.txParams, { |
|
|
|
|
|
|
|
value: ethUtil.addHexPrefix(amount), |
|
|
|
|
|
|
|
to: ethUtil.addHexPrefix(to), |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return editingTx |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SendTransactionScreen.prototype.onSubmit = function (event) { |
|
|
|
SendTransactionScreen.prototype.onSubmit = function (event) { |
|
|
|
event.preventDefault() |
|
|
|
event.preventDefault() |
|
|
|
const { |
|
|
|
const { |
|
|
@ -562,10 +606,10 @@ SendTransactionScreen.prototype.onSubmit = function (event) { |
|
|
|
gasPrice, |
|
|
|
gasPrice, |
|
|
|
signTokenTx, |
|
|
|
signTokenTx, |
|
|
|
signTx, |
|
|
|
signTx, |
|
|
|
|
|
|
|
updateTx, |
|
|
|
selectedToken, |
|
|
|
selectedToken, |
|
|
|
editingTransactionId, |
|
|
|
editingTransactionId, |
|
|
|
errors: { amount: amountError, to: toError }, |
|
|
|
errors: { amount: amountError, to: toError }, |
|
|
|
backToConfirmScreen, |
|
|
|
|
|
|
|
} = this.props |
|
|
|
} = this.props |
|
|
|
|
|
|
|
|
|
|
|
const noErrors = !amountError && toError === null |
|
|
|
const noErrors = !amountError && toError === null |
|
|
@ -577,9 +621,10 @@ SendTransactionScreen.prototype.onSubmit = function (event) { |
|
|
|
this.addToAddressBookIfNew(to) |
|
|
|
this.addToAddressBookIfNew(to) |
|
|
|
|
|
|
|
|
|
|
|
if (editingTransactionId) { |
|
|
|
if (editingTransactionId) { |
|
|
|
backToConfirmScreen(editingTransactionId) |
|
|
|
const editedTx = this.getEditedTx() |
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
updateTx(editedTx) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
const txParams = { |
|
|
|
const txParams = { |
|
|
|
from, |
|
|
|
from, |
|
|
@ -596,4 +641,5 @@ SendTransactionScreen.prototype.onSubmit = function (event) { |
|
|
|
selectedToken |
|
|
|
selectedToken |
|
|
|
? signTokenTx(selectedToken.address, to, amount, txParams) |
|
|
|
? signTokenTx(selectedToken.address, to, amount, txParams) |
|
|
|
: signTx(txParams) |
|
|
|
: signTx(txParams) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|