-
Notifications
You must be signed in to change notification settings - Fork 987
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
[#21853] fix: check deeplink pending request after wallet connect loaded #21873
base: develop
Are you sure you want to change the base?
Conversation
Jenkins Builds
|
(if web3-wallet | ||
{:db (dissoc db :wallet-connect/waiting-pair-url) | ||
:fx [[:effects.wallet-connect/pair | ||
{:web3-wallet web3-wallet | ||
:url url | ||
:on-fail #(log/error "Failed to pair with dApp" {:error %}) | ||
:on-success #(log/info "dApp paired successfully")}]]} | ||
{:db (assoc db :wallet-connect/waiting-pair-url url)})))) |
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 a bit difficult to understand why we're assoc/dissoc-ing the waiting-pair-url
here you know the context already.
I'd suggest to isolate the usage of waiting-pair-url
inside 2 events so its purpose is clearer (see an attempt below). The process-deeplink
event would be dispatched by the universal-links handler (status-im.common.universal-links
), while the pair-with-pending-deeplink
would be dispatched in :wallet-connect/on-init-success
. I assume the other changes (in :wallet-connect/send-response
and :wallet-connect/pair
), as well as the delay from the deeplink handler, wouldn't be necessary anymore, but let me know if that's not the case.
Also renamed it to :wallet-connect/pending-url
as "pending" seems more fitting than "waiting", but that's just a nitpick.
(rf/reg-event-fx
:wallet-connect/process-deeplink
(fn [{:keys [db]} [url]]
(let [web3-wallet (get db :wallet-connect/web3-wallet)]
(if web3-wallet
{:fx [[:dispatch [:wallet-connect/on-scan-connection url]]]}
{:db (assoc db :wallet-connect/pending-url url)}))))
(rf/reg-event-fx
:wallet-connect/pair-with-pending-deeplink
(fn [{:keys [db]}]
(when-let [pending-url (get db :wallet-connect/pending-url)]
{:db (dissoc db :wallet-connect/pending-url)
:fx [[:dispatch [:wallet-connect/on-scan-connection pending-url]]]})))
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.
Make sense will apply changes.
:on-success (fn [] | ||
(rf/dispatch [:wallet-connect/redirect-to-dapp]) | ||
(log/info "Successfully sent Wallet Connect response to dApp"))}]]})))) | ||
(when web3-wallet |
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.
why is this needed? When would we send a response without the web3-wallet already initialized?
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.
the only reason for this issue #21853 (comment) when i was checking it was this event triggered before web3-wallet have initiated
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.
might be that it's no longer needed, since we're not supposed to process requests without logging in i.e. without web3-wallet being initialized.
f5ae111
to
1c22eb2
Compare
fixes #21853
Summary
Areas that maybe impacted
Test Note
Regarding the issue discussed in PR #21833, here’s an explanation of how dApp requests are handled and the current limitations:
Handling dApp Requests
Event Listener
Deep Link
Push Notification (Not Yet Implemented)
for PR #21833 we can have a separate issue so i can discuss it with @clauxx and check for any solution.
Steps to test
Result
Simulator.Screen.Recording.-.iPhone.13.-.2024-12-27.at.17.11.05.mp4
status: ready