Fix a fix for sending TX for tokens with decimals other than 24

This commit is contained in:
Mikhail Mikheev 2019-10-04 17:35:24 +04:00
parent 19029819e2
commit b458aa44ba
1 changed files with 5 additions and 3 deletions

View File

@ -18,7 +18,7 @@ import { copyToClipboard } from '~/utils/clipboard'
import Hairline from '~/components/layout/Hairline' import Hairline from '~/components/layout/Hairline'
import SafeInfo from '~/routes/safe/components/Balances/SendModal/SafeInfo' import SafeInfo from '~/routes/safe/components/Balances/SendModal/SafeInfo'
import { setImageToPlaceholder } from '~/routes/safe/components/Balances/utils' import { setImageToPlaceholder } from '~/routes/safe/components/Balances/utils'
import { getStandardTokenContract } from '~/logic/tokens/store/actions/fetchTokens' import { getStandardTokenContract, getHumanFriendlyToken } from '~/logic/tokens/store/actions/fetchTokens'
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions' import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
import { getWeb3 } from '~/logic/wallets/getWeb3' import { getWeb3 } from '~/logic/wallets/getWeb3'
import { TX_NOTIFICATION_TYPES } from '~/logic/safe/transactions' import { TX_NOTIFICATION_TYPES } from '~/logic/safe/transactions'
@ -68,9 +68,11 @@ const ReviewTx = ({
if (!isSendingETH) { if (!isSendingETH) {
const StandardToken = await getStandardTokenContract() const StandardToken = await getStandardTokenContract()
const HumanFriendlyToken = await getHumanFriendlyToken()
const tokenInstance = await StandardToken.at(tx.token.address) const tokenInstance = await StandardToken.at(tx.token.address)
const decimals = await tokenInstance.decimals() const hfTokenInstance = await HumanFriendlyToken.at(tx.token.address)
txAmount = new BigNumber(tx.amount).div(10 ** decimals).toString() const decimals = await hfTokenInstance.decimals()
txAmount = new BigNumber(tx.amount).times(10 ** decimals.toNumber()).toString()
txData = tokenInstance.contract.methods.transfer(tx.recipientAddress, txAmount).encodeABI() txData = tokenInstance.contract.methods.transfer(tx.recipientAddress, txAmount).encodeABI()
// txAmount should be 0 if we send tokens // txAmount should be 0 if we send tokens