status-go/services
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
..
accounts feat(keycard): `DeleteAccountForMigratedKeypair` endpoint added 2023-01-13 11:09:57 +01:00
appmetrics feat: make kdf iterations configurable when creating a multiaccount (#2796) 2022-09-27 16:27:20 -04:00
browsers Upgrade linter to 1.50.0 2023-01-13 17:52:03 +00:00
chat chore: allow GetMembers for the communty by communityID only 2023-01-23 19:13:22 +02:00
ens feat: Support fetching accepted Activity Center notifications by multiple types (#3088) 2023-01-20 09:45:32 -03:00
ext feat: Support fetching accepted Activity Center notifications by multiple types (#3088) 2023-01-20 09:45:32 -03:00
gif feat: make kdf iterations configurable when creating a multiaccount (#2796) 2022-09-27 16:27:20 -04:00
local-notifications feat: add ticker in backend rather than in clients 2022-12-02 10:53:21 +01:00
mailservers fix: dropping peer in mailserver cycle 2023-01-18 09:28:08 -04:00
peer Fix hash & start moving to lifecycle 2021-07-20 10:57:38 +02:00
permissions feat: make kdf iterations configurable when creating a multiaccount (#2796) 2022-09-27 16:27:20 -04:00
personal feat: Rpc client manage multiple eth client (#2359) 2021-09-22 13:49:20 -04:00
rpcfilters synchronize display name (#2989) 2022-12-29 14:16:19 +08:00
rpcstats Move services to status-node 2021-07-20 10:57:38 +02:00
shhext Remove group members (#3011) 2022-12-10 08:26:51 +04:00
status fix(RequestCommunityInfoFromMailserver): Add useDatabase flag to read/not read community info before requesting mailserver.. 2022-11-30 11:10:13 +01:00
stickers fix: add 5 seconds timeout context when installing stickers 2023-01-13 10:27:12 +01:00
subscriptions feat: Rpc client manage multiple eth client (#2359) 2021-09-22 13:49:20 -04:00
typeddata fix: metamask test 2022-10-26 09:39:30 +02:00
updates feat: add service for checking if there are new versions available (#2552) 2022-06-08 08:38:26 -04:00
wakuext replace deprecated ioutil.TempDir with os.MkdirTemp 2023-01-03 15:40:11 +01:00
wakuv2ext feat: fetch curated communities from smart contract on optimism (#2685) 2022-06-02 08:17:52 -04:00
wallet feat: retrieve balance history for tokens and cache it to DB 2023-01-25 22:25:50 +04:00
web3provider replace deprecated ioutil.TempDir with os.MkdirTemp 2023-01-03 15:40:11 +01:00
utils.go New debug_postSync endpoint (#1046) 2018-06-25 15:27:17 +02:00