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(wallet)_: token supported networks #21451

Merged
merged 5 commits into from
Oct 24, 2024
Merged

Conversation

smohamedjavid
Copy link
Member

@smohamedjavid smohamedjavid commented Oct 17, 2024

fixes #20988

Summary

This PR fixes the networks/chains supported by the token based on the token list fetched from status-go instead of relying on the balance-per-chain map as status-go returns balance for chains only if there is a positive balance.

Platforms

  • Android
  • iOS

Areas that may be impacted

Functional

  • wallet/transactions

Steps to test

Prerequisites: A wallet account with a token balance on one network
  • Open Status
  • Navigate to Wallet > Account > Bridge
  • Verify the supported networks by each token is displayed below each token
  • Upon selecting a token, verify the token supported networks are selectable even if there is no balance on that network/chain
  • Navigate to Wallet > Account > Send
  • Verify the tokens are displayed correctly with networks supported by the token
  • Navigate to the routes generation page and verify Not available text is not shown on the receiver side
  • Verify the transaction can be performed

status: ready

@smohamedjavid smohamedjavid self-assigned this Oct 17, 2024
@status-im-auto
Copy link
Member

status-im-auto commented Oct 17, 2024

Jenkins Builds

Click to see older builds (36)
Commit #️⃣ Finished (UTC) Duration Platform Result
015a233 #1 2024-10-17 12:13:53 ~3 min tests 📄log
✔️ 015a233 #1 2024-10-17 12:19:15 ~8 min android-e2e 🤖apk 📲
✔️ 015a233 #1 2024-10-17 12:19:48 ~9 min android 🤖apk 📲
✔️ 015a233 #1 2024-10-17 12:19:53 ~9 min ios 📱ipa 📲
✔️ f59d0c0 #2 2024-10-17 15:19:18 ~4 min tests 📄log
✔️ f59d0c0 #2 2024-10-17 15:23:15 ~8 min android-e2e 🤖apk 📲
✔️ f59d0c0 #2 2024-10-17 15:23:26 ~8 min ios 📱ipa 📲
✔️ f59d0c0 #2 2024-10-17 15:23:40 ~9 min android 🤖apk 📲
f7dc535 #3 2024-10-18 18:50:23 ~3 min tests 📄log
✔️ f7dc535 #3 2024-10-18 18:54:20 ~7 min android 🤖apk 📲
✔️ f7dc535 #3 2024-10-18 18:55:15 ~8 min android-e2e 🤖apk 📲
✔️ f7dc535 #3 2024-10-18 18:56:27 ~9 min ios 📱ipa 📲
✔️ 86c4705 #4 2024-10-18 19:21:12 ~5 min tests 📄log
✔️ 86c4705 #4 2024-10-18 19:24:57 ~8 min ios 📱ipa 📲
✔️ 86c4705 #4 2024-10-18 19:25:00 ~9 min android-e2e 🤖apk 📲
✔️ 86c4705 #4 2024-10-18 19:26:50 ~10 min android 🤖apk 📲
✔️ e42042e #5 2024-10-22 11:09:28 ~5 min tests 📄log
✔️ e42042e #5 2024-10-22 11:12:03 ~7 min android-e2e 🤖apk 📲
✔️ e42042e #5 2024-10-22 11:12:56 ~8 min android 🤖apk 📲
✔️ e42042e #5 2024-10-22 11:13:31 ~9 min ios 📱ipa 📲
✔️ a910aef #6 2024-10-22 16:31:44 ~5 min tests 📄log
✔️ a910aef #6 2024-10-22 16:33:51 ~7 min android 🤖apk 📲
✔️ a910aef #6 2024-10-22 16:34:32 ~7 min android-e2e 🤖apk 📲
✔️ a910aef #6 2024-10-22 16:35:37 ~9 min ios 📱ipa 📲
✔️ c920da6 #7 2024-10-23 11:05:05 ~4 min tests 📄log
✔️ c920da6 #7 2024-10-23 11:08:01 ~7 min android-e2e 🤖apk 📲
✔️ c920da6 #7 2024-10-23 11:08:27 ~8 min android 🤖apk 📲
✔️ c920da6 #7 2024-10-23 11:10:51 ~10 min ios 📱ipa 📲
6e59d72 #8 2024-10-23 12:15:38 ~3 min tests 📄log
✔️ 6e59d72 #8 2024-10-23 12:19:41 ~7 min android 🤖apk 📲
✔️ 6e59d72 #8 2024-10-23 12:21:09 ~8 min android-e2e 🤖apk 📲
✔️ 6e59d72 #8 2024-10-23 12:22:40 ~10 min ios 📱ipa 📲
✔️ 435fb40 #9 2024-10-23 12:28:43 ~4 min tests 📄log
✔️ 435fb40 #9 2024-10-23 12:31:38 ~7 min android 🤖apk 📲
✔️ 435fb40 #9 2024-10-23 12:31:59 ~7 min android-e2e 🤖apk 📲
✔️ 435fb40 #9 2024-10-23 12:33:12 ~8 min ios 📱ipa 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 6090a53 #10 2024-10-23 16:15:42 ~4 min tests 📄log
✔️ 6090a53 #10 2024-10-23 16:18:45 ~7 min android-e2e 🤖apk 📲
✔️ 6090a53 #10 2024-10-23 16:20:59 ~10 min ios 📱ipa 📲
✔️ 6090a53 #10 2024-10-23 16:21:29 ~10 min android 🤖apk 📲
✔️ 5330c11 #11 2024-10-23 17:26:27 ~4 min tests 📄log
✔️ 5330c11 #11 2024-10-23 17:28:28 ~6 min android-e2e 🤖apk 📲
✔️ 5330c11 #11 2024-10-23 17:30:21 ~8 min android 🤖apk 📲
✔️ 5330c11 #11 2024-10-23 17:32:20 ~10 min ios 📱ipa 📲

