[wallet history] Stop watching each new block
This commit is contained in:
parent
166bdbf798
commit
7bfaa9255c
|
@ -1145,9 +1145,9 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||
}
|
||||
|
||||
@ReactMethod
|
||||
public void startWallet() {
|
||||
public void startWallet(final boolean watchNewBlocks) {
|
||||
Log.d(TAG, "StartWallet");
|
||||
Statusgo.startWallet();
|
||||
Statusgo.startWallet(watchNewBlocks);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
|
|
|
@ -747,11 +747,11 @@ RCT_EXPORT_METHOD(stopWallet) {
|
|||
StatusgoStopWallet();
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(startWallet) {
|
||||
RCT_EXPORT_METHOD(startWallet:(BOOL)watchNewBlocks) {
|
||||
#if DEBUG
|
||||
NSLog(@"StartWallet() method called");
|
||||
#endif
|
||||
StatusgoStartWallet();
|
||||
StatusgoStartWallet(watchNewBlocks);
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(stopLocalNotifications) {
|
||||
|
|
|
@ -193,7 +193,6 @@
|
|||
(or (:clock-value last-message)
|
||||
deleted-at-clock-value
|
||||
(utils.clocks/send 0)))]
|
||||
(println :FOOO last-message-clock-value public? remove-chat?)
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (-> db
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
[status-im.ui.screens.chat.state :as view.state]
|
||||
[status-im.utils.fx :as fx]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.chat.models.mentions :as mentions]))
|
||||
[status-im.chat.models.mentions :as mentions]
|
||||
[clojure.string :as string]))
|
||||
|
||||
(defn- prepare-message
|
||||
[message current-chat?]
|
||||
|
@ -147,6 +148,15 @@
|
|||
assoc
|
||||
:unviewed-messages-count (inc current-count))}))))
|
||||
|
||||
(fx/defn check-for-incoming-tx
|
||||
[cofx {{:keys [transaction-hash]} :command-parameters}]
|
||||
(when (and transaction-hash
|
||||
(not (string/blank? transaction-hash)))
|
||||
;; NOTE(rasom): dispatch later is needed because of circular dependency
|
||||
{:dispatch-later
|
||||
[{:dispatch [:watch-tx transaction-hash]
|
||||
:ms 20}]}))
|
||||
|
||||
(fx/defn receive-one
|
||||
{:events [::receive-one]}
|
||||
[{:keys [db] :as cofx} {:keys [message-id] :as message}]
|
||||
|
@ -165,7 +175,8 @@
|
|||
(fx/merge cofx
|
||||
(add-received-message message-with-chat-id)
|
||||
(update-unviewed-count message-with-chat-id)
|
||||
(chat-model/join-time-messages-checked chat-id))))))))
|
||||
(chat-model/join-time-messages-checked chat-id)
|
||||
(check-for-incoming-tx message-with-chat-id))))))))
|
||||
|
||||
;;TODO currently we process every message, we need to precess them by batches
|
||||
;;or better move processing to status-go
|
||||
|
|
|
@ -65,7 +65,8 @@
|
|||
{:db (-> db
|
||||
(update-in [:wallet :accounts]
|
||||
wallet/remove-transactions-since-block blockNumber)
|
||||
(transactions/update-fetching-status accounts :recent? false))
|
||||
(transactions/update-fetching-status accounts :recent? false)
|
||||
(dissoc :wallet/waiting-for-recent-history?))
|
||||
:transactions/get-transfers
|
||||
{:chain-tokens (:wallet/all-tokens db)
|
||||
:addresses (reduce
|
||||
|
@ -80,7 +81,7 @@
|
|||
:before-block blockNumber
|
||||
:limit 20
|
||||
:historical? true}}
|
||||
(wallet.core/restart-wallet-service)))
|
||||
(wallet.core/restart-wallet-service false false)))
|
||||
|
||||
(fx/defn new-wallet-event
|
||||
[cofx {:keys [type blockNumber accounts newTransactions] :as event}]
|
||||
|
|
|
@ -222,6 +222,12 @@
|
|||
(seq transfers)
|
||||
(concat (mapv add-transfer transfers))
|
||||
|
||||
(seq transfers)
|
||||
(concat
|
||||
(mapv (fn [{:keys [hash]}]
|
||||
(wallet/stop-watching-tx hash))
|
||||
transfers))
|
||||
|
||||
true
|
||||
(conj (wallet/update-balances
|
||||
(into [] (reduce (fn [acc {:keys [address block]}]
|
||||
|
|
|
@ -1184,14 +1184,19 @@
|
|||
(dissoc :app-in-background-since)
|
||||
(assoc :app-active-since now))}
|
||||
(mailserver/process-next-messages-request)
|
||||
(wallet/restart-wallet-service true false)
|
||||
#(when requires-bio-auth
|
||||
(biometric/authenticate % on-biometric-auth-result authentication-options)))))
|
||||
|
||||
(fx/defn on-going-in-background [{:keys [db now]}]
|
||||
{:db (-> db
|
||||
(dissoc :app-active-since)
|
||||
(assoc :app-in-background-since now))
|
||||
:dispatch-n [[:audio-recorder/on-background] [:audio-message/on-background]]})
|
||||
(fx/defn on-going-in-background
|
||||
[{:keys [db now] :as cofx}]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (-> db
|
||||
(dissoc :app-active-since)
|
||||
(assoc :app-in-background-since now))
|
||||
:dispatch-n [[:audio-recorder/on-background] [:audio-message/on-background]]}
|
||||
(wallet/clear-timeouts)))
|
||||
|
||||
(defn app-state-change [state {:keys [db] :as cofx}]
|
||||
(let [app-coming-from-background? (= state "active")
|
||||
|
|
|
@ -310,14 +310,15 @@
|
|||
:card-read-in-progress?
|
||||
:pin
|
||||
:multiaccount)
|
||||
(assoc :logged-in-since now))
|
||||
(assoc :logged-in-since now)
|
||||
(assoc :wallet/waiting-for-recent-history? true))
|
||||
::json-rpc/call
|
||||
[{:method "web3_clientVersion"
|
||||
:on-success #(re-frame/dispatch [::initialize-web3-client-version %])}]}
|
||||
;;FIXME
|
||||
(when nodes
|
||||
(fleet/set-nodes :eth.contract nodes))
|
||||
(wallet/restart-wallet-service)
|
||||
(wallet/restart-wallet-service true false)
|
||||
(if login-only?
|
||||
(login-only-events key-uid password save-password?)
|
||||
(create-only-events))
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
[status-im.utils.fx :as fx]
|
||||
[status-im.multiaccounts.core :as multiaccounts]
|
||||
[status-im.utils.keychain.core :as keychain]
|
||||
[status-im.notifications.core :as notifications]))
|
||||
[status-im.notifications.core :as notifications]
|
||||
[status-im.wallet.core :as wallet]))
|
||||
|
||||
(fx/defn logout-method
|
||||
[{:keys [db] :as cofx} {:keys [auth-method logout?]}]
|
||||
|
@ -22,6 +23,7 @@
|
|||
(notifications/logout-disable)
|
||||
(keychain/save-auth-method key-uid auth-method)
|
||||
(transport/stop-whisper)
|
||||
(wallet/clear-timeouts)
|
||||
(chaos-mode/stop-checking)
|
||||
(init/initialize-app-db))))
|
||||
|
||||
|
|
|
@ -267,9 +267,9 @@
|
|||
(log/debug "[native-module] stop-wallet")
|
||||
(.stopWallet ^js (status)))
|
||||
|
||||
(defn start-wallet []
|
||||
(log/debug "[native-module] start-wallet")
|
||||
(.startWallet ^js (status)))
|
||||
(defn start-wallet [watch-new-blocks?]
|
||||
(log/debug "[native-module] start-wallet" watch-new-blocks?)
|
||||
(.startWallet ^js (status) watch-new-blocks?))
|
||||
|
||||
(defn stop-local-notifications []
|
||||
(log/debug "[native-module] stop-local-notifications")
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
[status-im.utils.types :as types]
|
||||
[status-im.utils.utils :as utils]
|
||||
[status-im.wallet.prices :as prices]
|
||||
[status-im.wallet.core :as wallet]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
|
@ -247,6 +248,7 @@
|
|||
:signing/show-transaction-result nil}
|
||||
(prepare-unconfirmed-transaction result tx-obj symbol amount)
|
||||
(check-queue)
|
||||
(wallet/watch-tx result)
|
||||
#(when on-result
|
||||
{:dispatch (conj on-result result)}))))
|
||||
|
||||
|
@ -259,6 +261,7 @@
|
|||
(fx/merge
|
||||
cofx
|
||||
{:db (dissoc db :signing/tx :signing/sign)}
|
||||
(wallet/watch-tx transaction-hash)
|
||||
(if (keycard.common/keycard-multiaccount? db)
|
||||
(signing.keycard/hash-message
|
||||
{:data data
|
||||
|
@ -335,7 +338,6 @@
|
|||
[cofx response tx-obj hashed-password]
|
||||
(let [cofx-in-progress-false (assoc-in cofx [:db :signing/sign :in-progress?] false)
|
||||
{:keys [result error]} (types/json->clj response)]
|
||||
(log/debug "transaction-completed" error tx-obj)
|
||||
(if error
|
||||
(transaction-error cofx-in-progress-false error)
|
||||
(if (:command? tx-obj)
|
||||
|
@ -379,3 +381,90 @@
|
|||
:data (abi-spec/encode method params)}
|
||||
:on-result on-result
|
||||
:on-error on-error}))
|
||||
|
||||
(fx/defn sign-transaction-button-clicked-from-chat
|
||||
{:events [:wallet.ui/sign-transaction-button-clicked-from-chat]}
|
||||
[{:keys [db] :as cofx} {:keys [to amount from token]}]
|
||||
(let [{:keys [symbol address]} token
|
||||
amount-hex (str "0x" (abi-spec/number-to-hex amount))
|
||||
to-norm (ethereum/normalized-hex (if (string? to) to (:address to)))
|
||||
from-address (:address from)
|
||||
identity (:current-chat-id db)
|
||||
db (dissoc db :wallet/prepare-transaction)]
|
||||
(if to-norm
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db db}
|
||||
(sign {:tx-obj (if (= symbol :ETH)
|
||||
{:to to-norm
|
||||
:from from-address
|
||||
:chat-id identity
|
||||
:command? true
|
||||
:value amount-hex}
|
||||
{:to (ethereum/normalized-hex address)
|
||||
:from from-address
|
||||
:chat-id identity
|
||||
:command? true
|
||||
:data (abi-spec/encode
|
||||
"transfer(address,uint256)"
|
||||
[to-norm amount-hex])})}))
|
||||
{:db db
|
||||
::json-rpc/call
|
||||
[{:method (json-rpc/call-ext-method "requestAddressForTransaction")
|
||||
:params [(:current-chat-id db)
|
||||
from-address
|
||||
amount
|
||||
(when-not (= symbol :ETH)
|
||||
address)]
|
||||
:on-success #(re-frame/dispatch [:transport/message-sent % 1])}]})))
|
||||
|
||||
(fx/defn sign-transaction-button-clicked-from-request
|
||||
{:events [:wallet.ui/sign-transaction-button-clicked-from-request]}
|
||||
[{:keys [db] :as cofx} {:keys [amount from token]}]
|
||||
(let [{:keys [request-parameters chat-id]} (:wallet/prepare-transaction db)
|
||||
{:keys [symbol address]} token
|
||||
amount-hex (str "0x" (abi-spec/number-to-hex amount))
|
||||
to-norm (:address request-parameters)
|
||||
from-address (:address from)]
|
||||
(fx/merge cofx
|
||||
{:db (dissoc db :wallet/prepare-transaction)}
|
||||
(fn [cofx]
|
||||
(sign
|
||||
cofx
|
||||
{:tx-obj (if (= symbol :ETH)
|
||||
{:to to-norm
|
||||
:from from-address
|
||||
:message-id (:id request-parameters)
|
||||
:chat-id chat-id
|
||||
:command? true
|
||||
:value amount-hex}
|
||||
{:to (ethereum/normalized-hex address)
|
||||
:from from-address
|
||||
:command? true
|
||||
:message-id (:id request-parameters)
|
||||
:chat-id chat-id
|
||||
:data (abi-spec/encode
|
||||
"transfer(address,uint256)"
|
||||
[to-norm amount-hex])})})))))
|
||||
|
||||
(fx/defn sign-transaction-button-clicked
|
||||
{:events [:wallet.ui/sign-transaction-button-clicked]}
|
||||
[{:keys [db] :as cofx} {:keys [to amount from token gas gasPrice]}]
|
||||
(let [{:keys [symbol address]} token
|
||||
amount-hex (str "0x" (abi-spec/number-to-hex amount))
|
||||
to-norm (ethereum/normalized-hex (if (string? to) to (:address to)))
|
||||
from-address (:address from)]
|
||||
(fx/merge cofx
|
||||
{:db (dissoc db :wallet/prepare-transaction)}
|
||||
(sign
|
||||
{:tx-obj (merge {:from from-address
|
||||
;;gas and gasPrice from qr (eip681)
|
||||
:gas gas
|
||||
:gasPrice gasPrice}
|
||||
(if (= symbol :ETH)
|
||||
{:to to-norm
|
||||
:value amount-hex}
|
||||
{:to (ethereum/normalized-hex address)
|
||||
:data (abi-spec/encode
|
||||
"transfer(address,uint256)"
|
||||
[to-norm amount-hex])}))}))))
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
logged-in?
|
||||
[(mailserver/process-next-messages-request)
|
||||
(bottom-sheet/hide-bottom-sheet)
|
||||
(wallet/restart-wallet-service)]))))
|
||||
(wallet/restart-wallet-service false false)]))))
|
||||
|
||||
(defn apply-settings
|
||||
([sync?] (apply-settings sync? :default))
|
||||
|
@ -62,7 +62,7 @@
|
|||
(bottom-sheet/hide-bottom-sheet)
|
||||
(when (and cellular? sync?)
|
||||
(mailserver/process-next-messages-request))
|
||||
(wallet/restart-wallet-service))))))
|
||||
(wallet/restart-wallet-service false false))))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:mobile-network/continue-syncing
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
[status-im.ui.components.topbar :as topbar]
|
||||
[status-im.ui.screens.wallet.transactions.styles :as styles]
|
||||
[quo.core :as quo]
|
||||
[status-im.ui.components.toolbar :as toolbar])
|
||||
[status-im.ui.components.toolbar :as toolbar]
|
||||
[status-im.wallet.core :as wallet])
|
||||
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
|
||||
|
||||
(defn- transaction-icon
|
||||
|
@ -95,6 +96,20 @@
|
|||
{:style {:color colors/blue}}
|
||||
(i18n/label :t/check-on-etherscan)]]]))
|
||||
|
||||
(defn refresh []
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch [::wallet/restart])}
|
||||
[react/view
|
||||
{:style {:flex 1
|
||||
:padding-horizontal 14
|
||||
:flex-direction :row
|
||||
:align-items :center
|
||||
:background-color colors/blue-light
|
||||
:height 52}}
|
||||
[react/text
|
||||
{:style {:color colors/blue}}
|
||||
(i18n/label :t/refresh)]]])
|
||||
|
||||
(defn history-list
|
||||
[transactions-history-sections address]
|
||||
(let [fetching-recent-history? @(re-frame/subscribe [:wallet/fetching-recent-tx-history? address])
|
||||
|
@ -102,6 +117,7 @@
|
|||
all-fetched? @(re-frame/subscribe [:wallet/tx-history-fetched? address])]
|
||||
[react/view components.styles/flex
|
||||
[etherscan-link address]
|
||||
[refresh]
|
||||
(when fetching-recent-history?
|
||||
[react/view
|
||||
{:style {:flex 1
|
||||
|
|
|
@ -103,6 +103,13 @@
|
|||
(defn clear-timeout [id]
|
||||
(.clearTimeout background-timer id))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::clear-timeouts
|
||||
(fn [ids]
|
||||
(doseq [id ids]
|
||||
(when id
|
||||
(clear-timeout id)))))
|
||||
|
||||
(defn set-interval [cb ms]
|
||||
(.setInterval background-timer cb ms))
|
||||
|
||||
|
@ -121,4 +128,4 @@
|
|||
|
||||
(defn safe-replace [s m r]
|
||||
(when (string? s)
|
||||
(string/replace s m r)))
|
||||
(string/replace s m r)))
|
||||
|
|
|
@ -183,7 +183,7 @@
|
|||
(fx/merge cofx
|
||||
{::json-rpc/call [{:method "accounts_saveAccounts"
|
||||
:params [[account]]
|
||||
:on-success #()}]
|
||||
:on-success #(re-frame/dispatch [::wallet/restart])}]
|
||||
:db (-> db
|
||||
(assoc :multiaccount/accounts new-accounts)
|
||||
(dissoc :add-account))}
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
[status-im.utils.utils :as utils.utils]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.wallet.db :as wallet.db]
|
||||
[status-im.ethereum.abi-spec :as abi-spec]
|
||||
[status-im.signing.core :as signing]
|
||||
[clojure.string :as string]
|
||||
[status-im.contact.db :as contact.db]
|
||||
[status-im.ethereum.ens :as ens]
|
||||
|
@ -350,42 +348,6 @@
|
|||
[{:keys [db]} amount]
|
||||
{:db (assoc-in db [:wallet/prepare-transaction :amount-text] amount)})
|
||||
|
||||
(fx/defn sign-transaction-button-clicked-from-chat
|
||||
{:events [:wallet.ui/sign-transaction-button-clicked-from-chat]}
|
||||
[{:keys [db] :as cofx} {:keys [to amount from token]}]
|
||||
(let [{:keys [symbol address]} token
|
||||
amount-hex (str "0x" (abi-spec/number-to-hex amount))
|
||||
to-norm (ethereum/normalized-hex (if (string? to) to (:address to)))
|
||||
from-address (:address from)
|
||||
identity (:current-chat-id db)
|
||||
db (dissoc db :wallet/prepare-transaction)]
|
||||
(if to-norm
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db db}
|
||||
(signing/sign {:tx-obj (if (= symbol :ETH)
|
||||
{:to to-norm
|
||||
:from from-address
|
||||
:chat-id identity
|
||||
:command? true
|
||||
:value amount-hex}
|
||||
{:to (ethereum/normalized-hex address)
|
||||
:from from-address
|
||||
:chat-id identity
|
||||
:command? true
|
||||
:data (abi-spec/encode
|
||||
"transfer(address,uint256)"
|
||||
[to-norm amount-hex])})}))
|
||||
{:db db
|
||||
::json-rpc/call
|
||||
[{:method (json-rpc/call-ext-method "requestAddressForTransaction")
|
||||
:params [(:current-chat-id db)
|
||||
from-address
|
||||
amount
|
||||
(when-not (= symbol :ETH)
|
||||
address)]
|
||||
:on-success #(re-frame/dispatch [:transport/message-sent % 1])}]})))
|
||||
|
||||
(fx/defn request-transaction-button-clicked-from-chat
|
||||
{:events [:wallet.ui/request-transaction-button-clicked]}
|
||||
[{:keys [db] :as cofx} {:keys [to amount from token]}]
|
||||
|
@ -430,57 +392,6 @@
|
|||
:from-chat? true})
|
||||
:dispatch [:navigate-to :prepare-send-transaction]}))
|
||||
|
||||
(fx/defn sign-transaction-button-clicked-from-request
|
||||
{:events [:wallet.ui/sign-transaction-button-clicked-from-request]}
|
||||
[{:keys [db] :as cofx} {:keys [amount from token]}]
|
||||
(let [{:keys [request-parameters chat-id]} (:wallet/prepare-transaction db)
|
||||
{:keys [symbol address]} token
|
||||
amount-hex (str "0x" (abi-spec/number-to-hex amount))
|
||||
to-norm (:address request-parameters)
|
||||
from-address (:address from)]
|
||||
(fx/merge cofx
|
||||
{:db (dissoc db :wallet/prepare-transaction)}
|
||||
(fn [cofx]
|
||||
(signing/sign
|
||||
cofx
|
||||
{:tx-obj (if (= symbol :ETH)
|
||||
{:to to-norm
|
||||
:from from-address
|
||||
:message-id (:id request-parameters)
|
||||
:chat-id chat-id
|
||||
:command? true
|
||||
:value amount-hex}
|
||||
{:to (ethereum/normalized-hex address)
|
||||
:from from-address
|
||||
:command? true
|
||||
:message-id (:id request-parameters)
|
||||
:chat-id chat-id
|
||||
:data (abi-spec/encode
|
||||
"transfer(address,uint256)"
|
||||
[to-norm amount-hex])})})))))
|
||||
|
||||
(fx/defn sign-transaction-button-clicked
|
||||
{:events [:wallet.ui/sign-transaction-button-clicked]}
|
||||
[{:keys [db] :as cofx} {:keys [to amount from token gas gasPrice]}]
|
||||
(let [{:keys [symbol address]} token
|
||||
amount-hex (str "0x" (abi-spec/number-to-hex amount))
|
||||
to-norm (ethereum/normalized-hex (if (string? to) to (:address to)))
|
||||
from-address (:address from)]
|
||||
(fx/merge cofx
|
||||
{:db (dissoc db :wallet/prepare-transaction)}
|
||||
(signing/sign
|
||||
{:tx-obj (merge {:from from-address
|
||||
;;gas and gasPrice from qr (eip681)
|
||||
:gas gas
|
||||
:gasPrice gasPrice}
|
||||
(if (= symbol :ETH)
|
||||
{:to to-norm
|
||||
:value amount-hex}
|
||||
{:to (ethereum/normalized-hex address)
|
||||
:data (abi-spec/encode
|
||||
"transfer(address,uint256)"
|
||||
[to-norm amount-hex])}))}))))
|
||||
|
||||
(fx/defn set-and-validate-amount-request
|
||||
{:events [:wallet.request/set-and-validate-amount]}
|
||||
[{:keys [db]} amount symbol decimals]
|
||||
|
@ -629,28 +540,106 @@
|
|||
|
||||
(re-frame/reg-fx
|
||||
::start-wallet
|
||||
(fn []
|
||||
(log/info "start-wallet fx")
|
||||
(status/start-wallet)))
|
||||
(fn [watch-new-blocks?]
|
||||
(log/info "start-wallet fx" watch-new-blocks?)
|
||||
(status/start-wallet watch-new-blocks?)))
|
||||
|
||||
(def ms-10-min (* 10 60 1000))
|
||||
(def ms-20-min (* 20 60 1000))
|
||||
|
||||
(fx/defn stop-wallet
|
||||
[{:keys [db] :as cofx}]
|
||||
(let []
|
||||
{:db (assoc db :wallet-service/state :stopped)
|
||||
(let [state (get db :wallet-service/state)
|
||||
old-timeout (get db :wallet-service/restart-timeout)
|
||||
timeout (or
|
||||
old-timeout
|
||||
(utils.utils/set-timeout
|
||||
#(re-frame.core/dispatch [::restart])
|
||||
ms-20-min))]
|
||||
{:db (-> db
|
||||
(assoc :wallet-service/state :stopped)
|
||||
(assoc :wallet-service/restart-timeout timeout))
|
||||
::stop-wallet nil}))
|
||||
|
||||
(fx/defn start-wallet
|
||||
[{:keys [db] :as cofx}]
|
||||
(let []
|
||||
{:db (assoc db :wallet-service/state :started)
|
||||
::start-wallet nil}))
|
||||
[{:keys [db] :as cofx} watch-new-blocks?]
|
||||
(let [old-timeout (get db :wallet-service/restart-timeout)
|
||||
state (get db :wallet-service/state)
|
||||
timeout (utils.utils/set-timeout
|
||||
#(re-frame.core/dispatch [::restart])
|
||||
ms-20-min)]
|
||||
{:db (-> db
|
||||
(assoc :wallet-service/state :started)
|
||||
(assoc :wallet-service/restart-timeout timeout))
|
||||
::start-wallet watch-new-blocks?
|
||||
::utils.utils/clear-timeouts
|
||||
[old-timeout]}))
|
||||
|
||||
(fx/defn restart-wallet-service
|
||||
[{:keys [db] :as cofx}]
|
||||
(when (:multiaccount db)
|
||||
(let [syncing-allowed? (mobile-network-utils/syncing-allowed? cofx)]
|
||||
[{:keys [db] :as cofx} force-start? watch-new-blocks?]
|
||||
(when (or force-start? (:multiaccount db))
|
||||
(let [watching-txs? (get db :wallet/watch-txs)
|
||||
waiting? (get db :wallet/waiting-for-recent-history?)
|
||||
syncing-allowed? (mobile-network-utils/syncing-allowed? cofx)]
|
||||
(log/info "restart-wallet-service"
|
||||
"syncing-allowed" syncing-allowed?)
|
||||
(if syncing-allowed?
|
||||
(start-wallet cofx)
|
||||
"force-start?" force-start?
|
||||
"watching-txs?" watching-txs?
|
||||
"syncing-allowed?" syncing-allowed?
|
||||
"watch-new-blocks?" watch-new-blocks?)
|
||||
(if (and syncing-allowed?
|
||||
(or
|
||||
waiting?
|
||||
force-start?
|
||||
watching-txs?))
|
||||
(start-wallet cofx (boolean (or watch-new-blocks? watching-txs?)))
|
||||
(stop-wallet cofx)))))
|
||||
|
||||
(fx/defn restart
|
||||
{:events [::restart]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge
|
||||
{:db (dissoc db :wallet-service/restart-timeout)}
|
||||
(restart-wallet-service true false)))
|
||||
|
||||
(fx/defn watch-tx
|
||||
{:events [:watch-tx]}
|
||||
[{:keys [db] :as cofx} tx-id]
|
||||
(let [txs (get db :wallet/watch-txs)
|
||||
old-timeout (get db :wallet-service/restart-timeout)
|
||||
timeout (utils.utils/set-timeout
|
||||
(fn []
|
||||
(re-frame.core/dispatch [::stop-watching-txs]))
|
||||
ms-10-min)]
|
||||
(fx/merge
|
||||
{:db (-> db
|
||||
(update :wallet/watch-txs (fnil conj #{}) tx-id)
|
||||
(assoc :wallet/watch-txs-timeout timeout))
|
||||
::utils.utils/clear-timeouts
|
||||
[old-timeout]}
|
||||
(restart-wallet-service true true))))
|
||||
|
||||
(fx/defn stop-watching-txs
|
||||
{:events [::stop-watching-txs]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge
|
||||
{:db (dissoc db
|
||||
:wallet/watch-txs
|
||||
:wallet/watch-txs-timeout)}
|
||||
(restart-wallet-service false false)))
|
||||
|
||||
(fx/defn stop-watching-tx
|
||||
[{:keys [db] :as cofx} tx]
|
||||
(let [txs (get db :wallet/watch-txs)
|
||||
new-txs ((fnil disj #{}) txs tx)]
|
||||
(when (get txs tx)
|
||||
(if (empty? new-txs)
|
||||
(stop-watching-txs cofx)
|
||||
{:db (assoc db :wallet/watch-txs new-txs)}))))
|
||||
|
||||
(fx/defn clear-timeouts
|
||||
[{:keys [db]}]
|
||||
(let [watch-timeout-id (get db :wallet/watch-txs-timeout)
|
||||
restart-timeout-id (get db :wallet-service/restart-timeout)]
|
||||
{:db (dissoc db :wallet/watch-txs-timeout
|
||||
:wallet-service/restart-timeout)
|
||||
::utils.utils/clear-timeouts [watch-timeout-id restart-timeout-id]}))
|
||||
|
|
|
@ -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.63.11",
|
||||
"commit-sha1": "9814a9a5e76b6fe7d312f45bac41990bc0467d4d",
|
||||
"src-sha256": "01j365ja4z6rm2hs5ck5az7wrx35v1sfwly8i0gldrisnnrh26dh"
|
||||
"version": "v0.64.0",
|
||||
"commit-sha1": "002f9a55974ee49ba2e66f7cee5a6e27a668a59a",
|
||||
"src-sha256": "0rfl9j3sjavic0sp3jxf4z2p20blaipdc3r6svbnr2grkiadgn3f"
|
||||
}
|
||||
|
|
|
@ -1326,5 +1326,6 @@
|
|||
"timeline": "Timeline",
|
||||
"ethereum-account": "Ethereum account",
|
||||
"ethereum-address":"Ethereum address",
|
||||
"default-assets": "Default ERC20 and ERC721"
|
||||
"default-assets": "Default ERC20 and ERC721",
|
||||
"refresh": "Refresh"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue