Skip to content

Commit

Permalink
Fixes change wallet sheet missing balance (#6253)
Browse files Browse the repository at this point in the history
* wrong accessor causing the label to be blank

* add deprecated tag to old useWalletBalances hook
  • Loading branch information
walmat authored Nov 4, 2024
1 parent 42ab406 commit 4f8da7c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/components/change-wallet/AddressRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,30 @@ interface AddressRowProps {
export default function AddressRow({ contextMenuActions, data, editMode, onPress }: AddressRowProps) {
const notificationsEnabled = useExperimentalFlag(NOTIFICATIONS);

const { address, balances, color: accountColor, ens, image: accountImage, isSelected, isReadOnly, isLedger, label, walletId } = data;
const {
address,
balancesMinusHiddenBalances,
color: accountColor,
ens,
image: accountImage,
isSelected,
isReadOnly,
isLedger,
label,
walletId,
} = data;

const { colors, isDarkMode } = useTheme();

const labelQuaternary = useForegroundColor('labelQuaternary');

const balanceText = useMemo(() => {
if (!balances) {
if (!balancesMinusHiddenBalances) {
return lang.t('wallet.change_wallet.loading_balance');
}

return balances.balancesMinusHiddenBalances;
}, [balances]);
return balancesMinusHiddenBalances;
}, [balancesMinusHiddenBalances]);

const cleanedUpLabel = useMemo(() => removeFirstEmojiFromString(label), [label]);

Expand Down
6 changes: 6 additions & 0 deletions src/hooks/useWalletBalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ export type WalletBalanceResult = {
isLoading: boolean;
};

/**
* Hook to fetch balances for all wallets
* @deprecated - you probably want to use useWalletsWithBalancesAndNames instead which accounts for hidden assets balances
* @param wallets - All Rainbow wallets
* @returns Balances for all wallets
*/
const useWalletBalances = (wallets: AllRainbowWallets): WalletBalanceResult => {
const { nativeCurrency } = useAccountSettings();

Expand Down

0 comments on commit 4f8da7c

Please sign in to comment.