From 7eafe7ac4d8fae9827c14de643717ca211274383 Mon Sep 17 00:00:00 2001 From: Mitch Oz Date: Mon, 2 Dec 2024 15:36:53 -0600 Subject: [PATCH] fix some decimal handling and incorrect USDC.e symbol on drop down menu --- .../donate/Recurring/RecurringDonationCard.tsx | 17 ++++++++++------- .../SelectTokenModal/SelectTokenModal.tsx | 3 +-- .../Recurring/SelectTokenModal/StreamInfo.tsx | 12 ++++++------ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/components/views/donate/Recurring/RecurringDonationCard.tsx b/src/components/views/donate/Recurring/RecurringDonationCard.tsx index 8ad2737caf..85c64d0b94 100644 --- a/src/components/views/donate/Recurring/RecurringDonationCard.tsx +++ b/src/components/views/donate/Recurring/RecurringDonationCard.tsx @@ -44,7 +44,7 @@ import { showToastError, truncateToDecimalPlaces } from '@/lib/helpers'; import config from '@/configuration'; import { WrongNetworkLayer } from '../WrongNetworkLayer'; import { ModifySuperTokenModal } from './ModifySuperToken/ModifySuperTokenModal'; -import { limitFraction } from '@/helpers/number'; +import { limitFraction, formatDonation } from '@/helpers/number'; import AlloProtocolFirstDonationModal from './AlloProtocolFirstDonationModal'; import links from '@/lib/constants/links'; import Routes from '@/lib/constants/Routes'; @@ -570,12 +570,15 @@ export const RecurringDonationCard = () => { id: 'label.you_will_donate_total', })}{' '} - {limitFraction( - formatUnits( - totalStreamPerSec * - ONE_MONTH_SECONDS, - selectedRecurringToken - ?.token.decimals || 18, + {formatDonation( + limitFraction( + formatUnits( + totalStreamPerSec * + ONE_MONTH_SECONDS, + selectedRecurringToken + ?.token.decimals || + 18, + ), ), )}{' '} { diff --git a/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx b/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx index a841587642..cf5fb3c854 100644 --- a/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx +++ b/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx @@ -113,7 +113,6 @@ const SelectTokenInnerModal: FC = ({ return balances[symbol] !== undefined && balances[symbol] > 0n; }, ); - return ( <> @@ -137,6 +136,7 @@ const SelectTokenInnerModal: FC = ({ = ({ )} )} - {!isUserHasBalanceForAllSuperTokens && ( <> diff --git a/src/components/views/donate/Recurring/SelectTokenModal/StreamInfo.tsx b/src/components/views/donate/Recurring/SelectTokenModal/StreamInfo.tsx index e426975e33..2adac94dea 100644 --- a/src/components/views/donate/Recurring/SelectTokenModal/StreamInfo.tsx +++ b/src/components/views/donate/Recurring/SelectTokenModal/StreamInfo.tsx @@ -3,7 +3,7 @@ import styled from 'styled-components'; import { type FC } from 'react'; import { formatUnits } from 'viem'; import { useIntl } from 'react-intl'; -import { ISuperfluidStream } from '@/types/superFluid'; +import { ISuperfluidStream, IToken } from '@/types/superFluid'; import { limitFraction } from '@/helpers/number'; import { countActiveStreams } from '@/helpers/donate'; import { findTokenByAddress } from '@/helpers/superfluid'; @@ -11,6 +11,7 @@ import { TokenIconWithGIVBack } from '../../TokenIcon/TokenIconWithGIVBack'; interface IStreamInfoProps { stream: ISuperfluidStream[]; + superToken: IToken; balance: bigint; disable: boolean; onClick: () => void; @@ -20,12 +21,12 @@ interface IStreamInfoProps { export const StreamInfo: FC<IStreamInfoProps> = ({ stream, balance, + superToken, disable, onClick, isSuperToken, }) => { const { formatMessage } = useIntl(); - const totalFlowRate = stream.reduce( (acc, curr) => acc + BigInt(curr.currentFlowRate), 0n, @@ -38,7 +39,6 @@ export const StreamInfo: FC<IStreamInfoProps> = ({ const token = findTokenByAddress(stream[0].token.id); const underlyingToken = token?.underlyingToken; const activeStreamCount = countActiveStreams(stream); - return ( <Wrapper gap='16px' @@ -62,8 +62,8 @@ export const StreamInfo: FC<IStreamInfoProps> = ({ > <Row $justifyContent='space-between'> <Symbol> - <Caption $medium>{stream[0].token.symbol}</Caption> - <GrayCaption>{stream[0].token.name}</GrayCaption> + <Caption $medium>{superToken.symbol}</Caption> + <GrayCaption>{superToken.name}</GrayCaption> </Symbol> <Balance gap='4px'> <GrayCaption>Stream Balance</GrayCaption> @@ -78,7 +78,7 @@ export const StreamInfo: FC<IStreamInfoProps> = ({ ) : '--'} </Caption> - <Caption $medium>{stream[0].token.symbol}</Caption> + <Caption $medium>{superToken.symbol}</Caption> </Balance> </Row> {totalFlowRate !== undefined && (