Skip to content

Commit

Permalink
🎏 Add ff for wc scanner
Browse files Browse the repository at this point in the history
- Bring back missing event
  • Loading branch information
shivekkhurana committed Jun 5, 2024
1 parent aab6b3a commit e81cea7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/status_im/contexts/shell/qr_reader/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[status-im.contexts.communities.events]
[status-im.contexts.wallet.common.validation :as wallet-validation]
[status-im.contexts.wallet.wallet-connect.utils :as wc-utils]
[status-im.feature-flags :as ff]
[utils.debounce :as debounce]
[utils.ethereum.eip.eip681 :as eip681]
[utils.i18n :as i18n]
Expand Down Expand Up @@ -102,7 +103,9 @@
;; TODO: https://github.com/status-im/status-mobile/issues/18744
nil

(wc-utils/valid-uri? scanned-text)
(and
(wc-utils/valid-uri? scanned-text)
(ff/enabled? ::ff/wallet.wallet-connect))
(handle-wallet-connect scanned-text)

(url? scanned-text)
Expand Down
34 changes: 33 additions & 1 deletion src/status_im/contexts/wallet/wallet_connect/events.cljs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
(ns status-im.contexts.wallet.wallet-connect.events
(:require [re-frame.core :as rf]
[react-native.wallet-connect :as wallet-connect]
[status-im.constants :as constants]
[status-im.contexts.wallet.wallet-connect.core :as wallet-connect-core]
status-im.contexts.wallet.wallet-connect.effects
status-im.contexts.wallet.wallet-connect.processing-events
status-im.contexts.wallet.wallet-connect.responding-events
[status-im.contexts.wallet.wallet-connect.utils :as wc-utils]
[taoensso.timbre :as log]
[utils.ethereum.chain :as chain]))
[utils.ethereum.chain :as chain]
[utils.i18n :as i18n]))

(rf/reg-event-fx
:wallet-connect/init
Expand Down Expand Up @@ -155,3 +158,32 @@
:event :wallet-connect/approve-session})
(rf/dispatch
[:wallet-connect/reset-current-session-proposal]))}]]})))

(rf/reg-event-fx
:wallet-connect/on-scan-connection
(fn [_ [scanned-text]]
(let [parsed-uri (wallet-connect/parse-uri scanned-text)
version (:version parsed-uri)
expired? (-> parsed-uri
:expiryTimestamp
wc-utils/timestamp-expired?)
version-supported? (wc-utils/version-supported? version)]
(cond
expired?
{:fx [[:dispatch
[:toasts/upsert
{:type :negative
:theme :dark
:text (i18n/label :t/wallet-connect-qr-expired)}]]]}

(not version-supported?)
{:fx [[:dispatch
[:toasts/upsert
{:type :negative
:theme :dark
:text (i18n/label :t/wallet-connect-version-not-supported
{:version version})}]]]}

:else
{:fx [[:dispatch [:wallet-connect/pair scanned-text]]
[:dispatch [:dismiss-modal :screen/wallet.wallet-connect-session-proposal]]]}))))

0 comments on commit e81cea7

Please sign in to comment.