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

Token Discovery - Remap redux asset balances #3195

Merged
merged 15 commits into from
Jun 19, 2023

Conversation

hyphenized
Copy link
Contributor

@hyphenized hyphenized commented Mar 27, 2023

Prevents tokens with the same symbol from overriding existing balances. Changes the way combined amounts data is computed so that balances displayed in overview for e.g. USDC on Mainnet and USDC on Polygon get bundled together only if they both are sourced from a token list (or are network base assets).

To Test

  • Load any wallet that has two or more tokens with the same name, bnbspider2.crypto
  • You should not be able to see multiple tokens that share the same symbol
  • Switch to this branch, reload the extension, you should see all the missing tokens

Latest build: extension-builds-3195 (as of Mon, 19 Jun 2023 09:45:50 GMT).

Fixes discovered tokens name collision
`assetIDs` are now checked against network base assets instead of built-in
network assets alone, combined data now only merges asset amounts for
trusted and base network assets
@hyphenized hyphenized requested a review from a team March 27, 2023 23:42
@hyphenized hyphenized self-assigned this Mar 27, 2023
background/redux-slices/accounts.ts Outdated Show resolved Hide resolved
/**
* All network base assets have a chainID property
*/
export function isNetworkBaseAsset(asset: AnyAsset): asset is NetworkBaseAsset {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about this change, as we already have a second function that is named isBuiltInNetworkBaseAsset and is checking much more things I'm afraid someone will make a mistake and will think that isNetworkBaseAsset does the same thing.

I assume that this change is because on custom networks we only have chainID as an indicator that this is a base asset? Can we think about a name that will make it clear which function should be used when? isAnyNetworkBaseAsset, isCustomNetworkBaseAsset? Lmk what you think 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. Though since I could not find an instance of isBuiltInNetworkBaseAsset were we are still making use of those extra checks, I think we can replace it with this more generic alternative.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder about this. The names are slightly confusing. But however, functions isBuiltInNetworkBaseAsset and isNetworkBaseAsset take different parameters. This reduces the occurrence of mistakes. Therefore, it seems to me that it is not a big threat.

background/redux-slices/migrations/to-27.ts Outdated Show resolved Hide resolved
background/redux-slices/migrations/to-27.ts Outdated Show resolved Hide resolved
jagodarybacka
jagodarybacka previously approved these changes Apr 10, 2023
Copy link
Contributor

@jagodarybacka jagodarybacka left a comment

Choose a reason for hiding this comment

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

I'm not sure if bnbspider holds duplicated WETH anymore.

Overall seems fine, assets are reloaded but they are present after a few minutes which is a little bit annoying and I'm afraid people can complain about it. Please @0xDaedalus take a look before merging.

background/main.ts Outdated Show resolved Hide resolved
background/main.ts Outdated Show resolved Hide resolved
@jagodarybacka
Copy link
Contributor

Update with main broke types 🤔

@jagodarybacka
Copy link
Contributor

@hyphenized Is this PR still valid and we want to merge it at some point or not really?

@hyphenized hyphenized requested review from a team and removed request for 0xDaedalus June 7, 2023 07:40
@hyphenized
Copy link
Contributor Author

@hyphenized Is this PR still valid and we want to merge it at some point or not really?

AFAIK This addressed the issue of a collision between two assets named WETH, although most of these duplicate assets are likely spam, there should be no problem to merge this as long as we display those as unverified.

Paging @Shadowfiend for visibility

michalinacienciala added a commit that referenced this pull request Jun 13, 2023
This commit introduces E2E test that checks the functiolality of
verified/unverified tokens. Following general steps are executed:
1. Import account
2. Enable `Show unverified assets`
3. Hide asset
4. Trust asset
5. Hide trusted asset
A number of checks is performed during each step.

The commit also introduces helper functions and adds `data-testid` attribute to
a couple of DOM elements.

As some of the code is similar or identical as in the
#3418 PR which is yet not merged to
`main`, some conflicts may arise and will need to be resolved before this change
lands on `main`.

Also some changes will need to be made once
#3195 gets merged to `main`, as this
PR solves a bug causing failures in the tests (the failing part of the test was
temporarily commented out).
Copy link
Contributor

@kkosiorowska kkosiorowska left a comment

Choose a reason for hiding this comment

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

It seems to be working well. 🚀 Let's merge it.

Hidden tokens appeared on lists of unverified assets

Screenshot 2023-06-19 at 10 18 07

@kkosiorowska kkosiorowska merged commit 874e684 into main Jun 19, 2023
5 checks passed
@kkosiorowska kkosiorowska deleted the improve-balances-indexing branch June 19, 2023 09:45
@jagodarybacka
Copy link
Contributor

btw I recall we were meant to add another warning for these duplicated tokens, right? It looks very weird to have 3 AAVE tokens and none of them is the real one 🙈 cc @VladUXUI

@jagodarybacka jagodarybacka mentioned this pull request Jun 22, 2023
jagodarybacka added a commit that referenced this pull request Jun 23, 2023
## What's Changed
* Repeater Connection: Forward requests to new default when default is
switched off during dApp connection flow by @Shadowfiend in
#3462
* Auto-Not-So-Matic: Fix two matic.network URLs to polygon.technology by
@Shadowfiend in #3483
* v0.38.0 by @kkosiorowska in
#3480
* Case Dismissed: Forcibly show DAppConnectionInfoBar popover on first
dApp connection by @Shadowfiend in
#3464
* Add Hardhat Fork Functionality by @0xDaedalus in
#3247
* Faded Jeans: Rename fadeIn class to fade_in by @Shadowfiend in
#3485
* Fix issue for discovery transaction hash by @kkosiorowska in
#3458
* Full Sweep: Drop the USE_UPDATED_SIGNING_UI feature flag by
@Shadowfiend in #3475
* Token Discovery - Remap redux asset balances by @hyphenized in
#3195
* Make specific warnings for adding custom asset by @kkosiorowska in
#3478
* Run NFTs e2e tests on a controlled wallet address by
@michalinacienciala in #3487
* v0.38.1 by @jagodarybacka in
#3484


**Full Changelog**:
v0.38.1...v0.39.0
Latest build:
[extension-builds-3496](https://github.com/tahowallet/extension/suites/13792957673/artifacts/764738599)
(as of Thu, 22 Jun 2023 14:27:32 GMT).
hyphenized added a commit that referenced this pull request Aug 16, 2023
This commit introduces E2E test that checks the functiolality of
verified/unverified tokens. Following general steps are executed:
1. Import account
2. Enable `Show unverified assets`
3. Hide asset
4. Trust asset
5. Hide trusted asset
A number of checks is performed during each step.

The commit also introduces helper functions and adds `data-testid`
attribute to a couple of DOM elements.

TODO:

- [x] As some of the code is similar or identical as in the
#3418 PR which is yet not
merged to `main`, some conflicts may arise and will need to be resolved
before this change lands on `main`.
- [x] Also some changes will need to be made once
#3195 gets merged to `main`,
as this PR solves a bug causing failures in the tests (the failing part
of the test was temporarily commented out).
- [x] Add `E2E_TEST_ONLY_WALLET_JSON_BODY` and
`E2E_TEST_ONLY_WALLET_JSON_PASSWORD` secrets in GitHub's settings.
- [x] Wait for #3559 to be
merged and merge main to feature branch (should fix the failing
`e2e-tests` job)
- [x] Handle TODOs in the code

Latest build:
[extension-builds-3472](https://github.com/tahowallet/extension/suites/15116290312/artifacts/863816729)
(as of Tue, 15 Aug 2023 18:12:30 GMT).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants