-
Notifications
You must be signed in to change notification settings - Fork 393
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
Conversation
This looks good to me just need to add the migration |
a180448
to
63b9e6e
Compare
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? |
There was a problem hiding this 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
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. |
There was a problem hiding this 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( |
There was a problem hiding this comment.
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
.
hideDust, | ||
hideUntrustedAssets |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Simplified the logic to handle the extra filters & added some tests
813690c
to
e956630
Compare
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. 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. |
- Hide button now renders "close" if the toggle for hiding untrusted assets hasn't been turned on - Hide button now renders "Keep hidden" if asset has already been marked as untrusted
b13d8e2
to
0c422ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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
- 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
- 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
Thanks for the review, fixed! Not sure if this is the correct behaviour, could you confirm @VladUXUI ? |
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? |
Token list assets should't have any verified or unverified behaviour/status. As these are already verified and trusted by us |
There was a problem hiding this 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
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
There was a problem hiding this 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const isSmartContractAmount = isSmartContractFungibleAsset(assetAmount.asset) | |
const isSmartContractAsset = isSmartContractFungibleAsset(assetAmount.asset) |
if (isForciblyDisplayed) { | ||
return true | ||
} | ||
|
||
if (!isPresent) { | ||
return false | ||
} | ||
|
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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: {} }), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Assets set as hidden should not display the unverified asset warning icon
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. |
Adds a toggler to show/hide untrusted assets to the settings page
Closes #3213
To Test
hide untrusted assets
toggled on, the dialog should displayHide asset
andTrust asset
hide untrusted assets
toggled off, the dialog should displayClose
andTrust asset
Testing Env
Latest build: extension-builds-3250 (as of Fri, 12 May 2023 12:17:34 GMT).