[wallet #11570] Handle non archival RPC node

This commit is contained in:
Roman Volosovskyi 2020-12-30 18:01:40 +02:00
parent 35671226e4
commit 6c4097f521
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
7 changed files with 78 additions and 10 deletions

View File

@ -93,6 +93,16 @@
(defn network->chain-keyword [network]
(chain-id->chain-keyword (network->chain-id network)))
(defn current-network [db]
(let [networks (get db :networks/networks)
network-id (get db :networks/current-network)]
(get networks network-id)))
(def custom-rpc-node-id-len 45)
(defn custom-rpc-node? [{:keys [id]}]
(= custom-rpc-node-id-len (count id)))
(defn network->network-name [network]
(chain-id->chain-name (network->chain-id network)))

View File

@ -101,6 +101,10 @@
{:db (assoc db :wallet/fetching-error message)}
(wallet.core/stop-wallet)))
(fx/defn non-archival-node-detected
[{:keys [db] :as cofx} _]
{:db (assoc db :wallet/non-archival-node true)})
(fx/defn new-wallet-event
[cofx {:keys [type blockNumber accounts newTransactions] :as event}]
(log/debug "[wallet-subs] new-wallet-event"
@ -113,4 +117,5 @@
"recent-history-fetching" (recent-history-fetching-started cofx accounts)
"recent-history-ready" (recent-history-fetching-ended cofx event)
"fetching-history-error" (fetching-error cofx event)
"non-archival-node-detected" (non-archival-node-detected cofx event)
(log/warn ::unknown-wallet-event :type type :event event)))

View File

@ -174,6 +174,7 @@
(reg-root-key-sub :wallet/refreshing-history? :wallet/refreshing-history?)
(reg-root-key-sub :wallet/buy-crypto-hidden :wallet/buy-crypto-hidden)
(reg-root-key-sub :wallet/fetching-error :wallet/fetching-error)
(reg-root-key-sub :wallet/non-archival-node :wallet/non-archival-node)
;;commands
(reg-root-key-sub :commands/select-account :commands/select-account)
@ -362,6 +363,12 @@
(assoc network
:rpc-network? (get-in network [:config :UpstreamConfig :Enabled])))))
(re-frame/reg-sub
:custom-rpc-node
:<- [:current-network]
(fn [network]
(ethereum/custom-rpc-node? network)))
(re-frame/reg-sub
:chain-keyword
:<- [:current-network]
@ -913,8 +920,8 @@
:<- [:multiaccount]
(fn [[contacts multiaccount] [_ id identicon]]
(let [contact (or (get contacts id)
(when (= id (:public-key multiaccount)
multiaccount))
(when (= id (:public-key multiaccount))
multiaccount)
(if identicon
{:identicon identicon}
(contact.db/public-key->new-contact id)))]

View File

@ -106,15 +106,44 @@
{:style {:color colors/blue}}
(i18n/label :t/check-on-etherscan)]]]))
(defn custom-node []
[react/view
{:style {:flex 1
:padding-horizontal 14
:flex-direction :row
:align-items :center
:background-color (quo/get-color :warning-02)
:height 52}}
[react/text
{:style {:color (quo/get-color :warning-01)}}
(i18n/label :t/custom-node)]])
(defn non-archival-node []
[react/view
{:style {:flex 1
:padding-horizontal 14
:flex-direction :row
:align-items :center
:background-color (quo/get-color :negative-02)
:height 52}}
[react/text
{:style {:color (quo/get-color :negative-01)}}
(i18n/label :t/non-archival-node)]])
(defn history-list
[transactions-history-sections address]
(let [fetching-recent-history? @(re-frame/subscribe [:wallet/fetching-recent-tx-history? address])
fetching-more-history? @(re-frame/subscribe [:wallet/fetching-tx-history? address])
keycard-account? @(re-frame/subscribe [:multiaccounts/keycard-account?])
custom-rpc-node? @(re-frame/subscribe [:custom-rpc-node])
non-archival-rpc-node? @(re-frame/subscribe [:wallet/non-archival-node])
all-fetched? @(re-frame/subscribe [:wallet/tx-history-fetched? address])]
[react/view components.styles/flex
[etherscan-link address]
(cond non-archival-rpc-node?
[non-archival-node]
custom-rpc-node?
[custom-node])
(when fetching-recent-history?
[react/view
{:style {:flex 1

View File

@ -547,6 +547,21 @@
(def ms-10-min (datetime/minutes 10))
(def ms-20-min (datetime/minutes 20))
(def ms-2-min (datetime/minutes 2))
(def ms-4-min (datetime/minutes 4))
(defn get-restart-interval [db]
(if (ethereum/custom-rpc-node?
(ethereum/current-network db))
ms-4-min
ms-20-min))
(defn get-watching-interval [db]
(if (ethereum/custom-rpc-node?
(ethereum/current-network db))
ms-2-min
ms-10-min))
(fx/defn stop-wallet
[{:keys [db] :as cofx}]
(let [state (get db :wallet-service/state)
@ -555,7 +570,7 @@
old-timeout
(utils.utils/set-timeout
#(re-frame.core/dispatch [::restart])
ms-20-min))]
(get-restart-interval db)))]
{:db (-> db
(update :wallet dissoc :fetching)
(assoc :wallet-service/state :stopped)
@ -571,7 +586,7 @@
state (get db :wallet-service/state)
timeout (utils.utils/set-timeout
#(re-frame.core/dispatch [::restart])
ms-20-min)]
(get-restart-interval db))]
{:db (-> db
(assoc :wallet-service/state :started)
(assoc :wallet-service/restart-timeout timeout))
@ -647,7 +662,7 @@
timeout (utils.utils/set-timeout
(fn []
(re-frame.core/dispatch [::stop-watching-txs]))
ms-10-min)]
(get-watching-interval db))]
(fx/merge
{:db (-> db
(update :wallet/watch-txs (fnil conj #{}) tx-id)

View File

@ -2,7 +2,7 @@
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
"owner": "status-im",
"repo": "status-go",
"version": "v0.68.5",
"commit-sha1": "b5b1e19c2454ae1174915e6cb2fabaaa0955084c",
"src-sha256": "0gm2mlcrh1al197yzl2b57p0xvwjbz2jb5cbiq7a3cn43gvvcqy0"
"version": "v0.68.8",
"commit-sha1": "d8bccaff1838b674be5fb362c601c8e122f01962",
"src-sha256": "1487b2y849k535mskd81hzfhz622h588mbcmws0p2djhbcdnpvr4"
}

View File

@ -1401,5 +1401,7 @@
"transfer-ma-unknown-error-desc-1": "It looks like your multiaccount was not deleted. Database may have been reset",
"transfer-ma-unknown-error-desc-2": "Please check your account list and try again. If the account is not listed go to Access existing keys to recover with seed phrase",
"everyone": "Everyone",
"show-profile-pictures": "Show profile pictures of"
"show-profile-pictures": "Show profile pictures of",
"non-archival-node": "RPC endpoint doesn't support archival requests. Your local transfers history might be incomplete.",
"custom-node": "You are using custom RPC endpoint. Your local transfers history might be incomplete."
}