Resolve ENS names in the background
This commits resolves ENS names in the background, implementing retries and exponential backoff. All is handled in the background in status-go. Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
parent
76f9703afe
commit
b1ec418133
|
@ -178,39 +178,15 @@
|
||||||
:insert-gfycats [[public-key [:contacts/contacts public-key :name]]
|
:insert-gfycats [[public-key [:contacts/contacts public-key :name]]
|
||||||
[public-key [:contacts/contacts public-key :alias]]]}))
|
[public-key [:contacts/contacts public-key :alias]]]}))
|
||||||
|
|
||||||
(defn add-ens-names [contacts names]
|
|
||||||
(reduce-kv (fn [acc public-key-keyword result]
|
|
||||||
(let [verified (:verified result)
|
|
||||||
error (:error result)
|
|
||||||
ens-name (:name result)
|
|
||||||
ens-verified-at (:verifiedAt result)
|
|
||||||
public-key (str "0x" (name public-key-keyword))
|
|
||||||
contact (contact.db/public-key->contact contacts public-key)]
|
|
||||||
|
|
||||||
(if error
|
|
||||||
(assoc acc public-key contact)
|
|
||||||
(assoc acc public-key
|
|
||||||
(assoc contact
|
|
||||||
;; setting the name for now as ens-verification is not enabled because of geth 1.9 upgrade
|
|
||||||
:name ens-name
|
|
||||||
:ens-verified-at ens-verified-at
|
|
||||||
:ens-verified verified)))))
|
|
||||||
(or contacts {})
|
|
||||||
names))
|
|
||||||
|
|
||||||
(fx/defn names-verified
|
|
||||||
{:events [:contacts/ens-names-verified]}
|
|
||||||
[{:keys [db]} names]
|
|
||||||
{:db (update db :contacts/contacts add-ens-names names)})
|
|
||||||
|
|
||||||
(fx/defn name-verified
|
(fx/defn name-verified
|
||||||
{:events [:contacts/ens-name-verified]}
|
{:events [:contacts/ens-name-verified]}
|
||||||
[{:keys [db] :as cofx} public-key ens-name]
|
[{:keys [db now] :as cofx} public-key ens-name]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (update-in db [:contacts/contacts public-key]
|
{:db (update-in db [:contacts/contacts public-key]
|
||||||
merge
|
merge
|
||||||
{:name ens-name
|
{:name ens-name
|
||||||
:ens-verified-at (quot (time/timestamp) 1000)
|
:last-ens-clock-value now
|
||||||
|
:ens-verified-at now
|
||||||
:ens-verified true})}
|
:ens-verified true})}
|
||||||
|
|
||||||
(upsert-contact {:public-key public-key})))
|
(upsert-contact {:public-key public-key})))
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
:tributeToTalk :tribute-to-talk
|
:tributeToTalk :tribute-to-talk
|
||||||
:ensVerifiedAt :ens-verified-at
|
:ensVerifiedAt :ens-verified-at
|
||||||
:ensVerified :ens-verified
|
:ensVerified :ens-verified
|
||||||
|
:ensVerificationRetries :ens-verification-retries
|
||||||
|
:lastENSClockValue :last-ens-clock-value
|
||||||
:systemTags :system-tags
|
:systemTags :system-tags
|
||||||
:lastUpdated :last-updated})))
|
:lastUpdated :last-updated})))
|
||||||
|
|
||||||
|
@ -34,6 +36,8 @@
|
||||||
(clojure.set/rename-keys {:public-key :id
|
(clojure.set/rename-keys {:public-key :id
|
||||||
:ens-verified :ensVerified
|
:ens-verified :ensVerified
|
||||||
:ens-verified-at :ensVerifiedAt
|
:ens-verified-at :ensVerifiedAt
|
||||||
|
:last-ens-clock-value :lastENSClockValue
|
||||||
|
:ens-verification-retries :ensVerificationRetries
|
||||||
:photo-path :photoPath
|
:photo-path :photoPath
|
||||||
:tribute-to-talk :tributeToTalk
|
:tribute-to-talk :tributeToTalk
|
||||||
:system-tags :systemTags
|
:system-tags :systemTags
|
||||||
|
|
|
@ -131,6 +131,7 @@
|
||||||
:MailServerConfirmations config/mailserver-confirmations-enabled?
|
:MailServerConfirmations config/mailserver-confirmations-enabled?
|
||||||
:VerifyTransactionURL "https://mainnet.infura.io/v3/f315575765b14720b32382a61a89341a"
|
:VerifyTransactionURL "https://mainnet.infura.io/v3/f315575765b14720b32382a61a89341a"
|
||||||
:VerifyENSURL "https://mainnet.infura.io/v3/f315575765b14720b32382a61a89341a"
|
:VerifyENSURL "https://mainnet.infura.io/v3/f315575765b14720b32382a61a89341a"
|
||||||
|
:VerifyENSContractAddress "0x314159265dd8dbb310642f98f50c066173c1259b"
|
||||||
:VerifyTransactionChainID 1
|
:VerifyTransactionChainID 1
|
||||||
:DataSyncEnabled true
|
:DataSyncEnabled true
|
||||||
:PFSEnabled true}
|
:PFSEnabled true}
|
||||||
|
|
|
@ -36,9 +36,7 @@
|
||||||
(models.contact/ensure-contact cofx contact))
|
(models.contact/ensure-contact cofx contact))
|
||||||
|
|
||||||
(fx/defn handle-message [cofx message]
|
(fx/defn handle-message [cofx message]
|
||||||
(fx/merge cofx
|
(models.message/receive-one cofx message))
|
||||||
(models.message/receive-one message)
|
|
||||||
(ens/verify-names-from-message message (:from message))))
|
|
||||||
|
|
||||||
(fx/defn process-response [cofx response-js]
|
(fx/defn process-response [cofx response-js]
|
||||||
(let [chats (.-chats response-js)
|
(let [chats (.-chats response-js)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
|
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
|
||||||
"owner": "status-im",
|
"owner": "status-im",
|
||||||
"repo": "status-go",
|
"repo": "status-go",
|
||||||
"version": "v0.42.0",
|
"version": "develop",
|
||||||
"commit-sha1": "9cf640842b4d0266bcc1b30f6d776c250fdb5c04",
|
"commit-sha1": "v0.43.0",
|
||||||
"src-sha256": "0h8da2w3fbgrv6rmd4pib46r97g5q2wwg4a790f91dadsl67pmcl"
|
"src-sha256": "1pcsigvwlv1k4hnzfw2f7c9shhavinyqg6711xnq3jkr4j53j2p8"
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,30 +100,3 @@
|
||||||
(testing "the message is coming from us"
|
(testing "the message is coming from us"
|
||||||
(testing "it does not update contacts"
|
(testing "it does not update contacts"
|
||||||
(is (nil? (model/handle-contact-update {:db {:multiaccount {:public-key "me"}}} "me" 1 {})))))))
|
(is (nil? (model/handle-contact-update {:db {:multiaccount {:public-key "me"}}} "me" 1 {})))))))
|
||||||
|
|
||||||
(deftest add-ens-names-test
|
|
||||||
(with-redefs [gfycat/generate-gfy (constantly "generated")
|
|
||||||
identicon/identicon (constantly "generated")]
|
|
||||||
(testing "adding ens names"
|
|
||||||
(let [pk1 "048e57d37615380705cedf2eacc3543e7597eaed38c0bd0ff5b8c759406c657a29b4d6f4018ae323479dafa6bf1c821a422f2478a6759689afbca5e48fba720332"
|
|
||||||
pk2 "04318d20a2ca5fd0022579005ed24802e07d4ec610bede808dd13d3318af439e16d55be1a59af007a11120bd1c205861e5f53fe7b000a25e2b0d4eee7f0c5ebf7e"
|
|
||||||
expected {(str "0x" pk1) {:alias "generated"
|
|
||||||
:identicon "generated"
|
|
||||||
:name "name-1"
|
|
||||||
:ens-verified true
|
|
||||||
:ens-verified-at 1
|
|
||||||
:public-key (str "0x" pk1)
|
|
||||||
:system-tags #{}}
|
|
||||||
(str "0x" pk2) {:alias "generated"
|
|
||||||
:name "name-2"
|
|
||||||
:identicon "generated"
|
|
||||||
:ens-verified false
|
|
||||||
:ens-verified-at 2
|
|
||||||
:public-key (str "0x" pk2)
|
|
||||||
:system-tags #{}}}]
|
|
||||||
(is (= expected (model/add-ens-names {} {pk1 {:verified true
|
|
||||||
:name "name-1"
|
|
||||||
:verifiedAt 1}
|
|
||||||
pk2 {:verified false
|
|
||||||
:name "name-2"
|
|
||||||
:verifiedAt 2}})))))))
|
|
||||||
|
|
Loading…
Reference in New Issue