diff --git a/src/status_im/contexts/wallet/common/scan_account/view.cljs b/src/status_im/contexts/wallet/common/scan_account/view.cljs index 688b1b76cc..74a516bba8 100644 --- a/src/status_im/contexts/wallet/common/scan_account/view.cljs +++ b/src/status_im/contexts/wallet/common/scan_account/view.cljs @@ -1,17 +1,26 @@ (ns status-im.contexts.wallet.common.scan-account.view - (:require [status-im.common.scan-qr-code.view :as scan-qr-code] + (:require [clojure.string :as string] + [status-im.common.scan-qr-code.view :as scan-qr-code] [status-im.constants :as constants] [utils.debounce :as debounce] [utils.i18n :as i18n] [utils.re-frame :as rf])) -(defn- contains-address? +(def ^:private supported-networks #{:eth :arb1 :opt}) + +(defn- contains-supported-address? [s] - (boolean (re-find constants/regx-address-contains s))) + (let [address? (boolean (re-find constants/regx-address-contains s)) + networks (when address? + (as-> s $ + (string/split $ ":") + (butlast $))) + supported? (every? supported-networks (map keyword networks))] + (and address? supported?))) (defn- extract-address [scanned-text] - (first (re-seq constants/regx-address-contains scanned-text))) + (first (re-seq constants/regx-multichain-address scanned-text))) (defn view [] @@ -20,7 +29,7 @@ {:title (i18n/label :t/scan-qr) :subtitle (i18n/label :t/scan-an-account-qr-code) :error-message (i18n/label :t/oops-this-qr-does-not-contain-an-address) - :validate-fn #(contains-address? %) + :validate-fn #(contains-supported-address? %) :on-success-scan (fn [result] (let [address (extract-address result)] (when on-result (on-result address))