Skip to content

Commit bf0411d

Browse files
committed
fix: refactor token formatting
1 parent 0c0ec94 commit bf0411d

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

src/components/v5/common/CompletedAction/partials/CompletedExpenditureContent/CompletedExpenditureContent.tsx

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Repeat, UserFocus } from '@phosphor-icons/react';
22
import clsx from 'clsx';
33
import { BigNumber } from 'ethers';
4-
import moveDecimal from 'move-decimal-point';
54
import React, { type FC } from 'react';
65
import { type FieldValues } from 'react-hook-form';
76

@@ -20,7 +19,6 @@ import {
2019
} from '~types/graphql.ts';
2120
import { getRecipientsNumber, getTokensNumber } from '~utils/expenditures.ts';
2221
import { formatText } from '~utils/intl.ts';
23-
import { getTokenDecimalsWithFallback } from '~utils/tokens.ts';
2422
import MeatBallMenu from '~v5/shared/MeatBallMenu/MeatBallMenu.tsx';
2523
import { type MeatBallMenuItem } from '~v5/shared/MeatBallMenu/types.ts';
2624
import UserInfoPopover from '~v5/shared/UserInfoPopover/UserInfoPopover.tsx';
@@ -74,32 +72,18 @@ const CompletedExpenditureContent: FC<CompletedExpenditureContentProps> = ({
7472

7573
const stages = (metadata?.stages || []).map((stage) => {
7674
const currentSlot = slots.find((slot) => slot.id === stage.slotId);
77-
const token = allTokens.find(
78-
({ token: currentToken }) =>
79-
currentToken.tokenAddress === currentSlot?.payouts?.[0].tokenAddress,
80-
);
8175

8276
return {
8377
milestone: stage.name,
84-
amount: moveDecimal(
85-
currentSlot?.payouts?.[0].amount,
86-
-getTokenDecimalsWithFallback(token?.token.decimals),
87-
),
78+
amount: currentSlot?.payouts?.[0].amount,
8879
tokenAddress: currentSlot?.payouts?.[0].tokenAddress,
8980
};
9081
});
9182

92-
const summedAmount = stages.reduce((acc, { amount, tokenAddress }) => {
93-
const token = allTokens.find(
94-
({ token: currentToken }) => currentToken.tokenAddress === tokenAddress,
95-
);
96-
const formattedAmount = moveDecimal(
97-
amount || '0',
98-
getTokenDecimalsWithFallback(token?.token.decimals),
99-
);
100-
101-
return BigNumber.from(acc).add(BigNumber.from(formattedAmount));
102-
}, BigNumber.from('0'));
83+
const summedAmount = stages.reduce(
84+
(acc, { amount }) => BigNumber.from(acc).add(BigNumber.from(amount)),
85+
BigNumber.from('0'),
86+
);
10387

10488
const tokensCount = getTokensNumber(expenditure);
10589
const stagedPaymentTokenSymbol =

0 commit comments

Comments
 (0)