[wallet #11570] Handle non archival RPC node
This commit is contained in:
parent
35671226e4
commit
6c4097f521
|
@ -93,6 +93,16 @@
|
||||||
(defn network->chain-keyword [network]
|
(defn network->chain-keyword [network]
|
||||||
(chain-id->chain-keyword (network->chain-id 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]
|
(defn network->network-name [network]
|
||||||
(chain-id->chain-name (network->chain-id network)))
|
(chain-id->chain-name (network->chain-id network)))
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,10 @@
|
||||||
{:db (assoc db :wallet/fetching-error message)}
|
{:db (assoc db :wallet/fetching-error message)}
|
||||||
(wallet.core/stop-wallet)))
|
(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
|
(fx/defn new-wallet-event
|
||||||
[cofx {:keys [type blockNumber accounts newTransactions] :as event}]
|
[cofx {:keys [type blockNumber accounts newTransactions] :as event}]
|
||||||
(log/debug "[wallet-subs] new-wallet-event"
|
(log/debug "[wallet-subs] new-wallet-event"
|
||||||
|
@ -113,4 +117,5 @@
|
||||||
"recent-history-fetching" (recent-history-fetching-started cofx accounts)
|
"recent-history-fetching" (recent-history-fetching-started cofx accounts)
|
||||||
"recent-history-ready" (recent-history-fetching-ended cofx event)
|
"recent-history-ready" (recent-history-fetching-ended cofx event)
|
||||||
"fetching-history-error" (fetching-error 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)))
|
(log/warn ::unknown-wallet-event :type type :event event)))
|
||||||
|
|
|
@ -174,6 +174,7 @@
|
||||||
(reg-root-key-sub :wallet/refreshing-history? :wallet/refreshing-history?)
|
(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/buy-crypto-hidden :wallet/buy-crypto-hidden)
|
||||||
(reg-root-key-sub :wallet/fetching-error :wallet/fetching-error)
|
(reg-root-key-sub :wallet/fetching-error :wallet/fetching-error)
|
||||||
|
(reg-root-key-sub :wallet/non-archival-node :wallet/non-archival-node)
|
||||||
|
|
||||||
;;commands
|
;;commands
|
||||||
(reg-root-key-sub :commands/select-account :commands/select-account)
|
(reg-root-key-sub :commands/select-account :commands/select-account)
|
||||||
|
@ -362,6 +363,12 @@
|
||||||
(assoc network
|
(assoc network
|
||||||
:rpc-network? (get-in network [:config :UpstreamConfig :Enabled])))))
|
: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
|
(re-frame/reg-sub
|
||||||
:chain-keyword
|
:chain-keyword
|
||||||
:<- [:current-network]
|
:<- [:current-network]
|
||||||
|
@ -913,8 +920,8 @@
|
||||||
:<- [:multiaccount]
|
:<- [:multiaccount]
|
||||||
(fn [[contacts multiaccount] [_ id identicon]]
|
(fn [[contacts multiaccount] [_ id identicon]]
|
||||||
(let [contact (or (get contacts id)
|
(let [contact (or (get contacts id)
|
||||||
(when (= id (:public-key multiaccount)
|
(when (= id (:public-key multiaccount))
|
||||||
multiaccount))
|
multiaccount)
|
||||||
(if identicon
|
(if identicon
|
||||||
{:identicon identicon}
|
{:identicon identicon}
|
||||||
(contact.db/public-key->new-contact id)))]
|
(contact.db/public-key->new-contact id)))]
|
||||||
|
|
|
@ -106,15 +106,44 @@
|
||||||
{:style {:color colors/blue}}
|
{:style {:color colors/blue}}
|
||||||
(i18n/label :t/check-on-etherscan)]]]))
|
(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
|
(defn history-list
|
||||||
[transactions-history-sections address]
|
[transactions-history-sections address]
|
||||||
(let [fetching-recent-history? @(re-frame/subscribe [:wallet/fetching-recent-tx-history? 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])
|
fetching-more-history? @(re-frame/subscribe [:wallet/fetching-tx-history? address])
|
||||||
keycard-account? @(re-frame/subscribe [:multiaccounts/keycard-account?])
|
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])]
|
all-fetched? @(re-frame/subscribe [:wallet/tx-history-fetched? address])]
|
||||||
[react/view components.styles/flex
|
[react/view components.styles/flex
|
||||||
[etherscan-link address]
|
[etherscan-link address]
|
||||||
|
(cond non-archival-rpc-node?
|
||||||
|
[non-archival-node]
|
||||||
|
custom-rpc-node?
|
||||||
|
[custom-node])
|
||||||
(when fetching-recent-history?
|
(when fetching-recent-history?
|
||||||
[react/view
|
[react/view
|
||||||
{:style {:flex 1
|
{:style {:flex 1
|
||||||
|
|
|
@ -547,6 +547,21 @@
|
||||||
(def ms-10-min (datetime/minutes 10))
|
(def ms-10-min (datetime/minutes 10))
|
||||||
(def ms-20-min (datetime/minutes 20))
|
(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
|
(fx/defn stop-wallet
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(let [state (get db :wallet-service/state)
|
(let [state (get db :wallet-service/state)
|
||||||
|
@ -555,7 +570,7 @@
|
||||||
old-timeout
|
old-timeout
|
||||||
(utils.utils/set-timeout
|
(utils.utils/set-timeout
|
||||||
#(re-frame.core/dispatch [::restart])
|
#(re-frame.core/dispatch [::restart])
|
||||||
ms-20-min))]
|
(get-restart-interval db)))]
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(update :wallet dissoc :fetching)
|
(update :wallet dissoc :fetching)
|
||||||
(assoc :wallet-service/state :stopped)
|
(assoc :wallet-service/state :stopped)
|
||||||
|
@ -571,7 +586,7 @@
|
||||||
state (get db :wallet-service/state)
|
state (get db :wallet-service/state)
|
||||||
timeout (utils.utils/set-timeout
|
timeout (utils.utils/set-timeout
|
||||||
#(re-frame.core/dispatch [::restart])
|
#(re-frame.core/dispatch [::restart])
|
||||||
ms-20-min)]
|
(get-restart-interval db))]
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(assoc :wallet-service/state :started)
|
(assoc :wallet-service/state :started)
|
||||||
(assoc :wallet-service/restart-timeout timeout))
|
(assoc :wallet-service/restart-timeout timeout))
|
||||||
|
@ -647,7 +662,7 @@
|
||||||
timeout (utils.utils/set-timeout
|
timeout (utils.utils/set-timeout
|
||||||
(fn []
|
(fn []
|
||||||
(re-frame.core/dispatch [::stop-watching-txs]))
|
(re-frame.core/dispatch [::stop-watching-txs]))
|
||||||
ms-10-min)]
|
(get-watching-interval db))]
|
||||||
(fx/merge
|
(fx/merge
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(update :wallet/watch-txs (fnil conj #{}) tx-id)
|
(update :wallet/watch-txs (fnil conj #{}) tx-id)
|
||||||
|
|
|
@ -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.68.5",
|
"version": "v0.68.8",
|
||||||
"commit-sha1": "b5b1e19c2454ae1174915e6cb2fabaaa0955084c",
|
"commit-sha1": "d8bccaff1838b674be5fb362c601c8e122f01962",
|
||||||
"src-sha256": "0gm2mlcrh1al197yzl2b57p0xvwjbz2jb5cbiq7a3cn43gvvcqy0"
|
"src-sha256": "1487b2y849k535mskd81hzfhz622h588mbcmws0p2djhbcdnpvr4"
|
||||||
}
|
}
|
||||||
|
|
|
@ -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-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",
|
"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",
|
"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."
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue