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

fix(swap): round values for very small values in fiat and crypto #21442

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

briansztamfater
Copy link
Member

@briansztamfater briansztamfater commented Oct 15, 2024

fixes #21415
fixes #21419

Summary

This PR fixes fiat values shown as 0 when the value is less than 0.01, and also the same for crypto tokens when the value is less than 0.000001. Also fixes an error when long-tapping on an asset from the wallet main page and selecting "Swap".

Screenshot 2024-10-15 at 6 28 40 PM
Screenshot 2024-10-15 at 7 38 31 PM
Screenshot 2024-10-15 at 6 29 05 PM

Platforms

  • Android
  • iOS

Areas that maybe impacted

Functional
  • wallet / transactions

Steps to test

Issue #21415

  • Go to swap
  • Enter value with a lot of decimals (example: 0.000000000001 DAI)
  • Go to check rounding

Issue #21419

  • Go to wallet main page
  • Long tap asset (in my case WBTC)
  • Tap "Swap"
  • Verify no error is shown

status: ready

@status-im-auto
Copy link
Member

status-im-auto commented Oct 15, 2024

Jenkins Builds

Click to see older builds (14)
Commit #️⃣ Finished (UTC) Duration Platform Result
bc749b5 #1 2024-10-15 22:47:45 ~3 min tests 📄log
bc749b5 #1 2024-10-15 22:50:14 ~6 min ios 📄log
✔️ bc749b5 #1 2024-10-15 22:53:13 ~9 min android-e2e 🤖apk 📲
✔️ bc749b5 #1 2024-10-15 22:54:45 ~11 min android 🤖apk 📲
227360e #2 2024-10-15 23:09:07 ~2 min ios 📄log
✔️ 227360e #2 2024-10-15 23:11:16 ~4 min tests 📄log
✔️ 227360e #2 2024-10-15 23:13:22 ~6 min android-e2e 🤖apk 📲
✔️ 227360e #2 2024-10-15 23:14:39 ~7 min android 🤖apk 📲
227360e #3 2024-10-15 23:25:38 ~1 min ios 📄log
✔️ 227360e #4 2024-10-16 03:34:17 ~9 min ios 📱ipa 📲
✔️ 7ff75fc #3 2024-10-16 16:32:15 ~4 min tests 📄log
✔️ 7ff75fc #3 2024-10-16 16:34:48 ~7 min android 🤖apk 📲
✔️ 7ff75fc #3 2024-10-16 16:35:10 ~7 min android-e2e 🤖apk 📲
✔️ 7ff75fc #5 2024-10-16 16:36:27 ~8 min ios 📱ipa 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 369a375 #4 2024-10-18 09:59:57 ~4 min tests 📄log
✔️ 369a375 #4 2024-10-18 10:03:08 ~7 min android-e2e 🤖apk 📲
✔️ 369a375 #4 2024-10-18 10:03:12 ~8 min android 🤖apk 📲
✔️ 369a375 #6 2024-10-18 10:03:55 ~8 min ios 📱ipa 📲
✔️ d0f2db0 #5 2024-10-18 14:56:52 ~4 min tests 📄log
✔️ d0f2db0 #5 2024-10-18 14:58:58 ~6 min android 🤖apk 📲
✔️ d0f2db0 #5 2024-10-18 14:59:54 ~7 min android-e2e 🤖apk 📲
✔️ d0f2db0 #7 2024-10-18 15:01:18 ~9 min ios 📱ipa 📲

