Skip to content

Commit 347b85f

Browse files
authored
Rootstock checksum is not applied on the address page (#2500)
Fixes #2494
1 parent 96f2e11 commit 347b85f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Diff for: lib/address/getCheckedSummedAddress.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import { getAddress } from 'viem';
22

3+
import config from 'configs/app';
4+
35
export default function getCheckedSummedAddress(address: string): string {
46
try {
5-
return getAddress(address);
7+
return getAddress(
8+
address,
9+
// We need to pass chainId to getAddress to make it work correctly for some chains, e.g. Rootstock
10+
config.chain.id ? Number(config.chain.id) : undefined,
11+
);
612
} catch (error) {
713
return address;
814
}

Diff for: ui/pages/Address.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ const AddressPageContent = () => {
6969

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

7473
const checkDomainName = useCheckDomainNameParam(hash);
7574
const checkAddressFormat = useCheckAddressFormat(hash);
@@ -364,6 +363,10 @@ const AddressPageContent = () => {
364363
return;
365364
}, [ appProps.referrer ]);
366365

366+
// API always returns hash in check-summed format except for addresses that are not in the database
367+
// In this case it returns 404 with empty payload, so we calculate check-summed hash on the client
368+
const checkSummedHash = React.useMemo(() => addressQuery.data?.hash ?? getCheckedSummedAddress(hash), [ hash, addressQuery.data?.hash ]);
369+
367370
const titleSecondRow = (
368371
<Flex alignItems="center" w="100%" columnGap={ 2 } rowGap={ 2 } flexWrap={{ base: 'wrap', lg: 'nowrap' }}>
369372
{ addressQuery.data?.ens_domain_name && (

0 commit comments

Comments
 (0)