[fix 5688] fix calculating node version

Signed-off-by: Adam Babik <a.babik@designfortress.com>
This commit is contained in:
Eric Dvorsak 2018-08-29 14:32:42 +02:00 committed by Adam Babik
parent e9399167f6
commit 1fff9d7c19
No known key found for this signature in database
GPG Key ID: ED02515A1FC0D1B4
3 changed files with 9 additions and 6 deletions

View File

@ -160,7 +160,9 @@
(defn initialize-account [address {:keys [web3] :as cofx}]
(handlers-macro/merge-fx cofx
{:web3/set-default-account [web3 address]
:web3/fetch-node-version web3
:web3/fetch-node-version [web3
#(re-frame/dispatch
[:web3/fetch-node-version-callback %])]
:notifications/get-fcm-token nil}
(initialize-account-db address)
(models.protocol/initialize-protocol address)

View File

@ -39,15 +39,15 @@
(ethereum/normalized-address address)))
(defn fetch-node-version
[web3]
[web3 cb]
(.. web3
-version
(getNode
(fn [err resp]
(when-not err
(re-frame/dispatch [:web3/fetch-node-version-callback resp]))))))
(cb resp))))))
(defn fetch-node-version-callback
[resp {:keys [db]}]
(when-let [git-commit (nth (re-find #"-([0-9a-f]{7,})/" resp) 1)]
{:db (assoc db :web3-node-version git-commit)}))
(when-let [node-version (second (re-find #"StatusIM/v(.*)/.*/.*" resp))]
{:db (assoc db :web3-node-version node-version)}))

View File

@ -20,7 +20,8 @@
(re-frame/reg-fx
:web3/fetch-node-version
web3/fetch-node-version)
(fn [[web3 cb]]
(web3/fetch-node-version web3 cb)))
;;;; Events
(handlers/register-handler-fx