Cleanup erc20 amount calcs

This commit is contained in:
Daniel Sanchez 2021-01-15 17:33:35 +01:00
parent 4c45daa2e2
commit cdbe4dfc57
1 changed files with 1 additions and 3 deletions

View File

@ -37,7 +37,6 @@ import { TokenProps } from 'src/logic/tokens/store/model/token'
import { RecordOf } from 'immutable' import { RecordOf } from 'immutable'
import { useEstimateTransactionGas } from 'src/logic/hooks/useEstimateTransactionGas' import { useEstimateTransactionGas } from 'src/logic/hooks/useEstimateTransactionGas'
import { TransactionFees } from 'src/components/TransactionsFees' import { TransactionFees } from 'src/components/TransactionsFees'
import BigNumber from 'bignumber.js'
const useStyles = makeStyles(styles) const useStyles = makeStyles(styles)
const { nativeCoin } = getNetworkInfo() const { nativeCoin } = getNetworkInfo()
@ -75,8 +74,7 @@ const useTxData = (
if (!isSendingNativeToken) { if (!isSendingNativeToken) {
const StandardToken = await getHumanFriendlyToken() const StandardToken = await getHumanFriendlyToken()
const tokenInstance = await StandardToken.at(txToken.address as string) const tokenInstance = await StandardToken.at(txToken.address as string)
const decimals = await tokenInstance.decimals() const erc20TransferAmount = toTokenUnit(txAmount, txToken.decimals)
const erc20TransferAmount = new BigNumber(txAmount).times(10 ** decimals.toNumber()).toString()
txData = tokenInstance.contract.methods.transfer(recipientAddress, erc20TransferAmount).encodeABI() txData = tokenInstance.contract.methods.transfer(recipientAddress, erc20TransferAmount).encodeABI()
} }
setData(txData) setData(txData)