Commit d4612970 authored by Igor Stuev's avatar Igor Stuev Committed by GitHub

Filecoin: display address id instead of hash (#2497)

parent de43f3dc
......@@ -18,6 +18,10 @@ import AddressIdenticon from './AddressIdenticon';
type LinkProps = EntityBase.LinkBaseProps & Pick<EntityProps, 'address'>;
const getDisplayedAddress = (address: AddressProp, altHash?: string) => {
return address.filecoin?.robust ?? address.filecoin?.id ?? altHash ?? address.hash;
};
const Link = chakra((props: LinkProps) => {
const defaultHref = route({ pathname: '/address/[hash]', query: { ...props.query, hash: props.address.hash } });
......@@ -80,7 +84,7 @@ const Icon = (props: IconProps) => {
<Flex marginRight={ styles.marginRight }>
<AddressIdenticon
size={ props.size === 'lg' ? 30 : 20 }
hash={ props.address.filecoin?.robust ?? props.address.hash }
hash={ getDisplayedAddress(props.address) }
/>
</Flex>
);
......@@ -89,6 +93,7 @@ const Icon = (props: IconProps) => {
export type ContentProps = Omit<EntityBase.ContentBaseProps, 'text'> & Pick<EntityProps, 'address'> & { altHash?: string };
const Content = chakra((props: ContentProps) => {
const displayedAddress = getDisplayedAddress(props.address, props.altHash);
const nameTag = props.address.metadata?.tags.find(tag => tag.tagType === 'name')?.name;
const nameText = nameTag || props.address.ens_domain_name || props.address.name;
......@@ -102,7 +107,9 @@ const Content = chakra((props: ContentProps) => {
const label = (
<VStack gap={ 0 } py={ 1 } color="inherit">
<Box fontWeight={ 600 } whiteSpace="pre-wrap" wordBreak="break-word">{ nameText }</Box>
<Box whiteSpace="pre-wrap" wordBreak="break-word">{ props.address.filecoin?.robust ?? props.altHash ?? props.address.hash }</Box>
<Box whiteSpace="pre-wrap" wordBreak="break-word">
{ displayedAddress }
</Box>
</VStack>
);
......@@ -118,7 +125,7 @@ const Content = chakra((props: ContentProps) => {
return (
<EntityBase.Content
{ ...props }
text={ props.address.filecoin?.robust ?? props.altHash ?? props.address.hash }
text={ displayedAddress }
/>
);
});
......@@ -129,7 +136,7 @@ const Copy = (props: CopyProps) => {
return (
<EntityBase.Copy
{ ...props }
text={ props.address.filecoin?.robust ?? props.altHash ?? props.address.hash }
text={ getDisplayedAddress(props.address, props.altHash) }
/>
);
};
......
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