[#12071] Some ENS names starting with 0x are not picked up as universal links
Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
parent
a6eee856cf
commit
82f7fbf7e4
|
@ -12,7 +12,8 @@
|
||||||
[status-im.i18n.i18n :as i18n]
|
[status-im.i18n.i18n :as i18n]
|
||||||
[status-im.contact.core :as contact]
|
[status-im.contact.core :as contact]
|
||||||
[status-im.router.core :as router]
|
[status-im.router.core :as router]
|
||||||
[status-im.navigation :as navigation]))
|
[status-im.navigation :as navigation]
|
||||||
|
[status-im.utils.db :as utils.db]))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:resolve-public-key
|
:resolve-public-key
|
||||||
|
@ -27,10 +28,15 @@
|
||||||
(fx/defn new-chat-set-new-identity
|
(fx/defn new-chat-set-new-identity
|
||||||
{:events [:new-chat/set-new-identity]}
|
{:events [:new-chat/set-new-identity]}
|
||||||
[{db :db} new-identity-raw new-ens-name id]
|
[{db :db} new-identity-raw new-ens-name id]
|
||||||
(when (or (not id) (= id @resolve-last-id))
|
(let [new-identity (utils/safe-trim new-identity-raw)
|
||||||
|
ens-error (and (= new-identity-raw "0x") (not (string/blank? new-ens-name)))]
|
||||||
|
(when (and (or (not id) (= id @resolve-last-id))
|
||||||
|
(or ens-error (> (count new-identity) 4)))
|
||||||
|
(if ens-error
|
||||||
|
{:db (assoc-in db [:contacts/new-identity :state] :error)}
|
||||||
(let [new-identity (utils/safe-trim new-identity-raw)
|
(let [new-identity (utils/safe-trim new-identity-raw)
|
||||||
is-public-key? (and (string? new-identity)
|
is-public-key? (and (string? new-identity)
|
||||||
(string/starts-with? new-identity "0x"))
|
(utils.db/valid-public-key? new-identity))
|
||||||
is-ens? (and (not is-public-key?)
|
is-ens? (and (not is-public-key?)
|
||||||
(ens/valid-eth-name-prefix? new-identity))
|
(ens/valid-eth-name-prefix? new-identity))
|
||||||
error (db/validate-pub-key db new-identity)]
|
error (db/validate-pub-key db new-identity)]
|
||||||
|
@ -57,7 +63,7 @@
|
||||||
:cb #(re-frame/dispatch [:new-chat/set-new-identity
|
:cb #(re-frame/dispatch [:new-chat/set-new-identity
|
||||||
%
|
%
|
||||||
new-identity
|
new-identity
|
||||||
@resolve-last-id])}}))))))
|
@resolve-last-id])}}))))))))
|
||||||
|
|
||||||
(fx/defn clear-new-identity
|
(fx/defn clear-new-identity
|
||||||
{:events [::clear-new-identity ::new-chat-focus]}
|
{:events [::clear-new-identity ::new-chat-focus]}
|
||||||
|
|
|
@ -69,16 +69,14 @@
|
||||||
|
|
||||||
(defn match-contact-async
|
(defn match-contact-async
|
||||||
[chain {:keys [user-id]} callback]
|
[chain {:keys [user-id]} callback]
|
||||||
(let [public-key? (and (string? user-id)
|
(let [valid-key (and (spec/valid? :global/public-key user-id)
|
||||||
(string/starts-with? user-id "0x"))
|
|
||||||
valid-key (and (spec/valid? :global/public-key user-id)
|
|
||||||
(not= user-id ens/default-key))]
|
(not= user-id ens/default-key))]
|
||||||
(cond
|
(cond
|
||||||
(and public-key? valid-key)
|
(and valid-key)
|
||||||
(callback {:type :contact
|
(callback {:type :contact
|
||||||
:public-key user-id})
|
:public-key user-id})
|
||||||
|
|
||||||
(and (not public-key?) (string? user-id))
|
(and (not valid-key) (string? user-id))
|
||||||
(let [registry (get ens/ens-registries chain)
|
(let [registry (get ens/ens-registries chain)
|
||||||
ens-name (resolver/ens-name-parse user-id)
|
ens-name (resolver/ens-name-parse user-id)
|
||||||
on-success #(match-contact-async chain {:user-id %} callback)]
|
on-success #(match-contact-async chain {:user-id %} callback)]
|
||||||
|
|
|
@ -142,7 +142,7 @@
|
||||||
{:on-change-text
|
{:on-change-text
|
||||||
#(do
|
#(do
|
||||||
(reset! search-value %)
|
(reset! search-value %)
|
||||||
(re-frame/dispatch [:set-in [:contacts/new-identity :state] :searching])
|
(re-frame/dispatch [:set-in [:contacts/new-identity :state] :empty])
|
||||||
(debounce/debounce-and-dispatch [:new-chat/set-new-identity %] 600))
|
(debounce/debounce-and-dispatch [:new-chat/set-new-identity %] 600))
|
||||||
:on-submit-editing
|
:on-submit-editing
|
||||||
#(when (= state :valid)
|
#(when (= state :valid)
|
||||||
|
|
Loading…
Reference in New Issue