mirror of
https://github.com/status-im/status-mobile.git
synced 2025-02-20 20:38:35 +00:00
[wallet] Finetuning RPC calls for new accounts
This commit is contained in:
parent
46655dbd48
commit
460685212a
@ -54,7 +54,8 @@
|
|||||||
status-im.bootnodes.core
|
status-im.bootnodes.core
|
||||||
status-im.browser.core
|
status-im.browser.core
|
||||||
status-im.browser.permissions
|
status-im.browser.permissions
|
||||||
status-im.chat.models.transport))
|
status-im.chat.models.transport
|
||||||
|
[status-im.navigation :as navigation]))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:dismiss-keyboard
|
:dismiss-keyboard
|
||||||
@ -235,3 +236,11 @@
|
|||||||
:params []
|
:params []
|
||||||
:on-success (fn [on-ramps]
|
:on-success (fn [on-ramps]
|
||||||
(re-frame/dispatch [::crypto-loaded on-ramps]))}]})
|
(re-frame/dispatch [::crypto-loaded on-ramps]))}]})
|
||||||
|
|
||||||
|
(fx/defn open-buy-crypto-screen
|
||||||
|
{:events [:buy-crypto.ui/open-screen]}
|
||||||
|
[cofx]
|
||||||
|
(fx/merge
|
||||||
|
cofx
|
||||||
|
(navigation/navigate-to :buy-crypto nil)
|
||||||
|
(wallet/keep-watching-history)))
|
||||||
|
@ -64,7 +64,7 @@
|
|||||||
:color colors/white-transparent-70-persist}}
|
:color colors/white-transparent-70-persist}}
|
||||||
(ethereum/normalized-hex address)]]
|
(ethereum/normalized-hex address)]]
|
||||||
[react/view {:position :absolute :top 12 :right 12}
|
[react/view {:position :absolute :top 12 :right 12}
|
||||||
[react/touchable-highlight {:on-press #(re-frame/dispatch [:show-popover {:view :share-account :address address}])}
|
[react/touchable-highlight {:on-press #(re-frame/dispatch [:wallet/share-popover address])}
|
||||||
[icons/icon :main-icons/share {:color colors/white-persist
|
[icons/icon :main-icons/share {:color colors/white-persist
|
||||||
:accessibility-label :share-wallet-address-icon}]]]
|
:accessibility-label :share-wallet-address-icon}]]]
|
||||||
[react/view {:height button-group-height :background-color colors/black-transparent-20
|
[react/view {:height button-group-height :background-color colors/black-transparent-20
|
||||||
@ -83,7 +83,7 @@
|
|||||||
(i18n/label :t/receive)
|
(i18n/label :t/receive)
|
||||||
:main-icons/receive
|
:main-icons/receive
|
||||||
colors/white-persist
|
colors/white-persist
|
||||||
#(re-frame/dispatch [:show-popover {:view :share-account :address address}])]]]))
|
#(re-frame/dispatch [:wallet/share-popover address])]]]))
|
||||||
|
|
||||||
(defn render-collectible [{:keys [name icon amount] :as collectible}]
|
(defn render-collectible [{:keys [name icon amount] :as collectible}]
|
||||||
(let [items-number (money/to-fixed amount)]
|
(let [items-number (money/to-fixed amount)]
|
||||||
@ -170,7 +170,7 @@
|
|||||||
(i18n/label :t/receive)
|
(i18n/label :t/receive)
|
||||||
:main-icons/receive
|
:main-icons/receive
|
||||||
colors/blue-persist
|
colors/blue-persist
|
||||||
#(re-frame/dispatch [:show-popover {:view :share-account :address address}])]])
|
#(re-frame/dispatch [:wallet/share-popover address])]])
|
||||||
|
|
||||||
(defn anim-listener [anim-y scroll-y]
|
(defn anim-listener [anim-y scroll-y]
|
||||||
(let [to-show (atom false)]
|
(let [to-show (atom false)]
|
||||||
|
@ -64,8 +64,7 @@
|
|||||||
:icon :main-icons/share
|
:icon :main-icons/share
|
||||||
:accessibility-label :share-account-button
|
:accessibility-label :share-account-button
|
||||||
:on-press #(hide-sheet-and-dispatch
|
:on-press #(hide-sheet-and-dispatch
|
||||||
[:show-popover {:view :share-account
|
[:wallet/share-popover (:address account)])}]])
|
||||||
:address (:address account)}])}]])
|
|
||||||
|
|
||||||
(defn add-account []
|
(defn add-account []
|
||||||
(let [keycard? @(re-frame/subscribe [:keycard-multiaccount?])]
|
(let [keycard? @(re-frame/subscribe [:keycard-multiaccount?])]
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
(def learn-more-url "")
|
(def learn-more-url "")
|
||||||
|
|
||||||
(defn on-buy-crypto-pressed []
|
(defn on-buy-crypto-pressed []
|
||||||
(re-frame/dispatch [:navigate-to :buy-crypto]))
|
(re-frame/dispatch [:buy-crypto.ui/open-screen]))
|
||||||
|
|
||||||
(defn render-on-ramp [{:keys [name fees logo-url description] :as on-ramp}]
|
(defn render-on-ramp [{:keys [name fees logo-url description] :as on-ramp}]
|
||||||
[react/touchable-highlight {:on-press #(re-frame/dispatch [:navigate-to :buy-crypto-website on-ramp])
|
[react/touchable-highlight {:on-press #(re-frame/dispatch [:navigate-to :buy-crypto-website on-ramp])
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
[status-im.utils.datetime :as datetime]
|
[status-im.utils.datetime :as datetime]
|
||||||
status-im.wallet.recipient.core
|
status-im.wallet.recipient.core
|
||||||
[status-im.ui.screens.wallet.signing-phrase.views :as signing-phrase]
|
[status-im.ui.screens.wallet.signing-phrase.views :as signing-phrase]
|
||||||
[status-im.async-storage.core :as async-storage]))
|
[status-im.async-storage.core :as async-storage]
|
||||||
|
[status-im.popover.core :as popover.core]))
|
||||||
|
|
||||||
(defn get-balance
|
(defn get-balance
|
||||||
[{:keys [address on-success on-error]}]
|
[{:keys [address on-success on-error]}]
|
||||||
@ -590,7 +591,9 @@
|
|||||||
(ethereum/current-network db))
|
(ethereum/current-network db))
|
||||||
ms-4-min
|
ms-4-min
|
||||||
|
|
||||||
(and max-block (zero? max-block))
|
(and max-block
|
||||||
|
(zero? max-block)
|
||||||
|
(nil? (get db :wallet/keep-watching-until-ms)))
|
||||||
(log/info "[wallet] No transactions found")
|
(log/info "[wallet] No transactions found")
|
||||||
|
|
||||||
:else
|
:else
|
||||||
@ -780,15 +783,35 @@
|
|||||||
(navigation/navigate-back)))
|
(navigation/navigate-back)))
|
||||||
|
|
||||||
(fx/defn stop-fetching-on-empty-tx-history
|
(fx/defn stop-fetching-on-empty-tx-history
|
||||||
[{:keys [db] :as cofx} transfers]
|
[{:keys [db now] :as cofx} transfers]
|
||||||
(let [non-empty-history? (get db :wallet/non-empty-tx-history?)
|
(let [non-empty-history? (get db :wallet/non-empty-tx-history?)
|
||||||
custom-node? (ethereum/custom-rpc-node?
|
custom-node? (ethereum/custom-rpc-node?
|
||||||
(ethereum/current-network db))]
|
(ethereum/current-network db))
|
||||||
(if (and (not non-empty-history?)
|
until-ms (get db :wallet/keep-watching-until-ms)]
|
||||||
(empty? transfers)
|
(when-not (and until-ms (> until-ms now))
|
||||||
(not custom-node?))
|
(fx/merge
|
||||||
(clear-timeouts cofx)
|
cofx
|
||||||
{:db (assoc db :wallet/non-empty-tx-history? true)})))
|
{:db (dissoc db :wallet/keep-watching-until-ms)}
|
||||||
|
(if (and (not non-empty-history?)
|
||||||
|
(empty? transfers)
|
||||||
|
(not custom-node?))
|
||||||
|
(clear-timeouts)
|
||||||
|
(fn [{:keys [db]}]
|
||||||
|
{:db (assoc db :wallet/non-empty-tx-history? true)}))))))
|
||||||
|
|
||||||
|
(fx/defn keep-watching-history
|
||||||
|
{:events [:wallet/keep-watching]}
|
||||||
|
[{:keys [db now] :as cofx}]
|
||||||
|
(let [non-empty-history? (get db :wallet/non-empty-tx-history?)
|
||||||
|
restart? (and (not (get db :wallet/non-empty-tx-history?))
|
||||||
|
(not (get db :wallet-service/restart-timeout)))]
|
||||||
|
(fx/merge
|
||||||
|
cofx
|
||||||
|
(when-not non-empty-history?
|
||||||
|
{:db (assoc db :wallet/keep-watching-until-ms
|
||||||
|
(+ now (datetime/minutes 30)))})
|
||||||
|
(when restart?
|
||||||
|
(restart-wallet-service {:force-start? true})))))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
::set-inital-range
|
::set-inital-range
|
||||||
@ -826,3 +849,16 @@
|
|||||||
(get-in db [:wallet :accounts address :max-block] 0)
|
(get-in db [:wallet :accounts address :max-block] 0)
|
||||||
transfers)]
|
transfers)]
|
||||||
(set-max-block cofx address max-block)))
|
(set-max-block cofx address max-block)))
|
||||||
|
|
||||||
|
(fx/defn share
|
||||||
|
{:events [:wallet/share-popover]}
|
||||||
|
[{:keys [db] :as cofx} address]
|
||||||
|
(let [non-empty-history? (get db :wallet/non-empty-tx-history?)
|
||||||
|
restart? (and (not (get db :wallet/non-empty-tx-history?))
|
||||||
|
(not (get db :wallet-service/restart-timeout)))]
|
||||||
|
(fx/merge
|
||||||
|
cofx
|
||||||
|
(popover.core/show-popover
|
||||||
|
{:view :share-account
|
||||||
|
:address address})
|
||||||
|
(keep-watching-history))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user