diff --git a/src/components/layout/header/AccountDropdown.tsx b/src/components/layout/header/AccountDropdown.tsx index 14a1e73e..4decda63 100644 --- a/src/components/layout/header/AccountDropdown.tsx +++ b/src/components/layout/header/AccountDropdown.tsx @@ -11,6 +11,7 @@ import { AccountIdentity } from '@/components/shared/account-identity'; import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '@/components/ui/dropdown-menu'; import { useStyledToast } from '@/hooks/useStyledToast'; import { getExplorerURL } from '@/utils/external'; +import { SupportedNetworks } from '@/utils/networks'; export function AccountDropdown() { const { address, chainId } = useConnection(); @@ -61,6 +62,7 @@ export function AccountDropdown() { /> diff --git a/src/components/shared/account-actions-popover.tsx b/src/components/shared/account-actions-popover.tsx index 3e7fe38c..2f24fb41 100644 --- a/src/components/shared/account-actions-popover.tsx +++ b/src/components/shared/account-actions-popover.tsx @@ -11,7 +11,8 @@ import type { Address } from 'viem'; type AccountActionsPopoverProps = { address: Address; - children: ReactNode; + children?: ReactNode; + chainId?: number; }; /** @@ -20,7 +21,7 @@ type AccountActionsPopoverProps = { * - View account (positions page) * - View on Etherscan */ -export function AccountActionsPopover({ address, children }: AccountActionsPopoverProps) { +export function AccountActionsPopover({ address, chainId, children }: AccountActionsPopoverProps) { const toast = useStyledToast(); const handleCopy = useCallback(async () => { @@ -37,9 +38,9 @@ export function AccountActionsPopover({ address, children }: AccountActionsPopov }, [address]); const handleViewExplorer = useCallback(() => { - const explorerUrl = getExplorerURL(address, SupportedNetworks.Mainnet); + const explorerUrl = getExplorerURL(address, (chainId ?? SupportedNetworks.Mainnet) as SupportedNetworks); window.open(explorerUrl, '_blank', 'noopener,noreferrer'); - }, [address]); + }, [address, chainId]); return ( diff --git a/src/components/shared/account-identity.tsx b/src/components/shared/account-identity.tsx index 24085549..603763ef 100644 --- a/src/components/shared/account-identity.tsx +++ b/src/components/shared/account-identity.tsx @@ -19,6 +19,7 @@ import type { Address } from 'viem'; type AccountIdentityProps = { address: Address; + chainId: number; variant?: 'badge' | 'compact' | 'full'; linkTo?: 'explorer' | 'profile' | 'none'; copyable?: boolean; @@ -41,6 +42,7 @@ type AccountIdentityProps = { */ export function AccountIdentity({ address, + chainId, variant = 'badge', linkTo = 'none', copyable = false, @@ -72,7 +74,7 @@ export function AccountIdentity({ if (linkTo === 'none') return null; if (linkTo === 'explorer') { - return getExplorerURL(address as `0x${string}`, SupportedNetworks.Mainnet); + return getExplorerURL(address as `0x${string}`, chainId ?? SupportedNetworks.Mainnet); } if (linkTo === 'profile') { return `/positions/${address}`; @@ -152,7 +154,14 @@ export function AccountIdentity({ ); if (showActions) { - return {badgeElement}; + return ( + + {badgeElement} + + ); } return badgeElement; @@ -228,7 +237,14 @@ export function AccountIdentity({ ); if (showActions) { - return {compactElement}; + return ( + + {compactElement} + + ); } return compactElement; @@ -327,7 +343,14 @@ export function AccountIdentity({ ); if (showActions) { - return {fullElement}; + return ( + + {fullElement} + + ); } return fullElement; diff --git a/src/components/shared/allocator-card.tsx b/src/components/shared/allocator-card.tsx index e41add68..8cbc91f2 100644 --- a/src/components/shared/allocator-card.tsx +++ b/src/components/shared/allocator-card.tsx @@ -1,5 +1,7 @@ import type { Address } from 'viem'; import { AccountIdentity } from './account-identity'; +import { useConnection } from 'wagmi'; +import { SupportedNetworks } from '@/utils/networks'; type AllocatorCardProps = { name: string; @@ -18,6 +20,7 @@ export function AllocatorCard({ onSelect, disabled = false, }: AllocatorCardProps): JSX.Element { + const { chainId } = useConnection(); return (