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:
mmilad75 2024-05-13 14:54:39 +03:30 committed by GitHub
parent 2618a55dbc
commit 33da4bfabc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 5 deletions

View File

@ -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))