Fix sending TX for tokens with decimals other than 24

This commit is contained in:
Mikhail Mikheev 2019-10-04 17:09:29 +04:00 committed by mmv
parent 7929ff5908
commit b667f438ee
1 changed files with 3 additions and 0 deletions

View File

@ -1,5 +1,6 @@
// @flow // @flow
import React from 'react' import React from 'react'
import { BigNumber } from 'bignumber.js'
import OpenInNew from '@material-ui/icons/OpenInNew' import OpenInNew from '@material-ui/icons/OpenInNew'
import { withStyles } from '@material-ui/core/styles' import { withStyles } from '@material-ui/core/styles'
import Close from '@material-ui/icons/Close' import Close from '@material-ui/icons/Close'
@ -68,6 +69,8 @@ const ReviewTx = ({
if (!isSendingETH) { if (!isSendingETH) {
const StandardToken = await getStandardTokenContract() const StandardToken = await getStandardTokenContract()
const tokenInstance = await StandardToken.at(tx.token.address) const tokenInstance = await StandardToken.at(tx.token.address)
const decimals = await tokenInstance.decimals()
txAmount = new BigNumber(tx.amount).div(10 ** decimals).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