[wallet #11860] Show preloaded tx history when app is offline
This commit is contained in:
parent
a8ae933604
commit
7c4c520712
|
@ -60,9 +60,13 @@
|
|||
[{:keys [db]} accounts]
|
||||
(log/debug "[wallet-subs] recent-history-fetching-started"
|
||||
"accounts" accounts)
|
||||
{:db (-> db
|
||||
(transactions/update-fetching-status accounts :recent? true)
|
||||
(assoc :wallet/recent-history-fetching-started? true))})
|
||||
(let [event (get db :wallet/on-recent-history-fetching)]
|
||||
(cond-> {:db (-> db
|
||||
(transactions/update-fetching-status accounts :recent? true)
|
||||
(assoc :wallet/recent-history-fetching-started? true)
|
||||
(dissoc :wallet/on-recent-history-fetching))}
|
||||
event
|
||||
(assoc :dispatch event))))
|
||||
|
||||
(fx/defn recent-history-fetching-ended
|
||||
[{:keys [db] :as cofx} {:keys [accounts blockNumber]}]
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
(ns status-im.ethereum.transactions.core
|
||||
(:require [re-frame.core :as re-frame]
|
||||
(:require [cljs.spec.alpha :as spec]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.ens.core :as ens]
|
||||
[status-im.ethereum.decode :as decode]
|
||||
[status-im.ethereum.eip55 :as eip55]
|
||||
[status-im.ethereum.encode :as encode]
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
[status-im.ens.core :as ens]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.mobile-sync :as utils.mobile-sync]
|
||||
[status-im.wallet.core :as wallet]
|
||||
[taoensso.timbre :as log]
|
||||
[cljs.spec.alpha :as spec]))
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def confirmations-count-threshold 12)
|
||||
|
||||
|
@ -207,8 +208,12 @@
|
|||
{:db (update-fetching-status db addresses :history? false)})
|
||||
|
||||
(fx/defn tx-history-end-reached
|
||||
[{:keys [db]} address]
|
||||
{:db (assoc-in db [:wallet :fetching address :all-fetched?] true)})
|
||||
[{:keys [db] :as cofx} address]
|
||||
(let [syncing-allowed? (utils.mobile-sync/syncing-allowed? cofx)]
|
||||
{:db (assoc-in db [:wallet :fetching address :all-fetched?]
|
||||
(if syncing-allowed?
|
||||
:all
|
||||
:all-preloaded))}))
|
||||
|
||||
(fx/defn handle-new-transfer
|
||||
[{:keys [db] :as cofx} transfers {:keys [address limit]}]
|
||||
|
@ -289,9 +294,10 @@
|
|||
(re-frame/reg-fx
|
||||
:transactions/get-transfers
|
||||
(fn [{:keys [chain-tokens addresses before-block limit
|
||||
limit-per-address]
|
||||
limit-per-address fetch-more?]
|
||||
:as params
|
||||
:or {limit default-transfers-limit}}]
|
||||
:or {limit default-transfers-limit
|
||||
fetch-more? true}}]
|
||||
{:pre [(spec/valid?
|
||||
(spec/coll-of string?)
|
||||
addresses)]}
|
||||
|
@ -299,13 +305,14 @@
|
|||
"addresses" addresses
|
||||
"block" before-block
|
||||
"limit" limit
|
||||
"limit-per-address" limit-per-address)
|
||||
"limit-per-address" limit-per-address
|
||||
"fetch-more?" fetch-more?)
|
||||
(doseq [address addresses]
|
||||
(let [limit (or (get limit-per-address address)
|
||||
limit)]
|
||||
(json-rpc/call
|
||||
{:method "wallet_getTransfersByAddress"
|
||||
:params [address (encode/uint before-block) (encode/uint limit)]
|
||||
:params [address (encode/uint before-block) (encode/uint limit) fetch-more?]
|
||||
:on-success #(re-frame/dispatch
|
||||
[::new-transfers
|
||||
(enrich-transfers chain-tokens %)
|
||||
|
@ -313,6 +320,9 @@
|
|||
:limit limit)])
|
||||
:on-error #(re-frame/dispatch [::tx-fetching-failed address])})))))
|
||||
|
||||
(defn some-transactions-loaded? [db address]
|
||||
(not-empty (get-in db [:wallet :accounts address :transactions])))
|
||||
|
||||
(fx/defn fetch-more-tx
|
||||
{:events [:transactions/fetch-more]}
|
||||
[{:keys [db] :as cofx} address]
|
||||
|
@ -326,6 +336,7 @@
|
|||
:addresses [address]
|
||||
:before-block min-known-block
|
||||
:historical? true
|
||||
:fetch-more? (utils.mobile-sync/syncing-allowed? cofx)
|
||||
;; Transfers are requested before and including `min-known-block` because
|
||||
;; there is no guarantee that all transfers from that block are shown
|
||||
;; already. To make sure that we fetch the whole `default-transfers-limit`
|
||||
|
@ -334,3 +345,10 @@
|
|||
:limit-per-address {address (+ default-transfers-limit
|
||||
min-block-transfers-count)}}}
|
||||
(tx-fetching-in-progress [address]))))
|
||||
|
||||
(fx/defn get-fetched-transfers
|
||||
[{:keys [db]}]
|
||||
{:transactions/get-transfers
|
||||
{:chain-tokens (:wallet/all-tokens db)
|
||||
:addresses (map :address (get db :multiaccount/accounts))
|
||||
:fetch-more? false}})
|
||||
|
|
|
@ -35,15 +35,17 @@
|
|||
{:view :mobile-network})
|
||||
(sheet-defaults)]
|
||||
|
||||
logged-in?
|
||||
[(mailserver/process-next-messages-request)
|
||||
(bottom-sheet/hide-bottom-sheet)]
|
||||
|
||||
;; NOTE(rasom): When we log into account on-network-status-change is
|
||||
;; dispatched, but that doesn't mean there was a status change, thus
|
||||
;; no reason to restart wallet.
|
||||
(and logged-in? initialized?)
|
||||
[(wallet/restart-wallet-service-default)]))))
|
||||
[(mailserver/process-next-messages-request)
|
||||
(bottom-sheet/hide-bottom-sheet)
|
||||
(wallet/restart-wallet-service {:force-start? true})]
|
||||
|
||||
logged-in?
|
||||
[(mailserver/process-next-messages-request)
|
||||
(bottom-sheet/hide-bottom-sheet)]))))
|
||||
|
||||
(defn apply-settings
|
||||
([sync?] (apply-settings sync? :default))
|
||||
|
@ -67,7 +69,7 @@
|
|||
:remember-syncing-choice? (boolean remember-choice?) {})
|
||||
(when (and cellular? sync?)
|
||||
(mailserver/process-next-messages-request))
|
||||
(wallet/restart-wallet-service-default))))))
|
||||
(wallet/restart-wallet-service {:force-start? true}))))))
|
||||
|
||||
(fx/defn mobile-network-continue-syncing
|
||||
{:events [:mobile-network/continue-syncing]}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
[status-im.contact.core :as contact]
|
||||
[status-im.data-store.settings :as data-store.settings]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.ethereum.transactions.core :as transactions]
|
||||
[status-im.ethereum.eip55 :as eip55]
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
[status-im.keycard.common :as keycard.common]
|
||||
|
@ -94,6 +95,8 @@
|
|||
|
||||
:else
|
||||
(wallet/update-balances nil scan-all-tokens?))
|
||||
(when-not (utils.mobile-sync/syncing-allowed? cofx)
|
||||
(transactions/get-fetched-transfers))
|
||||
(prices/update-prices)))
|
||||
|
||||
(fx/defn login
|
||||
|
|
|
@ -1705,6 +1705,7 @@
|
|||
(re-frame/subscribe [:wallet.transactions/all-filters?])])
|
||||
(fn [[transactions filters all-filters?] [_ address]]
|
||||
{:all-filters? all-filters?
|
||||
:total (count transactions)
|
||||
:transaction-history-sections
|
||||
(->> transactions
|
||||
vals
|
||||
|
@ -2506,3 +2507,13 @@
|
|||
:<- [:multiaccount]
|
||||
(fn [multiaccount]
|
||||
(pos? (count (get multiaccount :images)))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:mobile-network/syncing-allowed?
|
||||
:<- [:network/type]
|
||||
:<- [:multiaccount]
|
||||
(fn [[network-type {:keys [syncing-on-mobile-network?]}]]
|
||||
(or (= network-type "wifi")
|
||||
(and
|
||||
(= network-type "cellular")
|
||||
syncing-on-mobile-network?))))
|
||||
|
|
|
@ -95,9 +95,8 @@
|
|||
:accessory-text items-number}]))
|
||||
|
||||
(views/defview transactions [address]
|
||||
(views/letsubs [{:keys [transaction-history-sections]}
|
||||
[:wallet.transactions.history/screen address]]
|
||||
[history/history-list transaction-history-sections address]))
|
||||
(views/letsubs [data [:wallet.transactions.history/screen address]]
|
||||
[history/history-list data address]))
|
||||
|
||||
(defn collectibles-link []
|
||||
[react/touchable-highlight
|
||||
|
|
|
@ -131,13 +131,14 @@
|
|||
(i18n/label :t/non-archival-node)]])
|
||||
|
||||
(defn history-list
|
||||
[transactions-history-sections address]
|
||||
[{:keys [transaction-history-sections total]} 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])]
|
||||
all-fetched? @(re-frame/subscribe [:wallet/tx-history-fetched? address])
|
||||
syncing-allowed? @(re-frame/subscribe [:mobile-network/syncing-allowed?])]
|
||||
[react/view {:flex 1}
|
||||
[etherscan-link address]
|
||||
(cond non-archival-rpc-node?
|
||||
|
@ -152,7 +153,7 @@
|
|||
[react/activity-indicator {:size :large
|
||||
:animating true}]])
|
||||
[list/section-list
|
||||
{:sections transactions-history-sections
|
||||
{:sections transaction-history-sections
|
||||
:key-fn :hash
|
||||
:render-data {:keycard-account? keycard-account?}
|
||||
:render-fn render-transaction
|
||||
|
@ -162,7 +163,7 @@
|
|||
:transactions-history-loading
|
||||
:transactions-history-empty)}]}]
|
||||
(when (and (not fetching-recent-history?)
|
||||
(not all-fetched?))
|
||||
(not= all-fetched? :all))
|
||||
(if fetching-more-history?
|
||||
[react/view
|
||||
{:style {:flex 1
|
||||
|
@ -173,6 +174,9 @@
|
|||
[toolbar/toolbar
|
||||
{:center
|
||||
[quo/button {:type :secondary
|
||||
:disabled (and (not syncing-allowed?)
|
||||
(or (= all-fetched? :all-preloaded)
|
||||
(zero? total)))
|
||||
:on-press (when-not fetching-more-history?
|
||||
#(re-frame/dispatch
|
||||
[:transactions/fetch-more address]))}
|
||||
|
|
|
@ -6,5 +6,6 @@
|
|||
(defn syncing-allowed? [{:keys [db]}]
|
||||
(let [network (:network/type db)
|
||||
{:keys [syncing-on-mobile-network?]} (:multiaccount db)]
|
||||
(not (and (= network "cellular")
|
||||
(not syncing-on-mobile-network?)))))
|
||||
(or (= network "wifi")
|
||||
(and syncing-on-mobile-network?
|
||||
(= network "cellular")))))
|
||||
|
|
|
@ -614,7 +614,6 @@
|
|||
interval)))
|
||||
max-known-block (get db :wallet/max-known-block 0)]
|
||||
{:db (-> db
|
||||
(update :wallet dissoc :fetching)
|
||||
(assoc :wallet-service/state :stopped)
|
||||
(assoc :wallet/max-known-block max-known-block)
|
||||
(assoc :wallet-service/restart-timeout timeout)
|
||||
|
@ -624,7 +623,7 @@
|
|||
::stop-wallet nil}))
|
||||
|
||||
(fx/defn start-wallet
|
||||
[{:keys [db] :as cofx} watch-new-blocks?]
|
||||
[{:keys [db] :as cofx} watch-new-blocks? on-recent-history-fetching]
|
||||
(let [old-timeout (get db :wallet-service/restart-timeout)
|
||||
state (get db :wallet-service/state)
|
||||
timeout (when-let [interval (get-restart-interval db)]
|
||||
|
@ -634,14 +633,15 @@
|
|||
{:db (-> db
|
||||
(assoc :wallet-service/state :started
|
||||
:wallet-service/restart-timeout timeout
|
||||
:wallet/was-started? true))
|
||||
:wallet/was-started? true
|
||||
:wallet/on-recent-history-fetching on-recent-history-fetching))
|
||||
::start-wallet watch-new-blocks?
|
||||
::utils.utils/clear-timeouts
|
||||
[old-timeout]}))
|
||||
|
||||
(fx/defn restart-wallet-service
|
||||
[{:keys [db] :as cofx}
|
||||
{:keys [force-start? watch-new-blocks? ignore-syncing-settings?]}]
|
||||
{:keys [force-start? watch-new-blocks? ignore-syncing-settings? on-recent-history-fetching]}]
|
||||
(when (or force-start? (:multiaccount db))
|
||||
(let [watching-txs? (get db :wallet/watch-txs)
|
||||
waiting? (get db :wallet/waiting-for-recent-history?)
|
||||
|
@ -657,7 +657,7 @@
|
|||
waiting?
|
||||
force-start?
|
||||
watching-txs?))
|
||||
(start-wallet cofx (boolean (or watch-new-blocks? watching-txs?)))
|
||||
(start-wallet cofx (boolean (or watch-new-blocks? watching-txs?)) on-recent-history-fetching)
|
||||
(stop-wallet cofx)))))
|
||||
|
||||
(def background-cooldown-time (datetime/minutes 3))
|
||||
|
|
|
@ -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.73.9",
|
||||
"commit-sha1": "d22182ea8273db6b68b63abc16cf43d1da835f81",
|
||||
"src-sha256": "1wsz4d11vfvrz9ys1jx9ygynxjdxz1xvavhhgmwkzy8asvhm3gas"
|
||||
"version": "v0.73.10",
|
||||
"commit-sha1": "04fb7fdb3d62e4b26cc33d6e2d6182c4b358a0f8",
|
||||
"src-sha256": "10inpyrigj73i63r3c7608kzmqbcif9v1f8nysw9gvizvaaj80ns"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue