Fix "Failed to get dApps" error when a session expired (#21531)

* fix: pass the topic instead of entire session

* chore: added logs for future debugging
This commit is contained in:
Lungu Cristian 2024-10-30 15:51:26 +02:00 committed by GitHub
parent 6d7697870d
commit 9862abb7eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

View File

@ -142,6 +142,7 @@
(rf/reg-event-fx :wallet-connect/approve-session-success (rf/reg-event-fx :wallet-connect/approve-session-success
(fn [{:keys [db]} [session]] (fn [{:keys [db]} [session]]
(log/info "Successfully approved WalletConnect session" session)
(let [total-connected-dapps (data-store/get-total-connected-dapps db)] (let [total-connected-dapps (data-store/get-total-connected-dapps db)]
{:fx [[:dispatch [:wallet-connect/on-new-session session]] {:fx [[:dispatch [:wallet-connect/on-new-session session]]
[:dispatch [:wallet-connect/reset-current-session-proposal]] [:dispatch [:wallet-connect/reset-current-session-proposal]]

View File

@ -54,6 +54,7 @@
(assoc session (assoc session
:accounts :accounts
(-> sessionJson (-> sessionJson
transforms/json->clj
:namespaces :namespaces
:eip155 :eip155
:accounts))) :accounts)))
@ -93,10 +94,10 @@
(defn sync-persisted-sessions (defn sync-persisted-sessions
[active-sessions persisted-sessions] [active-sessions persisted-sessions]
(-> (promesa/all (-> (promesa/all
(for [topic (find-inactive-sessions active-sessions (for [session (find-inactive-sessions active-sessions
persisted-sessions)] persisted-sessions)]
(do (log/info "Syncing disconnected session with persistance" topic) (do (log/info "Syncing disconnected session with persistance" session)
(rpc/wallet-disconnect-persisted-session topic)))) (rpc/wallet-disconnect-persisted-session (:topic session)))))
(promesa/catch (fn [err] (promesa/catch (fn [err]
(throw (ex-info "Failed to synchronize persisted sessions" (throw (ex-info "Failed to synchronize persisted sessions"
{:error err {:error err
@ -107,7 +108,11 @@
(promesa/let [persisted-sessions (get-persisted-sessions)] (promesa/let [persisted-sessions (get-persisted-sessions)]
(if online? (if online?
(promesa/let [active-sessions (get-active-sessions web3-wallet addresses)] (promesa/let [active-sessions (get-active-sessions web3-wallet addresses)]
(sync-persisted-sessions active-sessions persisted-sessions) (log/info "Got active Wallet Connect sessions" (map :topic active-sessions))
;; NOTE: handling the error here, so that if persistance fails, it doesn't affect the active
;; sessions
(-> (sync-persisted-sessions active-sessions persisted-sessions)
(promesa/catch #(log/error %)))
active-sessions) active-sessions)
persisted-sessions))) persisted-sessions)))