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

15647 dapps watched accounts and keycard accounts shouldnt be considered for wallet connect interactions #15877

Conversation

Seitseman
Copy link
Contributor

@Seitseman Seitseman commented Jul 29, 2024

fix(dApps): Improved handling of connected dApps.

closes: #15589
closes: #15647

What does the PR do

  1. Hiding DApps button on not supported wallet account selection
  2. Filtering DApps in connected dApps list based on account selection

Affected areas

dApps

StatusQ checklist

  • test changes in both light and dark theme?

Screenshot of functionality (including design for comparison)

Screen.Recording.2024-07-31.at.11.35.16.mov
  • I've checked the design and this PR matches it

Impact on end user

End users can see DApps button only when either all accounts are selected, or supported wallet address is selected (non watched, not keycard accounts).
In addition to that, the dApps list will show only dApps connected to the selected wallet address

How to test

Please create several wallet accounts, at least 1 watched address and 1 keycard address

Risk

Described potential risks and worst case scenarios.

  • Low risk: 2 devs MUST perform testing as specified above and attach their results as comments to this PR before merging.

Cool Spaceship Picture

🚀

@status-im-auto
Copy link
Member

status-im-auto commented Jul 29, 2024

Jenkins Builds

Click to see older builds (66)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 7c22bc7 #1 2024-07-29 22:22:13 ~6 min tests/nim 📄log
✔️ 7c22bc7 #1 2024-07-29 22:24:17 ~8 min macos/aarch64 🍎dmg
7c22bc7 #1 2024-07-29 22:27:48 ~12 min tests/ui 📄log
✔️ 7c22bc7 #1 2024-07-29 22:29:58 ~14 min macos/x86_64 🍎dmg
✔️ 7c22bc7 #1 2024-07-29 22:31:58 ~16 min linux-nix/x86_64 📦tgz
✔️ 7c22bc7 #1 2024-07-29 22:32:27 ~17 min linux/x86_64 📦tgz
✔️ 7c22bc7 #1 2024-07-29 22:40:45 ~25 min windows/x86_64 💿exe
✔️ 5acd634 #3 2024-07-30 18:16:03 ~6 min tests/nim 📄log
✔️ 5acd634 #3 2024-07-30 18:19:14 ~9 min macos/aarch64 🍎dmg
5acd634 #3 2024-07-30 18:22:03 ~12 min tests/ui 📄log
✔️ 5acd634 #3 2024-07-30 18:24:16 ~14 min linux-nix/x86_64 📦tgz
✔️ 5acd634 #3 2024-07-30 18:27:15 ~17 min macos/x86_64 🍎dmg
✔️ 5acd634 #3 2024-07-30 18:27:25 ~17 min linux/x86_64 📦tgz
✔️ a2c2693 #4 2024-07-30 18:38:55 ~6 min tests/nim 📄log
✔️ a2c2693 #4 2024-07-30 18:41:12 ~8 min macos/aarch64 🍎dmg
a2c2693 #4 2024-07-30 18:45:30 ~13 min tests/ui 📄log
✔️ a2c2693 #4 2024-07-30 18:45:31 ~13 min linux-nix/x86_64 📦tgz
✔️ a2c2693 #4 2024-07-30 18:46:58 ~14 min macos/x86_64 🍎dmg
✔️ a2c2693 #4 2024-07-30 18:47:30 ~15 min linux/x86_64 📦tgz
✔️ a2c2693 #4 2024-07-30 18:56:36 ~24 min windows/x86_64 💿exe
✔️ ea619c7 #5 2024-07-30 23:03:02 ~6 min tests/nim 📄log
✔️ ea619c7 #5 2024-07-30 23:03:49 ~7 min macos/aarch64 🍎dmg
✔️ ea619c7 #5 2024-07-30 23:04:44 ~8 min macos/x86_64 🍎dmg
✔️ ea619c7 #5 2024-07-30 23:09:26 ~12 min linux-nix/x86_64 📦tgz
ea619c7 #5 2024-07-30 23:09:41 ~13 min tests/ui 📄log
✔️ ea619c7 #5 2024-07-30 23:11:49 ~15 min linux/x86_64 📦tgz
✔️ ea619c7 #5 2024-07-30 23:21:20 ~24 min windows/x86_64 💿exe
ea619c7 #6 2024-07-31 09:11:02 ~12 min tests/ui 📄log
✔️ 6c040f2 #6 2024-07-31 18:01:34 ~6 min tests/nim 📄log
✔️ 6c040f2 #6 2024-07-31 18:02:20 ~7 min macos/aarch64 🍎dmg
6c040f2 #7 2024-07-31 18:07:36 ~12 min tests/ui 📄log
✔️ 6c040f2 #6 2024-07-31 18:07:59 ~12 min linux-nix/x86_64 📦tgz
✔️ 6c040f2 #6 2024-07-31 18:09:23 ~14 min macos/x86_64 🍎dmg
✔️ 6c040f2 #6 2024-07-31 18:10:30 ~15 min linux/x86_64 📦tgz
✔️ 6c040f2 #6 2024-07-31 18:21:54 ~26 min windows/x86_64 💿exe
✔️ 0add75c #7 2024-07-31 19:19:56 ~8 min macos/aarch64 🍎dmg
✔️ 0add75c #7 2024-07-31 19:19:56 ~8 min macos/x86_64 🍎dmg
✔️ 0add75c #7 2024-07-31 19:23:05 ~11 min tests/nim 📄log
✔️ e8b49c4 #8 2024-07-31 19:32:33 ~7 min macos/x86_64 🍎dmg
✔️ e8b49c4 #8 2024-07-31 19:34:05 ~9 min macos/aarch64 🍎dmg
✔️ e8b49c4 #8 2024-07-31 19:37:06 ~12 min tests/nim 📄log
✔️ e8b49c4 #8 2024-07-31 19:41:24 ~16 min linux-nix/x86_64 📦tgz
✔️ e8b49c4 #8 2024-07-31 19:43:24 ~18 min linux/x86_64 📦tgz
e8b49c4 #9 2024-07-31 19:46:12 ~21 min tests/ui 📄log
✔️ e8b49c4 #8 2024-07-31 20:06:15 ~41 min windows/x86_64 💿exe
✔️ e25f212 #9 2024-07-31 23:22:22 ~6 min tests/nim 📄log
✔️ e25f212 #9 2024-07-31 23:22:54 ~7 min macos/aarch64 🍎dmg
✔️ e25f212 #9 2024-07-31 23:27:41 ~11 min linux-nix/x86_64 📦tgz
e25f212 #10 2024-07-31 23:29:01 ~13 min tests/ui 📄log
✔️ e25f212 #9 2024-07-31 23:30:36 ~14 min macos/x86_64 🍎dmg
✔️ e25f212 #9 2024-07-31 23:30:39 ~14 min linux/x86_64 📦tgz
✔️ e25f212 #9 2024-07-31 23:41:44 ~25 min windows/x86_64 💿exe
✔️ 743c98e #10 2024-08-01 09:02:55 ~7 min tests/nim 📄log
✔️ 743c98e #10 2024-08-01 09:03:10 ~7 min macos/aarch64 🍎dmg
✔️ 743c98e #10 2024-08-01 09:06:21 ~10 min macos/x86_64 🍎dmg
743c98e #11 2024-08-01 09:08:40 ~12 min tests/ui 📄log
✔️ 743c98e #10 2024-08-01 09:08:50 ~13 min linux-nix/x86_64 📦tgz
✔️ 743c98e #10 2024-08-01 09:10:27 ~14 min linux/x86_64 📦tgz
✔️ 743c98e #10 2024-08-01 09:23:51 ~27 min windows/x86_64 💿exe
✔️ 50ecd64 #11 2024-08-02 09:47:04 ~6 min tests/nim 📄log
✔️ 50ecd64 #11 2024-08-02 09:48:32 ~8 min macos/x86_64 🍎dmg
✔️ 50ecd64 #11 2024-08-02 09:50:30 ~10 min macos/aarch64 🍎dmg
50ecd64 #12 2024-08-02 09:53:57 ~13 min tests/ui 📄log
✔️ 50ecd64 #11 2024-08-02 09:54:18 ~14 min linux-nix/x86_64 📦tgz
✔️ 50ecd64 #11 2024-08-02 09:55:26 ~15 min linux/x86_64 📦tgz
✔️ 50ecd64 #11 2024-08-02 10:12:42 ~32 min windows/x86_64 💿exe
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ dea9a9c #12 2024-08-02 13:04:52 ~6 min tests/nim 📄log
✔️ dea9a9c #12 2024-08-02 13:05:56 ~7 min macos/aarch64 🍎dmg
✔️ dea9a9c #12 2024-08-02 13:06:28 ~8 min macos/x86_64 🍎dmg
✔️ dea9a9c #12 2024-08-02 13:10:19 ~12 min linux-nix/x86_64 📦tgz
✔️ dea9a9c #13 2024-08-02 13:11:55 ~13 min tests/ui 📄log
✔️ dea9a9c #12 2024-08-02 13:12:53 ~14 min linux/x86_64 📦tgz
✔️ dea9a9c #12 2024-08-02 13:22:31 ~24 min windows/x86_64 💿exe
✔️ 5edbcff #13 2024-08-02 20:15:04 ~6 min tests/nim 📄log
✔️ 5edbcff #13 2024-08-02 20:16:12 ~7 min macos/aarch64 🍎dmg
✔️ 5edbcff #13 2024-08-02 20:16:47 ~8 min macos/x86_64 🍎dmg
✔️ 5edbcff #13 2024-08-02 20:20:41 ~12 min linux-nix/x86_64 📦tgz
✔️ 5edbcff #14 2024-08-02 20:21:53 ~13 min tests/ui 📄log
✔️ 5edbcff #13 2024-08-02 20:23:14 ~14 min linux/x86_64 📦tgz
✔️ 5edbcff #13 2024-08-02 20:33:40 ~24 min windows/x86_64 💿exe

