-
Notifications
You must be signed in to change notification settings - Fork 988
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
Dapps Typed Data request improvements #21333
Conversation
Jenkins Builds
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work 🚀
(-> typed-data | ||
(select-keys [:domain :message]) | ||
flatten-data | ||
(format-fields ": "))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the format from: wallets: 1:
copied from other products or is this a standard we are creating ourselves for Status? I find hard to imagine users can figure out the indexes and the flattening going on, but maybe not, things are crazy in terms of usability when signing.
Do you know if there's any interest in improving the designs or if any concerns were raised?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're doing small iterations on this. There is no standard around typed data, but there are definitely improvements to be made. Aside from the representation of arrays, which I agree that is not ideal, is the inclusion of custom types instead (or in addition) to key names, as it is now. The custom types should give more context around what the piece of data represents and the context it lives in. For now though, we decided move away from json but keep it simple at the same time.
@@ -0,0 +1,94 @@ | |||
(ns status-im.contexts.wallet.wallet-connect.utils.typed-data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@clauxx, is the Desktop app integrating now or will integrate with WC? Sorry if this is an obvious question, but my point is that I feel this logic doesn't belong in clients and should be in status-go. A lot of wallet-related code is living in the wrong place in my opinion. In the not so distant past, our high-level architectural goal was to build light clients and I think the goal still stands.
Well, this is just a thought for your PR, not a suggestion for change. It would be great if the Mobile Wallet team more heavily considered this factor because we are inflating too much the client with logic. It's great that you unit tested, but this is not always the case in mobile PRs. My belief and experience with status-go is that the slowdown in iterations would only come in the beginning as people learn how to solve with this backend-first mentality.
cc'ing @shivekkhurana @smohamedjavid just to bump this point a bit more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's on the client for now, since this logic is directly related to the UI and how we show the typed data to the user. We are dealing with limited horizontal space on mobile, so we had to find solutions to remove nesting. On the desktop this might not be an issue, so the representation there might be different.
(defn display-data-view | ||
[] | ||
(let [typed-data? (->> (rf/sub [:wallet-connect/current-request-method]) | ||
(contains? typed-data-methods))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be a separate subscription. typed-data-methods
is static, so the result for typed-data?
will be nicely cached.
[{:keys [label value]}] | ||
[quo/data-item | ||
{:card? false | ||
:container-style (merge style/data-item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge
is known to be quite slow, so if we can avoid it the better. Here you can use assoc
, or better extract the container-style
map into a var because it's a static map.
[["2"] 2]]))) | ||
|
||
(testing "correctly flattens a simple vec" | ||
(is (= (sut/flatten-data ["zero" "one"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ilmotta the comments were addressed 👍 |
71% of end-end tests have passed
Failed tests (2)Click to expandClass TestWalletMultipleDevice:
Class TestOneToOneChatMultipleSharedDevicesNewUi:
Passed tests (5)Click to expandClass TestWalletMultipleDevice:
Class TestCommunityOneDeviceMerged:
Class TestWalletOneDevice:
Class TestCommunityMultipleDeviceMerged:
|
Hey @clauxx! I get an error during testing that blocks me. my steps:
Thanks |
Hi! It will not work on testnet, since the data includes the wrong chainId (mainnet), and we check that for safety. It should work on Mainnet though. Did you make sure while connecting that both the dapp and the wallet are on mainnet? Should probably add this in the description. |
0% of end-end tests have passed
Failed tests (2)Click to expandClass TestOneToOneChatMultipleSharedDevicesNewUi:
Class TestWalletMultipleDevice:
|
Thanks @clauxx . I've checked on Mainnet once again (probably didn't turn Testnet switcher on dApp) 🤔. Looks good on both platforms! Have a tiny question regarding Network element from design here: Is it planned to be added or I should report it? PR can be merged. |
@mariia-skrypnyk I think it's not needed, as we're checking if the network of the session is the same as the one contained in the data (but it's not guaranteed it is), and if they're not the same we show a toast and reject the request. |
fixes #21278
Summary
User story
Improved the UI of the wallet connect typed data request by flattening the data and displaying it to the user, as seen in the screenshot below.
Steps to test
eth_signTypedData_v4
requeststatus: ready