status-go/services/wallet/transfer
Stefan a2ff03c79e feat: retrieve balance history for tokens and cache it to DB
Extends wallet module with the history package with the following
components:

BalanceDB (balance_db.go)

- Keeps track of balance information (token count, block, block timestamp)
for a token identity (chain, address, currency)
- The cached data is stored in `balance_history` table.
- Uniqueness constrained is enforced by the `balance_history_identify_entry`
UNIQUE index.
- Optimal DB fetching is ensured by the `balance_history_filter_entries`
index

Balance (balance.go)

- Provides two stages:
    - Fetch of balance history using RPC calls (Balance.update function)
    - Retrieving of cached balance data from the DB it exists (Balance.get
    function)
- Fetching and retrieving of data is done for specific time intervals
    defined by TimeInterval "enumeration"
- Update process is done for a token identity by the Balance.Update function
- The granularity of data points returned is defined by the constant
increment step define in `timeIntervalToStride` for each time interval.
- The `blocksStride` values have a common divisor to have cache hit
between time intervals.

Service (service.go)

- Main APIs
    - StartBalanceHistory: Regularly updates balance history for all
    enabled networks, available accounts and provided tokens.
    - GetBalanceHistory: retrieves cached token count for a token identity
    (chain, address, currency) for multiple chains
    - UpdateVisibleTokens: will set the list of tokens to have historical
    balance fetched. This is a simplification to limit tokens to a small
    list that make sense

Fetch balance history for ECR20 tokens

- Add token.Manager.GetTokenBalanceAt to fetch balance of a specific
block number of ECR20.
- Add tokenChainClientSource concrete implementation of DataSource
to fetch balance of ECR20 tokens.
- Chose the correct DataSource implementation based on the token
"is native" property.

Tests

Tests are implemented using a mock of `DataSource` interface used
to intercept the RPC calls.

Notes:

- the timestamp used for retrieving block balance is constant

Closes status-desktop: #8175, #8226, #8862
2023-01-25 22:25:50 +04:00
..
balance_cache.go feat: retrieve balance history for tokens and cache it to DB 2023-01-25 22:25:50 +04:00
block.go Upgrade linter to 1.50.0 2023-01-13 17:52:03 +00:00
block_test.go feat: make kdf iterations configurable when creating a multiaccount (#2796) 2022-09-27 16:27:20 -04:00
commands.go feat: add ticker in backend rather than in clients 2022-12-02 10:53:21 +01:00
concurrent.go feat: enable wallet without network binding (#2349) 2021-09-09 16:28:54 +02:00
concurrent_test.go feat: enable wallet without network binding (#2349) 2021-09-09 16:28:54 +02:00
controller.go feat: retrieve balance history for tokens and cache it to DB 2023-01-25 22:25:50 +04:00
database.go synchronize display name (#2989) 2022-12-29 14:16:19 +08:00
database_test.go feat: make kdf iterations configurable when creating a multiaccount (#2796) 2022-09-27 16:27:20 -04:00
downloader.go fix: wallet downloader for l2 chain 2023-01-11 09:56:08 +01:00
iterative.go Changes necessary to make wallet work pokt networks 2022-10-19 10:40:13 +02:00
iterative_test.go feat: enable wallet without network binding (#2349) 2021-09-09 16:28:54 +02:00
query.go feat: Added new BaseFee param inside transactions (#2847) 2022-09-09 20:22:59 +02:00
reactor.go Support for binance chains 2021-11-27 10:47:57 +02:00
view.go Add effective gas price to tx view 2022-09-27 17:15:56 +02:00