💾 Add persist WC session events

This commit is contained in:
Shivek Khurana 2024-06-21 15:33:48 +05:30
parent b5a09a334a
commit 8d928156ba
No known key found for this signature in database
GPG Key ID: 6BBA04C82FA07036
1 changed files with 20 additions and 18 deletions

View File

@ -146,24 +146,25 @@
:events constants/wallet-connect-supported-events :events constants/wallet-connect-supported-events
:accounts accounts}})] :accounts accounts}})]
{:fx [[:effects.wallet-connect/approve-session {:fx [[:effects.wallet-connect/approve-session
{:web3-wallet web3-wallet {:web3-wallet web3-wallet
:proposal current-proposal :proposal current-proposal
:supported-namespaces supported-namespaces :supported-namespaces supported-namespaces
:on-success (fn [] :on-success (fn []
(log/info "Wallet Connect session approved") (log/info "Wallet Connect session approved")
(let [metadata (-> current-proposal :params :proposer :metadata)] (let [metadata (-> current-proposal :params :proposer :metadata)]
(rf/dispatch [:wallet-connect/reset-current-session-proposal]) (rf/dispatch [:wallet-connect/reset-current-session-proposal])
(rf/dispatch [:wallet-connect/persist-session (rf/dispatch [:wallet-connect/persist-session
{:id (:id current-proposal) {:id (:id current-proposal)
:dapp-name (:name metadata) :dapp-name (:name metadata)
:dapp-url (:url metadata) :dapp-url (:url metadata)
:session-info current-proposal}]))) :session-info current-proposal}])))
:on-fail (fn [error] :on-fail (fn [error]
(log/error "Wallet Connect session approval failed" (log/error "Wallet Connect session approval failed"
{:error error {:error error
:event :wallet-connect/approve-session}) :event :wallet-connect/approve-session})
(rf/dispatch (rf/dispatch
[:wallet-connect/reset-current-session-proposal]))}] [:wallet-connect/reset-current-session-proposal]))}]
[:dispatch [:dismiss-modal :screen/wallet.wallet-connect-session-proposal]]]}))) [:dispatch [:dismiss-modal :screen/wallet.wallet-connect-session-proposal]]]})))
(rf/reg-event-fx (rf/reg-event-fx
@ -192,7 +193,8 @@
{:version version})}]]]} {:version version})}]]]}
:else :else
{:fx [[:dispatch [:wallet-connect/pair scanned-text]]]})))) {:fx [[:dispatch [:wallet-connect/pair scanned-text]]
[:dispatch [:dismiss-modal :screen/wallet.wallet-connect-session-proposal]]]}))))
(rf/reg-event-fx (rf/reg-event-fx
:wallet-connect/persist-session :wallet-connect/persist-session