diff --git a/src/app/common/hooks/account/use-account-names.ts b/src/app/common/hooks/account/use-account-names.ts index dbfe0849c73..25ec916329b 100644 --- a/src/app/common/hooks/account/use-account-names.ts +++ b/src/app/common/hooks/account/use-account-names.ts @@ -8,19 +8,18 @@ import { useCurrentAccountNames, useGetAccountNamesByAddressQuery, } from '@app/query/stacks/bns/bns.hooks'; -import { useCurrentAccountIndex } from '@app/store/accounts/account'; import { useCurrentStacksAccount } from '@app/store/accounts/blockchain/stacks/stacks-account.hooks'; export function useCurrentAccountDisplayName() { const account = useCurrentStacksAccount(); const { data: names = [] } = useCurrentAccountNames(); - const index = useCurrentAccountIndex(); return useMemo(() => { - if (isUndefined(index) && (!account || typeof account?.index !== 'number')) return 'Account'; + if (isUndefined(account?.index) && (!account || typeof account?.index !== 'number')) + return 'Account'; if (names[0]) return parseIfValidPunycode(names[0]); - return getAutogeneratedAccountDisplayName(index); - }, [account, names, index]); + return getAutogeneratedAccountDisplayName(account?.index); + }, [account, names]); } export function useAccountDisplayName({ address, index }: { index: number; address: string }) { diff --git a/src/app/features/current-account/current-account-avatar.tsx b/src/app/features/current-account/current-account-avatar.tsx index 39296fac380..4f68b3861d2 100644 --- a/src/app/features/current-account/current-account-avatar.tsx +++ b/src/app/features/current-account/current-account-avatar.tsx @@ -5,24 +5,22 @@ import { CircleProps } from 'leather-styles/jsx'; import { useCurrentAccountDisplayName } from '@app/common/hooks/account/use-account-names'; import { useDrawers } from '@app/common/hooks/use-drawers'; import { AccountAvatar } from '@app/components/account/account-avatar'; -import { useCurrentAccountIndex } from '@app/store/accounts/account'; -import { useStacksAccounts } from '@app/store/accounts/blockchain/stacks/stacks-account.hooks'; import { StacksAccount } from '@app/store/accounts/blockchain/stacks/stacks-account.models'; -export const CurrentAccountAvatar = memo((props: CircleProps) => { - const accountIndex = useCurrentAccountIndex(); - const accounts = useStacksAccounts(); - const currentAccount = accounts[accountIndex] as StacksAccount | undefined; - const name = useCurrentAccountDisplayName(); - const { setIsShowingSwitchAccountsState } = useDrawers(); - if (!currentAccount) return null; - return ( - setIsShowingSwitchAccountsState(true)} - publicKey={currentAccount.stxPublicKey} - {...props} - /> - ); -}); +export const CurrentAccountAvatar = memo( + (props: CircleProps & { stacksAccount: StacksAccount | undefined }) => { + const { stacksAccount } = props; + const name = useCurrentAccountDisplayName(); + const { setIsShowingSwitchAccountsState } = useDrawers(); + if (!stacksAccount) return null; + return ( + setIsShowingSwitchAccountsState(true)} + publicKey={stacksAccount.stxPublicKey} + {...props} + /> + ); + } +); diff --git a/src/app/features/current-account/popup-header.tsx b/src/app/features/current-account/popup-header.tsx index f77428dc1b9..33a72c2d2d0 100644 --- a/src/app/features/current-account/popup-header.tsx +++ b/src/app/features/current-account/popup-header.tsx @@ -28,7 +28,7 @@ interface PopupHeaderProps { displayAddresssBalanceOf?: 'all' | 'stx'; } function PopupHeaderSuspense({ displayAddresssBalanceOf = 'stx' }: PopupHeaderProps) { - const account = useCurrentStacksAccount(); + const stacksAccount = useCurrentStacksAccount(); const isBitcoinEnabled = useConfigBitcoinEnabled(); return ( @@ -39,6 +39,7 @@ function PopupHeaderSuspense({ displayAddresssBalanceOf = 'stx' }: PopupHeaderPr fontSize="16px" fontWeight={500} size="32px" + stacksAccount={stacksAccount} /> } > @@ -49,8 +50,8 @@ function PopupHeaderSuspense({ displayAddresssBalanceOf = 'stx' }: PopupHeaderPr - {account && displayAddresssBalanceOf === 'stx' && ( - + {stacksAccount && displayAddresssBalanceOf === 'stx' && ( + )} {isBitcoinEnabled && displayAddresssBalanceOf === 'all' && } diff --git a/src/app/pages/home/components/account-area.tsx b/src/app/pages/home/components/account-area.tsx deleted file mode 100644 index c611ba8e090..00000000000 --- a/src/app/pages/home/components/account-area.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { memo } from 'react'; - -import { HStack, HstackProps, Stack } from 'leather-styles/jsx'; - -import { CurrentAccountAvatar } from '@app/features/current-account/current-account-avatar'; -import { CurrentAccountName } from '@app/features/current-account/current-account-name'; -import { useCurrentAccountNativeSegwitAddressIndexZero } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks'; -import { useCurrentStacksAccount } from '@app/store/accounts/blockchain/stacks/stacks-account.hooks'; - -import { AccountTotalBalance } from '../../../components/account-total-balance'; - -export const CurrentAccount = memo((props: HstackProps) => { - const currentAccount = useCurrentStacksAccount(); - const btcAddress = useCurrentAccountNativeSegwitAddressIndexZero(); - - if (!currentAccount) return null; - return ( - - - - - - - - - - ); -}); diff --git a/src/app/pages/home/components/home.layout.tsx b/src/app/pages/home/components/home.layout.tsx index ec87c40e572..ed6182d0863 100644 --- a/src/app/pages/home/components/home.layout.tsx +++ b/src/app/pages/home/components/home.layout.tsx @@ -5,7 +5,7 @@ import { Stack } from 'leather-styles/jsx'; import { AccountInfoCard } from './account-info-card'; -type HomeLayoutProps = Record<'currentAccount' | 'children', React.ReactNode>; +type HomeLayoutProps = Record<'children', React.ReactNode>; export function HomeLayout({ children }: HomeLayoutProps) { return ( diff --git a/src/app/pages/home/home.tsx b/src/app/pages/home/home.tsx index d6187512d63..330b027f6a2 100644 --- a/src/app/pages/home/home.tsx +++ b/src/app/pages/home/home.tsx @@ -13,7 +13,6 @@ import { InAppMessages } from '@app/features/hiro-messages/in-app-messages'; import { homePageModalRoutes } from '@app/routes/app-routes'; import { ModalBackgroundWrapper } from '@app/routes/components/modal-background-wrapper'; -import { CurrentAccount } from './components/account-area'; import { HomeTabs } from './components/home-tabs'; import { HomeLayout } from './components/home.layout'; @@ -34,7 +33,7 @@ export function Home() { }); return ( - }> +