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

Conversation

@DiogoSoaress
Copy link
Contributor

@DiogoSoaress DiogoSoaress commented Nov 16, 2021

What it solves

Resolves #2965

How this PR fixes it

On searching for an existing AB entry we compare now the addresses checksum.
Before updating the Redux store we filter out AB entries with same address and chainId

How to test it

On any conditions, exporting and importing your address book should not generate any duplicated entries in the "Address Book"

Screenshots

Screen Shot 2021-11-16 at 16 31 13

@github-actions
Copy link

CLA Assistant Lite All Contributors have signed the CLA.

@DiogoSoaress
Copy link
Contributor Author

DiogoSoaress commented Nov 16, 2021

The bug seems to occur if the user had old data (don't know how old) in the Address Book and on exporting and importing it would create duplicated entries.

I was not able to reproduce it locally but open the PR to validate my solution and to share the deployments with the QA to see if it resolves the problem.

@github-actions
Copy link

github-actions bot commented Nov 16, 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 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@github-actions
Copy link

@coveralls
Copy link

coveralls commented Nov 16, 2021

Pull Request Test Coverage Report for Build 1471733840

  • 4 of 4 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 31.682%

Totals Coverage Status
Change from base Build 1471506684: 0.02%
Covered Lines: 2989
Relevant Lines: 8394

💛 - Coveralls

@github-actions
Copy link

github-actions bot commented Nov 16, 2021

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

@katspaugh
Copy link
Member

IMO it's not worth it fixing it like this. We should fix the import.

@DiogoSoaress
Copy link
Contributor Author

IMO it's not worth it fixing it like this. We should fix the import.

Fair enough. The import is working as expected, as it also overrides the duplicated entries https://github.com/gnosis/safe-react/blob/434fa9f45dd586403866cd3096b1280f387621ae/src/logic/addressBook/store/reducer/index.ts#L19-L30

It is very inefficient trying to fix this bug without actually being able to reproduce the faulty behavior.
Is there a more specific suggestion on how to fix the import? Maybe we could pair or should other dev (that can mimic the bug) pick it?

@katspaugh
Copy link
Member

@liliya-soroka can you share the content of your LS with the dupes?

@iamacook
Copy link
Contributor

Does @liliya-soroka's csv file have duplicates in it, or is it a purely visual based bug?

@DiogoSoaress
Copy link
Contributor Author

Does @liliya-soroka's csv file have duplicates in it, or is it a purely visual based bug?

The .csv we used to reproduce it had no duplicates.

@DiogoSoaress DiogoSoaress force-pushed the fix-duplicated-addresses-import branch from f10ff8e to 6c53631 Compare November 16, 2021 18:33
@DiogoSoaress DiogoSoaress marked this pull request as ready for review November 17, 2021 12:09
try {
hasSameChecksumAddress = checksumAddress(address) === checksumAddress(addressBookEntry.address)
} catch (e) {
console.error(e)
Copy link
Member

Choose a reason for hiding this comment

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

We don't use console.error. I would just return false here.

@DiogoSoaress
Copy link
Contributor Author

I was able to reproduce the bug by making getEntryIndex return false
https://github.com/gnosis/safe-react/blob/1566910b222b49a65e49502fac84d565e1f4ba5f/src/logic/addressBook/utils/index.ts#L60-L72

Used that data with duplicates to implement a filter before we return the reducer state so old duplicates are filtered out.

Copy link
Contributor

@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.

Looks good to me!

@DiogoSoaress DiogoSoaress changed the base branch from main to dev November 17, 2021 12:42
@github-actions
Copy link

Deployment links

🟠 Safe Rinkeby Safe Mainnet 🟣 Safe Polygon 🟡 Safe BSC Safe Arbitrum 🟢 Safe xDai

@francovenica
Copy link
Contributor

So I didn't have issues by importing csv with repeated entries, but I also didn't had issues back in prod when this issue was reported.
I can say that the importing is fine, and when you export it seems that all the repeated entries are removed (I import 110 entries in my file and you export 93 cuz the duplicated ones were not added to the LS), so that's good

@liliya-soroka You describe a way to reproduce it by using the mobile app. I'd like to see if that can be tried in this PR and verify if this works.

@katspaugh
Copy link
Member

@francovenica you could test by lowercasing all the addresses in your CSV.

@francovenica
Copy link
Contributor

Ok, tried by having a csv with the same entry 3 times, one checksummed, and the other 2 with upper and lower case characters.
After importing the address book still shows only 1 entry.

Looks good to me

@DiogoSoaress DiogoSoaress merged commit 74308d0 into dev Nov 22, 2021
@DiogoSoaress DiogoSoaress deleted the fix-duplicated-addresses-import branch November 22, 2021 12:02
@github-actions github-actions bot locked and limited conversation to collaborators Nov 22, 2021
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.

The same records are duplicated in the addressbook after the first importing

6 participants