From 1380f88c71bc2ce3577d57dcbadee6f1a2ddb8dc Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Tue, 18 Jun 2019 15:31:21 -0400 Subject: [PATCH] use token specific formatter for backing --- src/components/projects/BackProject.jsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/projects/BackProject.jsx b/src/components/projects/BackProject.jsx index c6ad027..bdaf827 100644 --- a/src/components/projects/BackProject.jsx +++ b/src/components/projects/BackProject.jsx @@ -7,8 +7,8 @@ import { withDatabase } from '@nozbe/watermelondb/DatabaseProvider' import { withStyles } from '@material-ui/core/styles' import { useProjectData, useProfileData } from './hooks' import {TextField, Button, MenuItem, Divider, Typography, Link} from '@material-ui/core' -import { toEther, toWei } from '../../utils/conversions' -import { getTokenLabel } from '../../utils/currencies' +import { toEther } from '../../utils/conversions' +import { getTokenLabel, getTokenByAddress } from '../../utils/currencies' const { transfer } = LiquidPledging.methods @@ -57,7 +57,8 @@ const SubmissionSection = ({ classes, profiles, delegatePledges, projectId, open const { amount, delegateProfile, delegatePledge } = values const dPledge = delegatePledges.find(d => d.idPledge === delegatePledge) const pledge = await dPledge.pledge.fetch() - const args = [delegateProfile.idProfile, delegatePledge, toWei(amount), projectId] + const { chainReadibleFn } = getTokenByAddress(pledge.token) + const args = [delegateProfile.idProfile, delegatePledge, chainReadibleFn(amount), projectId] console.log({values, args, pledge, delegatePledge}) const toSend = transfer(...args) const estimatedGas = await toSend.estimateGas() @@ -128,9 +129,10 @@ const SubmissionSection = ({ classes, profiles, delegatePledges, projectId, open const numPledges = filteredPledges.length const amount = filteredPledges.reduce((cv,pv) => cv + Number(pv.pledgeData.amount) ,0) const token = numPledges ? filteredPledges[0].pledgeData.token : '' + const amountFormatter = token ? getTokenByAddress(token).humanReadibleFn : toEther return ( - {profile.name} - {numPledges} Pledges - {toEther(amount.toString())} {getTokenLabel(token)} + {profile.name} - {numPledges} Pledges - {amountFormatter(amount.toString())} {getTokenLabel(token)} ) })} @@ -150,7 +152,7 @@ const SubmissionSection = ({ classes, profiles, delegatePledges, projectId, open > {filteredPledges.map(pledge => ( - {`Pledge no: ${pledge.idPledge} - Amount: ${toEther(pledge.pledgeData.amount)} ${getTokenLabel(pledge.pledgeData.token)}`} + {`Pledge no: ${pledge.idPledge} - Amount: ${getTokenByAddress(pledge.pledgeData.token).humanReadibleFn(pledge.pledgeData.amount)} ${getTokenLabel(pledge.pledgeData.token)}`} ))} }