This PR migrates all the amount-related long fields to BigInteger.
Currently, all the amounts are stored in long which is a 64-bit signed integer in Java. While it does the thing for small CCD amounts a typical user can face, CIS-2 tokens break it. In testnet, we have ETH.eth token with precision of 18. Having 100 ETH.eth on the balance overflows long and causes the wallet to crash.
Changes
Migrated account balances, token balances, transaction amounts, etc. from long to BigInteger
Migrated related database INTEGER fields to TEXT (auto migration)
Added Gson and Room type adapters for BigInteger
Fixed hardcoded 6 decimals in CurrencyUtil
Fixed limit of 6 decimals in CurrencyUtil amount regex
Added CurrencyUtil unit tests for extreme amounts
Added balance test to the AccountDaoUnitTest
Checklist
[x] My code follows the style of this project.
[x] The code compiles without warnings.
[x] I have performed a self-review of the changes.
[x] I have documented my code, in particular the intent of the
hard-to-understand areas.
[x] (If necessary) I have updated the CHANGELOG.
CLA acceptance
_Remove if not applicable.
By submitting the contribution I accept the terms and conditions of the
Contributor License Agreement v1.0
Purpose
This PR migrates all the amount-related
long
fields toBigInteger
.Currently, all the amounts are stored in
long
which is a 64-bit signed integer in Java. While it does the thing for small CCD amounts a typical user can face, CIS-2 tokens break it. In testnet, we have ETH.eth token with precision of 18. Having 100 ETH.eth on the balance overflowslong
and causes the wallet to crash.Changes
long
toBigInteger
INTEGER
fields toTEXT
(auto migration)BigInteger
CurrencyUtil
CurrencyUtil
amount regexCurrencyUtil
unit tests for extreme amountsAccountDaoUnitTest
Checklist
CLA acceptance
_Remove if not applicable.
By submitting the contribution I accept the terms and conditions of the Contributor License Agreement v1.0
link: https://developers.concordium.com/CLAs/Contributor-License-Agreement-v1.0.pdf
[x] I accept the above linked CLA.