Copy link
Contributor

@ulisesmac ulisesmac left a comment

Choose a reason for hiding this comment

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

Hi @smohamedjavid thanks for you PR!

I added some minor comments related to the code.

src/status_im/contexts/wallet/common/utils.cljs Outdated Show resolved Hide resolved
src/status_im/contexts/wallet/common/utils/networks.cljs Outdated Show resolved Hide resolved
src/status_im/contexts/wallet/send/events.cljs Outdated Show resolved Hide resolved
src/status_im/contexts/wallet/swap/utils.cljs Outdated Show resolved Hide resolved
src/status_im/subs/wallet/wallet.cljs Outdated Show resolved Hide resolved
src/status_im/subs/wallet/wallet.cljs Outdated Show resolved Hide resolved
Copy link
Member

@clauxx clauxx left a comment

Choose a reason for hiding this comment

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

hey @smohamedjavid, I noticed this PR adds changes in similar places as this one, just as an FYI.

Also, wondering if it's possible to isolate the changes in one place only, for instance: when we get the token data from status-go, can we update balances-per-chain to include the missing chains? I may be missing context here though, just wondering if the other changes are necessary.

@smohamedjavid
Copy link
Member Author

hey @smohamedjavid, I noticed this PR adds changes in similar places as this one, just as an FYI.

@clauxx - thanks for the heads up 👍 I guess I missed the context. I was under the impression that we need to display the supported networks below each token as we used to display (depending on the balance-per-chain key). I guess I will change it. Please merge your PR and I will make changes on top of it.

Also, wondering if it's possible to isolate the changes in one place only, for instance: when we get the token data from status-go, can we update balances-per-chain to include the missing chains? I may be missing context here though, just wondering if the other changes are necessary.

That was my first thought too. I was under the impression that the status-go returns the balance even if it's zero in supported chains for all tokens, but it's different for non-default tokens (ETH SNT STT DAI are default tokens). I was inclined to status-go, but I don't want to introduce any bugs close to release.

I will quickly add the missing chain while we save it to the app-db. I need to ensure the token list (as we depend on it for supported chains for each token) is fetched before we fetch the tokens for each account so that we can add any missing chains in balance-per-chain. I will make a quick update.

{:sources (:sources tokens)
:supported-chains-by-symbol supported-chains-by-symbol
:by-address (-> tokens :by-address vals)
:by-symbol by-symbol-vals})
Copy link
Contributor

Choose a reason for hiding this comment

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

The only thing that confuses me a little is that we're saving:supported-chains-by-symbol inside a structure called :tokens
Maybe it'd be better for it all to be saved in [:wallet :chains-by-symbol] instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since we group the chains IDs (by symbol) depending on the tokens list, I felt placing that data under the :wallet :tokens seems reasonable.

src/status_im/contexts/wallet/events.cljs Outdated Show resolved Hide resolved
Comment on lines +83 to +86
:by-address (-> tokens :by-address vals)
:by-symbol by-symbol-vals})
Copy link
Member

