Selected networks are not shown as preferred if a multichain wallet with preferred networks is scanned on the 'send to' page #19775 (#19899)
This commit is contained in:
parent
2618a55dbc
commit
33da4bfabc
|
@ -1,17 +1,26 @@
|
||||||
(ns status-im.contexts.wallet.common.scan-account.view
|
(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]
|
[status-im.constants :as constants]
|
||||||
[utils.debounce :as debounce]
|
[utils.debounce :as debounce]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(defn- contains-address?
|
(def ^:private supported-networks #{:eth :arb1 :opt})
|
||||||
|
|
||||||
|
(defn- contains-supported-address?
|
||||||
[s]
|
[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
|
(defn- extract-address
|
||||||
[scanned-text]
|
[scanned-text]
|
||||||
(first (re-seq constants/regx-address-contains scanned-text)))
|
(first (re-seq constants/regx-multichain-address scanned-text)))
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
|
@ -20,7 +29,7 @@
|
||||||
{:title (i18n/label :t/scan-qr)
|
{:title (i18n/label :t/scan-qr)
|
||||||
:subtitle (i18n/label :t/scan-an-account-qr-code)
|
:subtitle (i18n/label :t/scan-an-account-qr-code)
|
||||||
:error-message (i18n/label :t/oops-this-qr-does-not-contain-an-address)
|
: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]
|
:on-success-scan (fn [result]
|
||||||
(let [address (extract-address result)]
|
(let [address (extract-address result)]
|
||||||
(when on-result (on-result address))
|
(when on-result (on-result address))
|
||||||
|
|
Loading…
Reference in New Issue