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

fix: toBignumber conversion error with high balance #12010

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions app/components/UI/Stake/hooks/useBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
weiToFiatNumber,
} from '../../../../util/number';
import usePooledStakes from './usePooledStakes';
import { BN } from 'ethereumjs-util';

const useBalance = () => {
const accountsByChainId = useSelector(selectAccountsByChainId);
Expand Down Expand Up @@ -50,7 +51,10 @@ const useBalance = () => {
);

const { pooledStakesData } = usePooledStakes();
const assets = pooledStakesData.assets ?? 0;
const assets = useMemo(
() => new BN(pooledStakesData.assets),
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better if we can use hexToBN from @metamask/controller-utils if possible

[pooledStakesData],
);

const formattedStakedBalanceETH = useMemo(
() => `${renderFromWei(assets)} ETH`,
Expand All @@ -72,7 +76,7 @@ const useBalance = () => {
balanceFiat,
balanceWei,
balanceFiatNumber,
stakedBalanceWei: assets,
stakedBalanceWei: pooledStakesData.assets ?? '0',
formattedStakedBalanceETH,
stakedBalanceFiatNumber,
formattedStakedBalanceFiat,
Expand Down
Loading