use chainReadibleFn for transfers and withdraws

This commit is contained in:
Barry Gitarts 2019-06-14 15:39:38 -04:00
parent 8e358aa860
commit 0732600441
2 changed files with 6 additions and 6 deletions

View File

@ -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()

View File

@ -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)