Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alwx committed Feb 14, 2024
1 parent 4ce51b7 commit bba9459
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns status-im.contexts.communities.actions.addresses-for-permissions.events-test
(:require
[cljs.test :refer [is deftest]]
[cljs.test :refer [deftest is]]
[status-im.contexts.communities.actions.addresses-for-permissions.events :as sut]))

(def community-id "0x1")
Expand Down
85 changes: 58 additions & 27 deletions src/status_im/contexts/shell/qr_reader/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
[status-im.contexts.communities.events]
[status-im.contexts.wallet.common.validation :as wallet-validation]
[utils.debounce :as debounce]
[utils.i18n :as i18n]))
[utils.ethereum.eip.eip681 :as eip681]
[utils.i18n :as i18n]
[utils.url :as url]))

(def invalid-qr-toast
{:type :negative
Expand All @@ -29,10 +31,25 @@
[scanned-text]
(wallet-validation/eth-address? scanned-text))

(defn eip681-address?
[scanned-text]
(-> scanned-text
eip681/parse-uri
:address
boolean))

(defn pairing-qr-code?
[_]
false)

(defn wallet-connect-code?
[scanned-text]
(string/starts-with? scanned-text "wc:"))

(defn url?
[scanned-text]
(url/url? scanned-text))

(defn load-and-show-profile
[address]
(debounce/debounce-and-dispatch
Expand All @@ -53,32 +70,46 @@

(defn on-qr-code-scanned
[scanned-text]
(let [address (extract-id scanned-text)]
(cond
(text-for-url-path? scanned-text router/community-with-data-path)
;; TODO: https://github.com/status-im/status-mobile/issues/18743
nil

(text-for-url-path? scanned-text router/channel-path)
;; TODO: https://github.com/status-im/status-mobile/issues/18743
nil

(text-for-url-path? scanned-text router/user-with-data-path)
(load-and-show-profile address)

(or (validators/valid-public-key? scanned-text)
(validators/valid-compressed-key? scanned-text))
(load-and-show-profile scanned-text)

(eth-address? scanned-text)
(debounce/debounce-and-dispatch [:navigate-to :wallet-accounts address] 300)

(pairing-qr-code? scanned-text)
;; TODO: https://github.com/status-im/status-mobile/issues/18744
nil

:else
(show-invalid-qr-toast))))
(cond
(text-for-url-path? scanned-text router/community-with-data-path)
;; TODO: https://github.com/status-im/status-mobile/issues/18743
nil

(text-for-url-path? scanned-text router/channel-path)
;; TODO: https://github.com/status-im/status-mobile/issues/18743
nil

(text-for-url-path? scanned-text router/user-with-data-path)
(let [address (extract-id scanned-text)]
(load-and-show-profile address))

(or (validators/valid-public-key? scanned-text)
(validators/valid-compressed-key? scanned-text))
(load-and-show-profile scanned-text)

(eth-address? scanned-text)
(debounce/debounce-and-dispatch [:navigate-to :wallet-accounts scanned-text] 300)

(eip681-address? scanned-text)
(do
(debounce/debounce-and-dispatch [:wallet-legacy/request-uri-parsed
(eip681/parse-uri scanned-text)]
300)
(debounce/debounce-and-dispatch [:navigate-change-tab :wallet-stack] 300))

(pairing-qr-code? scanned-text)
;; TODO: https://github.com/status-im/status-mobile/issues/18744
nil

(wallet-connect-code? scanned-text)
;; WalletConnect is not working yet, this flow should be updated once WalletConnect is ready
nil

(url? scanned-text)
(debounce/debounce-and-dispatch [:browser.ui/open-url scanned-text] 300)

:else
(show-invalid-qr-toast)))

(defn- f-internal-view
[]
Expand Down
4 changes: 3 additions & 1 deletion src/status_im/contexts/shell/share/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
:background :blur
:size 32
:accessibility-label :shell-scan-button
:on-press #(rf/dispatch [:navigate-back])}
:on-press (fn []
(rf/dispatch [:navigate-back])
(rf/dispatch [:open-modal :shell-qr-reader]))}
:i/scan]]
[quo/text
{:size :heading-1
Expand Down

0 comments on commit bba9459

Please sign in to comment.