From b293fb11e3834fa82b8a0fe15d46e39aee61b594 Mon Sep 17 00:00:00 2001 From: Eric Dvorsak Date: Fri, 26 Oct 2018 20:50:14 +0200 Subject: [PATCH] [fix] fix ens name resolution the app was previously letting the user create a chat with a contact if a name typed in the input returned a valid public key at some point because the field wasn't cleaned up with latter typing Signed-off-by: Eric Dvorsak --- .../ui/screens/add_new/new_chat/events.cljs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/status_im/ui/screens/add_new/new_chat/events.cljs b/src/status_im/ui/screens/add_new/new_chat/events.cljs index 37ab931b3c..1c7d0ab843 100644 --- a/src/status_im/ui/screens/add_new/new_chat/events.cljs +++ b/src/status_im/ui/screens/add_new/new_chat/events.cljs @@ -15,17 +15,17 @@ (handlers/register-handler-fx :new-chat/set-new-identity (fn [{{:keys [web3 network network-status] :as db} :db} [_ new-identity]] - (let [new-identity-error (db/validate-pub-key db new-identity)] - (if (and (string? new-identity) - (string/starts-with? new-identity "0x")) - {:db (assoc db - :contacts/new-identity new-identity - :contacts/new-identity-error new-identity-error)} - (let [network (get-in db [:account/account :networks network]) - chain (ethereum/network->chain-keyword network)] - {:resolve-whisper-identity {:web3 web3 - :registry (get ens/ens-registries chain) - :ens-name (if (ens/is-valid-eth-name? new-identity) - new-identity - (str new-identity ".stateofus.eth")) - :cb #(re-frame/dispatch [:new-chat/set-new-identity %])}}))))) + (let [is-public-key? (and (string? new-identity) + (string/starts-with? new-identity "0x"))] + (merge {:db (assoc db + :contacts/new-identity new-identity + :contacts/new-identity-error (db/validate-pub-key db new-identity))} + (when-not is-public-key? + (let [network (get-in db [:account/account :networks network]) + chain (ethereum/network->chain-keyword network)] + {:resolve-whisper-identity {:web3 web3 + :registry (get ens/ens-registries chain) + :ens-name (if (ens/is-valid-eth-name? new-identity) + new-identity + (str new-identity ".stateofus.eth")) + :cb #(re-frame/dispatch [:new-chat/set-new-identity %])}}))))))