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

🥅 Filter connected dapps based on testnet mode, reject proposals and requests gracefully #20799

Merged
merged 21 commits into from
Jul 26, 2024

Conversation

shivekkhurana
Copy link
Contributor

@shivekkhurana shivekkhurana commented Jul 18, 2024

Implements #20794 (Not to be marked as fixed until tested)

Should fix #20693 (comment)

Fix Connected Dapps screen to respect Testnet mode selection in app

Approach: There are allowed chains in the session. If the app is on mainnet, we show only the sessions where allowed chains are mainnet.

Otherwise, we show all testnet sessions (ie Goerli and Sepolia both will show up). This is in accordance with how our app works.

--

Implements: #20362 (Not to be marked as fixed until tested)

Reject session proposal (on WC) gracefully via UI

  • Currently the proposal was rejected only on clicking decline button
  • This PR rejects it on clicking the cross button on the bottom sheet too

Reject session proposal (on WC) if networks are not supported (ie user is on testnet or dapp connected on a different chain all together)

  • So far, we only showed a toast if the networks were not supported
  • Now we properly reject the proposal too

Reject session requests automatically (on WC) if app switched modes or accounts

  • Right now, we only prevented the request modal from showing up
  • This PR sends the response to WC saying USER_REJECTED_CHAINS

@shivekkhurana shivekkhurana self-assigned this Jul 18, 2024
@status-im-auto
Copy link
Member

status-im-auto commented Jul 18, 2024

Jenkins Builds

Click to see older builds (77)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 27ee3fd #1 2024-07-18 13:24:48 ~5 min tests 📄log
✔️ 27ee3fd #1 2024-07-18 13:26:12 ~6 min android 🤖apk 📲
✔️ 27ee3fd #1 2024-07-18 13:27:33 ~8 min android-e2e 🤖apk 📲
✔️ 27ee3fd #1 2024-07-18 13:28:55 ~9 min ios 📱ipa 📲
✔️ 458e8a3 #2 2024-07-18 13:38:30 ~5 min tests 📄log
✔️ 458e8a3 #2 2024-07-18 13:39:46 ~6 min android-e2e 🤖apk 📲
✔️ 458e8a3 #2 2024-07-18 13:41:11 ~7 min android 🤖apk 📲
✔️ 458e8a3 #2 2024-07-18 13:42:44 ~9 min ios 📱ipa 📲
e7689c7 #3 2024-07-18 15:13:38 ~3 min tests 📄log
✔️ e7689c7 #3 2024-07-18 15:17:32 ~7 min android-e2e 🤖apk 📲
✔️ e7689c7 #3 2024-07-18 15:17:49 ~7 min android 🤖apk 📲
✔️ e7689c7 #3 2024-07-18 15:19:18 ~9 min ios 📱ipa 📲
40b0e61 #4 2024-07-18 16:02:09 ~4 min tests 📄log
5de50f6 #6 2024-07-18 16:06:12 ~2 min tests 📄log
b6c63a3 #8 2024-07-18 16:14:50 ~3 min tests 📄log
✔️ 348da17 #9 2024-07-18 16:19:35 ~4 min tests 📄log
✔️ 348da17 #9 2024-07-18 16:21:08 ~6 min android-e2e 🤖apk 📲
✔️ 348da17 #9 2024-07-18 16:21:53 ~7 min android 🤖apk 📲
✔️ 348da17 #9 2024-07-18 16:23:47 ~8 min ios 📱ipa 📲
✔️ 0fc628f #10 2024-07-18 17:00:13 ~7 min android-e2e 🤖apk 📲
✔️ 0fc628f #10 2024-07-18 17:00:23 ~7 min android 🤖apk 📲
✔️ 0fc628f #10 2024-07-18 17:00:56 ~8 min tests 📄log
✔️ 0fc628f #10 2024-07-18 17:02:22 ~9 min ios 📱ipa 📲
✔️ ca96fd5 #12 2024-07-19 09:43:01 ~4 min tests 📄log
✔️ ca96fd5 #12 2024-07-19 09:45:46 ~7 min android-e2e 🤖apk 📲
✔️ ca96fd5 #12 2024-07-19 09:47:14 ~8 min android 🤖apk 📲
✔️ ca96fd5 #12 2024-07-19 09:48:49 ~10 min ios 📱ipa 📲
✔️ 4b4aebb #13 2024-07-22 11:10:55 ~4 min tests 📄log
✔️ 4b4aebb #14 2024-07-22 11:13:15 ~6 min android 🤖apk 📲
✔️ 4b4aebb #14 2024-07-22 11:14:09 ~7 min android-e2e 🤖apk 📲
✔️ 4b4aebb #14 2024-07-22 11:15:33 ~9 min ios 📱ipa 📲
8404cb2 #14 2024-07-22 15:55:07 ~3 min tests 📄log
✔️ 8404cb2 #15 2024-07-22 15:57:57 ~6 min android 🤖apk 📲
✔️ 8404cb2 #15 2024-07-22 15:58:17 ~6 min android-e2e 🤖apk 📲
✔️ 8404cb2 #15 2024-07-22 16:00:30 ~9 min ios 📱ipa 📲
3224eb4 #17 2024-07-22 16:08:20 ~2 min tests 📄log
✔️ 3224eb4 #18 2024-07-22 16:12:15 ~6 min android-e2e 🤖apk 📲
✔️ 3224eb4 #18 2024-07-22 16:12:35 ~6 min android 🤖apk 📲
✔️ 3224eb4 #18 2024-07-22 16:15:19 ~9 min ios 📱ipa 📲
33dec83 #18 2024-07-22 16:28:06 ~2 min tests 📄log
d8723a9 #19 2024-07-22 16:31:49 ~3 min tests 📄log
✔️ d8723a9 #20 2024-07-22 16:35:06 ~6 min android-e2e 🤖apk 📲
✔️ d8723a9 #20 2024-07-22 16:36:31 ~7 min android 🤖apk 📲
✔️ d8723a9 #20 2024-07-22 16:37:37 ~8 min ios 📱ipa 📲
✔️ 4398730 #20 2024-07-23 16:25:10 ~4 min tests 📄log
✔️ 4398730 #21 2024-07-23 16:29:11 ~8 min android-e2e 🤖apk 📲
✔️ 4398730 #21 2024-07-23 16:29:18 ~8 min android 🤖apk 📲
✔️ 4398730 #21 2024-07-23 16:31:48 ~10 min ios 📱ipa 📲
✔️ b3beff7 #21 2024-07-24 09:45:48 ~5 min tests 📄log
✔️ b3beff7 #22 2024-07-24 09:46:55 ~6 min android-e2e 🤖apk 📲
✔️ b3beff7 #22 2024-07-24 09:49:05 ~8 min android 🤖apk 📲
✔️ b3beff7 #22 2024-07-24 09:49:31 ~9 min ios 📱ipa 📲
bfb61c6 #23 2024-07-24 11:39:20 ~3 min tests 📄log
✔️ bfb61c6 #24 2024-07-24 11:43:56 ~7 min android-e2e 🤖apk 📲
✔️ bfb61c6 #24 2024-07-24 11:44:05 ~7 min android 🤖apk 📲
✔️ bfb61c6 #24 2024-07-24 11:45:16 ~9 min ios 📱ipa 📲
aec2259 #24 2024-07-24 11:58:26 ~2 min tests 📄log
✔️ aec2259 #25 2024-07-24 12:03:14 ~7 min android-e2e 🤖apk 📲
✔️ aec2259 #25 2024-07-24 12:03:22 ~7 min android 🤖apk 📲
✔️ aec2259 #25 2024-07-24 12:06:06 ~10 min ios 📱ipa 📲
✔️ 9c2ee16 #25 2024-07-24 12:41:23 ~6 min tests 📄log
✔️ 9c2ee16 #26 2024-07-24 12:42:32 ~7 min android-e2e 🤖apk 📲
✔️ 9c2ee16 #26 2024-07-24 12:44:15 ~9 min ios 📱ipa 📲
✔️ 9c2ee16 #26 2024-07-24 12:45:27 ~10 min android 🤖apk 📲
✔️ 1adb957 #27 2024-07-24 14:27:04 ~4 min tests 📄log
✔️ 1adb957 #28 2024-07-24 14:29:20 ~6 min android 🤖apk 📲
✔️ 1adb957 #28 2024-07-24 14:29:24 ~6 min android-e2e 🤖apk 📲
✔️ 1adb957 #28 2024-07-24 14:31:58 ~8 min ios 📱ipa 📲
34a26b3 #28 2024-07-25 10:22:32 ~2 min tests 📄log
✔️ 34a26b3 #29 2024-07-25 10:28:10 ~8 min android-e2e 🤖apk 📲
✔️ 34a26b3 #29 2024-07-25 10:28:18 ~8 min android 🤖apk 📲
✔️ 34a26b3 #29 2024-07-25 10:29:07 ~9 min ios 📱ipa 📲
e5a878b #29 2024-07-25 16:29:20 ~3 min tests 📄log
24509ea #31 2024-07-25 16:35:08 ~2 min tests 📄log
✔️ 24509ea #32 2024-07-25 16:38:24 ~6 min android-e2e 🤖apk 📲
✔️ 24509ea #32 2024-07-25 16:39:40 ~7 min android 🤖apk 📲
✔️ 24509ea #32 2024-07-25 16:40:51 ~8 min ios 📱ipa 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 02b910d #32 2024-07-25 18:24:41 ~4 min tests 📄log
✔️ 02b910d #33 2024-07-25 18:26:07 ~6 min android-e2e 🤖apk 📲
✔️ 02b910d #33 2024-07-25 18:27:34 ~7 min android 🤖apk 📲
✔️ 02b910d #33 2024-07-25 18:28:43 ~8 min ios 📱ipa 📲
✔️ 93ea4eb #33 2024-07-26 12:46:59 ~4 min tests 📄log
✔️ 93ea4eb #34 2024-07-26 12:50:25 ~7 min android-e2e 🤖apk 📲
✔️ 93ea4eb #34 2024-07-26 12:50:41 ~7 min android 🤖apk 📲
✔️ 93ea4eb #34 2024-07-26 12:54:24 ~11 min ios 📱ipa 📲

@shivekkhurana shivekkhurana force-pushed the shivekkhurana/wc-dapps-list-testnet-filter branch 5 times, most recently from b6c63a3 to 348da17 Compare July 18, 2024 16:14
@shivekkhurana shivekkhurana changed the title 🥅 Filter connected dapps based on testnet mode 🥅 Filter connected dapps based on testnet mode, reject proposals and requests gracefully Jul 18, 2024
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.

Looks good! Thanks!

src/status_im/subs/wallet/wallet_connect.cljs Outdated Show resolved Hide resolved
@shivekkhurana shivekkhurana force-pushed the shivekkhurana/wc-dapps-list-testnet-filter branch from 0eceaf0 to ca96fd5 Compare July 19, 2024 09:38
@status-im-auto
Copy link
Member

57% of end-end tests have passed

Total executed tests: 7
Failed tests: 2
Expected to fail tests: 1
Passed tests: 4
IDs of failed tests: 727230,702745 
IDs of expected to fail tests: 727232 

Failed tests (2)

Click to expand
  • Rerun failed tests

  • Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745

    Device 1: Find `Button` by `xpath`: `//*[@text='Allow all']`
    Device 1: Tap on found: Button

    critical/chats/test_1_1_public_chats.py:278: in test_1_1_chat_non_latin_messages_stack_update_profile_photo
        self.profile_1.edit_profile_picture(image_index=2)
    ../views/profile_view.py:453: in edit_profile_picture
        self.select_photo_from_gallery_by_index(image_index)
    ../views/profile_view.py:480: in select_photo_from_gallery_by_index
        image_element.find_elements()[image_index].click()
    ../views/base_element.py:87: in find_elements
        return self.driver.find_elements(self.by, self.locator)
    ../../../../status-app-prs@tmp/venv/lib/python3.10/site-packages/appium/webdriver/webdriver.py:445: in find_elements
        return self.execute(RemoteCommand.FIND_ELEMENTS, {'using': by, 'value': value})['value'] or []
    ../../../../status-app-prs@tmp/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py:345: in execute
        self.error_handler.check_response(response)
    ../../../../status-app-prs@tmp/venv/lib/python3.10/site-packages/appium/webdriver/errorhandler.py:122: in check_response
        raise exception_class(msg=message, stacktrace=format_stacktrace(stacktrace))
     An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up
    E   Stacktrace:
    E   UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up
    E       at UIA2Proxy.command (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/jsonwp-proxy/proxy.js:355:13)
    E       at processTicksAndRejections (node:internal/process/task_queues:95:5)
    E       at AndroidUiautomator2Driver.helpers.doFindElementOrEls (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/lib/commands/find.js:30:10)
    E       at doFind (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:36:17)
    E       at wrappedCondFn (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/timeout.ts:137:14)
    E       at spin (/mnt/sauce/appium/appium-v2.0.0/node_modules/asyncbox/lib/asyncbox.js:221:20)
    E       at waitForCondition (/mnt/sauce/appium/appium-v2.0.0/node_modules/asyncbox/lib/asyncbox.js:238:10)
    E       at AndroidUiautomator2Driver.implicitWaitForCondition (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/timeout.ts:139:12)
    E       at AndroidUiautomator2Driver.findElOrEls (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:60:5)
    E       at AndroidUiautomator2Driver.findElOrElsWithProcessing (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/find.ts:60:12)
    E       at AndroidUiautomator2Driver.findElements (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/find.ts:79:12)
    



    Device sessions

    Class TestWalletMultipleDevice:

    1. test_wallet_send_asset_from_drawer, id: 727230

    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.00659 ETH

    critical/test_wallet.py:184: in test_wallet_send_asset_from_drawer
        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))]))
     Sender balance is not updated on Etherscan, it is 0.4933 but expected to be 0.4934
    



    Expected to fail tests (1)

    Click to expand

    Class TestWalletOneDevice:

    1. test_wallet_add_remove_watch_only_account, id: 727232

    Device 1: Find EditBox by accessibility id: add-address-to-watch
    Device 1: Type 0x8d2413447ff297d30bdc475f6d5cb00254685aae to EditBox

    critical/test_wallet.py:249: in test_wallet_add_remove_watch_only_account
        self.wallet_view.add_watch_only_account(address=address_to_watch, account_name=new_account_name)
    ../views/wallet_view.py:163: in add_watch_only_account
        self.account_has_activity_label.wait_for_visibility_of_element()
    ../views/base_element.py:147: in wait_for_visibility_of_element
        raise TimeoutException(
     Device 1: Text by accessibility id:`account-has-activity` is not found on the screen after wait_for_visibility_of_element 
    

    [[Missing networks in account address, https://github.com//issues/20166]]

    Device sessions

    Passed tests (4)

    Click to expand

    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

    Class TestWalletMultipleDevice:

    1. test_wallet_send_eth, id: 727229

    Class TestWalletOneDevice:

    1. test_wallet_add_remove_regular_account, id: 727231
    Device sessions

    @shivekkhurana shivekkhurana force-pushed the shivekkhurana/wc-dapps-list-testnet-filter branch 2 times, most recently from 8404cb2 to db47eaf Compare July 22, 2024 16:02
    @clauxx
    Copy link
    Member

    clauxx commented Jul 24, 2024

    @pavloburykh @qoqobolo the PR is ready for testing

    @pavloburykh pavloburykh self-assigned this Jul 24, 2024
    @shivekkhurana shivekkhurana force-pushed the shivekkhurana/wc-dapps-list-testnet-filter branch from b3beff7 to 99dabb8 Compare July 24, 2024 11:34
    @pavloburykh
    Copy link
    Contributor

    @shivekkhurana please take a look at the issues

    ISSUE 1 Undefined is not a function when connecting to dApp using wrong network

    Steps:

    1. Enable testmode
    2. Try to connect to any dApp which is on Mainnet
    3. Observe the error

    Actual result: Undefined is not a function error appears.

    telegram-cloud-document-2-5262829113772627537.mp4

    Status-debug-logs - 2024-07-24T142155.750.zip

    @shivekkhurana shivekkhurana force-pushed the shivekkhurana/wc-dapps-list-testnet-filter branch from 34a26b3 to e5a878b Compare July 25, 2024 16:25
    @shivekkhurana
    Copy link
    Contributor Author

    @qoqobolo Issues 4 and 5 should be fixed with this PR

    Sorry if I'm missing something but then why are these two issues listed in the PR description? Is this PR only supposed to fix #20362?

    @shivekkhurana the PR description seems kinda weird. I don't follow either why there's 3 issues linked, one of which was already closed, and the formatting with the large headers confuses me tbh 😆

    This PR has evolved over time. It mainly fixes connected dapps list, and other things just creeped in.

    @shivekkhurana shivekkhurana merged commit a45991b into develop Jul 26, 2024
    5 checks passed
    @shivekkhurana shivekkhurana deleted the shivekkhurana/wc-dapps-list-testnet-filter branch July 26, 2024 12:54
    J-Son89 pushed a commit that referenced this pull request Jul 26, 2024
    …requests gracefully (#20799)
    
    * 🥅 Filter connected dapps based on testnet mode
    
    - Fixes #20794
    
    * 🥅 Remove map, just filter
    
    * 💿 Rebase
    
    * ❌ Remove greedy fetch
    
    * 🙅‍♀️ Properly reject proposals and requests
    
    * 🎗️ Remove newline and move `set`
    
    - `set` was applied at the wrong place here
    
    * ✏️ Address review comments
    
    * 👀 Read proposal to reject from state
    
    * ◀️ Bring back network filtering
    
    * 🧹 Cleanup
    
    * ✏️ Move comment around
    
    * 🎣 Use filter operable accounts helper
    
    * ➕ Add back events deleted during rebase
    
    * 🧰 Fix Issue 2, Testnet sessions not visible
    
    * 🖊️ Fix lint
    
    * 🔗 Make testnet filtering more explicit
    
    * 🥢 Use union instead of two subsets call
    
    * ✏️ Fix lint
    
    * 🔇 Undo changes that creeped in an unrelated ns
    ilmotta pushed a commit that referenced this pull request Jul 28, 2024
    …requests gracefully (#20799)
    
    * 🥅 Filter connected dapps based on testnet mode
    
    - Fixes #20794
    
    * 🥅 Remove map, just filter
    
    * 💿 Rebase
    
    * ❌ Remove greedy fetch
    
    * 🙅‍♀️ Properly reject proposals and requests
    
    * 🎗️ Remove newline and move `set`
    
    - `set` was applied at the wrong place here
    
    * ✏️ Address review comments
    
    * 👀 Read proposal to reject from state
    
    * ◀️ Bring back network filtering
    
    * 🧹 Cleanup
    
    * ✏️ Move comment around
    
    * 🎣 Use filter operable accounts helper
    
    * ➕ Add back events deleted during rebase
    
    * 🧰 Fix Issue 2, Testnet sessions not visible
    
    * 🖊️ Fix lint
    
    * 🔗 Make testnet filtering more explicit
    
    * 🥢 Use union instead of two subsets call
    
    * ✏️ Fix lint
    
    * 🔇 Undo changes that creeped in an unrelated ns
    ilmotta added a commit that referenced this pull request Jul 30, 2024
    Revisions from develop:
    
    - 59ceddb develop origin/develop fix(wallet): fix bridge transactions (#20902)
    - 99ccbc3 Cover wallet send events with tests Part 2 #20411 #20533 (#20721)
    - 8c2d539 Enabling WalletConnect feature flag (#20906)
    - 67c83b1 fix(wallet): remove edit routes button in bridging (#20874)
    - 11a84ba feat(wallet): disable complex routing (#20901)
    - 1f5bb57 chore(wallet): disable bridging on unsupported tokens (#20846)
    - 4586f80 Add toggle in advanced settings for mobile data
    - 55c620e fix: create password for small screen (#20645)
    - 525609f Wallet Activity: transactions are not sorted by time #20808 (#20862)
    - 9065395 chore(settings): Disable telemetry option (#20881)
    - d27ab75 fix_:display group message using the new ui (#20787)
    - c6a1db6 ci: enable split apks & build only for arm64-v8a (#20683)
    - 73777e0 Ensure keycard account can send transaction after upgrading from v1 to v2 #20552 (#20845)
    - a6d3fc3 [#20524] fix: the missed keypairs are shown in the key pair list screen (#20888)
    - a671c70 fix broken screen and navigation when syncing fails (#20887)
    - a45991b 🥅 Filter connected dapps based on testnet mode, reject proposals and requests gracefully (#20799)
    - 2e9fa22 feat: wallet router v2 (#20631)
    - 737d8c4 rename sub to fix error when requesting to join community (#20868)
    - 3aa7e10 Sync process is blocked on Enabled notifications screen (#20883)
    - c1d2d44 perf: Fix app freeze after login (#20729)
    - 0fed811 e2e: updated testnet switching and added one test into smoke
    - 53c35cb fix(wallet): Linear gradient exception on invalid colors for watched account cards (#20854)
    - be82365 chore(settings)_: Remove testnet toggle from legacy advanced settings (#20875)
    - eae8a65 feat(wallet)_: Add beta info box in activity tab (#20873)
    - fe54a25 fix: not clearing network & web3-wallet on logout (#20886)
    - 15a4219 Reject wallet-connect request by dragging the modal down (#20763) (#20836)
    - 2ffbdac WalletConnect show expired toast (#20857)
    - 402eb83 fix Issue with scrolling WalletConnect transaction on Android (#20867)
    - ff88049 Fix WalletConnect header alignment on Android (#20860)
    - cee2124 WalletConnect no internet edge-cases (#20826)
    - 60ad7c8 chore(tests): New match-strict? cljs.test directive (#20825)
    - 4989c92 fix_: Adding own address as saved addresses (#20839)
    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.

    None yet

    6 participants