fix: ERC-20 transfer gas estimation and receiver address
This commit is contained in:
parent
4339e58e6a
commit
b816b195c9
1 changed files with 4 additions and 1 deletions
|
|
@ -101,6 +101,7 @@ function generateTx (_toAddress, wallet, amount, includesFee, cryptoCode) {
|
|||
|
||||
const isErc20Token = coins.utils.isErc20Token(cryptoCode)
|
||||
const toAddress = isErc20Token ? coins.utils.getErc20Token(cryptoCode).contractAddress : _toAddress.toLowerCase()
|
||||
const contractData = isErc20Token && contract.transfer.getData(_toAddress.toLowerCase(), hex(toSend))
|
||||
|
||||
const txTemplate = {
|
||||
from: fromAddress,
|
||||
|
|
@ -108,6 +109,8 @@ function generateTx (_toAddress, wallet, amount, includesFee, cryptoCode) {
|
|||
value: amount.toString()
|
||||
}
|
||||
|
||||
if (isErc20Token) txTemplate.data = contractData
|
||||
|
||||
const promises = [
|
||||
pify(web3.eth.estimateGas)(txTemplate),
|
||||
pify(web3.eth.getGasPrice)(),
|
||||
|
|
@ -140,7 +143,7 @@ function generateTx (_toAddress, wallet, amount, includesFee, cryptoCode) {
|
|||
if (isErc20Token) {
|
||||
const contract = web3.eth.contract(ABI.ERC20).at(toAddress)
|
||||
if (contract)
|
||||
rawTx.data = contract.transfer.getData(toAddress, hex(toSend))
|
||||
rawTx.data = contractData
|
||||
}
|
||||
|
||||
const tx = new Tx(rawTx)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue