Commit Graph

18 Commits

Author SHA1 Message Date
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
Andrea Maria Piana ed9ca8392c Upgrade linter to 1.50.0 2023-01-13 17:52:03 +00:00
Anthony Laibe 04de916cba fix: wallet downloader for l2 chain 2023-01-11 09:56:08 +01:00
frank 9137257638
synchronize display name (#2989) 2022-12-29 14:16:19 +08:00
Anthony Laibe c735e2a6bb feat: add wallet ticker 2022-12-02 10:53:21 +01:00
Anthony Laibe 0d1837f858 feat: add ticker in backend rather than in clients 2022-12-02 10:53:21 +01:00
Stefan 601484af3e feat: Retrieve balance history for native token
Add functionality to sample and retrieve balance history and cache
it in memory for the current transfer controller.

The end of the balance history is snapped at twice per day to
avoid having to query the blockchain again for each fetching within
12 hours interval

The functionality will be extended with DB caching, API call batching,
"smarter" cache hitting and syncing between devices

Updates: #7662
2022-11-07 22:39:21 +01:00
Roman Volosovskyi 5c3435c12f
Changes necessary to make wallet work pokt networks 2022-10-19 10:40:13 +02:00
Richard Ramos bf9abfc350
feat: make kdf iterations configurable when creating a multiaccount (#2796) 2022-09-27 16:27:20 -04:00
Roman Volosovskyi 506921509e
Add effective gas price to tx view 2022-09-27 17:15:56 +02:00
Khushboo-dev-cpp 1485b3b4c8
feat: Added new BaseFee param inside transactions (#2847) 2022-09-09 20:22:59 +02:00
Anthony Laibe ce0caa0f7f
feat: multi transaction (#2751) 2022-07-15 10:53:56 +02:00
Vitaliy Vlasov 011238b1d1 Wallet sync 2022-05-18 15:25:20 +03:00
Samuel Hawksby-Robinson e67592d556
Sync Settings (#2478)
* Sync Settings

* Added valueHandlers and Database singleton

Some issues remain, need a way to comparing incoming sql.DB to check if the connection is to a different file or not. Maybe make singleton instance per filename

* Added functionality to check the sqlite filename

* Refactor of Database.SaveSyncSettings to be used as a handler

* Implemented inteface for setting sync protobuf factories

* Refactored and completed adhoc send setting sync

* Tidying up

* Immutability refactor

* Refactor settings into dedicated package

* Breakout structs

* Tidy up

* Refactor of bulk settings sync

* Bug fixes

* Addressing feedback

* Fix code dropped during rebase

* Fix for db closed

* Fix for node config related crashes

* Provisional fix for type assertion - issue 2

* Adding robust type assertion checks

* Partial fix for null literal db storage and json encoding

* Fix for passively handling nil sql.DB, and checking if elem has len and if len is 0

* Added test for preferred name behaviour

* Adding saved sync settings to MessengerResponse

* Completed granular initial sync and clock from network on save

* add Settings to isEmpty

* Refactor of protobufs, partially done

* Added syncSetting receiver handling, some bug fixes

* Fix for sticker packs

* Implement inactive flag on sync protobuf factory

* Refactor of types and structs

* Added SettingField.CanSync functionality

* Addressing rebase artifact

* Refactor of Setting SELECT queries

* Refactor of string return queries

* VERSION bump and migration index bump

* Deactiveate Sync Settings

* Deactiveated preferred_name and send_status_updates

Co-authored-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2022-03-23 18:47:00 +00:00
Roman Volosovskyi 7ef2efaabd
Support for binance chains 2021-11-27 10:47:57 +02:00
Richard Ramos 38cc695753
waku2: log envelope hash and ids for all messages (#2427) 2021-11-11 12:13:55 -04:00
Anthony Laibe 26bfeddad4
feat: Rpc client manage multiple eth client (#2359) 2021-09-22 13:49:20 -04:00
Anthony Laibe 07651d4d06
feat: enable wallet without network binding (#2349)
* feat: enable wallet without network binding

* feat: make transfer network aware

* feat: allow to pass initial networks via config

* fix: nil check and feed

* feat: Add documentation with better function name

* fix: do not init the manager more than once

* fix: PR feedbacks

* Bump version

* Update Jenkinsfile.tests

* Convert int to string

Co-authored-by: RichΛrd <info@richardramos.me>
2021-09-09 16:28:54 +02:00