-
Notifications
You must be signed in to change notification settings - Fork 363
Strip network prefix from the Address when calling EthHashInfo #3037
Strip network prefix from the Address when calling EthHashInfo #3037
Conversation
CLA Assistant Lite All Contributors have signed the CLA. |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
|
E2E Tests Failed Failed tests:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit convoluted not using the props as they are intended.
@@ -12,7 +13,7 @@ const PrefixedEthHashInfo = ({ hash, ...rest }: Props): ReactElement => { | |||
|
|||
return ( | |||
<EthHashInfo | |||
hash={hash} | |||
hash={getAddressWithoutNetworkPrefix(hash)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you extracting it here and not sending them via their respective props?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted to implement it in the wrapper as a input sanitization. I don't think it invalidates the correct use of the hash
prop.
Doing this in the wrapper is also a way to address it in one single place and to not repeat it every time we call the <PrefixedEthHashInfo />
component.
Let me know if it makes sense. It is a simple tweak otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes the most sense to do this within the component. If you are intent on doing it in the wrapper, I think it's cleaner and more understandable to parse the hash directly and output the props accordingly, i.e.
const getPrefixedHashInfoProps = (hash: string, shouldShowShortName: boolean ): { shortName: string | undefined, hash: string }
<EthHashInfo
{...getPrefixedHashInfoProps(hash, shouldShowShortName)}
shouldShowShortName={showChainPrefix}
shouldCopyShortName={copyChainPrefix}
/>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure how this improves the solution. My view is that shortName
should be calculated independently of the hash
and vice versa.
The way to go would be maybe update the <EthHashInfo />
to have the input sanitization as the component responsability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamacook created a issue to tackle it 5afe/safe-react-components#171
What it solves
#3015 (comment) (Bug when uploading a QR code containing a chain prefix in the "Send Collectibles")
Resolves #3036
How this PR fixes it
EthHashInfo
and let the appearance settings decide if prefix should be displayedHow to test it
From #3015 (comment)
Screenshots