diff --git a/packages/widget/src/components/Header/WalletHeader.tsx b/packages/widget/src/components/Header/WalletHeader.tsx index 96ae0b654..f79f01adf 100644 --- a/packages/widget/src/components/Header/WalletHeader.tsx +++ b/packages/widget/src/components/Header/WalletHeader.tsx @@ -6,17 +6,13 @@ import { Box, IconButton, Typography } from '@mui/material'; import { useTranslation } from 'react-i18next'; import { useLocation, useNavigate } from 'react-router-dom'; import { useWallet, useWidgetConfig } from '../../providers'; -import { navigationRoutes } from '../../utils'; +import { navigationRoutes, shortenWalletAddress } from '../../utils'; import { HeaderAppBar } from './Header.style'; export const WalletHeader: React.FC = () => { const { t } = useTranslation(); const { account, disconnect } = useWallet(); - const walletAddress = account.address - ? `${account.address.substring(0, 7)}...${account.address.substring( - account.address.length - 7, - )}` - : null; + const walletAddress = shortenWalletAddress(account.address); return ( diff --git a/packages/widget/src/utils/wallet.ts b/packages/widget/src/utils/wallet.ts new file mode 100644 index 000000000..1e628ba55 --- /dev/null +++ b/packages/widget/src/utils/wallet.ts @@ -0,0 +1,4 @@ +export const shortenWalletAddress = (address?: string) => + address + ? `${address.substring(0, 5)}...${address.substring(address.length - 4)}` + : null;