Persistence works

- Also moved closing of modal to approval stage
This commit is contained in:
Shivek Khurana 2024-06-11 20:10:44 +05:30
parent 48b542067e
commit 4156433f5d
No known key found for this signature in database
GPG Key ID: 6BBA04C82FA07036
1 changed files with 16 additions and 11 deletions

View File

@ -110,7 +110,7 @@
(rf/reg-event-fx (rf/reg-event-fx
:wallet-connect/close-session-request :wallet-connect/close-session-request
(fn [_ _] (fn [_ _]
{:fx [[:dispatch [:navigate-back]] {:fx [[:dispatch [:dismiss-modal :screen/wallet.wallet-connect-session-proposal]]
[:dispatch [:wallet-connect/reset-current-session-request]]]})) [:dispatch [:wallet-connect/reset-current-session-request]]]}))
(rf/reg-event-fx (rf/reg-event-fx
@ -151,14 +151,20 @@
: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")
(prn current-proposal) (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
{:id (:id current-proposal)
:dapp-name (:name metadata)
:dapp-url (:url metadata)
: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]]]})))
(rf/reg-event-fx (rf/reg-event-fx
:wallet-connect/on-scan-connection :wallet-connect/on-scan-connection
@ -186,15 +192,14 @@
{: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
(fn [_ [{:keys [id dapp-name dapp-url session-info]}]] (fn [_ [{:keys [id dapp-name dapp-url session-info]}]]
{:fx [[:json-rpc/call {:fx [[:json-rpc/call
[{:method "wakuext_addWalletConnectSession" [{:method "wakuext_addWalletConnectSession"
:params [{:id id :params [{:id (str id)
:dappName dapp-name :dappName dapp-name
:dappUrl dapp-url :dappUrl dapp-url
:info (-> session-info :info (-> session-info
@ -214,4 +219,4 @@
{:fx [[:json-rpc/call {:fx [[:json-rpc/call
[{:method "wakuext_getWalletConnectSession" [{:method "wakuext_getWalletConnectSession"
:on-success [:wallet-connect/fetch-persisted-sessions-success] :on-success [:wallet-connect/fetch-persisted-sessions-success]
:on-error #(log/info "Wallet Connect fetch persistted sessions failed")}]]]})) :on-error #(log/info "Wallet Connect fetch persisted sessions failed")}]]]}))