Compare commits

...
Author SHA1 Message Date
frank d572d1cb37 fix_: account address derivation in mobile user upgrade 2024-08-21 19:41:13 +08:00
Andrea Maria Piana 5af5975ccd Revert "REMOVE ME - add logs"
This reverts commit a6688fb866.
2024-08-20 15:28:47 +01:00
Andrea Maria Piana 2f246a29cf update statusgo version 2024-08-20 15:27:30 +01:00
Sean Hagstrom 8241afaeea fix: adjust spacing and verbiage for terms-of-use and privacy-statement onboarding checkbox 2024-08-20 15:25:40 +01:00
frank 0f9d276032 fix_:parse route response
https://github.com/status-im/status-go/compare/9e7d1303...90b3d0fd
2024-08-20 14:35:52 +01:00
Lungu Cristian 411c892022 fix: dapp tx get-standard-crypto-format arg order (#21086) 2024-08-20 09:49:20 +01:00
Andrea Maria Piana a6688fb866 REMOVE ME - add logs
https://github.com/status-im/status-go/compare/9e7d1303...1abe2dec
2024-08-20 09:09:01 +01:00
Andrea Maria Piana 3e6ff0400e Revert "[Remove me] Set credentials to test:test in prod proxy"
This reverts commit 6b29021075.
2024-08-19 15:27:34 +01:00
Andrea Maria Piana de30a0fd83 update statusgo version 2024-08-19 10:40:23 +01:00
Andrea Maria Piana a0cc8c5686 update statusgo 2024-08-19 09:03:27 +01:00
Icaro Motta 5cdf964add feat(wallet): Make wallet behave well when device is offline (#21067)
We make the wallet closer to being offline-first, that is, once data is loaded,
going offline won’t cause unnecessary data re-fetches which currently cause all
balances and data to stay loading forever or eventually balances end up zeroed.

Areas that may be impacted: read-only data displayed in the wallet and editing
accounts.

Fixes https://github.com/status-im/status-mobile/issues/21066
2024-08-19 09:02:27 +01:00
Andrea Maria Piana 98653be7f8 flush hystrix 2024-08-16 19:56:04 +01:00
Andrea Maria Piana 22d47bcffa update statusgo 2024-08-16 14:59:49 +01:00
Andrea Maria Piana 24f82f0b10 Add caching of token amounts
https://github.com/status-im/status-go/compare/1f7816dd...da70d6f1
2024-08-16 14:14:57 +01:00
16 changed files with 122 additions and 64 deletions
@@ -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})
(def text-container
{:flex 1
:flex-direction :row
:flex-wrap :wrap
:align-self :center})
{:flex-direction :row
:flex-wrap :wrap})
(def text-aligner
{:flex 1
:flex-direction :row
:justify-content :center})
(def terms-privacy-container
{:gap 8
{:flex-direction :row
:padding-horizontal 20
:padding-vertical 8})
:padding-vertical 8
:gap 8})
(def plain-text
{:color colors/white-opa-70})
@@ -21,8 +21,7 @@
:actions :two-vertical-actions
:description :top
:description-top-text [rn/view
{:style style/terms-privacy-container
:flex-direction :row}
{:style style/terms-privacy-container}
[rn/view
{:accessibility-label :terms-privacy-checkbox-container}
[quo/selectors
@@ -30,7 +29,7 @@
:blur? true
:checked? terms-accepted?
:on-change #(set-terms-accepted? not)}]]
[rn/view {:style {:flex 1}}
[rn/view {:style style/text-aligner}
[rn/view {:style style/text-container}
[quo/text
{:style style/plain-text
@@ -47,7 +46,7 @@
[quo/text
{:style style/plain-text
:size :paragraph-2}
" & "]
" " (i18n/label :t/and) " "]
[quo/text
{:on-press #(rf/dispatch [:show-bottom-sheet
{:content (fn [] [privacy/privacy-statement])
+4 -4
View File
@@ -12,10 +12,10 @@
:wakuV2Nameserver "8.8.8.8"
:statusProxyEnabled config/status-proxy-enabled?
:statusProxyStageName config/status-proxy-stage-name
:statusProxyMarketUser "test"
:statusProxyMarketPassword "test"
:statusProxyBlockchainUser "test"
:statusProxyBlockchainPassword "test"
:statusProxyMarketUser config/STATUS_BUILD_PROXY_USER
:statusProxyMarketPassword config/STATUS_BUILD_PROXY_PASSWORD
:statusProxyBlockchainUser config/STATUS_BUILD_PROXY_USER
:statusProxyBlockchainPassword config/STATUS_BUILD_PROXY_PASSWORD
:openseaAPIKey config/opensea-api-key
:poktToken config/POKT_TOKEN
:infuraToken config/INFURA_TOKEN
@@ -2,6 +2,7 @@
(:require [camel-snake-kebab.extras :as cske]
[clojure.string :as string]
[react-native.platform :as platform]
[status-im.contexts.network.data-store :as network.data-store]
[status-im.contexts.wallet.collectible.utils :as collectible-utils]
[taoensso.timbre :as log]
[utils.ethereum.chain :as chain]
@@ -122,14 +123,15 @@
(rf/reg-event-fx
:wallet/request-collectibles-for-current-viewing-account
(fn [{:keys [db]} _]
(let [current-viewing-account (-> db :wallet :current-viewing-account-address)
[request-id] (get-unique-collectible-request-id 1)]
{:db (assoc-in db [:wallet :ui :collectibles :pending-requests] 1)
:fx [[:dispatch
[:wallet/request-new-collectibles-for-account
{:request-id request-id
:account current-viewing-account
:amount collectibles-request-batch-size}]]]})))
(when (network.data-store/online? db)
(let [current-viewing-account (-> db :wallet :current-viewing-account-address)
[request-id] (get-unique-collectible-request-id 1)]
{:db (assoc-in db [:wallet :ui :collectibles :pending-requests] 1)
:fx [[:dispatch
[:wallet/request-new-collectibles-for-account
{:request-id request-id
:account current-viewing-account
:amount collectibles-request-batch-size}]]]}))))
(defn- update-fetched-collectibles-progress
[db owner-address collectibles offset has-more?]
+15 -10
View File
@@ -7,6 +7,7 @@
[utils.number :as number]
[utils.string]))
(def missing-price-decimals 6) ; if we don't have the monetary value of the token, we default to 6 decimals
(defn get-first-name
[full-name]
(first (string/split full-name #" ")))
@@ -66,16 +67,20 @@
(defn get-standard-crypto-format
"For full details: https://github.com/status-im/status-mobile/issues/18225"
[{:keys [market-values-per-currency]} token-units]
(if (or (nil? token-units)
(nil? market-values-per-currency)
(money/equal-to token-units 0))
"0"
(let [price (-> market-values-per-currency :usd :price)
one-cent-value (if (pos? price) (/ 0.01 price) 0)
decimals-count (calc-max-crypto-decimals one-cent-value)]
(if (< token-units one-cent-value)
(str "<" (number/remove-trailing-zeroes (.toFixed one-cent-value decimals-count)))
(number/remove-trailing-zeroes (.toFixed token-units decimals-count))))))
(cond (or (nil? token-units)
(money/equal-to token-units 0))
"0"
(nil? (-> market-values-per-currency :usd :price))
(number/remove-trailing-zeroes (.toFixed token-units missing-price-decimals))
:else
(let [price (-> market-values-per-currency :usd :price)
one-cent-value (if (pos? price) (/ 0.01 price) 0)
decimals-count (calc-max-crypto-decimals one-cent-value)]
(if (< token-units one-cent-value)
(str "<" (number/remove-trailing-zeroes (.toFixed one-cent-value decimals-count)))
(number/remove-trailing-zeroes (.toFixed token-units decimals-count))))))
(defn get-market-value
[currency {:keys [market-values-per-currency]}]
@@ -64,6 +64,11 @@
(is (= (utils/get-standard-crypto-format {:market-values-per-currency market-values-per-currency}
token-units)
"0.005")))
(let [market-values-per-currency {:usd {:price nil}}
token-units (money/bignumber 0.0123456)]
(is (= (utils/get-standard-crypto-format {:market-values-per-currency market-values-per-currency}
token-units)
"0.012346")))
(let [market-values-per-currency {:usd {:price 0.005}}
token-units (money/bignumber 0.01)]
(is (= (utils/get-standard-crypto-format {:market-values-per-currency market-values-per-currency}
@@ -262,3 +262,7 @@
;; :cost () ;; tbd not used on desktop
:token-fees token-fees
:gas-amount (:tx-gas-amount new-path)}))
(defn tokens-never-loaded?
[db]
(nil? (get-in db [:wallet :ui :tokens-loading])))
+4 -1
View File
@@ -7,4 +7,7 @@
(def 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}})
+32 -10
View File
@@ -5,6 +5,7 @@
[clojure.string :as string]
[react-native.platform :as platform]
[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.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/check-recent-history-for-account address]]]}))
(rf/reg-event-fx
:wallet/get-accounts-success
(defn- reconcile-accounts
[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]]
(let [wallet-accounts (data-store/rpc->accounts accounts)
wallet-db (get db :wallet)
new-account? (:new-account? wallet-db)
navigate-to-account (:navigate-to-account wallet-db)]
{:db (assoc-in db
[:wallet :accounts]
(utils.collection/index-by :address wallet-accounts))
:fx (concat refresh-accounts-fx-dispatches
{:db (update-in db [:wallet :accounts] reconcile-accounts wallet-accounts)
:fx (concat (when (or (data-store/tokens-never-loaded? db)
(network.data-store/online? db))
refresh-accounts-fx-dispatches)
[(when new-account?
[:dispatch [:wallet/navigate-to-new-account navigate-to-account]])])})))
(rf/reg-event-fx
:wallet/get-accounts
(fn [_]
(rf/reg-event-fx :wallet/get-accounts
(fn []
{:fx [[:json-rpc/call
[{:method "accounts_getAccounts"
:on-success [:wallet/get-accounts-success]
@@ -486,7 +508,7 @@
{:test-networks-enabled? test-networks-enabled?
:is-goerli-enabled? is-goerli-enabled?})
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?
(->> (map #(-> (network-utils/id->network %)
name
@@ -518,8 +518,8 @@
(rf/reg-event-fx
:wallet/handle-suggested-routes
(fn [_ data]
(if-let [{:keys [code details]} (-> data :ErrorResponse first)]
(fn [_ [data]]
(if-let [{:keys [code details]} (-> data :ErrorResponse)]
(let [error-message (if (= code "0") "An error occurred" details)]
(log/error "failed to get suggested routes (async)"
{:event :wallet/handle-suggested-routes
@@ -531,7 +531,6 @@
candidates-fix (comp ->old-route-paths
remove-invalid-bonder-fees-routes)
routes (-> data
(first)
(data-store/rpc->suggested-routes)
(update :best best-routes-fix)
(update :candidates candidates-fix))]
+9 -3
View File
@@ -43,9 +43,15 @@
{:fx [[:dispatch [:wallet/reload]]]}
"wallet-blockchain-status-changed"
{:fx [[:dispatch
[:wallet/blockchain-status-changed
(transforms/js->clj event-js)]]]}
{:fx [[:dispatch-later
;; Don't dispatch immediately because the signal may arrive as
;; 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"
{:fx
+6 -2
View File
@@ -152,8 +152,12 @@
(fn [toasts [_ toast-id & cursor]]
(get-in toasts (into [:toasts toast-id] cursor))))
(re-frame/reg-sub
:network/offline?
(re-frame/reg-sub :network/offline?
:<- [:network/status]
(fn [status]
(= status :offline)))
(re-frame/reg-sub :network/online?
:<- [:network/status]
(fn [status]
(= status :online)))
+9 -8
View File
@@ -48,11 +48,10 @@
:wallet/home-tokens-loading?
:<- [:wallet/tokens-loading]
(fn [tokens-loading]
(or (empty? tokens-loading)
(->> tokens-loading
vals
(some true?)
boolean))))
(->> tokens-loading
vals
(some true?)
boolean)))
(rf/reg-sub
:wallet/current-viewing-account-tokens-loading?
@@ -351,9 +350,10 @@
:<- [:wallet/accounts]
:<- [:wallet/balances-in-selected-networks]
:<- [:wallet/tokens-loading]
:<- [:network/online?]
:<- [:profile/currency-symbol]
:<- [: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}]
(let [account-type (cond
(= operable :no) :missing-keypair
@@ -373,8 +373,9 @@
account
keypair)}]))
#(rf/dispatch [:wallet/navigate-to-account address]))
:loading? (or (get tokens-loading address)
(not (contains? tokens-loading address)))
:loading? (and online?
(or (get tokens-loading address)
(not (contains? tokens-loading address))))
:balance (utils/prettify-balance currency-symbol
(get balances address)))))
accounts)))
@@ -133,8 +133,7 @@
max-fees-fiat (wallet-utils/calculate-token-fiat-value {:currency currency
:balance max-fees-ether
:token eth-token})
max-fees-fiat-formatted (-> max-fees-ether
(wallet-utils/get-standard-crypto-format eth-token)
max-fees-fiat-formatted (-> (wallet-utils/get-standard-crypto-format eth-token max-fees-ether)
(wallet-utils/get-standard-fiat-format currency-symbol
max-fees-fiat))
balance (-> eth-token
+3 -3
View File
@@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "release/0.182.x",
"commit-sha1": "dd787c982aac6cd2d376c9eb8c5a32a31c8f4405",
"src-sha256": "0i5s7hdy27xjwb4vfg90w6b336149sdawq8x0xa9ynix0f7i6ixc"
"version": "fix/generate_account2",
"commit-sha1": "58ee4f0461740f5b74f9655ea47275410bd05135",
"src-sha256": "032badg45ibya6h7ahg6hdb1z90363hq043va3cf5cvhjakbw8l2"
}