Skip to content

Commit

Permalink
fix: forknet balances
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Oct 16, 2023
1 parent 9c60d75 commit ac09b2d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/common/components/BalanceReminderPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {IconAddToMetamask} from '@yearn-finance/web-lib/icons/IconAddToMetamask'
import {IconCross} from '@yearn-finance/web-lib/icons/IconCross';
import {IconWallet} from '@yearn-finance/web-lib/icons/IconWallet';
import {toAddress, truncateHex} from '@yearn-finance/web-lib/utils/address';
import {cl} from '@yearn-finance/web-lib/utils/cl';
import {formatAmount} from '@yearn-finance/web-lib/utils/format.number';
import {ImageWithFallback} from '@common/components/ImageWithFallback';
import {useWallet} from '@common/contexts/useWallet';
Expand Down Expand Up @@ -89,7 +90,7 @@ function TokenItem({element}: {element: TBalanceReminderElement}): ReactElement
}

export function BalanceReminderPopover(): ReactElement {
const {balances: tokens, isLoading, triggerForknetBalances} = useWallet();
const {balances: tokens, isLoading, triggerForknetBalances, shouldUseForknetBalances} = useWallet();
const {address, ens, isActive, onDesactivate} = useWeb3();
const {vaults} = useYearn();

Expand Down Expand Up @@ -155,7 +156,11 @@ export function BalanceReminderPopover(): ReactElement {
<Popover.Panel className={'yearn--shadow absolute right-0 top-6 z-[1000] mt-3 w-screen max-w-xs md:-right-4 md:top-4'}>
<div className={'overflow-hidden'}>
<div className={'relative bg-neutral-0 p-0'}>
<div className={'absolute left-4 top-4 opacity-0 transition-colors hover:opacity-100'}>
<div
className={cl(
'absolute left-4 top-4 opacity-0 transition-colors hover:opacity-100',
shouldUseForknetBalances ? 'opacity-100' : 'opacity-0'
)}>
<button
onClick={(): void => {
// Special command to enable dev forknet balances
Expand Down
3 changes: 3 additions & 0 deletions apps/common/contexts/useWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export type TWalletContext = {
cumulatedValueInVaults: number;
balancesNonce: number;
isLoading: boolean;
shouldUseForknetBalances: boolean;
refresh: (tokenList?: TUseBalancesTokens[]) => Promise<TChainTokens>;
triggerForknetBalances: () => void;
};
Expand All @@ -97,6 +98,7 @@ const defaultProps = {
cumulatedValueInVaults: 0,
balancesNonce: 0,
isLoading: true,
shouldUseForknetBalances: false,
refresh: async (): Promise<TChainTokens> => ({}),
triggerForknetBalances: (): void => {}
};
Expand Down Expand Up @@ -335,6 +337,7 @@ export const WalletContextApp = memo(function WalletContextApp({children}: {chil
balancesNonce: nonce,
cumulatedValueInVaults,
isLoading: isLoading || false,
shouldUseForknetBalances,
refresh: onRefresh,
triggerForknetBalances: (): void => set_shouldUseForknetBalances((s): boolean => !s)
}),
Expand Down

0 comments on commit ac09b2d

Please sign in to comment.