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

Make specific warnings for adding custom asset #3478

Merged
merged 6 commits into from
Jun 20, 2023
Merged

Conversation

kkosiorowska
Copy link
Contributor

@kkosiorowska kkosiorowska commented Jun 14, 2023

Closes #3325

What

We should display more detailed warnings to the user when adding assets. Users are trying to add an asset that already exists, this can be for 1 of 3 reasons:

1 - They have 0 balance so they don't see it
2 - They only have dust, need to toggle off "hide assets"
3 - Asset is already on the list but they didn't notice it.

UI

Before
Screenshot 2023-06-14 at 10 17 46

After
Screenshot 2023-06-16 at 10 32 13
Screenshot 2023-06-16 at 10 32 51
Screenshot 2023-06-16 at 10 31 58
Screenshot 2023-06-16 at 10 31 36

Testing

Check that the messages are displayed correctly:

  • Try adding an asset whose balance is greater than $2
  • Try adding an asset whose balance is smaller than $2 when Hide asset balances under $2 is on
  • try adding an asset whose balance is smaller than $2 when Hide asset balances under $2 is off
  • Try adding an asset with a balance of 0. (Add the token and then try to do it again)
    • Address: 0x841fad6eae12c286d1fd18d1d525dffa75c7effe
    • Token:0x841fad6eae12c286d1fd18d1d525dffa75c7effe
    • Network: Fantom network

Latest build: extension-builds-3478 (as of Tue, 20 Jun 2023 16:21:31 GMT).

Copy link
Contributor

@Shadowfiend Shadowfiend left a comment

Choose a reason for hiding this comment

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

Some quick notes on the messages, haven't tested or actually looked beyond that messages file yet. Love this change though 🙌

ui/_locales/en/messages.json Outdated Show resolved Hide resolved
ui/_locales/en/messages.json Outdated Show resolved Hide resolved
ui/_locales/en/messages.json Outdated Show resolved Hide resolved
Shadowfiend
Shadowfiend previously approved these changes Jun 15, 2023
Copy link
Contributor

@Shadowfiend Shadowfiend left a comment

Choose a reason for hiding this comment

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

Code looks good, gotta test drive it (hoping for tomorrow).

Copy link
Contributor

@hyphenized hyphenized left a comment

Choose a reason for hiding this comment

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

Looks great! Found one minor thing

assetData?.mainCurrencyAmount !== undefined &&
assetData?.mainCurrencyAmount < userValueDustThreshold

const showWarningAboutNoBalance =
!showWarningAboutDust && assetData?.mainCurrencyAmount === 0
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 want to show this warning only if hide dust is enabled and display the visibility message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In fact, this message should be displayed when the balance is zero.
https://github.com/tahowallet/extension/assets/23117945/2fee5d65-33d1-4483-a573-7614e9eedfbb

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I missed a word, comment should've said "Do we want to show this warning only if hide dust is enabled and display the visibility message otherwise?"

My question was: if hide dust is not enabled should we display "Asset already exists, you should see it in your asset list "?

Copy link
Contributor Author

@kkosiorowska kkosiorowska Jun 16, 2023

Choose a reason for hiding this comment

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

And if its balance is not zero then yes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see! We should check that setting's value here too then. In the video, after disabling hide dust, the same warning shows up.

"warning.alreadyExists.desc": {
"dust": "Your balance is below {{sign}}{{amount}}. You will see it once you turn off “{{settings}}” in Settings.",
"noBalance": "Your balance is 0, you will see it once your balance is over {{sign}}{{amount}}.",
"visibility": "You should see in it in your asset list."
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
"visibility": "You should see in it in your asset list."
"visibility": "You should see it in your asset list."

Comment on lines 387 to 398
{showWarningAboutDust &&
t("warning.alreadyExists.desc.dust", {
...warningOptions,
settings: sharedT(
"settings.hideSmallAssetBalance",
warningOptions
),
})}
{showWarningAboutNoBalance &&
t("warning.alreadyExists.desc.noBalance", warningOptions)}
{showWarningAboutVisibility &&
t("warning.alreadyExists.desc.visibility")}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can move these to a function and structure by priority with either a switch statement or early returns, this would also allow us to get rid of the !showOtherWarning checks.

e.g.

 const renderWarningText = () => {
    const showWarningAboutDust = ...something

    if (showWarningAboutDust) {
      return t("warning.alreadyExists.desc.dust", {
        ...warningOptions,
        settings: sharedT("settings.hideSmallAssetBalance", warningOptions),
      })
    }

    // showWarningAboutNoBalance
    if (hideDustEnabled && ...) {
      return t("warning.alreadyExists.desc.noBalance", warningOptions)
    }

    // showWarningAboutVisibility
    return t("warning.alreadyExists.desc.visibility")
  }

@kkosiorowska
Copy link
Contributor Author

After changing the copy, there was a problem with the right padding. IMO, it didn't look good. @VladUXUI Could you please confirm if 24 px is fine?

Before
Screenshot 2023-06-16 at 10 40 44

After
Screenshot 2023-06-16 at 10 41 10

@VladUXUI
Copy link
Contributor

24px looks good @kkosiorowska !
Thank you

Copy link
Contributor

@hyphenized hyphenized left a comment

Choose a reason for hiding this comment

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

🚢 🚢 🚢

@hyphenized hyphenized merged commit 813a1f5 into main Jun 20, 2023
@hyphenized hyphenized deleted the asset-warnings branch June 20, 2023 16:21
@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).
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.

Add custom asset copy tweak
4 participants