Skip to content

Commit

Permalink
Selected networks are not shown as preferred if a multichain wallet w…
Browse files Browse the repository at this point in the history
…ith preferred networks is scanned on the 'send to' page #19775 (#19899)
  • Loading branch information
mmilad75 committed May 13, 2024
1 parent 2618a55 commit 33da4bf
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/status_im/contexts/wallet/common/scan_account/view.cljs
Original file line number Diff line number Diff line change
@@ -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
[]
Expand All @@ -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))
Expand Down

0 comments on commit 33da4bf

Please sign in to comment.