@@ -264,7 +272,37 @@ QObject {

sdk: root.wcSDK
store: root.store
supportedAccountsModel: d.supportedAccountsModel
supportedAccountsModel: SortFilterProxyModel {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

check in 'disconnect' if proper dApp from proper wallet address is disconnected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Disconnect works correctly

@Seitseman Seitseman changed the base branch from master to release/2.30.x July 30, 2024 18:04
@Seitseman Seitseman force-pushed the 15647-dapps-watched-accounts-and-keycard-accounts-shouldnt-be-considered-for-wallet-connect-interactions branch 3 times, most recently from a2c2693 to ea619c7 Compare July 30, 2024 22:56
@Seitseman Seitseman marked this pull request as ready for review July 31, 2024 08:59
@saledjenic
Copy link
Contributor

Shouldn't we fix issues on master and then cherry-pick them for RC?

Copy link
Member

@micieslak micieslak left a comment

Choose a reason for hiding this comment

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

looks ok in general, some questions mainly


readonly property SortFilterProxyModel dappsModel: SortFilterProxyModel {
objectName: "DAppsModelFiltered"
sourceModel: d.dappsModel.count ? d.dappsModel : null
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
sourceModel: d.dappsModel.count ? d.dappsModel : null
sourceModel: d.dappsModel.count ? d.dappsModel : null

that check looks unusual, why is it needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was done because SFPM once its source model is bind, and roles initialized, will not "refresh" roles for the usecases of dynamicRole: true of ListModel.
Right now when app starts, walletconnect service will send data to d.dappsModel that has slightly different structure then the following data entries.

Copy link
Member

@micieslak micieslak Aug 1, 2024

Choose a reason for hiding this comment

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

That's something not clear for me. dynamicRole: true only allows various types for the same role.
So it's valid then:

append({name:"X"})
append({name:4})

but

append({name:"X"})
append({name:4, surname: "Y"})

will result with a model with only name role. surname won't be added.

And SFPM doesn't care about role types at all. So I wonder why it's needed here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like right now dApps are stored in local cache in slightly different format than what is actually needed to properly filter them by connected address. And when locally stored dApps are overwritten by up-to-date data from wallet connect, dappsModel is cleared first. dynamicRoles: true seems to be covering that case.
Anyways, based on our discussions with you and then with Stefan, I will adjust that data and remove both dynamicRoles and that binding in "DAppsModelFiltered" SFML.

Copy link
Member

@caybro caybro left a comment

Choose a reason for hiding this comment

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

LGTM in general, some minor stuff inline

ui/app/AppLayouts/Wallet/controls/DappsComboBox.qml Outdated Show resolved Hide resolved
@Seitseman
Copy link
Contributor Author

Shouldn't we fix issues on master and then cherry-pick them for RC?

@saledjenic , per https://www.notion.so/Desktop-app-Release-process-356bbe7c40d14db3b64ab364800a48c9 points 8 and 9, fix goes into the release branch and then into master

Copy link
Contributor

@stefandunca stefandunca left a comment

Choose a reason for hiding this comment

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

After testing and looking into the code it seems the behavior for multiple session per dapps is not working as expected. Please see my comments inline. Basically, multiple sessions for one dapp will not work. Also disconnecting a dapp with an account selected will disconnect the sessions for other accounts with the same dapp.

@Seitseman Seitseman force-pushed the 15647-dapps-watched-accounts-and-keycard-accounts-shouldnt-be-considered-for-wallet-connect-interactions branch from ea619c7 to 6c040f2 Compare July 31, 2024 17:54
@Seitseman
Copy link
Contributor Author

20240731_220317.mp4

@Seitseman Seitseman force-pushed the 15647-dapps-watched-accounts-and-keycard-accounts-shouldnt-be-considered-for-wallet-connect-interactions branch from 6c040f2 to 0add75c Compare July 31, 2024 19:11
@Seitseman Seitseman force-pushed the 15647-dapps-watched-accounts-and-keycard-accounts-shouldnt-be-considered-for-wallet-connect-interactions branch 2 times, most recently from e8b49c4 to e25f212 Compare July 31, 2024 23:15
@alexjba
Copy link
Contributor

alexjba commented Aug 1, 2024

The CI test failure looks legit!

Copy link
Contributor

@alexjba alexjba left a comment

Choose a reason for hiding this comment

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

Once concern! What about keycard status accounts? Should we disable the dApps entirely for these accounts? Currently I can't sign any transaction with the keycard status account even if the wallet account is not on keycard. When signing, the keycard auth screen is prompted and I can't use it for signing!

Maybe it's a general issue, will continue looking on it!

@@ -35,6 +35,8 @@ QObject {
readonly property alias dappsModel: dappsProvider.dappsModel
readonly property alias requestHandler: requestHandler

readonly property bool isServiceAvailableForAddressSelection: dappsProvider.supportedAccountsModel.count
Copy link
Contributor

Choose a reason for hiding this comment

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

We're assuming here the dappsProvider.supportedAccountsModel is and will always be a ListModel. This can be changed to dappsProvider.supportedAccountsModel.ModelCount.count

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be fixed

@alexjba
Copy link
Contributor

alexjba commented Aug 1, 2024

Once concern! What about keycard status accounts? Should we disable the dApps entirely for these accounts? Currently I can't sign any transaction with the keycard status account even if the wallet account is not on keycard. When signing, the keycard auth screen is prompted and I can't use it for signing!

Maybe it's a general issue, will continue looking on it!

It's not a general issue! Only dapps fail to sign non keycard wallet accounts with keycard status account!

sourceModel: d.supportedAccountsModel
filters: ValueFilter {
roleName: "address"
value: root.walletRootStore.selectedAddress === model.address
Copy link
Contributor

@alexjba alexjba Aug 1, 2024

Choose a reason for hiding this comment

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

WRN 2024-08-01 11:19:17.779+03:00 qt warning topics="qt" tid=4930042 text="ReferenceError: model is not defined" file=qrc:/app/AppLayouts/Wallet/services/dapps/WalletConnectService.qml:284 category=default

Copy link
Contributor

Choose a reason for hiding this comment

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

The value filter expect a value, like root.walletRootStore.selectedAddress. Although this is not 100% safe because we need the filter not to be case sensitive.
An alternative would be a FastExpressionFilter comparing the strings and ignoring the case

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, on a second look, I think it's safer to do a FastExpressionFilter unless we want to fiddle around with a RegExpFilter and setting the case sensitivity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be reverted back to FastExpressionFilter

Copy link
Member

Choose a reason for hiding this comment

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

If it's only about case sensitivity, RegExpFilter is better indeed (faster) and not complicated to use.

There is RegExpFilter.FixedString syntax mode available and caseSensitivity property as well. So there is even no need to deal with any regexes.

@stefandunca
Copy link
Contributor

I pushed a temporary change as documentation on how the mapping of dapps with sessions and accounts work. Then joined @Seitseman in a conversation around this proposal. We agreed with @Seitseman to get back to the original idea and deduplicate dapps given that now user has no way to know for the same dapp which account is connected to in all accounts selection.

const sessions = DAppsHelpers.filterActiveSessionsForKnownAccounts(allSessions, root.supportedAccountsModel)
for (const key in sessions) {
const dapp = sessions[key].peer.metadata
const dAppsMap = []
Copy link
Member

Choose a reason for hiding this comment

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

shoudn't it be an object?

Suggested change
const dAppsMap = []
const dAppsMap = {}

Comment on lines 97 to 98
for (const topic in dAppsMap) {
dapps.append(dAppsMap[topic]);
Copy link
Member

Choose a reason for hiding this comment

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

It's good practice to append array in one call whenever possible.
E.g. sth like that (not tested):

dapps.append(dAppsMap.map(t => dAppsMap[t]))

Copy link
Member

Choose a reason for hiding this comment

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

Btw, ideally at this stage we should more carefully inspect the incoming data before putting into the model. We can take only what's needed and sanitize (e.g. if some fields are optional and may be not present we should provide e.g. "" instead in order to have always the same set of roles). Then dynamicRoles and tricks with SFPM won't be needed at all.

Copy link
Contributor

@stefandunca stefandunca left a comment

Choose a reason for hiding this comment

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

Great job Roman.

To have the same behavior for persistence you have to propagate the NIM's getActiveSessions to the controller and use it through the DAppsStore and run the same logic as the SDK's getActiveSessions

@Seitseman Seitseman force-pushed the 15647-dapps-watched-accounts-and-keycard-accounts-shouldnt-be-considered-for-wallet-connect-interactions branch 2 times, most recently from 50ecd64 to dea9a9c Compare August 2, 2024 12:57
Copy link
Contributor

@alexjba alexjba left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you! 🍻
Two minor comments

1. Hiding DApps button on not supported wallet account selection
2. Filtering DApps in connected dApps list based on account selection

closes: #15589
closes: #15647
@Seitseman Seitseman force-pushed the 15647-dapps-watched-accounts-and-keycard-accounts-shouldnt-be-considered-for-wallet-connect-interactions branch from dea9a9c to 5edbcff Compare August 2, 2024 20:08
@Seitseman
Copy link
Contributor Author

@iurimatias , should this PR be merged into 2.30 release?

@Seitseman
Copy link
Contributor Author

cherry-pick into master: #15985

@jrainville jrainville merged commit 11d7ad8 into release/2.30.x Aug 5, 2024
9 checks passed
@jrainville jrainville deleted the 15647-dapps-watched-accounts-and-keycard-accounts-shouldnt-be-considered-for-wallet-connect-interactions branch August 5, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dApps - watched accounts and keycard accounts shouldn't be considered for wallet connect interactions
8 participants