Commit bbc37ef1 authored by tom goriunov's avatar tom goriunov Committed by GitHub

Display checksum-ed addresses (#2240)

Fixes #2222
parent 67703471
import { getAddress } from 'viem';
export default function getCheckedSummedAddress(address: string): string {
try {
return getAddress(address);
} catch (error) {
return address;
}
}
...@@ -6,6 +6,7 @@ import type { EntityTag } from 'ui/shared/EntityTags/types'; ...@@ -6,6 +6,7 @@ import type { EntityTag } from 'ui/shared/EntityTags/types';
import type { RoutedTab } from 'ui/shared/Tabs/types'; import type { RoutedTab } from 'ui/shared/Tabs/types';
import config from 'configs/app'; import config from 'configs/app';
import getCheckedSummedAddress from 'lib/address/getCheckedSummedAddress';
import useAddressMetadataInfoQuery from 'lib/address/useAddressMetadataInfoQuery'; import useAddressMetadataInfoQuery from 'lib/address/useAddressMetadataInfoQuery';
import useApiQuery from 'lib/api/useApiQuery'; import useApiQuery from 'lib/api/useApiQuery';
import { useAppContext } from 'lib/contexts/app'; import { useAppContext } from 'lib/contexts/app';
...@@ -60,6 +61,7 @@ const AddressPageContent = () => { ...@@ -60,6 +61,7 @@ const AddressPageContent = () => {
const tabsScrollRef = React.useRef<HTMLDivElement>(null); const tabsScrollRef = React.useRef<HTMLDivElement>(null);
const hash = getQueryParamString(router.query.hash); const hash = getQueryParamString(router.query.hash);
const checkSummedHash = React.useMemo(() => getCheckedSummedAddress(hash), [ hash ]);
const areQueriesEnabled = !useCheckDomainNameParam(hash); const areQueriesEnabled = !useCheckDomainNameParam(hash);
const addressQuery = useAddressQuery({ hash, isEnabled: areQueriesEnabled }); const addressQuery = useAddressQuery({ hash, isEnabled: areQueriesEnabled });
...@@ -310,7 +312,7 @@ const AddressPageContent = () => { ...@@ -310,7 +312,7 @@ const AddressPageContent = () => {
/> />
) } ) }
<AddressEntity <AddressEntity
address={{ ...addressQuery.data, hash, name: '', ens_domain_name: '', implementations: null }} address={{ ...addressQuery.data, hash: checkSummedHash, name: '', ens_domain_name: '', implementations: null }}
isLoading={ isLoading } isLoading={ isLoading }
fontFamily="heading" fontFamily="heading"
fontSize="lg" fontSize="lg"
...@@ -325,7 +327,7 @@ const AddressPageContent = () => { ...@@ -325,7 +327,7 @@ const AddressPageContent = () => {
{ !isLoading && !addressQuery.data?.is_contract && config.features.account.isEnabled && ( { !isLoading && !addressQuery.data?.is_contract && config.features.account.isEnabled && (
<AddressFavoriteButton hash={ hash } watchListId={ addressQuery.data?.watchlist_address_id }/> <AddressFavoriteButton hash={ hash } watchListId={ addressQuery.data?.watchlist_address_id }/>
) } ) }
<AddressQrCode address={{ hash }} isLoading={ isLoading }/> <AddressQrCode address={{ hash: checkSummedHash }} isLoading={ isLoading }/>
<AccountActionsMenu isLoading={ isLoading }/> <AccountActionsMenu isLoading={ isLoading }/>
<HStack ml="auto" gap={ 2 }/> <HStack ml="auto" gap={ 2 }/>
{ !isLoading && addressQuery.data?.is_contract && addressQuery.data?.is_verified && config.UI.views.address.solidityscanEnabled && { !isLoading && addressQuery.data?.is_contract && addressQuery.data?.is_verified && config.UI.views.address.solidityscanEnabled &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment