use chainReadibleFn for transfers and withdraws
This commit is contained in:
parent
8e358aa860
commit
0732600441
|
@ -10,8 +10,7 @@ import Card from '@material-ui/core/Card'
|
||||||
import CardActions from '@material-ui/core/CardActions'
|
import CardActions from '@material-ui/core/CardActions'
|
||||||
import CardContent from '@material-ui/core/CardContent'
|
import CardContent from '@material-ui/core/CardContent'
|
||||||
import Collapse from '@material-ui/core/Collapse'
|
import Collapse from '@material-ui/core/Collapse'
|
||||||
import { getTokenLabel } from '../../utils/currencies'
|
import { getTokenLabel, getTokenByAddress } from '../../utils/currencies'
|
||||||
import { toWei } from '../../utils/conversions'
|
|
||||||
import styles from './CardStyles'
|
import styles from './CardStyles'
|
||||||
import { useRowData } from './hooks'
|
import { useRowData } from './hooks'
|
||||||
|
|
||||||
|
@ -25,7 +24,8 @@ function TransferCard({ row, handleClose, classes }) {
|
||||||
onSubmit={async (values, { setSubmitting: _setSubmitting, resetForm, setStatus: _setStatus }) => {
|
onSubmit={async (values, { setSubmitting: _setSubmitting, resetForm, setStatus: _setStatus }) => {
|
||||||
const { idPledge, pledge } = row
|
const { idPledge, pledge } = row
|
||||||
const { idSender, amount, idReceiver } = values
|
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 toSend = transfer(...args)
|
||||||
const estimatedGas = await toSend.estimateGas()
|
const estimatedGas = await toSend.estimateGas()
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,7 @@ import TextField from '@material-ui/core/TextField'
|
||||||
import Collapse from '@material-ui/core/Collapse'
|
import Collapse from '@material-ui/core/Collapse'
|
||||||
import LiquidPledging from '../../embarkArtifacts/contracts/LiquidPledging'
|
import LiquidPledging from '../../embarkArtifacts/contracts/LiquidPledging'
|
||||||
import LPVault from '../../embarkArtifacts/contracts/LPVault'
|
import LPVault from '../../embarkArtifacts/contracts/LPVault'
|
||||||
import { getTokenLabel } from '../../utils/currencies'
|
import { getTokenLabel, getTokenByAddress } from '../../utils/currencies'
|
||||||
import { toWei } from '../../utils/conversions'
|
|
||||||
import styles from './CardStyles'
|
import styles from './CardStyles'
|
||||||
import { useRowData } from './hooks'
|
import { useRowData } from './hooks'
|
||||||
|
|
||||||
|
@ -31,7 +30,8 @@ function Withdraw({ handleClose, classes, rowData, authorizedPayment }) {
|
||||||
onSubmit={async (values, { setSubmitting: _setSubmitting, resetForm: _resetForm, setStatus: _setStatus }) => {
|
onSubmit={async (values, { setSubmitting: _setSubmitting, resetForm: _resetForm, setStatus: _setStatus }) => {
|
||||||
const { amount } = values
|
const { amount } = values
|
||||||
const paymentId = isPaying ? authorizedPayment[0]['returnValues']['idPayment'] : rowData.idPledge
|
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
|
const sendFn = isPaying ? confirmPayment : withdraw
|
||||||
try {
|
try {
|
||||||
const toSend = sendFn(...args)
|
const toSend = sendFn(...args)
|
||||||
|
|
Loading…
Reference in New Issue