Account balances in AccountEntities are not synced with on-chain data
ipapandinas opened this issue · 0 comments
Description
Balances amount are not synced with on-chain data in AccountEntities. Today dApps builder should always take balances from blockchain directly to ensure reliable data.
Removing the AccountEntity from the Indexer may be considered, but for some use cases it would be important to sort accounts by their balances. This issue provides a solution to fix AccountEntity to track balances with the correct data.
Solution considered
Only 9 events from the balance FRAME change user's balances:
- balances.BalanceSet
- balances.Deposit
- balances.DustLost
- balances.Endowed
- balances.Reserved
- balances.Slashed
- balances.Transfer
- balances.Unreserved
- balances.Withdraw
The first argument is always who
referring to the user's address; a generic helper can be implemented.
Only one specific case exists for balances.Transfer
. The recipient account balance have to be updated too. We can parse the second arguments referring to the receiver's address.