show ens name for chats created using ens name
This commit is contained in:
parent
a21454039b
commit
3e19f929e9
|
@ -13,7 +13,8 @@
|
||||||
[status-im.tribute-to-talk.whitelist :as whitelist]
|
[status-im.tribute-to-talk.whitelist :as whitelist]
|
||||||
[status-im.ui.screens.navigation :as navigation]
|
[status-im.ui.screens.navigation :as navigation]
|
||||||
[status-im.utils.config :as config]
|
[status-im.utils.config :as config]
|
||||||
[status-im.utils.fx :as fx]))
|
[status-im.utils.fx :as fx]
|
||||||
|
[status-im.utils.datetime :as time]))
|
||||||
|
|
||||||
(fx/defn load-contacts
|
(fx/defn load-contacts
|
||||||
{:events [::contacts-loaded]}
|
{:events [::contacts-loaded]}
|
||||||
|
@ -71,7 +72,7 @@
|
||||||
(update :system-tags
|
(update :system-tags
|
||||||
(fnil #(conj % :contact/added) #{})))]
|
(fnil #(conj % :contact/added) #{})))]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (assoc-in db [:contacts/new-identity] "")}
|
{:db (dissoc db :contacts/new-identity)}
|
||||||
(upsert-contact contact)
|
(upsert-contact contact)
|
||||||
(whitelist/add-to-whitelist public-key)
|
(whitelist/add-to-whitelist public-key)
|
||||||
(send-contact-request contact)
|
(send-contact-request contact)
|
||||||
|
@ -94,7 +95,7 @@
|
||||||
(when (not= (get-in db [:multiaccount :public-key]) public-key)
|
(when (not= (get-in db [:multiaccount :public-key]) public-key)
|
||||||
(let [contact (build-contact cofx public-key)]
|
(let [contact (build-contact cofx public-key)]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (assoc-in db [:contacts/new-identity] "")}
|
{:db (dissoc db :contacts/new-identity)}
|
||||||
(upsert-contact contact)))))
|
(upsert-contact contact)))))
|
||||||
|
|
||||||
(fx/defn handle-contact-update
|
(fx/defn handle-contact-update
|
||||||
|
@ -176,3 +177,12 @@
|
||||||
{:events [:contacts/ens-names-verified]}
|
{:events [:contacts/ens-names-verified]}
|
||||||
[{:keys [db]} names]
|
[{:keys [db]} names]
|
||||||
{:db (update db :contacts/contacts add-ens-names names)})
|
{:db (update db :contacts/contacts add-ens-names names)})
|
||||||
|
|
||||||
|
(fx/defn name-verified
|
||||||
|
{:events [:contacts/ens-name-verified]}
|
||||||
|
[{:keys [db]} public-key ens-name]
|
||||||
|
{:db (update-in db [:contacts/contacts public-key]
|
||||||
|
merge
|
||||||
|
{:name ens-name
|
||||||
|
:ens-verified-at (quot (time/timestamp) 1000)
|
||||||
|
:ens-verified true})})
|
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
(spec/def :contacts/contacts (spec/nilable (spec/map-of :global/not-empty-string :contact/contact)))
|
(spec/def :contacts/contacts (spec/nilable (spec/map-of :global/not-empty-string :contact/contact)))
|
||||||
;;public key of new contact during adding this new contact
|
;;public key of new contact during adding this new contact
|
||||||
(spec/def :contacts/new-identity (spec/nilable string?))
|
(spec/def :contacts/new-identity (spec/nilable map?))
|
||||||
(spec/def :contacts/new-identity-error (spec/nilable string?))
|
(spec/def :contacts/new-identity-error (spec/nilable string?))
|
||||||
;;on showing this contact's profile (andrey: better to move into profile ns)
|
;;on showing this contact's profile (andrey: better to move into profile ns)
|
||||||
(spec/def :contacts/identity (spec/nilable :global/not-empty-string))
|
(spec/def :contacts/identity (spec/nilable :global/not-empty-string))
|
||||||
|
|
|
@ -1210,17 +1210,13 @@
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:contact/qr-code-scanned
|
:contact/qr-code-scanned
|
||||||
[(re-frame/inject-cofx :random-id-generator)]
|
[(re-frame/inject-cofx :random-id-generator)]
|
||||||
(fn [{:keys [db] :as cofx} [_ contact-identity _]]
|
(fn [{:keys [db] :as cofx} [_ contact-identity _]]
|
||||||
(let [current-multiaccount (:multiaccount db)
|
(let [validation-result (new-chat.db/validate-pub-key db contact-identity)]
|
||||||
fx {:db (assoc db :contacts/new-identity contact-identity)}
|
|
||||||
validation-result (new-chat.db/validate-pub-key db contact-identity)]
|
|
||||||
(if (some? validation-result)
|
(if (some? validation-result)
|
||||||
{:utils/show-popup {:title (i18n/label :t/unable-to-read-this-code)
|
{:utils/show-popup {:title (i18n/label :t/unable-to-read-this-code)
|
||||||
:content validation-result
|
:content validation-result
|
||||||
:on-dismiss #(re-frame/dispatch [:navigate-to-clean :home])}}
|
:on-dismiss #(re-frame/dispatch [:navigate-to-clean :home])}}
|
||||||
(fx/merge cofx
|
(chat/start-chat cofx contact-identity {:navigation-reset? true})))))
|
||||||
fx
|
|
||||||
(chat/start-chat contact-identity {:navigation-reset? true}))))))
|
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:contact.ui/start-group-chat-pressed
|
:contact.ui/start-group-chat-pressed
|
||||||
|
@ -1237,7 +1233,11 @@
|
||||||
:contact.ui/contact-code-submitted
|
:contact.ui/contact-code-submitted
|
||||||
[(re-frame/inject-cofx :random-id-generator)]
|
[(re-frame/inject-cofx :random-id-generator)]
|
||||||
(fn [{{:contacts/keys [new-identity]} :db :as cofx} _]
|
(fn [{{:contacts/keys [new-identity]} :db :as cofx} _]
|
||||||
(chat/start-chat cofx new-identity {:navigation-reset? true})))
|
(let [{:keys [public-key ens-name]} new-identity]
|
||||||
|
(fx/merge cofx
|
||||||
|
(chat/start-chat public-key {:navigation-reset? true})
|
||||||
|
#(when ens-name
|
||||||
|
(contact/name-verified % public-key ens-name))))))
|
||||||
|
|
||||||
;; search module
|
;; search module
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
[status-im.ethereum.ens :as ens]
|
[status-im.ethereum.ens :as ens]
|
||||||
[status-im.ethereum.resolver :as resolver]
|
[status-im.ethereum.resolver :as resolver]
|
||||||
[status-im.ui.screens.add-new.new-chat.db :as db]
|
[status-im.ui.screens.add-new.new-chat.db :as db]
|
||||||
[status-im.utils.handlers :as handlers]))
|
[status-im.utils.handlers :as handlers]
|
||||||
|
[status-im.ethereum.stateofus :as stateofus]))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:resolve-public-key
|
:resolve-public-key
|
||||||
|
@ -14,17 +15,19 @@
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:new-chat/set-new-identity
|
:new-chat/set-new-identity
|
||||||
(fn [{{:keys [network-status] :as db} :db} [_ new-identity]]
|
(fn [{db :db} [_ new-identity new-ens-name]]
|
||||||
(let [is-public-key? (and (string? new-identity)
|
(let [is-public-key? (and (string? new-identity)
|
||||||
(string/starts-with? new-identity "0x"))]
|
(string/starts-with? new-identity "0x"))]
|
||||||
(merge {:db (assoc db
|
(merge {:db (assoc db
|
||||||
:contacts/new-identity new-identity
|
:contacts/new-identity {:public-key new-identity :ens-name new-ens-name}
|
||||||
:contacts/new-identity-error (db/validate-pub-key db new-identity))}
|
:contacts/new-identity-error (db/validate-pub-key db new-identity))}
|
||||||
(when (and (not is-public-key?)
|
(when (and (not is-public-key?)
|
||||||
(ens/valid-eth-name-prefix? new-identity))
|
(ens/valid-eth-name-prefix? new-identity))
|
||||||
(let [chain (ethereum/chain-keyword db)]
|
(let [chain (ethereum/chain-keyword db)
|
||||||
|
ens-name (string/lower-case
|
||||||
|
(if (ens/is-valid-eth-name? new-identity)
|
||||||
|
new-identity
|
||||||
|
(stateofus/subdomain new-identity)))]
|
||||||
{:resolve-public-key {:registry (get ens/ens-registries chain)
|
{:resolve-public-key {:registry (get ens/ens-registries chain)
|
||||||
:ens-name (if (ens/is-valid-eth-name? new-identity)
|
:ens-name ens-name
|
||||||
new-identity
|
:cb #(re-frame/dispatch [:new-chat/set-new-identity % ens-name])}}))))))
|
||||||
(str new-identity ".stateofus.eth"))
|
|
||||||
:cb #(re-frame/dispatch [:new-chat/set-new-identity %])}}))))))
|
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
|
|
||||||
(defmethod navigation/preload-data! :new-chat
|
(defmethod navigation/preload-data! :new-chat
|
||||||
[db _]
|
[db _]
|
||||||
(assoc db :contacts/new-identity nil))
|
(dissoc db :contacts/new-identity :contacts/new-identity-error))
|
||||||
|
|
Loading…
Reference in New Issue