diff --git a/src/components/table/TransferCard.jsx b/src/components/table/TransferCard.jsx index 1153744..c44f4a2 100644 --- a/src/components/table/TransferCard.jsx +++ b/src/components/table/TransferCard.jsx @@ -10,8 +10,7 @@ import Card from '@material-ui/core/Card' import CardActions from '@material-ui/core/CardActions' import CardContent from '@material-ui/core/CardContent' import Collapse from '@material-ui/core/Collapse' -import { getTokenLabel } from '../../utils/currencies' -import { toWei } from '../../utils/conversions' +import { getTokenLabel, getTokenByAddress } from '../../utils/currencies' import styles from './CardStyles' import { useRowData } from './hooks' @@ -25,7 +24,8 @@ function TransferCard({ row, handleClose, classes }) { onSubmit={async (values, { setSubmitting: _setSubmitting, resetForm, setStatus: _setStatus }) => { const { idPledge, pledge } = row const { idSender, amount, idReceiver } = values - const args = [idSender, idPledge, toWei(amount.toString()), idReceiver] + const { chainReadibleFn } = getTokenByAddress(pledge.token) + const args = [idSender, idPledge, chainReadibleFn(amount), idReceiver] const toSend = transfer(...args) const estimatedGas = await toSend.estimateGas() diff --git a/src/components/table/WithdrawCard.jsx b/src/components/table/WithdrawCard.jsx index 8d4a37c..c733706 100644 --- a/src/components/table/WithdrawCard.jsx +++ b/src/components/table/WithdrawCard.jsx @@ -14,8 +14,7 @@ import TextField from '@material-ui/core/TextField' import Collapse from '@material-ui/core/Collapse' import LiquidPledging from '../../embarkArtifacts/contracts/LiquidPledging' import LPVault from '../../embarkArtifacts/contracts/LPVault' -import { getTokenLabel } from '../../utils/currencies' -import { toWei } from '../../utils/conversions' +import { getTokenLabel, getTokenByAddress } from '../../utils/currencies' import styles from './CardStyles' import { useRowData } from './hooks' @@ -31,7 +30,8 @@ function Withdraw({ handleClose, classes, rowData, authorizedPayment }) { onSubmit={async (values, { setSubmitting: _setSubmitting, resetForm: _resetForm, setStatus: _setStatus }) => { const { amount } = values const paymentId = isPaying ? authorizedPayment[0]['returnValues']['idPayment'] : rowData.idPledge - const args = isPaying ? [paymentId] : [paymentId, toWei(amount)] + const { chainReadibleFn } = getTokenByAddress(rowData.token) + const args = isPaying ? [paymentId] : [paymentId, chainReadibleFn(amount)] const sendFn = isPaying ? confirmPayment : withdraw try { const toSend = sendFn(...args)