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

Wallet: token input conversion #18539

Merged
merged 12 commits into from
Jan 20, 2024
Merged

Wallet: token input conversion #18539

merged 12 commits into from
Jan 20, 2024

Conversation

OmarBasem
Copy link
Contributor

@OmarBasem OmarBasem commented Jan 17, 2024

fixes: #18499, #18538

This PR fixes the coversion rate from crypto to fiat used in the token input component.

Also fixes the crypto decimal places used in the token input component.

Screen_Recording_20240117_161258_Status.mp4

@status-im-auto
Copy link
Member

status-im-auto commented Jan 17, 2024

Jenkins Builds

Click to see older builds (32)
Commit #️⃣ Finished (UTC) Duration Platform Result
ee25873 #3 2024-01-17 12:17:47 ~5 min tests 📄log
✔️ ee25873 #3 2024-01-17 12:18:59 ~7 min android-e2e 🤖apk 📲
✔️ ee25873 #3 2024-01-17 12:19:24 ~7 min android 🤖apk 📲
✔️ ee25873 #3 2024-01-17 12:21:20 ~9 min ios 📱ipa 📲
dc0db61 #4 2024-01-19 03:41:36 ~4 min tests 📄log
✔️ dc0db61 #4 2024-01-19 03:44:34 ~7 min ios 📱ipa 📲
✔️ dc0db61 #4 2024-01-19 03:45:38 ~8 min android-e2e 🤖apk 📲
✔️ dc0db61 #4 2024-01-19 03:45:39 ~8 min android 🤖apk 📲
dc0db61 #5 2024-01-19 03:48:05 ~4 min tests 📄log
ee35f3c #6 2024-01-19 03:56:32 ~5 min tests 📄log
✔️ ee35f3c #5 2024-01-19 03:58:07 ~6 min ios 📱ipa 📲
✔️ ee35f3c #5 2024-01-19 03:58:16 ~7 min android-e2e 🤖apk 📲
✔️ ee35f3c #5 2024-01-19 03:59:31 ~8 min android 🤖apk 📲
79fe2cb #7 2024-01-19 04:11:16 ~5 min tests 📄log
✔️ 79fe2cb #6 2024-01-19 04:12:59 ~6 min ios 📱ipa 📲
✔️ 79fe2cb #6 2024-01-19 04:13:17 ~7 min android-e2e 🤖apk 📲
✔️ 79fe2cb #6 2024-01-19 04:13:24 ~7 min android 🤖apk 📲
06a49e7 #8 2024-01-19 04:18:34 ~4 min tests 📄log
✔️ 06a49e7 #7 2024-01-19 04:20:37 ~6 min ios 📱ipa 📲
✔️ 06a49e7 #7 2024-01-19 04:20:49 ~7 min android 🤖apk 📲
✔️ 06a49e7 #7 2024-01-19 04:20:53 ~7 min android-e2e 🤖apk 📲
3c581a1 #9 2024-01-19 11:20:28 ~4 min tests 📄log
✔️ 3c581a1 #8 2024-01-19 11:21:25 ~5 min ios 📱ipa 📲
✔️ 3c581a1 #8 2024-01-19 11:22:40 ~7 min android 🤖apk 📲
✔️ 3c581a1 #8 2024-01-19 11:22:51 ~7 min android-e2e 🤖apk 📲
7ffc7ad #10 2024-01-19 11:31:33 ~4 min tests 📄log
✔️ 7ffc7ad #9 2024-01-19 11:33:56 ~7 min android 🤖apk 📲
✔️ 7ffc7ad #9 2024-01-19 11:34:04 ~7 min android-e2e 🤖apk 📲
✔️ 79c789f #10 2024-01-19 11:41:14 ~6 min ios 📱ipa 📲
✔️ 79c789f #10 2024-01-19 11:42:50 ~8 min android-e2e 🤖apk 📲
79c789f #11 2024-01-19 11:43:43 ~9 min tests 📄log
✔️ 79c789f #10 2024-01-19 11:44:25 ~10 min android 🤖apk 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
6d8e0db #12 2024-01-19 11:52:56 ~5 min tests 📄log
✔️ 6d8e0db #11 2024-01-19 11:54:35 ~7 min android 🤖apk 📲
✔️ 6d8e0db #11 2024-01-19 11:55:45 ~8 min android-e2e 🤖apk 📲
✔️ 6d8e0db #11 2024-01-19 11:58:35 ~11 min ios 📱ipa 📲
✔️ 2c60662 #13 2024-01-20 05:37:24 ~5 min tests 📄log
✔️ 2c60662 #12 2024-01-20 05:39:35 ~8 min ios 📱ipa 📲
✔️ 2c60662 #12 2024-01-20 05:40:17 ~8 min android-e2e 🤖apk 📲
✔️ 2c60662 #12 2024-01-20 05:40:28 ~9 min android 🤖apk 📲

