Only show the Wallet Connect requests for the logged in user (#20815)
Co-authored-by: Lungu Cristian <lungucristian95@gmail.com>
This commit is contained in:
parent
4b7c906df2
commit
d623cc8444
|
@ -127,3 +127,19 @@
|
|||
:url (get-in session [:peer :metadata :url])
|
||||
:accounts (get-in session [:namespaces :eip155 :accounts])
|
||||
:disconnected false})
|
||||
|
||||
(defn filter-operable-accounts
|
||||
[accounts]
|
||||
(filter #(and (:operable? %)
|
||||
(not (:watch-only? %)))
|
||||
accounts))
|
||||
|
||||
(defn filter-sessions-for-account-addresses
|
||||
[account-addresses sessions]
|
||||
(filter (fn [{:keys [accounts]}]
|
||||
(some (fn [account]
|
||||
(some (fn [account-address]
|
||||
(clojure.string/includes? account account-address))
|
||||
account-addresses))
|
||||
accounts))
|
||||
sessions))
|
||||
|
|
|
@ -55,9 +55,7 @@
|
|||
(log/info "Received Wallet Connect session proposal: " {:id (:id proposal)})
|
||||
(let [accounts (get-in db [:wallet :accounts])
|
||||
current-viewing-address (get-in db [:wallet :current-viewing-account-address])
|
||||
available-accounts (filter #(and (:operable? %)
|
||||
(not (:watch-only? %)))
|
||||
(vals accounts))
|
||||
available-accounts (wallet-connect-core/filter-operable-accounts (vals accounts))
|
||||
networks (wallet-connect-core/get-networks-by-mode db)
|
||||
session-networks (wallet-connect-core/proposal-networks-intersection proposal
|
||||
networks)
|
||||
|
@ -204,9 +202,15 @@
|
|||
:wallet-connect/fetch-active-sessions-success
|
||||
(fn [{:keys [db now]} [sessions]]
|
||||
(let [persisted-sessions (:wallet-connect/sessions db)
|
||||
account-addresses (->> (get-in db [:wallet :accounts])
|
||||
vals
|
||||
wallet-connect-core/filter-operable-accounts
|
||||
(map :address))
|
||||
sessions (->> (js->clj sessions :keywordize-keys true)
|
||||
vals
|
||||
(map wallet-connect-core/sdk-session->db-session))
|
||||
(map wallet-connect-core/sdk-session->db-session)
|
||||
(wallet-connect-core/filter-sessions-for-account-addresses
|
||||
account-addresses))
|
||||
expired-sessions (remove
|
||||
(fn [{:keys [expiry]}]
|
||||
(> expiry (/ now 1000)))
|
||||
|
|
Loading…
Reference in New Issue