@briansztamfater briansztamfater force-pushed the fix/display-low-numbers branch 2 times, most recently from 227360e to 7ff75fc Compare October 16, 2024 16:27
(let [number (or (money/bignumber amount)
(money/bignumber 0))
amount-fixed-decimals (number/to-fixed number display-decimals)]
(if (and (= amount-fixed-decimals "0")
Copy link
Contributor

@alwx alwx Oct 16, 2024

Choose a reason for hiding this comment

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

why "0" and not 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's because number/to-fixed calls remove-trailing-zeroes fn which returns a string

@@ -26,6 +26,7 @@
[utils.string :as utils.string]))

(def ^:private default-text-for-unfocused-input "0.00")
(def ^:private default-token-symbol "ETH")
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 if we don't have this constant somewhere already

Copy link
Contributor

@alwx alwx left a comment

Choose a reason for hiding this comment

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

Approved but added two small comments

@Horupa-Olena Horupa-Olena self-assigned this Oct 17, 2024
@Horupa-Olena Horupa-Olena force-pushed the fix/display-low-numbers branch from 7ff75fc to 369a375 Compare October 18, 2024 09:54
@status-im-auto
Copy link
Member

75% of end-end tests have passed

Total executed tests: 8
Failed tests: 2
Expected to fail tests: 0
Passed tests: 6
IDs of failed tests: 740490,702843 

Failed tests (2)

Click to expand
  • Rerun failed tests

  • Class TestCommunityMultipleDeviceMerged:

    1. test_community_message_edit, id: 702843
    Test setup failed: critical/chats/test_public_chat_browsing.py:311: in prepare_devices
        self.drivers, self.loop = create_shared_drivers(2)
    base_test_case.py:310: in create_shared_drivers
        drivers = loop.run_until_complete(start_threads(test_suite_data.current_test.name,
    /usr/lib/python3.10/asyncio/base_events.py:649: in run_until_complete
        return future.result()
    __init__.py:26: in start_threads
        returns[k] = await returns[k]
    /usr/lib/python3.10/concurrent/futures/thread.py:58: in run
        result = self.fn(*self.args, **self.kwargs)
    ../../../../status-app-prs-rerun@tmp/venv/lib/python3.10/site-packages/appium/webdriver/webdriver.py:257: in __init__
        super().__init__(
    ../../../../status-app-prs-rerun@tmp/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py:206: in __init__
        self.start_session(capabilities)
    ../../../../status-app-prs-rerun@tmp/venv/lib/python3.10/site-packages/appium/webdriver/webdriver.py:346: in start_session
        response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps)
    ../../../../status-app-prs-rerun@tmp/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py:345: in execute
        self.error_handler.check_response(response)
    ../../../../status-app-prs-rerun@tmp/venv/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py:229: in check_response
        raise exception_class(message, screen, stacktrace)
     Sauce could not start your job. For more information on what happened, please visit https://app.eu-central-1.saucelabs.com/tests/eb8ebda6a8284de29682e5aede2e0211
    



    Class TestWalletOneDevice:

    1. test_wallet_balance_mainnet, id: 740490

    Device 1: Find Button by accessibility id: network-dropdown
    Device 1: Tap on found: Button

    critical/test_wallet.py:249: in test_wallet_balance_mainnet
        self.errors.verify_no_errors()
    base_test_case.py:192: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     For the Ether the wrong value 0.0051 is shown, expected 0.0052 in total
    E    For the Uniswap the wrong value 0.127 is shown, expected 0.627 in total
    E    For the Ether the wrong value 0.0 is shown, expected 0.0001 on Arbitrum
    E    For the Uniswap the wrong value 0.0 is shown, expected 0.5 on Arbitrum
    



    Passed tests (6)

    Click to expand

    Class TestCommunityOneDeviceMerged:

    1. test_community_copy_and_paste_message_in_chat_input, id: 702742
    Device sessions

    2. test_restore_multiaccount_with_waku_backup_remove_switch, id: 703133
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745
    Device sessions

    Class TestWalletMultipleDevice:

    1. test_wallet_send_asset_from_drawer, id: 727230
    2. test_wallet_send_eth, id: 727229

    Class TestWalletOneDevice:

    1. test_wallet_add_remove_regular_account, id: 727231

    Copy link
    Contributor

    @mohsen-ghafouri mohsen-ghafouri left a comment

    Choose a reason for hiding this comment

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

    LGTM

    @Horupa-Olena
    Copy link

    @briansztamfater Thank you for your PR.
    Regarding the symbols, everything is fine.
    As for the long tap bug, I tried different combinations under various conditions but couldn’t reproduce the issue. So, we’ll assume it's fixed.

    You can go ahead and merge this PR.

    @briansztamfater briansztamfater force-pushed the fix/display-low-numbers branch from 369a375 to d0f2db0 Compare October 18, 2024 14:51
    @briansztamfater briansztamfater merged commit 7e5df76 into develop Oct 18, 2024
    5 checks passed
    @briansztamfater briansztamfater deleted the fix/display-low-numbers branch October 18, 2024 15:10
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    Archived in project
    Status: Done
    5 participants