diff --git a/src/status_im/ui/screens/wallet/choose_recipient/events.cljs b/src/status_im/ui/screens/wallet/choose_recipient/events.cljs index 97a8866dca..eadc714595 100644 --- a/src/status_im/ui/screens/wallet/choose_recipient/events.cljs +++ b/src/status_im/ui/screens/wallet/choose_recipient/events.cljs @@ -13,11 +13,18 @@ (defn choose-address-and-name [db address name] (update db :wallet/send-transaction assoc :to-address address :to-name name)) +(defn- extract-address [s] + ;; First try to parse as EIP67 URI, if not assume this is an address directly + (if-let [m (eip67/parse-uri s)] + (:address m) + s)) + (handlers/register-handler-fx :choose-recipient (fn [{{:keys [web3] :as db} :db} [_ data name]] (let [{:keys [view-id]} db - address (:address (eip67/parse-uri data)) + address (extract-address data) + ;; isAddress works with or without address with leading '0x' valid-address? (.isAddress web3 address)] (cond-> {:db db} (= :choose-recipient view-id) (assoc :dispatch [:navigate-back]) diff --git a/src/status_im/ui/screens/wallet/choose_recipient/views.cljs b/src/status_im/ui/screens/wallet/choose_recipient/views.cljs index dddbaec6d2..3e808603c2 100644 --- a/src/status_im/ui/screens/wallet/choose_recipient/views.cljs +++ b/src/status_im/ui/screens/wallet/choose_recipient/views.cljs @@ -1,6 +1,7 @@ (ns status-im.ui.screens.wallet.choose-recipient.views (:require-macros [status-im.utils.views :refer [defview letsubs]]) - (:require [re-frame.core :as re-frame] + (:require [clojure.string :as string] + [re-frame.core :as re-frame] [status-im.components.camera :as camera] [status-im.components.icons.vector-icons :as vector-icons] [status-im.components.react :as react] @@ -40,7 +41,7 @@ [react/touchable-highlight {:style (styles/recipient-touchable true) :on-press #(react/get-from-clipboard (fn [clipboard] - (re-frame/dispatch [:choose-recipient clipboard nil])))} + (re-frame/dispatch [:choose-recipient (string/trim clipboard) nil])))} [react/view {:style styles/recipient-button} [react/text {:style styles/recipient-button-text} (i18n/label :t/wallet-address-from-clipboard)]