[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 <eric@status.im>
This commit is contained in:
parent
c348342590
commit
b293fb11e3
|
@ -15,17 +15,17 @@
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:new-chat/set-new-identity
|
:new-chat/set-new-identity
|
||||||
(fn [{{:keys [web3 network network-status] :as db} :db} [_ new-identity]]
|
(fn [{{:keys [web3 network network-status] :as db} :db} [_ new-identity]]
|
||||||
(let [new-identity-error (db/validate-pub-key db new-identity)]
|
(let [is-public-key? (and (string? new-identity)
|
||||||
(if (and (string? new-identity)
|
(string/starts-with? new-identity "0x"))]
|
||||||
(string/starts-with? new-identity "0x"))
|
(merge {:db (assoc db
|
||||||
{:db (assoc db
|
:contacts/new-identity new-identity
|
||||||
:contacts/new-identity new-identity
|
:contacts/new-identity-error (db/validate-pub-key db new-identity))}
|
||||||
:contacts/new-identity-error new-identity-error)}
|
(when-not is-public-key?
|
||||||
(let [network (get-in db [:account/account :networks network])
|
(let [network (get-in db [:account/account :networks network])
|
||||||
chain (ethereum/network->chain-keyword network)]
|
chain (ethereum/network->chain-keyword network)]
|
||||||
{:resolve-whisper-identity {:web3 web3
|
{:resolve-whisper-identity {:web3 web3
|
||||||
:registry (get ens/ens-registries chain)
|
:registry (get ens/ens-registries chain)
|
||||||
:ens-name (if (ens/is-valid-eth-name? new-identity)
|
:ens-name (if (ens/is-valid-eth-name? new-identity)
|
||||||
new-identity
|
new-identity
|
||||||
(str new-identity ".stateofus.eth"))
|
(str new-identity ".stateofus.eth"))
|
||||||
:cb #(re-frame/dispatch [:new-chat/set-new-identity %])}})))))
|
:cb #(re-frame/dispatch [:new-chat/set-new-identity %])}}))))))
|
||||||
|
|
Loading…
Reference in New Issue