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: use signed stacks account in transaction #4923 #5152

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 4 additions & 5 deletions src/app/common/hooks/account/use-account-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down
1 change: 0 additions & 1 deletion src/app/features/container/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export function Container() {
const navigate = useNavigate();
const { pathname: locationPathname } = useLocation();
const pathname = locationPathname as RouteUrls;

const analytics = useAnalytics();
const hasStateRehydrated = useHasStateRehydrated();
const { chain, name: chainName } = useCurrentNetworkState();
Expand Down
14 changes: 5 additions & 9 deletions src/app/features/current-account/current-account-avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,23 @@ import { memo } from 'react';
import { CircleProps } from 'leather-styles/jsx';

import { useCurrentAccountDisplayName } from '@app/common/hooks/account/use-account-names';
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';
import { useCurrentStacksAccount } from '@app/store/accounts/blockchain/stacks/stacks-account.hooks';
import { AccountAvatar } from '@app/ui/components/account/account-avatar/account-avatar';

interface CurrentAccountAvatar extends CircleProps {
toggleSwitchAccount(): void;
}
export const CurrentAccountAvatar = memo(({ toggleSwitchAccount }: CurrentAccountAvatar) => {
const accountIndex = useCurrentAccountIndex();
const accounts = useStacksAccounts();
const currentAccount = accounts[accountIndex] as StacksAccount | undefined;
const stacksAccount = useCurrentStacksAccount();
const name = useCurrentAccountDisplayName();
if (!stacksAccount) return null;

if (!currentAccount) return null;
return (
<AccountAvatar
index={currentAccount.index}
index={stacksAccount.index}
name={name}
onClick={() => toggleSwitchAccount()}
publicKey={currentAccount.stxPublicKey}
publicKey={stacksAccount.stxPublicKey}
/>
);
});
Loading