-
Notifications
You must be signed in to change notification settings - Fork 981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error while storing wallet raw-balances
#17896
Comments
@ilmotta Maybe you are interested on this. |
Interesting and funny that: (number? ##NaN)
;; => true
|
And besides the docstring of
(NaN? ##NaN)
(NaN? "Hola")
(NaN? "0x")
;; All of them => true
(NaN? 10)
(NaN? "0x0")
(NaN? "0x1")
;; All of them => false Maybe due to the implementation based on JS: (defn ^boolean NaN?
[val]
(js/isNaN val)) |
Interesting @ulisesmac! What's going on is that very big numbers can't be represented as integers in the computer without a special big int implementation. The function In the part of the code dealing with wallet and token values, we should always use bignums, which currently live in |
The bug to me is in the calling code, which should use proper bignums, not in the function |
Thanks @ilmotta !!! I agree, as you said we should use |
raw-balances
* Add `utils.money/add` version able to work with `nil`s * Store token raw-balance as big-number * Improve account balance calculations using `utils.money` existing functions * Update `:wallet/tokens-filtered` sub * Make `prettify-balance` able to work with bignumbers
* Add `utils.money/add` version able to work with `nil`s * Store token raw-balance as big-number * Improve account balance calculations using `utils.money` existing functions * Update `:wallet/tokens-filtered` sub * Make `prettify-balance` able to work with bignumbers
Bug Report
Problem
Theutils.number/parse-int
function is returning0
or the default value given when we attempt to parse very long numbers, such as walletraw-balance
values, e.g. 150 000 SNTs would be represented as150000000000000000000000
, and:The reason is we are checking if the number is an integer usingclojure.core/integer?
, which says no.Update:
While requesting and storing the
:raw-balance
for the wallet in app-db,utils.number/parse-int
has been used, that function returns a0
when the number is too large (e.g. 150 000 SNT, would be"150000000000000000000000"
).For wallet balances, we should always use big number functions (please check the ns
utils.money
).This issue consists of updating the raw-balance stored to properly use big numbers.
Expected behavior
Properly store the raw balances, test with 150,000 received and other smaller and bigger amounts.
Actual behavior
If we receive a big raw balance, the total balance in the account cards in the wallet page report $0.00
The text was updated successfully, but these errors were encountered: