[BUG #1991] Make sure provided eth address is valid

This commit is contained in:
Julien Eluard 2017-10-06 14:20:12 +02:00 committed by Roman Volosovskyi
parent 54d68081b4
commit e99cae58cc
3 changed files with 15 additions and 5 deletions

View File

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

View File

@ -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]}]

View File

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