Skip to content

Commit

Permalink
add more robust addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
isstuev committed Oct 24, 2024
1 parent 24f397b commit 2c8b228
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 17 deletions.
7 changes: 4 additions & 3 deletions types/api/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface Address extends UserTags {
block_number_balance_updated_at: number | null;
coin_balance: string | null;
creator_address_hash: string | null;
creator_filecoin_robust_address?: string | null;
creation_tx_hash: string | null;
exchange_rate: string | null;
ens_domain_name: string | null;
Expand Down Expand Up @@ -271,9 +272,9 @@ export type AddressEpochRewardsItem = {
}

export type AddressFilecoinParams = {
actor_type: FilecoinActorType;
id: string;
robust: string;
actor_type?: FilecoinActorType;
id?: string | null;
robust?: string | null;
}

export type FilecoinActorType =
Expand Down
1 change: 1 addition & 0 deletions types/api/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface SmartContract {
remappings?: Array<string>;
};
verified_twin_address_hash: string | null;
verified_twin_filecoin_robust_address?: string | null;
proxy_type: SmartContractProxyType | null;
language: string | null;
license_type: SmartContractLicenseType | null;
Expand Down
4 changes: 4 additions & 0 deletions types/api/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface SearchResultToken {
total_supply: string | null;
is_verified_via_admin_panel: boolean;
is_smart_contract_verified: boolean;
filecoin_robust_address?: string | null;
}

export interface SearchResultAddressOrContract {
Expand All @@ -23,6 +24,7 @@ export interface SearchResultAddressOrContract {
address: string;
is_smart_contract_verified: boolean;
certified?: true;
filecoin_robust_address?: string | null;
url?: string; // not used by the frontend, we build the url ourselves
ens_info?: {
address_hash: string;
Expand All @@ -36,6 +38,7 @@ export interface SearchResultDomain {
type: 'ens_domain';
name: string | null;
address: string;
filecoin_robust_address?: string | null;
is_smart_contract_verified: boolean;
url?: string; // not used by the frontend, we build the url ourselves
ens_info: {
Expand All @@ -49,6 +52,7 @@ export interface SearchResultDomain {
export interface SearchResultLabel {
type: 'label';
address: string;
filecoin_robust_address?: string | null;
name: string;
is_smart_contract_verified: boolean;
url?: string; // not used by the frontend, we build the url ourselves
Expand Down
1 change: 1 addition & 0 deletions types/api/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface TokenInfo<T extends TokenType = TokenType> {
bridge_type?: string | null;
origin_chain_id?: string | null;
foreign_address?: string | null;
filecoin_robust_address?: string | null;
}

export interface TokenCounters {
Expand Down
8 changes: 6 additions & 2 deletions ui/address/AddressDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ const AddressDetails = ({ addressQuery, scrollRef }: Props) => {
has_token_transfers: true,
has_validated_blocks: false,
filecoin: undefined,
creator_filecoin_robust_address: null,
creator_address_hash: null,
}), [ addressHash ]);

// error handling (except 404 codes)
Expand All @@ -87,6 +89,8 @@ const AddressDetails = ({ addressQuery, scrollRef }: Props) => {
return null;
}

const creatorAddressHash = data.creator_address_hash;

return (
<>
{ addressQuery.isDegradedData && <ServiceDegradationWarning isLoading={ addressQuery.isPlaceholderData } mb={ 6 }/> }
Expand Down Expand Up @@ -140,7 +144,7 @@ const AddressDetails = ({ addressQuery, scrollRef }: Props) => {

<AddressNameInfo data={ data } isLoading={ addressQuery.isPlaceholderData }/>

{ data.is_contract && data.creation_tx_hash && data.creator_address_hash && (
{ data.is_contract && data.creation_tx_hash && (creatorAddressHash) && (
<>
<DetailsInfoItem.Label
hint="Transaction and address of creation"
Expand All @@ -150,7 +154,7 @@ const AddressDetails = ({ addressQuery, scrollRef }: Props) => {
</DetailsInfoItem.Label>
<DetailsInfoItem.Value>
<AddressEntity
address={{ hash: data.creator_address_hash }}
address={{ hash: creatorAddressHash, filecoin: { robust: data.creator_filecoin_robust_address } }}
truncation="constant"
noIcon
/>
Expand Down
2 changes: 1 addition & 1 deletion ui/address/contract/ContractCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const ContractCode = ({ addressHash, contractQuery, channel }: Props) => {
<Alert status="warning" whiteSpace="pre-wrap" flexWrap="wrap">
<span>Contract is not verified. However, we found a verified contract with the same bytecode in Blockscout DB </span>
<AddressEntity
address={{ hash: data.verified_twin_address_hash, is_contract: true }}
address={{ hash: data.verified_twin_address_hash, filecoin: { robust: data.verified_twin_filecoin_robust_address }, is_contract: true }}
truncation="constant"
fontSize="sm"
fontWeight="500"
Expand Down
9 changes: 6 additions & 3 deletions ui/searchResults/SearchResultListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
const shouldHighlightHash = ADDRESS_REGEXP.test(searchTerm);
const address = {
hash: data.address,
filecoin: {
robust: data.filecoin_robust_address,
},
is_contract: data.type === 'contract',
is_verified: data.is_smart_contract_verified,
name: null,
Expand Down Expand Up @@ -288,7 +291,7 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
<Grid templateColumns={ templateCols } alignItems="center" gap={ 2 }>
<Skeleton isLoaded={ !isLoading } overflow="hidden" display="flex" alignItems="center">
<Text whiteSpace="nowrap" overflow="hidden">
<HashStringShortenDynamic hash={ data.address } isTooltipDisabled/>
<HashStringShortenDynamic hash={ data.filecoin_robust_address || data.address } isTooltipDisabled/>
</Text>
{ data.is_smart_contract_verified && <IconSvg name="status/success" boxSize="14px" color="green.500" ml={ 1 } flexShrink={ 0 }/> }
</Skeleton>
Expand Down Expand Up @@ -333,7 +336,7 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
return (
<Flex alignItems="center">
<Box overflow="hidden">
<HashStringShortenDynamic hash={ data.address }/>
<HashStringShortenDynamic hash={ data.filecoin_robust_address || data.address }/>
</Box>
{ data.is_smart_contract_verified && <IconSvg name="status/success" boxSize="14px" color="green.500" ml={ 1 } flexShrink={ 0 }/> }
</Flex>
Expand Down Expand Up @@ -384,7 +387,7 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
return (
<Flex alignItems="center" gap={ 3 }>
<Box overflow="hidden">
<HashStringShortenDynamic hash={ data.address }/>
<HashStringShortenDynamic hash={ data.filecoin_robust_address || data.address }/>
</Box>
{
data.ens_info.names_count > 1 ?
Expand Down
9 changes: 6 additions & 3 deletions ui/searchResults/SearchResultTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
<Td fontSize="sm" verticalAlign="middle">
<Skeleton isLoaded={ !isLoading } whiteSpace="nowrap" overflow="hidden" display="flex" alignItems="center">
<Box overflow="hidden" whiteSpace="nowrap" w={ data.is_smart_contract_verified ? 'calc(100%-28px)' : 'unset' }>
<HashStringShortenDynamic hash={ data.address }/>
<HashStringShortenDynamic hash={ data.filecoin_robust_address || data.address }/>
</Box>
{ data.is_smart_contract_verified && <IconSvg name="status/success" boxSize="14px" color="green.500" ml={ 1 } flexShrink={ 0 }/> }
</Skeleton>
Expand All @@ -100,6 +100,9 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
const addressName = data.name || data.ens_info?.name;
const address = {
hash: data.address,
filecoin: {
robust: data.filecoin_robust_address,
},
is_contract: data.type === 'contract',
is_verified: data.is_smart_contract_verified,
name: null,
Expand Down Expand Up @@ -174,7 +177,7 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
<Td fontSize="sm" verticalAlign="middle">
<Flex alignItems="center" overflow="hidden">
<Box overflow="hidden" whiteSpace="nowrap" w={ data.is_smart_contract_verified ? 'calc(100%-28px)' : 'unset' }>
<HashStringShortenDynamic hash={ data.address }/>
<HashStringShortenDynamic hash={ data.filecoin_robust_address || data.address }/>
</Box>
{ data.is_smart_contract_verified && <IconSvg name="status/success" boxSize="14px" color="green.500" ml={ 1 } flexShrink={ 0 }/> }
</Flex>
Expand Down Expand Up @@ -392,7 +395,7 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
<Td>
<Flex alignItems="center" overflow="hidden">
<Box overflow="hidden" whiteSpace="nowrap" w={ data.is_smart_contract_verified ? 'calc(100%-28px)' : 'unset' }>
<HashStringShortenDynamic hash={ data.address }/>
<HashStringShortenDynamic hash={ data.filecoin_robust_address || data.address }/>
</Box>
{ data.is_smart_contract_verified && <IconSvg name="status/success" boxSize="14px" color="green.500" ml={ 1 } flexShrink={ 0 }/> }
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const SearchBarSuggestAddress = ({ data, isMobile, searchTerm }: Props) => {
{ data.certified && <ContractCertifiedLabel boxSize={ 5 } iconSize={ 5 } ml={ 1 }/> }
</Flex>
);
const addressEl = <HashStringShortenDynamic hash={ data.address } isTooltipDisabled/>;
const addressEl = <HashStringShortenDynamic hash={ data.filecoin_robust_address || data.address } isTooltipDisabled/>;

if (isMobile) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const SearchBarSuggestDomain = ({ data, isMobile, searchTerm }: Props) => {
whiteSpace="nowrap"
variant="secondary"
>
<HashStringShortenDynamic hash={ data.address } isTooltipDisabled/>
<HashStringShortenDynamic hash={ data.filecoin_robust_address || data.address } isTooltipDisabled/>
</Text>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const SearchBarSuggestLabel = ({ data, isMobile, searchTerm }: Props) => {
whiteSpace="nowrap"
variant="secondary"
>
<HashStringShortenDynamic hash={ data.address } isTooltipDisabled/>
<HashStringShortenDynamic hash={ data.filecoin_robust_address || data.address } isTooltipDisabled/>
</Text>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const SearchBarSuggestToken = ({ data, isMobile, searchTerm }: Props) => {

const address = (
<Text variant="secondary" whiteSpace="nowrap" overflow="hidden">
<HashStringShortenDynamic hash={ data.address } isTooltipDisabled/>
<HashStringShortenDynamic hash={ data.filecoin_robust_address || data.address } isTooltipDisabled/>
</Text>
);

Expand Down
3 changes: 3 additions & 0 deletions ui/tokenInstance/details/TokenInstanceCreatorAddress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const TokenInstanceCreatorAddress = ({ hash }: Props) => {

const creatorAddress = {
hash: addressQuery.data.creator_address_hash,
filecoin: {
robust: addressQuery.data.creator_filecoin_robust_address,
},
is_contract: false,
implementations: null,
};
Expand Down
3 changes: 2 additions & 1 deletion ui/tokens/TokensListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const TokensTableItem = ({

const {
address,
filecoin_robust_address: filecoinRobustAddress,
exchange_rate: exchangeRate,
type,
holders,
Expand Down Expand Up @@ -70,7 +71,7 @@ const TokensTableItem = ({
</Grid>
<Flex justifyContent="space-between" alignItems="center" width="150px" ml={ 7 } mt={ -2 }>
<AddressEntity
address={{ hash: address }}
address={{ hash: address, filecoin: { robust: filecoinRobustAddress } }}
isLoading={ isLoading }
truncation="constant"
noIcon
Expand Down
4 changes: 4 additions & 0 deletions ui/tokens/TokensTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const TokensTableItem = ({

const {
address,
filecoin_robust_address: filecoinRobustAddress,
exchange_rate: exchangeRate,
type,
holders,
Expand All @@ -45,6 +46,9 @@ const TokensTableItem = ({

const tokenAddress: AddressEntityProps['address'] = {
hash: address,
filecoin: {
robust: filecoinRobustAddress,
},
name: '',
is_contract: true,
is_verified: false,
Expand Down

0 comments on commit 2c8b228

Please sign in to comment.