From 347b85fd9040e7a75a35d42054ab289cdf9c6fda Mon Sep 17 00:00:00 2001 From: tom goriunov Date: Tue, 14 Jan 2025 11:55:56 +0100 Subject: [PATCH] Rootstock checksum is not applied on the address page (#2500) Fixes #2494 --- lib/address/getCheckedSummedAddress.ts | 8 +++++++- ui/pages/Address.tsx | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/address/getCheckedSummedAddress.ts b/lib/address/getCheckedSummedAddress.ts index 6cf744620d..5c92b9a390 100644 --- a/lib/address/getCheckedSummedAddress.ts +++ b/lib/address/getCheckedSummedAddress.ts @@ -1,8 +1,14 @@ import { getAddress } from 'viem'; +import config from 'configs/app'; + export default function getCheckedSummedAddress(address: string): string { try { - return getAddress(address); + return getAddress( + address, + // We need to pass chainId to getAddress to make it work correctly for some chains, e.g. Rootstock + config.chain.id ? Number(config.chain.id) : undefined, + ); } catch (error) { return address; } diff --git a/ui/pages/Address.tsx b/ui/pages/Address.tsx index 5cd1347bb3..98443517ae 100644 --- a/ui/pages/Address.tsx +++ b/ui/pages/Address.tsx @@ -69,7 +69,6 @@ const AddressPageContent = () => { const tabsScrollRef = React.useRef(null); const hash = getQueryParamString(router.query.hash); - const checkSummedHash = React.useMemo(() => getCheckedSummedAddress(hash), [ hash ]); const checkDomainName = useCheckDomainNameParam(hash); const checkAddressFormat = useCheckAddressFormat(hash); @@ -364,6 +363,10 @@ const AddressPageContent = () => { return; }, [ appProps.referrer ]); + // API always returns hash in check-summed format except for addresses that are not in the database + // In this case it returns 404 with empty payload, so we calculate check-summed hash on the client + const checkSummedHash = React.useMemo(() => addressQuery.data?.hash ?? getCheckedSummedAddress(hash), [ hash, addressQuery.data?.hash ]); + const titleSecondRow = ( { addressQuery.data?.ens_domain_name && (