Commit Graph

58 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
Anthony Laibe e8cd779e35 feat: api to return service up or down 2023-01-21 13:11:03 +01:00
dlipicar c2a8dd8a0c
feat(wallet): add price cache (#3107) 2023-01-19 11:49:48 -03:00
dlipicar 77a56e2b93
Feature/8640 unified currency rounding (#3079)
* feat(@desktop/wallet): added iso4217 library for fiat currency display decimals

* feat(@desktop/wallet): added token peg info and use numbers for token market values

* feat(@desktop/wallet): added
2023-01-12 14:54:14 -03:00
dlipicar 7d04be3613
Revert "feat/currency rounding (#3041)" (#3046)
This reverts commit 3d22f4a86d.
2023-01-04 09:40:26 -03:00
dlipicar 3d22f4a86d
feat/currency rounding (#3041)
* feat(@desktop/wallet): added iso4217 library for fiat currency display decimals

* feat(@desktop/wallet): added token peg info and use numbers for token market values

* feat(@desktop/wallet): extend wallet api to fetch prices in multiple currencies

* chore(@desktop/wallet): rename token peg field for clarity
2023-01-03 10:24:55 -03:00
Anthony Laibe 6abbe98cd2 feat: allow to lock amount in router 2022-12-21 16:58:33 +01:00
Anthony Laibe d7bf19fdbb feat: allow to get wallet token for specific addresses 2022-12-08 09:16:17 +01:00
Anthony Laibe c735e2a6bb feat: add wallet ticker 2022-12-02 10:53:21 +01:00
Anthony Laibe eff02a79a9 feat: add wallet token endpoint 2022-12-02 09:32:07 +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
Sale Djenic b0b23076a0 feat: `GetDerivedAddressDetails` added to accounts api 2022-10-28 13:27:55 +02:00
Anthony Laibe b11643e66d feat: hop integration 2022-10-26 09:39:30 +02:00
Khushboo-dev-cpp 3364c159f4
feat: Added API for getting historical data for a token (#2882) 2022-10-10 21:02:04 +02:00
Stefan b9d6e6d8c8 feat: sync saved addresses
Main changes:
- Extend saved addresses DB with sync info: sync timestamp, update timestamp
and soft removed flag
- Create custom protobuf message payload to sync saved addresses
- Cleanup saved addresses on each start of messenger, by deleting
soft removed older entries
- Sync all saved addresses on Messenger.SyncDevices calls
- Sync particular changes to saved addresses
- Add SavedAddressManager instance to messenger
  - Note, can't find a clean way to pass the SavedAddressManager to the
  messenger, so we create another one
- Add tests for sync and new DB API

Closes: #7229
2022-10-10 11:26:35 +02:00
Stefan aa4d95917c feat: merge favourites with saved address
Remove Favourites APIs and update the saved address APIs

Added up migration scripts that move the favourites from the old table
to the saved_addresses table with true flag and then drop the favourites table.

Required by #6546
2022-09-12 13:46:04 +02:00
Khushboo-dev-cpp 25a80cf20b
feat(CryptoCompareApi): Get token details from crypto compare (#2793) 2022-08-23 10:46:15 +02:00
Anthony Laibe ce0caa0f7f
feat: multi transaction (#2751) 2022-07-15 10:53:56 +02:00
Khushboo-dev-cpp b2ce92fd41
feat: Add logic to re caculate route for sending a transaction based on networks disabled by the user (#2742) 2022-07-14 16:22:42 +02:00
Anthony Laibe 35c4001e57
feat: estimate time for a transaction (#2744) 2022-07-12 14:25:32 +02:00
Vitaliy Vlasov 3dee94e505 Wallet sync for generated accounts 2022-07-06 19:24:43 +03:00
Anthony Laibe 4a3c4ad0ca
feat: allows to pass array of chain ids (#2733) 2022-07-04 09:48:30 +02:00
Anthony Laibe 8c0f230644
feat: Simple transaction router (#2686) 2022-06-09 15:09:56 +02:00
Khushboo-dev-cpp 15e5584ed2
feat: Add hasActivity param to derived addresses (#2663)
Added functionality to find target address when 6th param in path is added
for ex: "m'/44'/60'/0'/0/500" reperents the Address at the 500th index

Added a api to get the Address derived from a private key
2022-05-18 13:31:45 +02:00
Anthony Laibe e199ddbe9d
feat: get wallet api (#2619) 2022-05-10 09:48:05 +02:00
Anthony Laibe 907ba8ee5c
feat: visible token api (#2624) 2022-04-13 09:55:38 +02:00
Anthony Laibe 4d39547b81
Feat/expose registrar address (#2600)
* feat: expose registrar address

* fix code gen
2022-04-04 12:54:44 -04:00
Anthony Laibe 16311512cb
feat: add suggested fees api (#2604) 2022-03-29 17:12:05 -04:00
Anthony Laibe b629d6fa74
feat: move fetch prices to status-go (#2595) 2022-03-23 09:35:58 +01:00
Anthony Laibe 66d511e33f
feat: add opensea api key (#2528) 2022-02-16 10:22:19 +01:00
Anthony Laibe 9d8ec4432e
feat: Add token store API (#2482) 2022-01-14 10:21:00 +01:00
Richard Ramos ee41e30881
feat: extract node config from settings to individual tables (#2470) 2022-01-12 16:04:43 -04: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 95dcbef5e5
feat: enable rinkeby for opensea (#2357) 2021-09-20 12:24:07 -04:00
Eric Mastro 06d4163de8
feat: Add Saved Addresses CRUD (#2356) 2021-09-10 14:08:22 -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
Anthony Laibe 8f9c644dae
feat: fetch assets from opensea (#2320) 2021-08-20 15:53:24 -04:00
Roman Volosovskyi d1dc5f1e27
[wallet] Add wallet_getChachedBalances method 2021-05-25 10:03:05 +03:00
Roman Volosovskyi 6037570901
[wallet] Pending transactions API 2021-04-23 18:20:38 +03:00
Roman Volosovskyi f3ee49c110
[wallet] cleanup 2021-04-08 23:30:27 +03:00
Roman Volosovskyi 5a76e93063
[wallet] WatchTransaction method 2021-03-30 21:18:48 +03:00
Roman Volosovskyi 04fb7fdb3d
[wallet] GetTransfersByAddress for preloaded transfers 2021-03-24 17:35:34 +02:00
Roman Volosovskyi a7f2e94999
[wallet] Store account's last known balance and nonce 2021-03-15 16:18:12 +02:00
Roman Volosovskyi d21cd6aba1
[wallet] Set initial blocks range for a new empty account 2021-03-03 10:05:52 +02:00
Roman Volosovskyi 363ab0a2ab
[wallet] Avoid some unnecessary RPC requests
- avoid making RPC request for `zero - zero` range
- avoid checking of nonce for a lower block in the range if it is zero
  in a higher block
- on `wallet_getTransfersByAddress` scanning of history is skipped if
  zero block is already reached
- no need to fetch block num before fetching token balances
2021-02-17 13:55:27 +02:00
Samuel Hawksby-Robinson db962e0135 Added API for getting on ramp data 2021-02-17 09:53:45 +01:00
Roman Volosovskyi d8bccaff18
[wallet] Detect non archival RPC node 2021-01-25 14:52:14 +02:00
andrey 397ee840c6 [#2042] Wrong ERC20 decimal rounding in "Set max" 2020-09-22 16:00:47 +02:00