Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Components support eip3770 prefixes #2896

Merged

Conversation

DiogoSoaress
Copy link
Member

@DiogoSoaress DiogoSoaress commented Oct 26, 2021

What it solves

Resolves #2757 and #2842

How this PR fixes it

This PR allows to copy/display addresses as per settings

How to test it

Tweak the Appearence settings and verify if the addresses are displayed/copied with/without the chain prefix

Screenshots

Screen Shot 2021-10-29 at 12 19 16

Screen Shot 2021-10-29 at 12 18 38

Screen Shot 2021-10-29 at 12 18 25

@github-actions
Copy link

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link

github-actions bot commented Oct 26, 2021

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 1 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@github-actions
Copy link

@coveralls
Copy link

coveralls commented Oct 26, 2021

Pull Request Test Coverage Report for Build 1444457765

  • 5 of 17 (29.41%) changed or added relevant lines in 9 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 31.689%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/components/CustomIconText/index.tsx 0 1 0.0%
src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx 0 1 0.0%
src/routes/safe/components/Transactions/TxList/MethodValue.tsx 0 1 0.0%
src/routes/safe/components/Transactions/TxList/TxSummary.tsx 0 1 0.0%
src/components/SafeListSidebar/SafeList/SafeListItem.tsx 0 2 0.0%
src/routes/safe/components/Settings/Appearance/index.tsx 0 2 0.0%
src/components/AppLayout/Sidebar/SafeHeader/index.tsx 0 4 0.0%
Files with Coverage Reduction New Missed Lines %
src/routes/safe/components/Settings/ManageOwners/ReplaceOwnerModal/screens/OwnerForm/index.tsx 1 0%
Totals Coverage Status
Change from base Build 1443243556: 0.03%
Covered Lines: 2979
Relevant Lines: 8377

💛 - Coveralls

@DiogoSoaress DiogoSoaress linked an issue Oct 28, 2021 that may be closed by this pull request
@DiogoSoaress DiogoSoaress force-pushed the components-support-eip3770-prefixes branch from 5640525 to a39cf15 Compare October 28, 2021 20:20
@github-actions
Copy link

github-actions bot commented Oct 29, 2021

E2E Tests Failed
Check the results here: https://github.com/gnosis/safe-react-e2e-tests/actions/runs/1444481745

Failed tests:

  • ❌ Add an existing safe Add an existing safe
  • ❌ Safe Apps List Safe Apps List
  • ❌ Safe Balances Safe Balances

@DiogoSoaress
Copy link
Member Author

I did not introduce the prefix where the connected network is explicit:

  • ProviderInfo where we get the connected wallet info
  • UserDetails card
  • Header in the left side menu
  • SafeList in the left side menu

Also prefixing the InlineEthHashInfo with the shortName caused me some hesitation.

Please let me know what do you think.

@DiogoSoaress DiogoSoaress marked this pull request as ready for review October 29, 2021 10:13
Copy link
Member

@iamacook iamacook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked for instances where we render addresses outside of EthHashInfo?


type ExplorerInfo = () => { url: string; alt: string }

interface Props {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just import the interface from the component? If it's not exported, you could use Parameters<typeof PrefixedEthHashInfo>[0].

@@ -37,8 +37,7 @@ const Appearance = (): ReactElement => {
<Heading tag="h2">Use Chain-Specific Addresses</Heading>
<Paragraph>You can choose whether to prepend EIP-3770 short chain names accross Safes.</Paragraph>
<Paragraph>
{showShortName && <strong>{shortName}:</strong>}
{safeAddress}
<PrefixedEthHashInfo hash={safeAddress} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

explorerUrl?: ExplorerInfo
}

const PrefixedEthHashInfo: React.FC<Props> = ({ hash, ...rest }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A basic test for this new component would be in order.

@@ -158,7 +164,7 @@ const SafeHeader = ({
<ButtonHelper onClick={onReceiveClick}>
<Icon size="sm" type="qrCode" tooltip="Show QR" />
</ButtonHelper>
<CopyToClipboardBtn textToCopy={address} />
<CopyToClipboardBtn textToCopy={copyChainPrefix ? `${shortName}:${address}` : `${address}`} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CopyToClipboardBtn is used in two other places, should we also create a wrapper for it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was implementing a wrapper for it called CopyAddressToClipboardBtn but the CopyToClipboardBtn is only copying an address in the SafeHeader component.
Screen Shot 2021-11-01 at 11 16 34
Is it worthy to implement the wrapper afterall?

@francovenica
Copy link
Contributor

Question. Should the checkbox in the modal of the safe QR code remember its status of checked/unchecked after you close it? It seems that it copies the status of the checkbox in Settings > Appearance, so I'm not sure is just "temporary add/remove prefix" kind of thing, or if that checkbox should also change the checkbox in the settings as well.
Check the gif:
11-03-2021_x(3302)

@DiogoSoaress
Copy link
Member Author

DiogoSoaress commented Nov 3, 2021

Question. Should the checkbox in the modal of the safe QR code remember its status of checked/unchecked after you close it? It seems that it copies the status of the checkbox in Settings > Appearance, so I'm not sure is just "temporary add/remove prefix" kind of thing, or if that checkbox should also change the checkbox in the settings as well. Check the gif: 11-03-2021_x(3302)

The QR modal defaults to the value set in settings. Also, toggling the check box on the Receiving modal deliberately does not update the Settings > Appearance (store value) as described in #2888 (comment)
Can you confirm this is the behavior to carry on @katspaugh ?

@katspaugh
Copy link
Member

Yes, that's how we intended it to be.
But I also see Franco's point, it might be good to remember the user's choice in the QR modal specifically. Up to you, @DiogoSoaress.

@francovenica
Copy link
Contributor

Note:

I'm ignoring inputs where addresses go, like this one:
image
Only once the input is set and becomes "read only" should have the index in front of it.

Places checked:

  • Create safe:
    -- Review step > Owners addresses
  • Add safe:
    -- Owner step > Owner list
    -- Review step > Owner/Safe addresses
    -- QR code for the safe > Safe address
  • Safes Sidebar:
    -- Safes list
    -- Owned safes list
  • Send funds / Send collectibles modal:
    -- Safe address
    -- List of receivers and the receiver itself
    -- Review step > Safe and receiver
  • Contract interaction modal:
    -- Contract address
  • Transactions: (Queue and History)
    -- Owners who signed and executed
    -- Tx details: Hash, Safe hash, receivers of a tx, contracts, modules, addresses inside "Actions", Safe creation tx
  • Address Book:
    -- Entry list
    -- "Send" modal
  • Settings Appearance:
    -- safe address example
  • Settings Owners:
    -- Owner list
    -- Edit owner name modal
    -- Replace owner step 1 and 2
    -- Remove owner modal step 1 and 3
    -- Add owner step 3
  • Settings Spending Limit:
    -- Owner list
    -- Allowance removal modal
    -- Allowance add/edit modal steps 1 and 2
  • Settings Advanced
    -- List of modules
    -- List of Tx guards (maybe, I don't have a guard to enable, so I could not test this one)
  • Settings Remove safe modal

Question:

Should Values that are used as inputs in contract interaction methods should have the prefix? I don't know if all the addresses you will use as values for contract interactions are always from the same chainID or not
image

Places where the prefix is missing:

1 - Sidebar doesn't show the prefix. Is it because they are already under the network label? Still, I think that for consistency sake they should have it
image

2 - The dropdown of the owner connected to the safe app:
image

3 - The safe in the sidebar itself
image

4 - Address book values:
image

5 - There is a font that is not correct in the "Spending limit" section. I've checked other PR's but the font is fine on those, so I think it broke just in this PR
To see this go to the spending limit, open the modal by trying to create one
How it looks:
image

How it should look:
image

@DiogoSoaress
Copy link
Member Author

@francovenica thank you for the detailed QA 🙏

I had left in a commentary above open to discussion all the places you point so thank you for the feedback!
Screen Shot 2021-11-08 at 23 14 08

  1. – 4. I'm going to implement the chain prefix for the sake of consistency as you mention 👍

  2. The font seems to be good in the Rinkeby deployment -> (Averta, monospace) so maybe it didn't load when you opened the URL. Did you tried to refresh the page?
    Screen Shot 2021-11-08 at 23 11 24

@github-actions
Copy link

github-actions bot commented Nov 8, 2021

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 1 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@DiogoSoaress DiogoSoaress force-pushed the components-support-eip3770-prefixes branch from 16cc7cd to 7df7897 Compare November 8, 2021 22:42
@DiogoSoaress
Copy link
Member Author

DiogoSoaress commented Nov 9, 2021

@francovenica answering to the question

Should Values that are used as inputs in contract interaction methods should have the prefix? I don't know if all the addresses you will use as values for contract interactions are always from the same chainID or not

The answer we got -> "we can now safely assume that addresses are always meant fo the same chain id"
https://gnosisinc.slack.com/archives/CQB729LLF/p1636411988161700

So yeah, we should also display it there. I think is under the scope of #2954 however

@iamacook
Copy link
Member

iamacook commented Nov 9, 2021

I think we agreed internally that you need not include the shortName anywhere in the sidebar, or in the wallet connection information because the network name is clear there.

@DiogoSoaress
Copy link
Member Author

DiogoSoaress commented Nov 9, 2021

@iamacook True! though I found Franco's "sake of consistency" point valid as per the kickoff output. Also I implemented it and looks good indeed --> https://pr2896--safereact.review-safe.gnosisdev.com/app/rinkeby
Would like to welcome a last feedback on it. I would go for it 👍

@iamacook
Copy link
Member

iamacook commented Nov 9, 2021

@iamacook True! though I found Franco's "sake of consistency" point valid as per the kickoff output. Also I implemented it and looks good indeed --> https://pr2896--safereact.review-safe.gnosisdev.com Would like to welcome a last feedback on it. I would go for it 👍

I would argue that all of the stated positions are already truncated. The user needs to see enough of their address to know which one it is.

Your link 404s.

@DiogoSoaress
Copy link
Member Author

We show the same number of characters with and without the chain prefix
toggle chain prefix

Again, just welcoming another round of feedback now that it was implemented. @katspaugh @francovenica

@iamacook
Copy link
Member

iamacook commented Nov 9, 2021

I think it's clear enough as is but it's personal opinion.

image
image
image

@francovenica
Copy link
Contributor

I think it's clear enough as is but it's personal opinion.

image image image

Technically we also have it in most modals, so it shouldn't be necessary there either, but just for the sake of not having to wonder "we should put the prefix here o not" and just put it everywhere we can
image

@francovenica
Copy link
Contributor

francovenica commented Nov 10, 2021

I had left in a commentary above open to discussion all the places you point so thank you for the feedback!

Screen Shot 2021-11-08 at 23 14 08

I'm a terrible reader. Sorry :(

Still, all the new prefixes in the sidebar, connect and safe list look fine
The ones from the AB are fine as well
I'm ignoring the prefix for addresses used in contract interactions for now then. I'll recheck in the 2954

I'm still seeing the wrong font in the Spending limit modal. I'm using Chrome in windows10 btw. We can ignore it for now since it not part of this ticket, and I'll check again when I do regression in the release branch.

I'm ok approving this ticket. Moving it to QA done

@iamacook
Copy link
Member

I think it's clear enough as is but it's personal opinion.
image image image

Technically we also have it in most modals, so it shouldn't be necessary there either, but just for the sake of not having to wonder "we should put the prefix here o not" and just put it everywhere we can image

I feel like modals are a bit more important and should have a shortName because that's when a user sends their funds. Let's perhaps discuss this in our stand-up today? @katspaugh @johannesmoormann

@francovenica
Copy link
Contributor

@DiogoSoaress The fix on the sidebar for safe looks fine
image

@DiogoSoaress DiogoSoaress changed the base branch from dev to feature/eip-3770-prefixes November 15, 2021 15:59
@DiogoSoaress DiogoSoaress merged commit 253d4bf into feature/eip-3770-prefixes Nov 16, 2021
@DiogoSoaress DiogoSoaress deleted the components-support-eip3770-prefixes branch November 16, 2021 08:41
@github-actions github-actions bot locked and limited conversation to collaborators Nov 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants