Skip to content

Commit

Permalink
[Job Launcher Client] Fix amount normalization (#1180)
Browse files Browse the repository at this point in the history
* fix: normalize amounts

* do not round
  • Loading branch information
m00n620 authored Nov 3, 2023
1 parent 04b52bb commit ae1e181
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useJobDetails } from '../../../hooks/useJobDetails';
import { useSnackbar } from '../../../providers/SnackProvider';
import * as jobService from '../../../services/job';
import { JobStatus } from '../../../types';
import { formatAmount } from '../../../utils/bignumber';

const CardContainer = styled(Card)(({ theme }) => ({
borderRadius: '16px',
Expand Down Expand Up @@ -103,7 +104,7 @@ export default function JobDetail() {
/>
<CardTextRow
label="Paid Out HMT"
value={`${data.details.paidOut} HMT`}
value={`${formatAmount(data.details.paidOut.toString())} HMT`}
/>
<CardTextRow label="Amount of Jobs" value="" />
<CardTextRow label="Workers assigned" value="" />
Expand All @@ -124,11 +125,13 @@ export default function JobDetail() {
<CardTextRow label="Staker" value={data.staking.staker} />
<CardTextRow
label="Staked HMT"
value={`${data.staking.allocated} HMT`}
value={`${formatAmount(
data.staking.allocated.toString()
)} HMT`}
/>
<CardTextRow
label="Slashed HMT"
value={`${data.staking.slashed} HMT`}
value={`${formatAmount(data.staking.slashed.toString())} HMT`}
/>
</Stack>
</CardContainer>
Expand Down Expand Up @@ -165,7 +168,9 @@ export default function JobDetail() {
/>
<CardTextRow
label="Fund Amount"
value={`${data.manifest.fundAmount} HMT`}
value={`${formatAmount(
data.manifest.fundAmount.toString()
)} HMT`}
/>
<CardTextRow
label="Job Requester"
Expand Down
4 changes: 1 addition & 3 deletions packages/apps/job-launcher/client/src/utils/bignumber.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { ethers, BigNumber } from 'ethers';

export const formatAmount = (amount: string) => {
return Number(ethers.utils.formatUnits(BigNumber.from(amount), 18)).toFixed(
2
);
return ethers.utils.formatUnits(BigNumber.from(amount), 18);
};

1 comment on commit ae1e181

@vercel
Copy link

@vercel vercel bot commented on ae1e181 Nov 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

job-launcher-client – ./packages/apps/job-launcher/client

job-launcher-client-humanprotocol.vercel.app
job-launcher-client-git-develop-humanprotocol.vercel.app
job-launcher-client-nine.vercel.app

Please sign in to comment.