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): display very small numbers max values, fix scientific notation, display long number & handle decimal mismatch #21388

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

briansztamfater
Copy link
Member

@briansztamfater briansztamfater commented Oct 4, 2024

fixes #21348
fixes #21347
fixes #21331
fixes #21330

Summary

This PR fixes a couple of bugs in the Swap flow:

  1. Remaining decimals token shown in Scientific Notation on swap page if max label is tapped
  2. Long numbers in swap receive field not properly displayed
  3. Default token in the receiving field of swap is not SNT
  4. Handling decimal mismatch when switching tokens with different decimal support

Platforms

  • Android
  • iOS

Areas that maybe impacted

Functional
  • wallet / transactions

Steps to test

Issue 1

  • Open Status
  • Restore a user with a token that has a very small remaining decimal value (e.g., 0.000000000262783357 DAI).
  • Go to swaps
  • Select that token in the select asset to pay screen
  • Tap "Max" value
  • Verify the value is not in scientific notation

Issue 2

  • Open Status
  • Log in
  • Go to swaps
  • Select some 18 decimals token in the receiving value
  • Enter some values
  • Verify the values are displayed properly with gradients in the beginning of the input (pay token) and in the end pf the input (receive token)

[NOTE] There's an Android bug in our current version of React Native (0.73) that prevents us to position the text input at the start of it (facebook/react-native#44171), thus will have to follow-up on this once we update to 0.74+ where this seems to be fixed (reactwg/react-native-releases#283)

Issue 3

  • Open Status
  • Login
  • Go to swaps
  • Select an asset
  • Verify the default asset to receive is SNT

Issue 4

  • Open Status
  • Login
  • Go to swaps
  • Select a token with 18 decimal support (like DAI) in the asset to pay field
  • Change the token to one with 6 decimal support (like USDC)
  • Verify the input is cleared when decimals of the current value and thew new selected token don't match

status: ready

@briansztamfater briansztamfater marked this pull request as draft October 4, 2024 15:50
@briansztamfater briansztamfater self-assigned this Oct 4, 2024
@status-im-auto
Copy link
Member

status-im-auto commented Oct 4, 2024

Jenkins Builds

Click to see older builds (32)
Commit #️⃣ Finished (UTC) Duration Platform Result
840f0d9 #1 2024-10-04 15:52:35 ~3 min tests 📄log
a7c430b #2 2024-10-04 15:59:24 ~3 min tests 📄log
✔️ a7c430b #2 2024-10-04 16:03:22 ~7 min android 🤖apk 📲
✔️ a7c430b #2 2024-10-04 16:03:57 ~7 min android-e2e 🤖apk 📲
✔️ a7c430b #2 2024-10-04 16:06:03 ~9 min ios 📱ipa 📲
✔️ 590ffe3 #3 2024-10-05 01:18:23 ~4 min tests 📄log
✔️ 590ffe3 #3 2024-10-05 01:21:28 ~7 min android-e2e 🤖apk 📲
✔️ 590ffe3 #3 2024-10-05 01:21:39 ~7 min android 🤖apk 📲
✔️ 590ffe3 #3 2024-10-05 01:23:31 ~9 min ios 📱ipa 📲
✔️ a2c08e2 #4 2024-10-05 23:54:01 ~4 min tests 📄log
✔️ a2c08e2 #4 2024-10-05 23:57:20 ~7 min android-e2e 🤖apk 📲
✔️ a2c08e2 #4 2024-10-05 23:57:49 ~8 min android 🤖apk 📲
✔️ 827adec #5 2024-10-06 00:02:51 ~4 min tests 📄log
✔️ 754bbfd #6 2024-10-06 00:07:40 ~4 min tests 📄log
✔️ 754bbfd #6 2024-10-06 00:10:32 ~6 min android 🤖apk 📲
✔️ 754bbfd #6 2024-10-06 00:12:11 ~8 min ios 📱ipa 📲
✔️ 538d51c #7 2024-10-07 03:45:02 ~4 min tests 📄log
✔️ 538d51c #7 2024-10-07 03:47:15 ~6 min android 🤖apk 📲
✔️ 538d51c #7 2024-10-07 03:47:45 ~7 min android-e2e 🤖apk 📲
✔️ 538d51c #7 2024-10-07 03:49:12 ~8 min ios 📱ipa 📲
✔️ bce3eb3 #8 2024-10-07 05:02:54 ~4 min tests 📄log
✔️ bce3eb3 #8 2024-10-07 05:05:49 ~7 min android-e2e 🤖apk 📲
✔️ bce3eb3 #8 2024-10-07 05:05:59 ~7 min android 🤖apk 📲
✔️ bce3eb3 #8 2024-10-07 05:07:01 ~8 min ios 📱ipa 📲
✔️ 2a9d3b4 #9 2024-10-08 16:41:57 ~3 min tests 📄log
✔️ 2a9d3b4 #9 2024-10-08 16:45:06 ~7 min android-e2e 🤖apk 📲
✔️ 2a9d3b4 #9 2024-10-08 16:46:46 ~8 min android 🤖apk 📲
✔️ 2a9d3b4 #9 2024-10-08 16:46:46 ~8 min ios 📱ipa 📲
✔️ b385258 #10 2024-10-08 21:09:05 ~4 min tests 📄log
✔️ b385258 #10 2024-10-08 21:12:25 ~7 min android-e2e 🤖apk 📲
✔️ b385258 #10 2024-10-08 21:12:33 ~7 min android 🤖apk 📲
✔️ b385258 #10 2024-10-08 21:13:24 ~8 min ios 📱ipa 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 584fb5c #11 2024-10-08 21:56:05 ~4 min tests 📄log
✔️ 584fb5c #11 2024-10-08 21:58:59 ~7 min android-e2e 🤖apk 📲
✔️ 584fb5c #11 2024-10-08 21:59:34 ~7 min android 🤖apk 📲
✔️ 584fb5c #11 2024-10-08 22:00:26 ~8 min ios 📱ipa 📲
✔️ 7e05edf #12 2024-10-09 02:37:45 ~4 min tests 📄log
✔️ 7e05edf #12 2024-10-09 02:41:04 ~7 min android-e2e 🤖apk 📲
✔️ 7e05edf #12 2024-10-09 02:41:31 ~7 min android 🤖apk 📲
✔️ 7e05edf #12 2024-10-09 02:42:17 ~8 min ios 📱ipa 📲

@briansztamfater briansztamfater force-pushed the fix/swap-scientific-notation branch 5 times, most recently from 827adec to 754bbfd Compare October 6, 2024 00:03
@briansztamfater briansztamfater changed the title [WIP] fix(swap): display very small numbers max values, fix scientific notation & display long numbers fix(swap): display very small numbers max values, fix scientific notation, display long number & handle decimal mismatch Oct 7, 2024
@briansztamfater briansztamfater marked this pull request as ready for review October 7, 2024 03:20
@briansztamfater briansztamfater force-pushed the fix/swap-scientific-notation branch 2 times, most recently from 538d51c to bce3eb3 Compare October 7, 2024 04:58
@shivekkhurana shivekkhurana added the wallet-core Issues for mobile wallet team label Oct 7, 2024
@shivekkhurana shivekkhurana added this to the 2.31.0 Beta milestone Oct 7, 2024
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

Copy link
Member

@seanstrom seanstrom left a comment

Choose a reason for hiding this comment

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

Thanks for the PR 🙌
Overall, I think the code looks good, but I'm just not sure I understand some of the intended behaviour, so I left a few comments.

If possible, could you also provide some screen captures showing the new behaviour please? 🙏

Comment on lines +79 to +93
(def gradient-start
{:width 64
:position :absolute
:top 0
:left 0
:bottom 0
:z-index 1})

(def gradient-end
{:width 64
:position :absolute
:top 0
:right 0
:bottom 0
:z-index 1})
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can add a def named gradient-common for all the shared keys?

Comment on lines +47 to +49
(def icon-size 32)
(def container-padding 24)
(def max-cursor-position 5)
Copy link
Member

Choose a reason for hiding this comment

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

How are we calculating the container-padding value? Is it possible to reference this from a style file?

Copy link
Member

Choose a reason for hiding this comment

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

for max-cursor-position, is it possible that value will need to smaller on devices with smaller screens?

@VolodLytvynenko VolodLytvynenko self-assigned this Oct 8, 2024
@status-im-auto
Copy link
Member

100% of end-end tests have passed

Total executed tests: 7
Failed tests: 0
Expected to fail tests: 0
Passed tests: 7

Passed tests (7)

Click to expand

Class TestCommunityMultipleDeviceMerged:

1. test_community_message_edit, id: 702843
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
Device sessions

Class TestOneToOneChatMultipleSharedDevicesNewUi:

1. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745
Device sessions

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

@VolodLytvynenko
Copy link
Contributor

hi @briansztamfater thank you for PR.
issue 21331 is fixed
issue 21348 still reproducible for Android devices. First numbers are not visible in the "receive" field
Pixel XL API 33 (Android studion)
image

Pixel 7a, Android 13
image

@briansztamfater
Copy link
Member Author

briansztamfater commented Oct 8, 2024

Hey @VolodLytvynenko, that's a known issue, check note from issue 2 in PR description. We can create a issue to follow up after we upgrade the React Native version

@VolodLytvynenko
Copy link
Contributor

Hey @VolodLytvynenko, that's a known issue, check note from issue 2 in PR description. We can create a issue to follow up after we upgrade the React Native version

@briansztamfater Oh yes, sorry for this. I have missed this

Unfortunately issue 21331 is not fixed fully. There is some additional way to make SNT not default in the receive field. Take a look please

Steps to Reproduce:

  1. User is on the main page.
  2. Long tap the asset and tap "Swap."

Actual Result:

SNT is not shown as the default token in the "receive" field.

snt.mp4

Expected result

SNT is shown as the default token in "receive" field

@briansztamfater
Copy link
Member Author

Hey @VolodLytvynenko, that's a known issue, check note from issue 2 in PR description. We can create a issue to follow up after we upgrade the React Native version

@briansztamfater Oh yes, sorry for this. I have missed this

Unfortunately issue 21331 is not fixed fully. There is some additional way to make SNT not default in the receive field. Take a look please

Steps to Reproduce:

  1. User is on the main page.
  2. Long tap the asset and tap "Swap."

Actual Result:

SNT is not shown as the default token in the "receive" field.

snt.mp4

Expected result

SNT is shown as the default token in "receive" field

@VolodLytvynenko thanks for testing, and sorry about that, issue should be fixed now :)

…ndle decimal mismatch when changing tokens, display long numbers

Signed-off-by: Brian Sztamfater <[email protected]>
@status-im-auto
Copy link
Member

86% of end-end tests have passed

Total executed tests: 7
Failed tests: 1
Expected to fail tests: 0
Passed tests: 6
IDs of failed tests: 727229 

Failed tests (1)

Click to expand
  • Rerun failed tests

  • Class TestWalletMultipleDevice:

    1. test_wallet_send_eth, id: 727229

    Device 2: Find `Text` by `xpath`: `//android.view.ViewGroup[@content-desc='container']/android.widget.TextView[@text='Ether']/../android.widget.TextView[3]`
    Device 2: `Text` is `0.08409 ETH`

    critical/test_wallet.py:159: in test_wallet_send_eth
        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))]))
     Sender balance is not updated on Etherscan, it is 0.3972 but expected to be 0.3973
    



    Passed tests (6)

    Click to expand

    Class TestCommunityMultipleDeviceMerged:

    1. test_community_message_edit, id: 702843
    Device sessions

    Class TestWalletOneDevice:

    1. test_wallet_add_remove_regular_account, id: 727231
    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

    Class TestCommunityOneDeviceMerged:

    1. test_restore_multiaccount_with_waku_backup_remove_switch, id: 703133
    Device sessions

    2. test_community_copy_and_paste_message_in_chat_input, id: 702742
    Device sessions

    @VolodLytvynenko
    Copy link
    Contributor

    @VolodLytvynenko thanks for testing, and sorry about that, issue should be fixed now :)

    Hey, thank you for the fix! SNT is usually shown as the default, but sometimes it doesn’t appear, especially right after the initial login

    Steps to Reproduce:

    1. User is on the main page.
    2. Long tap the asset and tap "Swap."
    3. Check default asset
    4. Relogin and try again steps 1-3 if issue is not reproduced

    Actual result:

    SNT is not shown as the default token in the "Receive" field after relogin.

    defaultsnt.mp4

    Expected Result:

    SNT should be displayed as the default token in the "Receive" field after relogin.

    ENV:

    IOS, Android
    logs.zip

    @VolodLytvynenko
    Copy link
    Contributor

    @briansztamfater additionally, we discussed the issue related to predefined SNT yesterday. Could you take a look and see if this issue can be fixed within the scope of this PR? Otherwise, it can be addressed separately

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    request-manual-qa wallet-core Issues for mobile wallet team
    Projects
    Status: IN TESTING
    Status: QA
    6 participants