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 - Add untrusted assets visibility toggler to settings #3250

Closed
wants to merge 28 commits into from

Conversation

hyphenized
Copy link
Contributor

@hyphenized hyphenized commented Apr 4, 2023

Adds a toggler to show/hide untrusted assets to the settings page

Closes #3213

To Test

  • Set a few tokens as trusted
  • Go to the settings page and toggle "Hide untrusted assets"
  • Check that the wallet asset list does not display the rest of untrusted assets, these should be under hidden assets now
  • Verify that trusted assets that are dust do not display if hide dust is enabled
  • Assets marked as hidden/trusted should not display the unverified asset warning icon
  • Interact with an unverified asset, mark it as trusted/untrusted
    • Wallet should no longer display warning sign in the asset list
    • Wallet should no longer display unverified asset status in the single asset page
    • Single asset page should display Hide asset / Show asset
    • Clicking on either of these options should change the asset trusted status
  • For unverified assets:
    • In the single asset page, clicking on an unverified asset should bring up the warning slide up panel
    • With hide untrusted assets toggled on, the dialog should display Hide asset and Trust asset
    • With hide untrusted assets toggled off, the dialog should display Close and Trust asset
  • For tokenlist assets:
    • In the single asset page, you should be able to hide it and send it to the hidden assets list
    • Clicking on "Show" should send a token-list asset back to the main asset list
  • Discovered assets should display transaction source when available

Testing Env

SUPPORT_ASSET_TRUST=true

Latest build: extension-builds-3250 (as of Fri, 12 May 2023 12:17:34 GMT).

@hyphenized hyphenized requested a review from a team April 4, 2023 16:50
@hyphenized hyphenized self-assigned this Apr 4, 2023
@0xDaedalus
Copy link
Contributor

This looks good to me just need to add the migration

@Shadowfiend
Copy link
Contributor

Quick Q here: I'm puzzled as to how this interacts with the show/hide hidden assets collapsing in the asset list. Is a hidden asset different from an untrusted asset? How does the user find out the distinction? Or is this work meant to supersede that work?

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.

Currently, after separating hidden assets, the toggler is not doing anything.

Screen.Recording.2023-04-18.at.09.36.56.mov

@hyphenized
Copy link
Contributor Author

Quick Q here: I'm puzzled as to how this interacts with the show/hide hidden assets collapsing in the asset list. Is a hidden asset different from an untrusted asset? How does the user find out the distinction? Or is this work meant to supersede that work?

Hidden assets may be asset balances that are dust, assets that have not been marked as trusted or a combination of the former (assets market as trusted but which balances are considered dust). Does that makes sense? cc @VladUXUI

@kkosiorowska I've fixed the toggler, please give it another look when you can.

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 looks really good ⚡️Let's still wait for Vlad's response.

@@ -71,12 +72,54 @@ const shouldForciblyDisplayAsset = (
return isDoggo || isNetworkBaseAsset(assetAmount.asset)
}

