diff --git a/app/[locale]/address/[addressOrName]/page.tsx b/app/[locale]/address/[addressOrName]/page.tsx index 0c90f0cf6..b5dbdb0d4 100644 --- a/app/[locale]/address/[addressOrName]/page.tsx +++ b/app/[locale]/address/[addressOrName]/page.tsx @@ -1,6 +1,6 @@ import AllowanceDashboard from 'components/allowances/dashboard/AllowanceDashboard'; import { isNullish } from 'lib/utils'; -import { getChainName } from 'lib/utils/chains'; +import { getChainName, isSupportedChain } from 'lib/utils/chains'; import { shortenAddress } from 'lib/utils/formatting'; import { getAddressAndDomainName } from 'lib/utils/whois'; import type { Metadata, NextPage } from 'next'; @@ -25,7 +25,9 @@ export const generateMetadata = async ({ const { address, domainName } = await getAddressAndDomainName(addressOrName); const addressDisplay = domainName ?? shortenAddress(address); - const chainName = getChainName(Number(searchParams.chainId || 1)); + const chainIdFromSearchParams = Number(searchParams.chainId || 1); + const chainId = isSupportedChain(chainIdFromSearchParams) ? chainIdFromSearchParams : 1; + const chainName = getChainName(chainId); const title = isNullish(searchParams.chainId) ? t('address.meta.title', { addressDisplay }) diff --git a/lib/hooks/page-context/AddressPageContext.tsx b/lib/hooks/page-context/AddressPageContext.tsx index d4af96cce..4ad8a4c7c 100644 --- a/lib/hooks/page-context/AddressPageContext.tsx +++ b/lib/hooks/page-context/AddressPageContext.tsx @@ -45,7 +45,7 @@ export const AddressPageContextProvider = ({ children, address, domainName, init const queryChainId = Number.parseInt(searchParams.get('chainId') as string); const defaultChainId = [initialChainId, queryChainId, chain?.id, 1] .filter((chainId) => !isNullish(chainId)) - .find((chainId) => isSupportedChain(chainId!)) as number; + .find((chainId) => isSupportedChain(chainId)) as number; const [selectedChainId, selectChain] = useState(defaultChainId); // Note: We use useLayoutEffect here, because this is the only setup that works with the "spenderSearch" query param as well