diff --git a/src/status_im/translations/en.cljs b/src/status_im/translations/en.cljs index 2d9a91ccb5..ebdce89b8f 100644 --- a/src/status_im/translations/en.cljs +++ b/src/status_im/translations/en.cljs @@ -401,6 +401,7 @@ :wallet-choose-recipient "Choose Recipient" :wallet-choose-from-contacts "Choose From Contacts" :wallet-address-from-clipboard "Use Address From Clipboard" + :wallet-invalid-address "Address is invalid" :wallet-browse-photos "Browse Photos" :validation-amount-invalid "Amount is not valid" :validation-amount-invalid-number "Amount is not a valid number" diff --git a/src/status_im/ui/screens/events.cljs b/src/status_im/ui/screens/events.cljs index 0fac9f6440..62299238f3 100644 --- a/src/status_im/ui/screens/events.cljs +++ b/src/status_im/ui/screens/events.cljs @@ -177,6 +177,11 @@ (fn [] (notifications/get-fcm-token))) +(reg-fx + :show-error + (fn [content] + (utils/show-popup "Error" content))) + (re-frame/reg-fx :show-confirmation (fn [{:keys [title content confirm-button-text on-accept on-cancel]}] 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 147e810908..c79a43a0fb 100644 --- a/src/status_im/ui/screens/wallet/choose_recipient/events.cljs +++ b/src/status_im/ui/screens/wallet/choose_recipient/events.cljs @@ -1,5 +1,6 @@ (ns status-im.ui.screens.wallet.choose-recipient.events - (:require [status-im.utils.handlers :as handlers])) + (:require [status-im.i18n :as i18n] + [status-im.utils.handlers :as handlers])) (handlers/register-handler-db :wallet/toggle-flashlight @@ -13,10 +14,13 @@ (handlers/register-handler-fx :choose-recipient - (fn [{:keys [db]} [_ address name]] - (let [{:keys [view-id]} db] - (cond-> {:db (choose-address-and-name db address name)} - (= :choose-recipient view-id) (assoc :dispatch [:navigate-back]))))) + (fn [{{:keys [web3] :as db} :db} [_ address name]] + (let [{:keys [view-id]} db + valid-address? (.isAddress web3 address)] + (cond-> {:db db} + (= :choose-recipient view-id) (assoc :dispatch [:navigate-back]) + valid-address? (update :db #(choose-address-and-name % address name)) + (not valid-address?) (assoc :show-error (i18n/label :t/wallet-invalid-address)))))) (handlers/register-handler-fx :wallet-open-send-transaction