fix_: Profile with ENS fixes (#21003)

This commit:

- fixes profile with ENS can edit their name
- fixes identicon ring is shown for the profile with ENS
- updates the profile URL for the profile with ENS 

Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
This commit is contained in:
Mohamed Javid 2024-08-30 20:25:02 +05:30 committed by GitHub
parent 113f9aaa81
commit 1663848b7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 21 deletions

View File

@ -3,6 +3,7 @@
[clojure.set :as set]
[clojure.string :as string]
[legacy.status-im.data-store.visibility-status-updates :as visibility-status-updates]
[status-im.contexts.wallet.common.validation :as validation]
[utils.ethereum.eip.eip55 :as eip55]))
(defn rpc->visible-tokens
@ -35,6 +36,7 @@
(update :pinned-mailservers rpc->pinned-mailservers)
(update :link-previews-enabled-sites set)
(update :currency rpc->currency)
(assoc :ens-name? (validation/ens-name? (:preferred-name settings)))
(visibility-status-updates/<-rpc-settings)
(set/rename-keys {:compressedKey :compressed-key
:emojiHash :emoji-hash})))

View File

@ -178,13 +178,10 @@
[{:keys [db]} [{:keys [public-key on-success]}]]
(let [profile-public-key (get-in db [:profile/profile :public-key])
profile? (or (not public-key) (= public-key profile-public-key))
ens-name? (if profile?
(get-in db [:profile/profile :ens-name?])
(get-in db [:contacts/contacts public-key :ens-name]))
public-key (if profile? profile-public-key public-key)]
(when public-key
{:json-rpc/call
[{:method (if ens-name? "wakuext_shareUserURLWithENS" "wakuext_shareUserURLWithData")
[{:method "wakuext_shareUserURLWithData"
:params [public-key]
:on-success (fn [url]
(rf/dispatch [:universal-links/save-profile-url public-key url])

View File

@ -45,8 +45,8 @@
(let [db {:profile/profile {:ens-name? true :public-key pubkey}}
rst (links/generate-profile-url {:db db} [])]
(are [result expected] (match? result expected)
"wakuext_shareUserURLWithENS" (-> rst :json-rpc/call first :method)
pubkey (-> rst :json-rpc/call first :params first)))))
"wakuext_shareUserURLWithData" (-> rst :json-rpc/call first :method)
pubkey (-> rst :json-rpc/call first :params first)))))
(testing "user has no ens name"
(testing "it calls the ens rpc method with public keyas param"
(let [db {:profile/profile {:public-key pubkey}}
@ -60,8 +60,8 @@
db {:contacts/contacts {pubkey {:ens-name ens}}}
rst (links/generate-profile-url {:db db} [{:public-key pubkey}])]
(are [result expected] (match? result expected)
"wakuext_shareUserURLWithENS" (-> rst :json-rpc/call first :method)
pubkey (-> rst :json-rpc/call first :params first)))))
"wakuext_shareUserURLWithData" (-> rst :json-rpc/call first :method)
pubkey (-> rst :json-rpc/call first :params first)))))
(testing "contact has no ens name"
(testing "it calls the ens rpc method with public keyas param"
(let [db {:contacts/contacts {pubkey {:public-key pubkey}}}

View File

@ -11,18 +11,18 @@
(defn items
[theme]
(let [profile (rf/sub [:profile/profile-with-image])
customization-color (rf/sub [:profile/customization-color])
bio (:bio profile)
full-name (profile.utils/displayed-name profile)]
(let [{:keys [bio ens-name?] :as profile} (rf/sub [:profile/profile-with-image])
customization-color (rf/sub [:profile/customization-color])
full-name (profile.utils/displayed-name profile)]
[{:label (i18n/label :t/profile)
:items [{:title (i18n/label :t/name)
:on-press #(rf/dispatch [:open-modal :edit-name])
:blur? true
:label :text
:label-props (utils/truncate-str full-name constants/profile-name-max-length)
:action :arrow
:container-style style/item-container}
:items [(cond-> {:title (i18n/label :t/name)
:blur? true
:label :text
:label-props (utils/truncate-str full-name constants/profile-name-max-length)
:container-style style/item-container}
(not ens-name?)
(assoc :on-press #(rf/dispatch [:open-modal :edit-name])
:action :arrow))
{:title (i18n/label :t/bio)
:on-press #(rf/dispatch [:open-modal :edit-bio])
:blur? true

View File

@ -1,7 +1,11 @@
(ns status-im.contexts.wallet.common.validation
(:require [status-im.constants :as constants]))
(:require [clojure.string :as string]
[status-im.constants :as constants]))
(defn ens-name? [s] (boolean (re-find constants/regx-ens s)))
(defn ens-name?
[s]
(and (not (string/blank? s))
(boolean (re-find constants/regx-ens s))))
(defn private-key?
[s]
(or (re-find constants/regx-private-key-hex s)