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