@clauxx clauxx Oct 22, 2024

Choose a reason for hiding this comment

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

Not a change you introduced, but what's the point of grouping the tokens by symbol and by address (as a map of symbols/tokens and token data), if we end up dismissing that and use the vector of token data? I assume it was originally done to make extraction of token data easier/quicker, without having to go through the entire list of tokens. Here though, it seems like we are storing the tokens as a vector in the db three times, and it's not clear to me why. The token list is pretty large, so storing it 3 times seems excessive tbh.

There's also quite a bit of data here that we're fetching/storing, which I guess was added for swaps, but I'm not sure if this data ends up being used anywhere. Specifically, :details-per-token, :prices-per-token, :market-values-per-token.

cc: @status-im/wallet-mobile-devs (in case anyone knows the reason)

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess @alwx is the best person to answer.

Copy link
Contributor

Choose a reason for hiding this comment

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

The original idea was to copy this logic from desktop :) It was part of a bigger issue and I assumed that it's better to do all of it at once.

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

88% of end-end tests have passed

Total executed tests: 8
Failed tests: 1
Expected to fail tests: 0
Passed tests: 7
IDs of failed tests: 702843 

Failed tests (1)

Click to expand
  • Rerun failed tests

  • Class TestCommunityMultipleDeviceMerged:

    1. test_community_message_edit, id: 702843

    Device 2: Find `Text` by `xpath`: `//android.view.ViewGroup[@content-desc='chat-item']//android.widget.TextView[contains(@text,'https://status.app/c/')]`
    Device 2: Wait for element `Button` for max 120s and click when it is available

    Test setup failed: critical/chats/test_public_chat_browsing.py:350: in prepare_devices
        self.community_2.join_community()
    ../views/chat_view.py:420: in join_community
        self.join_button.wait_and_click(120)
    ../views/base_element.py:100: in wait_and_click
        self.wait_for_visibility_of_element(sec)
    ../views/base_element.py:147: in wait_for_visibility_of_element
        raise TimeoutException(
     Device 2: Button by accessibility id:`show-request-to-join-screen-button` is not found on the screen after wait_for_visibility_of_element
    



    Device sessions

    Passed tests (7)

    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 TestWalletOneDevice:

    1. test_wallet_add_remove_regular_account, id: 727231
    2. test_wallet_balance_mainnet, id: 740490

    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

    @VolodLytvynenko
    Copy link
    Contributor

    Hi @smohamedjavid thank you for PR. take a look at found issue:

    ISSUE 1: Network drawer shows networks with 0 balances

    Steps:

    1. Restore user with assets on a specific network (excluding DAI, ETH, SNT).
    2. Go to the wallet page.
    3. Long tap the asset and tap "swap."

    Actual result:

    The network drawer displays networks where the asset isn't present.

    Example: I have Chainlink on Optimism only, but I see Mainnet and Arbitrum in the network selection drawer as well

    networks_pr.mp4

    Expected result:

    The drawer should only show networks where the selected asset exists. In case if user has assets only on one network, then current user should be navigated directly to the swap page. See on nightly

    networks_night.mp4

    Devices:

    Pixel 7a, Android 13
    iPhone 11 Pro Max, iOS 17

    @smohamedjavid
    Copy link
    Member Author

    @VolodLytvynenko - Thanks for testing the PR 🙏 . The issue 1 should be fixed now. Please retest.

    @VolodLytvynenko
    Copy link
    Contributor

    VolodLytvynenko commented Oct 23, 2024

    ISSUE 2: 'Not available' shown in TO section if token isn't available on selected network

    Steps:

    1. Restore user with a token available on one or two networks. (However this token should be supported on the all networks. Example: ETH, DAI etc)
    2. Go to the send flow.
    3. Try to build a route.

    Actual result:

    User can't build a bridge route on the send page for a network where the asset isn't available.

    Example: In my case the user has DAI on the L1 network, but in the "send to" page, Optimism and Arbitrum are shown as 'Not available' in the TO section.

    image

    Expected result:

    The networks should be shown as available on send to page in case if user even does not have assets on current networks

    OS:

    IOS, Android

    Devices:

    • Pixel 7a, Android 13
    • iPhone 11 Pro Max, IOS 17

    @smohamedjavid
    Copy link
    Member Author

    @VolodLytvynenko - The issue 2 should be fixed now. Please retest. 🙏

    @status-im-auto
    Copy link
    Member

    62% of end-end tests have passed

    Total executed tests: 8
    Failed tests: 3
    Expected to fail tests: 0
    Passed tests: 5
    
    IDs of failed tests: 727231,740490,702843 
    

    Failed tests (3)

    Click to expand
  • Rerun failed tests

  • Class TestWalletOneDevice:

    1. test_wallet_add_remove_regular_account, id: 727231
    Test setup failed: critical/test_wallet.py:200: in prepare_devices
        self.drivers, self.loop = create_shared_drivers(1)
    base_test_case.py:330: in create_shared_drivers
        raise e
    base_test_case.py:320: in create_shared_drivers
        test_suite_data.current_test.testruns[-1].jobs[drivers[i].session_id] = i + 1
     '_asyncio.Future' object has no attribute 'session_id'
    



    2. test_wallet_balance_mainnet, id: 740490

    Test setup failed: critical/test_wallet.py:200: in prepare_devices
        self.drivers, self.loop = create_shared_drivers(1)
    base_test_case.py:330: in create_shared_drivers
        raise e
    base_test_case.py:320: in create_shared_drivers
        test_suite_data.current_test.testruns[-1].jobs[drivers[i].session_id] = i + 1
     '_asyncio.Future' object has no attribute 'session_id'
    



    Class TestCommunityMultipleDeviceMerged:

    1. test_community_message_edit, id: 702843

    Device 2: Find Text by xpath: //android.view.ViewGroup[@content-desc='chat-item']//android.widget.TextView[contains(@text,'https://status.app/c/')]
    Device 2: Wait for element Button for max 120s and click when it is available

    Test setup failed: critical/chats/test_public_chat_browsing.py:350: in prepare_devices
        self.community_2.join_community()
    ../views/chat_view.py:420: in join_community
        self.join_button.wait_and_click(120)
    ../views/base_element.py:100: in wait_and_click
        self.wait_for_visibility_of_element(sec)
    ../views/base_element.py:147: in wait_for_visibility_of_element
        raise TimeoutException(
     Device 2: Button by accessibility id:`show-request-to-join-screen-button` is not found on the screen after wait_for_visibility_of_element
    



    Device sessions

    Passed tests (5)

    Click to expand

    Class TestWalletMultipleDevice:

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

    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

    @smohamedjavid Thank you for fixes. Unfortunatly one more place related to this issue is introduced after last commit, however can be considered as follow up

    PR_ISSUE 3: Token shown as 'Not available' in "edit preferences" drawer despite being supported

    Steps::

    1. Restore user with a token available on one or two networks. (However this token should be supported on the all networks. Example: ETH, DAI etc)
    2. Go to the send flow.
    3. Try to build a route.
    4. Tap "edit" button to enable "edit preferences" drawer
    notsup.mp4

    Actual result:

    The token is shown as 'Not available' in the "edit preferences" drawer, even though the token is supported on the selected networks.

    image

    Expected result:

    The token should be shown as supported in the "edit preferences" drawer if it is supported on those networks

    Devices:

    • Pixel 7a, Android 13
    • iPhone 11 Pro Max, IOS 17

    @smohamedjavid
    Copy link
    Member Author

    @VolodLytvynenko - Issue 3 should be fixed now. Please retest. 🙏

    @VolodLytvynenko
    Copy link
    Contributor

    VolodLytvynenko commented Oct 23, 2024

    Unfortunately can't understand the root cause of this issue. I will send you the user and the assets where this happens

    PR_ISSUE 4: 'Not available' still shown in TO section

    Actual result:

    image

    Devices:

    • Pixel 7a, Android 13
    • iPhone 11 Pro Max, IOS 17

    @smohamedjavid
    Copy link
    Member Author

    @VolodLytvynenko - Issue 4 should be fixed now. Please retest 🙏

    @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: 703133,702843 
    

    Failed tests (2)

    Click to expand
  • Rerun failed tests

  • Class TestCommunityOneDeviceMerged:

    1. test_restore_multiaccount_with_waku_backup_remove_switch, id: 703133

    # STEP: Check that removed user is not shown in the list anymore
    Device 1: Wait for element `Button` for max 30s and click when it is available

    critical/chats/test_public_chat_browsing.py:240: in test_restore_multiaccount_with_waku_backup_remove_switch
        self.sign_in.show_profiles_button.wait_and_click()
    ../views/base_element.py:100: in wait_and_click
        self.wait_for_visibility_of_element(sec)
    ../views/base_element.py:147: in wait_for_visibility_of_element
        raise TimeoutException(
     Device 1: Button by accessibility id:`show-profiles` is not found on the screen after wait_for_visibility_of_element
    



    Device sessions

    Class TestCommunityMultipleDeviceMerged:

    1. test_community_message_edit, id: 702843

    Device 2: Find Text by xpath: //android.view.ViewGroup[@content-desc='chat-item']//android.widget.TextView[contains(@text,'https://status.app/c/')]
    Device 2: Wait for element Button for max 120s and click when it is available

    Test setup failed: critical/chats/test_public_chat_browsing.py:350: in prepare_devices
        self.community_2.join_community()
    ../views/chat_view.py:420: in join_community
        self.join_button.wait_and_click(120)
    ../views/base_element.py:100: in wait_and_click
        self.wait_for_visibility_of_element(sec)
    ../views/base_element.py:147: in wait_for_visibility_of_element
        raise TimeoutException(
     Device 2: Button by accessibility id:`show-request-to-join-screen-button` is not found on the screen after wait_for_visibility_of_element
    



    Device sessions

    Passed tests (6)

    Click to expand

    Class TestWalletOneDevice:

    1. test_wallet_add_remove_regular_account, id: 727231
    2. test_wallet_balance_mainnet, id: 740490

    Class TestCommunityOneDeviceMerged:

    1. test_community_copy_and_paste_message_in_chat_input, id: 702742
    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

    @status-im-auto
    Copy link
    Member

    0% of end-end tests have passed

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

    Failed tests (2)

    Click to expand
  • Rerun failed tests

  • Class TestCommunityMultipleDeviceMerged:

    1. test_community_message_edit, id: 702843

    Device 2: Find `Text` by `xpath`: `//android.view.ViewGroup[@content-desc='chat-item']//android.widget.TextView[contains(@text,'https://status.app/c/')]`
    Device 2: Wait for element `Button` for max 120s and click when it is available

    Test setup failed: critical/chats/test_public_chat_browsing.py:350: in prepare_devices
        self.community_2.join_community()
    ../views/chat_view.py:420: in join_community
        self.join_button.wait_and_click(120)
    ../views/base_element.py:100: in wait_and_click
        self.wait_for_visibility_of_element(sec)
    ../views/base_element.py:147: in wait_for_visibility_of_element
        raise TimeoutException(
     Device 2: Button by accessibility id:`show-request-to-join-screen-button` is not found on the screen after wait_for_visibility_of_element
    



    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_restore_multiaccount_with_waku_backup_remove_switch, id: 703133

    # STEP: Check that removed user is not shown in the list anymore
    Device 1: Wait for element Button for max 30s and click when it is available

    critical/chats/test_public_chat_browsing.py:240: in test_restore_multiaccount_with_waku_backup_remove_switch
        self.sign_in.show_profiles_button.wait_and_click()
    ../views/base_element.py:100: in wait_and_click
        self.wait_for_visibility_of_element(sec)
    ../views/base_element.py:147: in wait_for_visibility_of_element
        raise TimeoutException(
     Device 1: Button by accessibility id:`show-profiles` is not found on the screen after wait_for_visibility_of_element
    



    Device sessions

    @VolodLytvynenko
    Copy link
    Contributor

    hi @smohamedjavid thank you for PR. No issues from my side. PR can be merged

    @smohamedjavid smohamedjavid merged commit c62d7d5 into develop Oct 24, 2024
    5 checks passed
    @smohamedjavid smohamedjavid deleted the fix/token-networks branch October 24, 2024 10:30
    ilmotta pushed a commit that referenced this pull request Oct 28, 2024
    This commit 
    - fixes the networks/chains supported by the token based on the token list fetched from status-go instead of relying on the balance-per-chain map as status-go returns balance for chains only if there is a positive balance
    - adds supported-networks key to token data map for network details
    
    Signed-off-by: Mohamed Javid <[email protected]>
    ilmotta pushed a commit that referenced this pull request Oct 28, 2024
    This commit 
    - fixes the networks/chains supported by the token based on the token list fetched from status-go instead of relying on the balance-per-chain map as status-go returns balance for chains only if there is a positive balance
    - adds supported-networks key to token data map for network details
    
    Signed-off-by: Mohamed Javid <[email protected]>
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    Status: DONE
    Development

    Successfully merging this pull request may close these issues.

    Bridging of assets is blocked unless user has a positive balance of this asset ("Network is not available")
    9 participants