Skip to content

Commit

Permalink
Rootstock checksum is not applied on the address page (#2500)
Browse files Browse the repository at this point in the history
Fixes #2494
  • Loading branch information
tom2drum authored Jan 14, 2025
1 parent 96f2e11 commit 347b85f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/address/getCheckedSummedAddress.ts
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion ui/pages/Address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ const AddressPageContent = () => {

const tabsScrollRef = React.useRef<HTMLDivElement>(null);
const hash = getQueryParamString(router.query.hash);
const checkSummedHash = React.useMemo(() => getCheckedSummedAddress(hash), [ hash ]);

const checkDomainName = useCheckDomainNameParam(hash);
const checkAddressFormat = useCheckAddressFormat(hash);
Expand Down Expand Up @@ -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 = (
<Flex alignItems="center" w="100%" columnGap={ 2 } rowGap={ 2 } flexWrap={{ base: 'wrap', lg: 'nowrap' }}>
{ addressQuery.data?.ens_domain_name && (
Expand Down

0 comments on commit 347b85f

Please sign in to comment.