Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d572d1cb37 | ||
|
|
5af5975ccd | ||
|
|
2f246a29cf | ||
|
|
8241afaeea | ||
|
|
0f9d276032 | ||
|
|
411c892022 | ||
|
|
a6688fb866 | ||
|
|
3e6ff0400e | ||
|
|
de30a0fd83 | ||
|
|
a0cc8c5686 | ||
|
|
5cdf964add | ||
|
|
98653be7f8 | ||
|
|
22d47bcffa | ||
|
|
24f82f0b10 |
@@ -0,0 +1,5 @@
|
|||||||
|
(ns status-im.contexts.network.data-store)
|
||||||
|
|
||||||
|
(defn online?
|
||||||
|
[{:network/keys [status]}]
|
||||||
|
(= :online status))
|
||||||
@@ -7,15 +7,19 @@
|
|||||||
:justify-content :flex-end})
|
:justify-content :flex-end})
|
||||||
|
|
||||||
(def text-container
|
(def text-container
|
||||||
{:flex 1
|
{:flex-direction :row
|
||||||
:flex-direction :row
|
:flex-wrap :wrap})
|
||||||
:flex-wrap :wrap
|
|
||||||
:align-self :center})
|
(def text-aligner
|
||||||
|
{:flex 1
|
||||||
|
:flex-direction :row
|
||||||
|
:justify-content :center})
|
||||||
|
|
||||||
(def terms-privacy-container
|
(def terms-privacy-container
|
||||||
{:gap 8
|
{:flex-direction :row
|
||||||
:padding-horizontal 20
|
:padding-horizontal 20
|
||||||
:padding-vertical 8})
|
:padding-vertical 8
|
||||||
|
:gap 8})
|
||||||
|
|
||||||
(def plain-text
|
(def plain-text
|
||||||
{:color colors/white-opa-70})
|
{:color colors/white-opa-70})
|
||||||
|
|||||||
@@ -21,8 +21,7 @@
|
|||||||
:actions :two-vertical-actions
|
:actions :two-vertical-actions
|
||||||
:description :top
|
:description :top
|
||||||
:description-top-text [rn/view
|
:description-top-text [rn/view
|
||||||
{:style style/terms-privacy-container
|
{:style style/terms-privacy-container}
|
||||||
:flex-direction :row}
|
|
||||||
[rn/view
|
[rn/view
|
||||||
{:accessibility-label :terms-privacy-checkbox-container}
|
{:accessibility-label :terms-privacy-checkbox-container}
|
||||||
[quo/selectors
|
[quo/selectors
|
||||||
@@ -30,7 +29,7 @@
|
|||||||
:blur? true
|
:blur? true
|
||||||
:checked? terms-accepted?
|
:checked? terms-accepted?
|
||||||
:on-change #(set-terms-accepted? not)}]]
|
:on-change #(set-terms-accepted? not)}]]
|
||||||
[rn/view {:style {:flex 1}}
|
[rn/view {:style style/text-aligner}
|
||||||
[rn/view {:style style/text-container}
|
[rn/view {:style style/text-container}
|
||||||
[quo/text
|
[quo/text
|
||||||
{:style style/plain-text
|
{:style style/plain-text
|
||||||
@@ -47,7 +46,7 @@
|
|||||||
[quo/text
|
[quo/text
|
||||||
{:style style/plain-text
|
{:style style/plain-text
|
||||||
:size :paragraph-2}
|
:size :paragraph-2}
|
||||||
" & "]
|
" " (i18n/label :t/and) " "]
|
||||||
[quo/text
|
[quo/text
|
||||||
{:on-press #(rf/dispatch [:show-bottom-sheet
|
{:on-press #(rf/dispatch [:show-bottom-sheet
|
||||||
{:content (fn [] [privacy/privacy-statement])
|
{:content (fn [] [privacy/privacy-statement])
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
:wakuV2Nameserver "8.8.8.8"
|
:wakuV2Nameserver "8.8.8.8"
|
||||||
:statusProxyEnabled config/status-proxy-enabled?
|
:statusProxyEnabled config/status-proxy-enabled?
|
||||||
:statusProxyStageName config/status-proxy-stage-name
|
:statusProxyStageName config/status-proxy-stage-name
|
||||||
:statusProxyMarketUser "test"
|
:statusProxyMarketUser config/STATUS_BUILD_PROXY_USER
|
||||||
:statusProxyMarketPassword "test"
|
:statusProxyMarketPassword config/STATUS_BUILD_PROXY_PASSWORD
|
||||||
:statusProxyBlockchainUser "test"
|
:statusProxyBlockchainUser config/STATUS_BUILD_PROXY_USER
|
||||||
:statusProxyBlockchainPassword "test"
|
:statusProxyBlockchainPassword config/STATUS_BUILD_PROXY_PASSWORD
|
||||||
:openseaAPIKey config/opensea-api-key
|
:openseaAPIKey config/opensea-api-key
|
||||||
:poktToken config/POKT_TOKEN
|
:poktToken config/POKT_TOKEN
|
||||||
:infuraToken config/INFURA_TOKEN
|
:infuraToken config/INFURA_TOKEN
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
(:require [camel-snake-kebab.extras :as cske]
|
(:require [camel-snake-kebab.extras :as cske]
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[react-native.platform :as platform]
|
[react-native.platform :as platform]
|
||||||
|
[status-im.contexts.network.data-store :as network.data-store]
|
||||||
[status-im.contexts.wallet.collectible.utils :as collectible-utils]
|
[status-im.contexts.wallet.collectible.utils :as collectible-utils]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[utils.ethereum.chain :as chain]
|
[utils.ethereum.chain :as chain]
|
||||||
@@ -122,14 +123,15 @@
|
|||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/request-collectibles-for-current-viewing-account
|
:wallet/request-collectibles-for-current-viewing-account
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
(let [current-viewing-account (-> db :wallet :current-viewing-account-address)
|
(when (network.data-store/online? db)
|
||||||
[request-id] (get-unique-collectible-request-id 1)]
|
(let [current-viewing-account (-> db :wallet :current-viewing-account-address)
|
||||||
{:db (assoc-in db [:wallet :ui :collectibles :pending-requests] 1)
|
[request-id] (get-unique-collectible-request-id 1)]
|
||||||
:fx [[:dispatch
|
{:db (assoc-in db [:wallet :ui :collectibles :pending-requests] 1)
|
||||||
[:wallet/request-new-collectibles-for-account
|
:fx [[:dispatch
|
||||||
{:request-id request-id
|
[:wallet/request-new-collectibles-for-account
|
||||||
:account current-viewing-account
|
{:request-id request-id
|
||||||
:amount collectibles-request-batch-size}]]]})))
|
:account current-viewing-account
|
||||||
|
:amount collectibles-request-batch-size}]]]}))))
|
||||||
|
|
||||||
(defn- update-fetched-collectibles-progress
|
(defn- update-fetched-collectibles-progress
|
||||||
[db owner-address collectibles offset has-more?]
|
[db owner-address collectibles offset has-more?]
|
||||||
|
|||||||
@@ -262,3 +262,7 @@
|
|||||||
;; :cost () ;; tbd not used on desktop
|
;; :cost () ;; tbd not used on desktop
|
||||||
:token-fees token-fees
|
:token-fees token-fees
|
||||||
:gas-amount (:tx-gas-amount new-path)}))
|
:gas-amount (:tx-gas-amount new-path)}))
|
||||||
|
|
||||||
|
(defn tokens-never-loaded?
|
||||||
|
[db]
|
||||||
|
(nil? (get-in db [:wallet :ui :tokens-loading])))
|
||||||
|
|||||||
@@ -7,4 +7,7 @@
|
|||||||
|
|
||||||
(def defaults
|
(def defaults
|
||||||
{:ui {:network-filter network-filter-defaults
|
{:ui {:network-filter network-filter-defaults
|
||||||
:tokens-loading {}}})
|
;; Note: we set it to nil by default to differentiate when the user logs
|
||||||
|
;; in and the device is offline, versus re-fetching when offline and
|
||||||
|
;; tokens already exist in the app-db.
|
||||||
|
:tokens-loading nil}})
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[react-native.platform :as platform]
|
[react-native.platform :as platform]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
|
[status-im.contexts.network.data-store :as network.data-store]
|
||||||
[status-im.contexts.settings.wallet.effects]
|
[status-im.contexts.settings.wallet.effects]
|
||||||
[status-im.contexts.settings.wallet.events]
|
[status-im.contexts.settings.wallet.events]
|
||||||
[status-im.contexts.wallet.common.activity-tab.events]
|
[status-im.contexts.wallet.common.activity-tab.events]
|
||||||
@@ -107,23 +108,44 @@
|
|||||||
[:dispatch [:wallet/request-new-collectibles-for-account-from-signal address]]
|
[:dispatch [:wallet/request-new-collectibles-for-account-from-signal address]]
|
||||||
[:dispatch [:wallet/check-recent-history-for-account address]]]}))
|
[:dispatch [:wallet/check-recent-history-for-account address]]]}))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(defn- reconcile-accounts
|
||||||
:wallet/get-accounts-success
|
[db-accounts-by-address new-accounts]
|
||||||
|
(reduce
|
||||||
|
(fn [res {:keys [address] :as account}]
|
||||||
|
;; Because we add extra fields (tokens and collectibles) into the RPC
|
||||||
|
;; response from accounts_getAccounts, if we are offline we want to keep
|
||||||
|
;; the old balances in the accounts, thus we merge the up-to-date account
|
||||||
|
;; from status-go into the cached accounts. We also merge when online
|
||||||
|
;; because we will re-fetch balances anyway.
|
||||||
|
;;
|
||||||
|
;; Refactor improvement: don't augment entities from status-go, store
|
||||||
|
;; tokens and collectibles in separate keys in the app-db indexed by
|
||||||
|
;; account address.
|
||||||
|
(assoc res
|
||||||
|
address
|
||||||
|
(-> (get db-accounts-by-address address)
|
||||||
|
(merge account)
|
||||||
|
;; These should not be cached, otherwise when going
|
||||||
|
;; offline->online collectibles won't be fetched.
|
||||||
|
(dissoc :current-collectible-idx :has-more-collectibles?))))
|
||||||
|
{}
|
||||||
|
new-accounts))
|
||||||
|
|
||||||
|
(rf/reg-event-fx :wallet/get-accounts-success
|
||||||
(fn [{:keys [db]} [accounts]]
|
(fn [{:keys [db]} [accounts]]
|
||||||
(let [wallet-accounts (data-store/rpc->accounts accounts)
|
(let [wallet-accounts (data-store/rpc->accounts accounts)
|
||||||
wallet-db (get db :wallet)
|
wallet-db (get db :wallet)
|
||||||
new-account? (:new-account? wallet-db)
|
new-account? (:new-account? wallet-db)
|
||||||
navigate-to-account (:navigate-to-account wallet-db)]
|
navigate-to-account (:navigate-to-account wallet-db)]
|
||||||
{:db (assoc-in db
|
{:db (update-in db [:wallet :accounts] reconcile-accounts wallet-accounts)
|
||||||
[:wallet :accounts]
|
:fx (concat (when (or (data-store/tokens-never-loaded? db)
|
||||||
(utils.collection/index-by :address wallet-accounts))
|
(network.data-store/online? db))
|
||||||
:fx (concat refresh-accounts-fx-dispatches
|
refresh-accounts-fx-dispatches)
|
||||||
[(when new-account?
|
[(when new-account?
|
||||||
[:dispatch [:wallet/navigate-to-new-account navigate-to-account]])])})))
|
[:dispatch [:wallet/navigate-to-new-account navigate-to-account]])])})))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx :wallet/get-accounts
|
||||||
:wallet/get-accounts
|
(fn []
|
||||||
(fn [_]
|
|
||||||
{:fx [[:json-rpc/call
|
{:fx [[:json-rpc/call
|
||||||
[{:method "accounts_getAccounts"
|
[{:method "accounts_getAccounts"
|
||||||
:on-success [:wallet/get-accounts-success]
|
:on-success [:wallet/get-accounts-success]
|
||||||
@@ -486,7 +508,7 @@
|
|||||||
{:test-networks-enabled? test-networks-enabled?
|
{:test-networks-enabled? test-networks-enabled?
|
||||||
:is-goerli-enabled? is-goerli-enabled?})
|
:is-goerli-enabled? is-goerli-enabled?})
|
||||||
chains-filtered-by-mode (remove #(not (contains? chain-ids-by-mode %)) down-chain-ids)
|
chains-filtered-by-mode (remove #(not (contains? chain-ids-by-mode %)) down-chain-ids)
|
||||||
chains-down? (seq chains-filtered-by-mode)
|
chains-down? (and (network.data-store/online? db) (seq chains-filtered-by-mode))
|
||||||
chain-names (when chains-down?
|
chain-names (when chains-down?
|
||||||
(->> (map #(-> (network-utils/id->network %)
|
(->> (map #(-> (network-utils/id->network %)
|
||||||
name
|
name
|
||||||
|
|||||||
@@ -518,8 +518,8 @@
|
|||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/handle-suggested-routes
|
:wallet/handle-suggested-routes
|
||||||
(fn [_ data]
|
(fn [_ [data]]
|
||||||
(if-let [{:keys [code details]} (-> data :ErrorResponse first)]
|
(if-let [{:keys [code details]} (-> data :ErrorResponse)]
|
||||||
(let [error-message (if (= code "0") "An error occurred" details)]
|
(let [error-message (if (= code "0") "An error occurred" details)]
|
||||||
(log/error "failed to get suggested routes (async)"
|
(log/error "failed to get suggested routes (async)"
|
||||||
{:event :wallet/handle-suggested-routes
|
{:event :wallet/handle-suggested-routes
|
||||||
@@ -531,7 +531,6 @@
|
|||||||
candidates-fix (comp ->old-route-paths
|
candidates-fix (comp ->old-route-paths
|
||||||
remove-invalid-bonder-fees-routes)
|
remove-invalid-bonder-fees-routes)
|
||||||
routes (-> data
|
routes (-> data
|
||||||
(first)
|
|
||||||
(data-store/rpc->suggested-routes)
|
(data-store/rpc->suggested-routes)
|
||||||
(update :best best-routes-fix)
|
(update :best best-routes-fix)
|
||||||
(update :candidates candidates-fix))]
|
(update :candidates candidates-fix))]
|
||||||
|
|||||||
@@ -43,9 +43,15 @@
|
|||||||
{:fx [[:dispatch [:wallet/reload]]]}
|
{:fx [[:dispatch [:wallet/reload]]]}
|
||||||
|
|
||||||
"wallet-blockchain-status-changed"
|
"wallet-blockchain-status-changed"
|
||||||
{:fx [[:dispatch
|
{:fx [[:dispatch-later
|
||||||
[:wallet/blockchain-status-changed
|
;; Don't dispatch immediately because the signal may arrive as
|
||||||
(transforms/js->clj event-js)]]]}
|
;; soon as the device goes offline. We need to give some time for
|
||||||
|
;; RN to dispatch the network status update, otherwise when going
|
||||||
|
;; offline the user will immediately see a toast saying "provider
|
||||||
|
;; X is down".
|
||||||
|
[{:ms 500
|
||||||
|
:dispatch [:wallet/blockchain-status-changed
|
||||||
|
(transforms/js->clj event-js)]}]]]}
|
||||||
|
|
||||||
"wallet-activity-filtering-done"
|
"wallet-activity-filtering-done"
|
||||||
{:fx
|
{:fx
|
||||||
|
|||||||
@@ -152,8 +152,12 @@
|
|||||||
(fn [toasts [_ toast-id & cursor]]
|
(fn [toasts [_ toast-id & cursor]]
|
||||||
(get-in toasts (into [:toasts toast-id] cursor))))
|
(get-in toasts (into [:toasts toast-id] cursor))))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub :network/offline?
|
||||||
:network/offline?
|
|
||||||
:<- [:network/status]
|
:<- [:network/status]
|
||||||
(fn [status]
|
(fn [status]
|
||||||
(= status :offline)))
|
(= status :offline)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub :network/online?
|
||||||
|
:<- [:network/status]
|
||||||
|
(fn [status]
|
||||||
|
(= status :online)))
|
||||||
|
|||||||
@@ -48,11 +48,10 @@
|
|||||||
:wallet/home-tokens-loading?
|
:wallet/home-tokens-loading?
|
||||||
:<- [:wallet/tokens-loading]
|
:<- [:wallet/tokens-loading]
|
||||||
(fn [tokens-loading]
|
(fn [tokens-loading]
|
||||||
(or (empty? tokens-loading)
|
(->> tokens-loading
|
||||||
(->> tokens-loading
|
vals
|
||||||
vals
|
(some true?)
|
||||||
(some true?)
|
boolean)))
|
||||||
boolean))))
|
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:wallet/current-viewing-account-tokens-loading?
|
:wallet/current-viewing-account-tokens-loading?
|
||||||
@@ -351,9 +350,10 @@
|
|||||||
:<- [:wallet/accounts]
|
:<- [:wallet/accounts]
|
||||||
:<- [:wallet/balances-in-selected-networks]
|
:<- [:wallet/balances-in-selected-networks]
|
||||||
:<- [:wallet/tokens-loading]
|
:<- [:wallet/tokens-loading]
|
||||||
|
:<- [:network/online?]
|
||||||
:<- [:profile/currency-symbol]
|
:<- [:profile/currency-symbol]
|
||||||
:<- [:wallet/keypairs]
|
:<- [:wallet/keypairs]
|
||||||
(fn [[accounts balances tokens-loading currency-symbol keypairs]]
|
(fn [[accounts balances tokens-loading online? currency-symbol keypairs]]
|
||||||
(mapv (fn [{:keys [color address watch-only? key-uid operable] :as account}]
|
(mapv (fn [{:keys [color address watch-only? key-uid operable] :as account}]
|
||||||
(let [account-type (cond
|
(let [account-type (cond
|
||||||
(= operable :no) :missing-keypair
|
(= operable :no) :missing-keypair
|
||||||
@@ -373,8 +373,9 @@
|
|||||||
account
|
account
|
||||||
keypair)}]))
|
keypair)}]))
|
||||||
#(rf/dispatch [:wallet/navigate-to-account address]))
|
#(rf/dispatch [:wallet/navigate-to-account address]))
|
||||||
:loading? (or (get tokens-loading address)
|
:loading? (and online?
|
||||||
(not (contains? tokens-loading address)))
|
(or (get tokens-loading address)
|
||||||
|
(not (contains? tokens-loading address))))
|
||||||
:balance (utils/prettify-balance currency-symbol
|
:balance (utils/prettify-balance currency-symbol
|
||||||
(get balances address)))))
|
(get balances address)))))
|
||||||
accounts)))
|
accounts)))
|
||||||
|
|||||||
@@ -133,8 +133,7 @@
|
|||||||
max-fees-fiat (wallet-utils/calculate-token-fiat-value {:currency currency
|
max-fees-fiat (wallet-utils/calculate-token-fiat-value {:currency currency
|
||||||
:balance max-fees-ether
|
:balance max-fees-ether
|
||||||
:token eth-token})
|
:token eth-token})
|
||||||
max-fees-fiat-formatted (-> max-fees-ether
|
max-fees-fiat-formatted (-> (wallet-utils/get-standard-crypto-format eth-token max-fees-ether)
|
||||||
(wallet-utils/get-standard-crypto-format eth-token)
|
|
||||||
(wallet-utils/get-standard-fiat-format currency-symbol
|
(wallet-utils/get-standard-fiat-format currency-symbol
|
||||||
max-fees-fiat))
|
max-fees-fiat))
|
||||||
balance (-> eth-token
|
balance (-> eth-token
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||||
"owner": "status-im",
|
"owner": "status-im",
|
||||||
"repo": "status-go",
|
"repo": "status-go",
|
||||||
"version": "test/set-api-proxy-test-debug",
|
"version": "fix/generate_account2",
|
||||||
"commit-sha1": "022b6fd45b99819ec14baabd6d482ae85ed468bf",
|
"commit-sha1": "58ee4f0461740f5b74f9655ea47275410bd05135",
|
||||||
"src-sha256": "03p7x3s9005ghi02x334077nxwdhwlkxmvhcnc07lsygfsnzkkzk"
|
"src-sha256": "032badg45ibya6h7ahg6hdb1z90363hq043va3cf5cvhjakbw8l2"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user