@status-im-auto
Copy link
Member

92% of end-end tests have passed

Total executed tests: 48
Failed tests: 1
Expected to fail tests: 3
Passed tests: 44
IDs of failed tests: 702851 
IDs of expected to fail tests: 703503,702808,703629 

Failed tests (1)

Click to expand
  • Rerun failed tests

  • Class TestActivityCenterContactRequestMultipleDevicePR:

    1. test_activity_center_contact_request_accept_swipe_mark_all_as_read, id: 702851

    Device 2: Button element not found
    Device 2: Find `Button` by `accessibility id`: `add-a-contact`

    activity_center/test_activity_center.py:102: in test_activity_center_contact_request_accept_swipe_mark_all_as_read
        self.home_2.add_a_contact_chat_bottom_sheet_button.click()
    ../views/base_element.py:90: in click
        self.find_element().click()
    ../views/base_element.py:79: in find_element
        raise NoSuchElementException(
     Device 2: Button by accessibility id: `add-a-contact` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    Device sessions

    Expected to fail tests (3)

    Click to expand

    Class TestCommunityMultipleDeviceMergedTwo:

    1. test_community_join_when_node_owner_offline, id: 703629

    Device 2: Tap on found: Button
    Device 2: Looking for community: 'open community'

    critical/chats/test_public_chat_browsing.py:1178: in test_community_join_when_node_owner_offline
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     open community is not listed inside Pending communities tab
    E    Joined status is not displayed
    E    open community is not listed inside Joined communities tab 
    

    [[Can't join a community if admin goes offline, https://github.com//issues/17678]]

    Device sessions

    Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_offline_pn, id: 702808

    Device 3: Looking for a message by text: message from old member
    Device 3: Looking for a message by text: message from new member

    critical/chats/test_group_chat.py:324: in test_group_chat_offline_pn
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Messages PN was not fetched from offline 
    

    [[Data delivery issue]]

    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_community_discovery, id: 703503

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Curated communities not loading, https://github.com//issues/17852]]

    Passed tests (44)

    Click to expand

    Class TestOneToOneChatMultipleSharedDevicesNewUiTwo:

    1. test_1_1_chat_delete_via_long_press_relogin, id: 702784
    Device sessions

    2. test_1_1_chat_is_shown_message_sent_delivered_from_offline, id: 702783
    Device sessions

    3. test_1_1_chat_mute_chat, id: 703496
    Device sessions

    Class TestCommunityMultipleDeviceMerged:

    1. test_community_several_images_send_reply, id: 703194
    Device sessions

    2. test_community_one_image_send_reply, id: 702859
    Device sessions

    3. test_community_emoji_send_copy_paste_reply, id: 702840
    Device sessions

    4. test_community_mark_all_messages_as_read, id: 703086
    Device sessions

    5. test_community_contact_block_unblock_offline, id: 702894
    Device sessions

    6. test_community_edit_delete_message_when_offline, id: 704615
    Device sessions

    7. test_community_message_delete, id: 702839
    Device sessions

    8. test_community_message_send_check_timestamps_sender_username, id: 702838
    Device sessions

    9. test_community_links_with_previews_github_youtube_twitter_gif_send_enable, id: 702844
    Device sessions

    10. test_community_message_edit, id: 702843
    Device sessions

    11. test_community_unread_messages_badge, id: 702841
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_emoji_send_reply_and_open_link, id: 702782
    Device sessions

    2. test_1_1_chat_text_message_delete_push_disappear, id: 702733
    Device sessions

    3. test_1_1_chat_push_emoji, id: 702813
    Device sessions

    4. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745
    Device sessions

    5. test_1_1_chat_edit_message, id: 702855
    Device sessions

    6. test_1_1_chat_send_image_save_and_share, id: 703391
    Device sessions

    7. test_1_1_chat_pin_messages, id: 702731
    Device sessions

    8. test_1_1_chat_message_reaction, id: 702730
    Device sessions

    Class TestDeepLinksOneDevice:

    1. test_links_open_universal_links_from_chat, id: 704613
    Device sessions

    2. test_links_deep_links, id: 702775
    Device sessions

    Class TestCommunityMultipleDeviceMergedTwo:

    1. test_community_markdown_support, id: 702809
    Device sessions

    2. test_community_hashtag_links_to_community_channels, id: 702948
    Device sessions

    3. test_community_mentions_push_notification, id: 702786
    Device sessions

    4. test_community_leave, id: 702845
    Device sessions

    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

    3. test_community_undo_delete_message, id: 702869
    Device sessions

    4. test_community_navigate_to_channel_when_relaunch, id: 702846
    Device sessions

    5. test_community_mute_community_and_channel, id: 703382
    Device sessions

    Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_pin_messages, id: 702732
    Device sessions

    2. test_group_chat_mute_chat, id: 703495
    Device sessions

    3. test_group_chat_send_image_save_and_share, id: 703297
    Device sessions

    4. test_group_chat_reactions, id: 703202
    Device sessions

    5. test_group_chat_join_send_text_messages_push, id: 702807
    Device sessions

    Class TestActivityMultipleDevicePRTwo:

    1. test_activity_center_mentions, id: 702957
    Device sessions

    2. test_activity_center_admin_notification_accept_swipe, id: 702958
    Device sessions

    Class TestActivityCenterContactRequestMultipleDevicePR:

    1. test_add_contact_field_validation, id: 702777
    Device sessions

    2. test_activity_center_contact_request_decline, id: 702850
    Device sessions

    Class TestActivityMultipleDevicePR:

    1. test_navigation_jump_to, id: 702936
    Device sessions

    2. test_activity_center_reply_read_unread_delete_filter_swipe, id: 702947
    Device sessions

    @@ -14,11 +14,13 @@
    [reagent.core :as reagent]))

    (defn calc-value
    [crypto? currency token value conversion]
    [crypto? currency token value conversion crypto-decimals]
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    We should avoid functions with 3+ positional args, better to use a map imo

    (let [num-value (if (string? value) (parse-double (or value "0")) value)]
    (if crypto?
    (str (get common/currency-label currency) (.toFixed (* num-value conversion) 2))
    (str (.toFixed (/ num-value conversion) 2) " " (string/upper-case (or (clj->js token) ""))))))
    (str (.toFixed (/ num-value conversion) (or crypto-decimals 2))
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    Imo it would be nice to separate the two functions of the if,
    e. calc-crypto and calc-fiat
    So it's
    (if crypto?
    (calc-crypto ...)
    (calc-fiat ...))
    And just reads nicely 👌

    @pavloburykh pavloburykh self-assigned this Jan 18, 2024
    @pavloburykh
    Copy link
    Contributor

    @OmarBasem thanks for the PR.

    Could you please provide some details on this fix?

    Also fixes the crypto decimal places used in the token input component.

    Can you show with screenshot examples how it was before the fix and how it is now? So far it is not clear for me what has been changed in terms of this fix. Thank you!

    @OmarBasem
    Copy link
    Contributor Author

    OmarBasem commented Jan 18, 2024

    Hi @pavloburykh,

    Both fixes are for the same component in the video.

    This PR fixes the coversion rate from crypto to fiat used in the token input component.

    If you try to send a token you would notice the conversion rate when you switch fiat/crypto on that screen is currently incorrect.

    Also fixes the crypto decimal places used in the token input component.

    Currently if you choose to send ETH for example you would see on that screen that ETH is shown using so many decimal places. That current behaviour incorrect.

    If something is still unclear please let me know

    @pavloburykh
    Copy link
    Contributor

    pavloburykh commented Jan 18, 2024

    If something is still unclear please let me know

    Thanks for the answer @OmarBasem! Just curious why would we want to limit decimals amount on send token screens? In this case - it will not show the accurate amount of tokens. Where do we get the requirements on how many decimals we should show?

    For example, in this PR we show 5 decimals for ETH and 2 decimals for DAI though both tokens may have 18 decimals.

    Sorry, maybe I have missed some discussion on this topic, would appreciate if you share the links if such exist. I need this info to be sure in expected result otherwise my testing can not be valid. The Designs are showing 2 decimals for ETH which is completely weird.

    @pavloburykh
    Copy link
    Contributor

    pavloburykh commented Jan 18, 2024

    @OmarBasem meanwhile I have faced the issue and I am not sure if it is PR related. I cannot reproduce it on nightly.

    ISSUE 1 Cannot read property 'eq' of null error when selecting token for sending (Android)

    So far reproducing only on Android (Samsung Galaxy A52, Android 12)

    Steps:

    1. Recover user with tokens
    2. Open wallet - Send - My accounts - Select account - Select token
    3. Observe the result

    Actual result: Cannot read property 'eq' of null error appears. It does not happen every time.

    Status-debug-logs (95).zip
    photo_2024-01-18 15 03 52

    telegram-cloud-document-2-5282794599960559219.mp4

    Expected result: no error

    @pavloburykh
    Copy link
    Contributor

    If something is still unclear please let me know

    Thanks for the answer @OmarBasem! Just curious why would we want to limit decimals amount on send token screens? In this case - it will not show the accurate amount of tokens. Where do we get the requirements on how many decimals we should show?

    For example, in this PR we show 5 decimals for ETH and 2 decimals for DAI though both tokens may have 18 decimals.

    Sorry, maybe I have missed some discussion on this topic, would appreciate if you share the links if such exist. I need this info to be sure in expected result otherwise my testing can not be valid. The Designs are showing 2 decimals for ETH which is completely weird.

    @OmarBasem UPDATE: I have found this info status-im/status-desktop#8640 Will consider it to be a source of truth.

    @OmarBasem
    Copy link
    Contributor Author

    OmarBasem commented Jan 18, 2024

    @OmarBasem UPDATE: I have found this info status-im/status-desktop#8640 Will consider it to be a source of truth.

    @pavloburykh Yeah that's the information. Btw, this information comes from status-go so you don't have to worry about math details.

    Regarding issue 1, is this issue reproducible on develop cause we are facing a similar issue on develop in debug mode (a crash after selecting token which doesn't happen everytime) and there is currently another PR that should fix it #18532

    @pavloburykh
    Copy link
    Contributor

    @OmarBasem thank you for clarification. PR is ready to be merged.

    @OmarBasem OmarBasem force-pushed the wallet/fix-conversion branch 3 times, most recently from 79c789f to 6d8e0db Compare January 19, 2024 11:46
    @OmarBasem OmarBasem merged commit 826ab66 into develop Jan 20, 2024
    6 checks passed
    @OmarBasem OmarBasem deleted the wallet/fix-conversion branch January 20, 2024 06:23
    Pau1fitz pushed a commit to Pau1fitz/status-mobile that referenced this pull request Jan 22, 2024
    (defn get-crypto-decimals-count
    [{:keys [market-values-per-currency]}]
    (let [price (get-in market-values-per-currency [:usd :price])
    one-cent-value (if (pos? price) (/ 0.01 price) 0)]
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    Should price be a big number?

    Cc @ulisesmac

    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    Yeah, I think price should be.

    JS numbers' implementation sometimes have an unexpected behaviour. since we are dealing with money, better to be safe 👍

    Choose a reason for hiding this comment

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

    Yeah, I think price should be.

    JS numbers' implementation sometimes have an unexpected behaviour. since we are dealing with money, better to be safe 👍

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    Archived in project
    Archived in project
    Development

    Successfully merging this pull request may close these issues.

    Send flow: input amount screen incorrect rate conversion
    7 participants