From 474b66bbffd808f53b365dca572661b2d98ebf79 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Thu, 7 Mar 2024 14:51:57 +0000 Subject: [PATCH] feat: add alias to wallet menu --- .../vega-wallet/vega-wallet-menu.tsx | 52 ++++++++++++++++--- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/apps/trading/components/vega-wallet/vega-wallet-menu.tsx b/apps/trading/components/vega-wallet/vega-wallet-menu.tsx index 02a341980..c2ca3bd16 100644 --- a/apps/trading/components/vega-wallet/vega-wallet-menu.tsx +++ b/apps/trading/components/vega-wallet/vega-wallet-menu.tsx @@ -12,6 +12,8 @@ import CopyToClipboard from 'react-copy-to-clipboard'; import { ViewType, useSidebar } from '../sidebar'; import { useGetCurrentRouteId } from '../../lib/hooks/use-get-current-route-id'; import { useT } from '../../lib/use-t'; +import { usePartyProfilesQuery } from '../vega-wallet-connect-button/__generated__/PartyProfiles'; +import { useProfileDialogStore } from '../../stores/profile-dialog-store'; export const VegaWalletMenu = ({ setMenu, @@ -23,6 +25,11 @@ export const VegaWalletMenu = ({ const currentRouteId = useGetCurrentRouteId(); const setViews = useSidebar((store) => store.setViews); + const { data } = usePartyProfilesQuery({ + variables: { partyIds: pubKeys.map((pk) => pk.publicKey) }, + skip: pubKeys.length <= 0, + }); + const activeKey = useMemo(() => { return pubKeys?.find((pk) => pk.publicKey === pubKey); }, [pubKey, pubKeys]); @@ -37,14 +44,21 @@ export const VegaWalletMenu = ({ return (
- {(pubKeys || []).map((pk) => ( - - ))} + {(pubKeys || []).map((pk) => { + const profile = data?.partiesProfilesConnection?.edges.find( + (e) => e.node.partyId === pk.publicKey + ); + return ( + + ); + })}
@@ -72,14 +86,19 @@ export const VegaWalletMenu = ({ const KeypairListItem = ({ pk, isActive, + alias, onSelectItem, + setMenu, }: { pk: Key; isActive: boolean; + alias: string | undefined; onSelectItem: (pk: string) => void; + setMenu: (open: 'nav' | 'wallet' | null) => void; }) => { const t = useT(); const [copied, setCopied] = useCopyTimeout(); + const setOpen = useProfileDialogStore((store) => store.setOpen); return (
{copied && {t('Copied')}} + + + +
); };