Compare commits

...
Author SHA1 Message Date
Andrea Maria Piana 1c0144cb1b Reset hystrix circuit when going back online
Wallet doesn't handle well going offline, this PR improves the
situation.

It's difficult to test as you fallback on Infura, you can check logs for
proper usage (you should not see any `open circuit` error after coming
back online, while you will get them when offline).

To test:

1) Fetch balances
2) Go offline, fetch a few times balances
3) Go online, fetch balances

In develop:
- You will see `open circuits` in the logs after step 3)
Here:
- You will not see `open circuits`

Basically on develop from when you go offline, you will be hitting
infura directly for a while.
This PR fixes that behavior so we hit our proxy instead.

https://github.com/status-im/status-go/compare/d394da0f...10a12762
2024-08-16 15:49:41 +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
3 changed files with 23 additions and 13 deletions
+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}
+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": "feat/close-hystrix-on-going-online",
"commit-sha1": "10a12762c21e9124d623a6619e8cac90116dc1b9",
"src-sha256": "0r1zxnfkbf16fry1nysxpl00d88r9fr59b6h07fnzp5nkpzzyxjb"
}