// Hides dust, untrusted assets and missing amounts.
export function isAssetAmountVisible(
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking comment
I think this could be moved to a separate file with utils for accounts. In that case, the test file can also be split into two. As for nfts-utils.ts.

Comment on lines +317 to +324
hideDust,
hideUntrustedAssets
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking comment

I wonder if it's better to make it one object with settings for assets and pass it here. What I mean is that I would like to avoid increasing the number of parameters for the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, we don't need the to pass the current network as a parameter anymore either

background/redux-slices/selectors/accountsSelectors.ts Outdated Show resolved Hide resolved
Base automatically changed from trust-issues to main April 19, 2023 21:31
@VladUXUI
Copy link
Contributor

Hidden assets may be asset balances that are dust, assets that have not been marked as trusted or a combination of the former (assets market as trusted but which balances are considered dust). Does that makes sense? cc @VladUXUI

This was not my initial thinking. But i like the idea. Initially i thought as dust and untrusted to be totally separate. Since dust has it's own UX of showing up in the list with the toggle.

But i think i like the idea of having them all in the same place.
So let's go with it.

This also means that if the toggle is off, all the dust assets will move to the main list right?

@kkosiorowska
Copy link
Contributor

This also means that if the toggle is off, all the dust assets will move to the main list right?

If we are talking about a toggle for dust. As far as I can see, yes.

@VladUXUI
Copy link
Contributor

Couple of things here on the UX side (although uncertain what to actually comment on)
1 - If i marked an asset as trusted, it shouldn't have the yellow Attention icon anymore
2 - Trust/untrust is missing from the token details page
image

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.

  • once I trust asset I can no longer untrust it, Hide asset is doing nothing
    image

  • on single asset page I can see Asset not verified for tokens from token lists
    image

Copy link
Contributor

@0xDaedalus 0xDaedalus left a comment

Choose a reason for hiding this comment

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

I'd like to requests 2 e2e tests here, lets test the following

  1. For a token that is initially trusted:
  • Set token to untrusted
  • Token displays as untrusted in Wallet
  • Set it back to trusted
  • Token displays as trusted in Wallet
  1. For a token that is initially untrusted:
  • Set token to trusted
  • Token displays as trusted in Wallet
  • Set it back to untrusted
  • Token displays as untrusted in Wallet

@hyphenized
Copy link
Contributor Author

  • once I trust asset I can no longer untrust it, Hide asset is doing nothing
    image

Thanks for the review, fixed!

  • on single asset page I can see Asset not verified for tokens from token lists
    image

Not sure if this is the correct behaviour, could you confirm @VladUXUI ?

@Shadowfiend
Copy link
Contributor

on single asset page I can see Asset not verified for tokens from token lists
Not sure if this is the correct behaviour

As I absorb this feature into my brain—why would we see Asset not verified for a token list asset? We have baseline trust for token list assets, right? And Asset not verified is a textual reminder that an asset is not trusted, correct?

@VladUXUI
Copy link
Contributor

VladUXUI commented May 9, 2023

Token list assets should't have any verified or unverified behaviour/status. As these are already verified and trusted by us

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.

Hide button was fixed but I wonder - do we want to implement everything in this PR or not? For example I can see in figma that send and swap buttons are changing state between disabled and enabled depending on asset state
image
Also once we trust given asset - should we display this popup once again if we are switching between hidden/shown asset?
"Trust asset" button is not triggering that popup but "warning" icon on assets list is triggering that popup every time.

Screen.Recording.2023-05-09.at.13.41.10.mov

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.

Some ideas and improvements

const isTrusted =
!isCustomAsset || assetAmount.asset.metadata?.trusted === true

const isSmartContractAmount = isSmartContractFungibleAsset(assetAmount.asset)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const isSmartContractAmount = isSmartContractFungibleAsset(assetAmount.asset)
const isSmartContractAsset = isSmartContractFungibleAsset(assetAmount.asset)

Comment on lines +95 to +102
if (isForciblyDisplayed) {
return true
}

if (!isPresent) {
return false
}

Copy link
Contributor

Choose a reason for hiding this comment

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

non blocking - I would rather return early, there is no point defining 4 other variables if we already know the result

) {
acc.combinedAssetAmounts.push(assetAmount)
} else if (isPresent) {
} else {
// FIXME: Assets with very low values should still be displayed as dust e.g. "<0,01"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to create an issue for that?

expect(
isAssetAmountVisible(
createCompleteAssetAmount(
createSmartContractAsset({ metadata: {} }),
Copy link
Contributor

Choose a reason for hiding this comment

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

Whats the default if metadata is empty? is it trusted or untrusted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No metadata means no token lists so this is an unverified, untrusted asset

@@ -24,12 +25,14 @@ export type UIState = {
selectedAccount: AddressOnNetwork
showingActivityDetailID: string | null
initializationLoadingTimeExpired: boolean
// FIXME: Move these settings to preferences service db
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a plumbing task for it? I think it won't happen if we won't plan it

{asset.metadata?.discoveryTx && (
<li>
<div className="left">{t("discoveryTx")}</div>
<div className="right">
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use SharedAddress component here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could but SharedAddress has some logic specific to name resolution.

ui/pages/SingleAsset.tsx Outdated Show resolved Hide resolved
@kkosiorowska kkosiorowska self-assigned this May 16, 2023
@kkosiorowska
Copy link
Contributor

There has been a change in logic for trusted/untrusted assets. The current status of this feature can be found in #3394. Let's close it.

@kkosiorowska kkosiorowska deleted the show-me-the-money branch June 14, 2023 14:06
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.

Separate untrusted tokens option from “Hide asset balances under $2”
6 participants