Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't allow duplicate signers in safe creation #3427

Merged
merged 3 commits into from
Mar 14, 2024
Merged

Conversation

usame-algan
Copy link
Member

@usame-algan usame-algan commented Mar 12, 2024

What it solves

Resolves #3415

The fix implemented in #3060 added a new onChange call to the Autocomplete to render the AddressInputReadOnly whenever the user selects an address book entry in the input field and display validation errors in this separate component.

However if a deps array is also passed to AddressBookInput it triggers a revalidation which is not propagated because AddressInputReadOnly is rendered instead of AddressInput.

How this PR fixes it

  • Simplify and move AddressInputReadOnly into AddressInput
  • Add the read-only logic into AddressInput
  • Adds a new useChain hook

How to test it

  1. Create a new Safe
  2. Add the same owner twice
  3. Observe an error is visible

Make sure that the fix from #3060 is still working:

  1. Open an existing safe
  2. Go to the owner settings and add a new owner
  3. Choose the safe itself as an owner
  4. Observe an error is visible

Check that other places where AddressInput and AddressBookInput are used are still working

  • Create address book entry
  • Load safe
  • TxHistory filter
  • Create transactions
  • Recovery

Screenshots

Screenshot 2024-03-12 at 16 10 22 Screenshot 2024-03-12 at 16 10 43

Checklist

  • I've tested the branch on mobile πŸ“±
  • I've documented how it affects the analytics (if at all) πŸ“Š
  • I've written a unit/e2e test for it (if applicable) πŸ§‘β€πŸ’»

Copy link

github-actions bot commented Mar 12, 2024

Copy link

github-actions bot commented Mar 12, 2024

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 0 N/A
  • Result: βœ… success
  • Annotations: 0 total

Report generated by eslint-plus-action

Copy link

github-actions bot commented Mar 12, 2024

πŸ“¦ Next.js Bundle Analysis for safe-wallet-web

This analysis was generated by the Next.js Bundle Analysis action. πŸ€–

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 1016.32 KB (🟑 +278 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Four Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/new-safe/create 32.35 KB (🟒 -487 B) 1.02 MB
/new-safe/load 18.49 KB (🟒 -489 B) 1.01 MB
/transactions 89.07 KB (🟒 -500 B) 1.08 MB
/transactions/history 89.03 KB (🟒 -500 B) 1.08 MB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

Copy link

github-actions bot commented Mar 12, 2024

Coverage report

St.❔
Category Percentage Covered / Total
🟑 Statements
79.4% (+0.03% πŸ”Ό)
11125/14011
πŸ”΄ Branches
58.42% (+0.04% πŸ”Ό)
2611/4469
🟑 Functions
66.14% (+0.07% πŸ”Ό)
1795/2714
🟒 Lines
80.66% (+0.03% πŸ”Ό)
10021/12423
Show files with reduced coverage πŸ”»
St.❔
File Statements Branches Functions Lines
🟒
... / index.tsx
92.31% (-0.72% πŸ”»)
91.67% (+3.43% πŸ”Ό)
75% (-1.92% πŸ”»)
94.12% (-0.62% πŸ”»)

Test suite run success

1411 tests passing in 195 suites.

Report generated by πŸ§ͺjest coverage report action from 0b1a360

Copy link
Member

@schmanu schmanu left a comment

Choose a reason for hiding this comment

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

I think it really helps to merge these components πŸ‘

Could we add a test for this new fix? There is a AddressBookInput unit test already.

@francovenica
Copy link
Contributor

I created a e2e test for this. I'll make my PR once this ticket is merged to dev

@francovenica
Copy link
Contributor

LGTM
The duplication error works fine for the autocomplete feature and by copy/pasting the address as well
dup signer fix

# Conflicts:
#	src/components/common/AddressInputReadOnly/index.tsx
Copy link

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 0 N/A
  • Result: βœ… success
  • Annotations: 0 total

Report generated by eslint-plus-action

@usame-algan usame-algan merged commit fb99e9d into dev Mar 14, 2024
14 checks passed
@usame-algan usame-algan deleted the duplicate-signers branch March 14, 2024 10:03
@github-actions github-actions bot locked and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating a New Safe Account Allows Duplicate Signers
3 participants