Skip to content

Commit

Permalink
feat: add balance polling to two other pages (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvava authored Feb 13, 2025
1 parent c3af0bf commit 49b65e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/pages/Home/components/Portfolio/Assets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ import { isBitcoinNetwork } from '@src/background/services/network/utils/isBitco
import { useAnalyticsContext } from '@src/contexts/AnalyticsProvider';
import { useTokenPriceMissing } from '@src/hooks/useTokenPriceIsMissing';
import { PAndL } from '@src/components/common/ProfitAndLoss';
import { useLiveBalance } from '@src/hooks/useLiveBalance';
import { TokenType } from '@avalabs/vm-module-types';

enum AssetsTabs {
TOKENS,
ACTIVITY,
}

const POLLED_BALANCES = [TokenType.NATIVE, TokenType.ERC20];

export function Assets() {
const { t } = useTranslation();
const { network } = useNetworkContext();
Expand Down Expand Up @@ -70,6 +74,8 @@ export function Assets() {
return isPriceMissingFromNetwork(network?.chainId);
}, [isPriceMissingFromNetwork, network]);

useLiveBalance(POLLED_BALANCES);

return (
<Stack sx={{ flexGrow: 1 }}>
<Stack
Expand Down
6 changes: 6 additions & 0 deletions src/pages/Wallet/TokenFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ import { isXchainNetwork } from '@src/background/services/network/utils/isAvalan
import { getUnconfirmedBalanceInCurrency } from '@src/background/services/balances/models';
import { isTokenMalicious } from '@src/utils/isTokenMalicious';
import { MaliciousTokenWarningBox } from '@src/components/common/MaliciousTokenWarning';
import { useLiveBalance } from '@src/hooks/useLiveBalance';
import { TokenType } from '@avalabs/vm-module-types';

const POLLED_BALANCES = [TokenType.NATIVE, TokenType.ERC20];

export function TokenFlow() {
const { t } = useTranslation();
Expand Down Expand Up @@ -97,6 +101,8 @@ export function TokenFlow() {
}
}, [activeAccount, hasAccessToActiveNetwork, tokensWithBalances]);

useLiveBalance(POLLED_BALANCES);

if (!hasAccessToActiveNetwork) {
return (
<NotSupportedByWallet
Expand Down

0 comments on commit 49b65e7

Please sign in to comment.