Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Job Launcher Client] Fix amount normalization #1180

Merged
merged 3 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
};