Commit Graph

799 Commits

Author SHA1 Message Date
Cuteivist c0d1f11ac2
fix_: Fill chain ids for bridge (#5751) 2024-08-26 09:53:21 +02:00
Andrea Maria Piana e07182b3f3 fix_: Don't count error rate for circuit breaker on cancel and handle
not found
2024-08-20 15:26:28 +01:00
Dario Gabriel Lipicar 479eb71372 fix(wallet)_: prevent backwards range in GetHeadersInRange 2024-08-20 10:49:22 -03:00
Dario Gabriel Lipicar 1d173734a6 fix(wallet)_: set a separate id (and circuit) for the cryptcompare proxy 2024-08-20 14:32:14 +01:00
frank 83aa01c7da
chore_:update route error details (#5749) 2024-08-20 21:14:35 +08:00
Dario Gabriel Lipicar ba005f0d6f chore(wallet)_:make coingeco unit tests not call the real provider 2024-08-20 09:04:30 -03:00
Sale Djenic 759034ec7a fix_: crash when selected token cannot be found is fixed 2024-08-19 09:59:18 +02:00
Sale Djenic 2f08c4c6f9 fix_: crash sending collectibles fixed
When mapping `MultipathProcessorTxArgs` to `ProcessorInputParams` setting `FromChain` was missed.
2024-08-19 09:59:18 +02:00
frank 9cdfd6fb42
fix scheduler panic after quick stop (#5724)
* fix_: scheduler panic after quick stop

* test_: fix failed test TestScheduler_Enqueue_ValidateOrder
2024-08-16 21:16:29 +08:00
Andrea Maria Piana 9e5fa3f22c feat_: Cache GetWalletToken method and split circuits
This commits does a few things:

1) Adds cache of token amount to the GetWalletToken endpoint, used by
   mobile, in case the user is offline.

2) Split circuits by chain-id (when available) and by host+index when
   not

3) It makes GetWalletToken always refresh, as that's directed from an
   user action and we want to respect that. A cool down of 10s should be
   added in the future to avoid spamming.
2024-08-16 14:02:29 +01:00
Andrea Maria Piana 0954a4ad13 feat!: drive proxy stage name from the client 2024-08-14 18:50:01 +00:00
Icaro Motta f837bb55c4
fix(wallet)_: pass loop var by value to goroutine (#5710) 2024-08-14 16:45:55 +01:00
Anthony Laibe 1287e5af14 fix_: Token cache usage
When fetch or cache, always return the cache
Do not save if the token is not being returns
Resolve connection map AFTER making the call
2024-08-14 13:18:58 +02:00
Igor Sirotin 9175e45e61
fix_: block on logout (#5696)
* fix_: check context on processAndPushTelemetry

* fix_: fix waitgroup add/done in Waku

* fix(pendingTracker)_: stop the pending transacitonTracker on logout

* chore_: lint fix

---------

Co-authored-by: Jonathan Rainville <rainville.jonathan@gmail.com>
2024-08-12 22:30:13 +01:00
Sale Djenic 4a78d7c1e9 fix_: when preparing a balance map skip chains where cannot get the balance, instead of returning the error 2024-08-12 17:35:19 +02:00
Sale Djenic db5e5832d1 fix_: calculating route for erc721 checks one more call if the function doesn't exist on the contract
Old ERC721 contracts do not have  `safeTransferFrom` function, because of that we couldn't estimate the gas
and we couldn't resolve the right route. Now we firstly check for `safeTransferFrom` function which is supported
by ERC721A contracts and if the contract doesn't have it then we do `transferFrom` function call.

Example of ERC721A contract:
- https://etherscan.io/address/0x0024bc1035d30ae229a4712189b32131758cb000#code

Example of ERC721 contract:
- https://etherscan.io/address/0x06012c8cf97bead5deae237070f9587f8e7a266d#code
2024-08-12 17:26:56 +02:00
dlipicar b9d083c6d5
feat(wallet): add split onramp url endpoint (#5656)
* feat(wallet)_: add split onramp url endpoint & fix onrmap url
2024-08-12 12:53:32 +00:00
saledjenic 79b1c547d1
Improvements on resolving nonce (#5658)
* chore_: unused `BuildTx` function removed from the processor interface and types that are implement it

Since the `BuildTx` function is not used anywhere, it's removed from the code.

* fix_: resolving nonce improvements

When the app sends more than a single tx from the same account on the same chain, some
chains do not return appropriate nonce (they do not consider pending txs), because of
that we place more tx with the same nonce, where all but the first one fail.

Changes in this PR keep track of nonces being used in the same sending/bridging flow, which means
for the first tx from the multi txs the app asks the chain for the nonce, and every next nonce is resolved
by incrementing the last used nonce by 1.
2024-08-12 08:07:32 -04:00
Anthony Laibe 74fa567cda fix(wallet)_: return balance when available, do not fail all 2024-08-12 08:49:35 +02:00
dlipicar d7fcbd3444
feat(wallet)_: handle paraswap price impact error (#5622) 2024-08-07 23:33:44 +01:00
Sale Djenic 2129a3f95c feat_: accounts/saved addresses capacity related api endpoints added
Added endpoints:
- `RemainingAccountCapacity`
- `RemainingKeypairCapacity`
- `RemainingWatchOnlyAccountCapacity`
- `RmaininngCapacityForSavedAddresses`
2024-08-06 08:19:33 +02:00
Ivan Belyakov c84b136b4a fix(wallet)_: fixed error with parsing coingecko response.
For tokens that it does not support and some that were listed in mapping
we responded with error
2024-08-02 09:21:01 +02:00
Sale Djenic cf1a6631f8 fix_: the last known route with positive balance returned if no route without balance/bonder error
The Router algorithm is checking all the routes in order to find one the user has a balance to execute it
even that one is not the cheapest one. But if the user has some balances, but not enough to execute any
of suggested routes, we we're returning the last route which was checked, with the changes from this commit
we will return the last route for which the user has some balance, but not enough.
2024-08-01 15:26:01 +02:00
Belal Shehab 89d6c55d3e
fix(wallet)_: Handle balance fetching errors & fallback to cached values (#5628)
- Return errors from fetchBalancesForChain and GetBalancesAtByChain instead of silently ignoring them.
 - Use cached balances if fetching new data fails, preventing empty wallets and ensuring data consistency.
 - Fixed unit tests that was expecting GetBalancesAtByChain to always return nil error

Closes #15767

Co-authored-by: belalshehab <belal@status.im>
2024-08-01 12:54:29 +01:00
Ivan Belyakov b74d9e6b4e feat(wallet)_: add status proxy RPC urls for blockchain providers
Replace the status proxy URL for cryptocompare.
2024-08-01 08:19:20 +02:00
Sale Djenic 8787da1b89 feat_: added new error which will be returned in case bonder fee is higher than the amount being sent 2024-07-31 15:12:05 +02:00
Cuteivist daef6ee030
chore_: Validate multi tx type (#5619) 2024-07-31 06:45:11 +02:00
Sale Djenic 19b5bcf3ce chore_: endpoint for checking address checksum validity added to wallet api
- added `IsChecksumValidForAddress` function to `wallet` api
2024-07-30 17:38:29 +02:00
IvanBelyakoff 5b34cd9e9f
feat(wallet)_: add basic auth for cryptocompare proxy (#5536)
* feat(wallet)_: add basic auth for cryptocompare proxy

* test(wallet)_: add a test for httpclient used in market clients
2024-07-30 14:48:22 +01:00
IvanBelyakoff bf6c0c4cc6
fix(wallet)_: fix provider down event happening too often (#5595)
* fix(wallet)_: fix provider down event happening too often

- handle context cancelled error
- do not count expected errors when calling tokenURI as providers
  errors
- use archival not for optimism (was silently added by Grove makeing the
  old URL non-archival)

Closes #5555

* test(wallet)_: add test for collectibles manager to verify that main
circuit is not tripped calling by tokenURI method
2024-07-29 18:07:43 +01:00
Sale Djenic 18885b3663 test_: flaky router tests fixed
Closes https://github.com/status-im/status-go/issues/5601
2024-07-29 16:53:56 +02:00
Sale Djenic 20c1b83b7c chore_: when returning errors, give precedence to custom (network) errors 2024-07-29 10:05:56 +02:00
Sale Djenic 9472e18315 fix_: setting best route only when we have it 2024-07-29 10:05:56 +02:00
Igor Sirotin e76d93d340
chore: skip flaky tests (#5606)
* chore_: skip TestPeerCount

* chore_: skip flaky wallet tests

* chore_: skip flaky TestMemberReceivesPendingRequestToJoinAfterAfterGettingTokenMasterRole
2024-07-27 10:27:26 +01:00
Godfrain Jacques 72baaebe39
fix_: conversion from int to string causes code scanning error (#5600)
fixes #5599
2024-07-26 11:56:48 -07:00
belalshehab 03cb3ad0ab fix(Wallet)_: Add quotes around token symbol in insufficient balance error messages to ensure valid JSON parsing 2024-07-26 13:16:23 +03:00
Igor Sirotin 870ede0829
fix_: tests (#5585)
* fix_: router tests errors sprintf

* chore_: skip flaky tests
2024-07-25 23:27:12 +01:00
saledjenic 2bbdb35f6c
Added improvements in resolving the best route (#5569)
* fix_: filtering out routes which do not match the amount in

* fix_: finding the best route logic updated

* fix_: "to" chains being used in sending bridge tx via hop are more explicit

Using `ChainIDTo` depicts better an intention which chain should be used.

* chore_: checking for required balance improved

An error contains now more details, for which token on which chain there is not enough balance for
executing a tx. Also check for required balance now calculates in fees for all tx that possibly can be
sent from the same chain.
2024-07-25 08:15:30 -04:00
dlipicar 0456dcef8b
fix(wallet)_: exclude paraswap providers not supporting partner fees (#5573) 2024-07-24 16:29:54 -04:00
Dario Gabriel Lipicar 7c4b43b4d9 feat(wallet)_: incorporate partner fees for L1 paraswap swaps 2024-07-23 15:27:43 -03:00
Sale Djenic 4d2d20cff4 fix_: allow sending 0 value transactions 2024-07-23 18:19:10 +02:00
Dario Gabriel Lipicar 67890853bf feat_: add support for approve and swap activity entries 2024-07-22 18:29:13 -03:00
Dario Gabriel Lipicar afc6e7bcb9 feat(router)_: return processor error when no routes are found 2024-07-19 17:44:08 +02:00
Dario Gabriel Lipicar 6a155bc6dc feat_: add Mercuryio widget id 2024-07-19 09:03:15 -03:00
Stefan dc62171219 fix(dapps)_: don't require chain ID for signing typed data v4
The reused implementation from signing typed data V1 was used
in case of signing typed data V4. This implementation required
chain ID to be present in the typed data. This change fixes
the issue by making chainID optional for signing typed data V4.
2024-07-19 09:00:01 +02:00
Ivan Belyakov d07f9b5b16 fix(wallet)_: no balance chart for tokens, due to wrong symbol (ETH) used
instead.

Fixed padding points being removed from final result, regression.
Edge points not added per address as it does not make sense.
Fixed padding points number with respect to edge points number.
Padding points now duplicate previous entry.
Fixed timestamp boundaries to ignore addresses, as we want the whole
range for all passed addresses.
Fixed missing indices in balance_history table and clean up of
duplicate rows.
Removed ERC1155 from balance history sql query
2024-07-18 13:11:02 +02:00
Emil Sawicki eac07af5d7 fix(activity)_: Remove duplicated ids for nft fetching 2024-07-17 12:20:35 +02:00
Emil Sawicki 89f1feade0 fix(activity)_: report other token types than ERC20
This fixes incremental updates for tokens and proper report of
token type for mobile (in desktop we didn't use it)

Closes: #15233
2024-07-17 12:20:35 +02:00
Emil Sawicki 094d26dc66 fix_: Add pending tx for collectibles 2024-07-15 13:00:21 +01:00
Dario Gabriel Lipicar 21101c9444 feat(wallet)!: return routerV2 suggested routes whenever available, on top of error if the best route doesn't pass all checks 2024-07-12 17:59:41 -03:00
Andrea Maria Piana 9a59d6a459 feat(metrics)_: add centralized metrics
This commit adds support for centralized metrics.
There are two providers as of now, and we haven't quite decided which
one to go for, so for the time being both are supported.
It also introduces a new endpoint InitializeApplication that replaces
OpenAccounts
2024-07-11 10:05:31 +01:00
Emil Sawicki b2e5e7a81c feat(wallet)_: Remove deprecated for estimated time api 2024-07-09 14:39:52 +02:00
Stefan 5336c47f1b feat(dapps)_: extend and improve sign
Add `wallet_SafeSignTypedDataForDApps` with support for
`eth_signTypedData` and `eth_signTypedData_v4`
Reject if the chain to sign doesn't matches the target chain
for typed data signing

Add `wallet_HashMessageForSigning` with to support hashing messages
for signing in a safe way as per EIP-191 v45 and supporting
to hash messages for signing on the client side (keycard)

Deprecate `wallet_SignTypedDataV4``

Updates: #15361
2024-07-09 09:01:36 +02:00
Sale Djenic 378e5741b9 feat_: the router - add candidates, as potential paths, by taking the max amount on enabled chains 2024-07-05 14:51:34 +02:00
Ivan Belyakov 4b19845592 chore(wallet)_: Added a test for Market manager FetchTokenMarketValues
Added a nil/empty command test for circuit breaker
2024-07-05 12:39:19 +01:00
Ivan Belyakov a009855bbb feat(wallet)_: use CircuitBreaker for blockhain RPC calls
fix usage of circuit breaker for collectibles and market data to
match the implementation
2024-07-05 12:39:19 +01:00
Ivan Belyakov 23b185ae2b fix(wallet)_: fixed some errors handling that caused provider up/down
banner
2024-07-05 13:35:44 +02:00
Anthony Laibe abb570dd3f fix_: l1 fees at 0 and fix base fees sepolia 2024-07-05 11:04:29 +02:00
Ivan Belyakov 3983114ae5 test(wallet)_: add unit tests for balance fetcher
replace types with interfaces where necessary to allow mocking
implement fake eth scanner and erc20 contracts
2024-07-04 09:29:49 +02:00
Ivan Belyakov d180e19fa8 test(wallet)_: moved all balance related code from token.Manager to
balance_fetcher.BalanceFetcher

Split methods into smaller ones for testability
2024-07-04 09:29:49 +02:00
Anthony Laibe 135ab9a5cf chore_: add missing token 2024-07-04 09:28:18 +02:00
belalshehab 1e0a24f1b8 fix(wallet)_: use consistent invalid timestamp constant
- Replaced `unknownUpdateTimestamp` with `InvalidTimestamp` to maintain consistency.
2024-07-04 02:22:01 +03:00
belalshehab f98c411b32 feat(wallet)_: add new API to restart the wallet reload timer
- Added `restartWalletReloadTimer` method in `api.go` to expose an API for restarting the wallet reload timer.
- Implemented `Restart` method in `reader.go` to stop and start the wallet reader.
- Updated reader_test.go to comply with minimum test coverage threshold
2024-07-03 20:36:17 +03:00
Samuel Hawksby-Robinson 5f666e6ad9 test(router_validation)_: blended my validation with latest develop 2024-07-03 11:47:04 +01:00
Samuel Hawksby-Robinson 3c1326be48 test(router_validation)_: Resolved invalid recursive type aliasing
Additionally I've resolved a panic when AmountIn and/or AmountOut is nil
2024-07-03 11:47:04 +01:00
Samuel Hawksby-Robinson 59853fdbe2 test(router_validation)_: integrated the new errors into test loigc 2024-07-03 11:47:04 +01:00
Samuel Hawksby-Robinson e4420533d6 test(router_validation)_: removed error consts, see #5362 2024-07-03 11:47:04 +01:00
Samuel Hawksby-Robinson da2af02049 test(router_validation)_: Added test cases for Sticker and Swaps 2024-07-03 11:47:04 +01:00
Samuel Hawksby-Robinson cdaca322d0 test(router_validation)_: Added Error consts for all tested paths 2024-07-03 11:47:04 +01:00
Samuel Hawksby-Robinson 79d0d08cfd test(router_validation)_: Added full test cases for validateInputData 2024-07-03 11:47:04 +01:00
Samuel Hawksby-Robinson f6f1b56cf7 test(router_validation)_: Added validation to prevent all excluded networks 2024-07-03 11:47:04 +01:00
Stefan a535aedad5 fix(dapps)_: fix session identity
The pairing topic was used instead the topic for the session identity
which caused session management issues.

Updates: #15189
2024-07-02 19:17:28 +02:00
Stefan db8168105d fix(dapps)_: fix JSON marshaling for walletconnect.DBSession
Updates: #15189
2024-07-02 19:17:28 +02:00
Stefan 23aae48a40 feat(dapps)_: expose wallet_GetWalletConnectActiveSessions API
Add API test to get the required coverage

Updates: #15189
2024-07-02 19:17:28 +02:00
Dario Gabriel Lipicar 4d7c2683f5 fix_: fix swap in routerV2 2024-07-01 15:07:17 +02:00
Sale Djenic 443cd412f7 feat_: the router returns route there is a balance on even that's not the cheapest route
If there are multiple routes across multiple networks, but the user doesn't have a positive balance
on the network which the router initially suggested as the best (cheapest) route, then we are not returning
an error saying there are not enough balance, but instead try to suggest the route on the network where
the user has a positive balance even that's not the cheapest route (it should be the second cheapest route,
but if there are not enough balance on it we proceed with the third cheapest route and so on...).
2024-07-01 15:07:17 +02:00
Sale Djenic 92361d9e20 feat_: new endpoint added for an async route/s calculation
- `GetSuggestedRoutesV2Async` calculates the route/s based on input parameters and sends
`wallet.suggested.routes` signal to notify a client.
2024-07-01 15:07:17 +02:00
Sale Djenic 8bcb6ce667 chore!: wallet related signals alignment
A signal type `wallet` which had an event `type` set to `sing-transactions` is now a new signal
type `wallt.sing.transactions` with event which represents list of transactions that need to be signed.
2024-07-01 15:07:17 +02:00
Igor Sirotin 49eaabaca5
feat: adapt create/restore/login endpoints for keycard usage (#5311)
* chore_: remove duplicated `StartNodeWithKey`

* feat(KeycardPairing)_: added GetPairings method

* chore_: simplify startNode... methods

* chore_: added encryption path to be derived

* fix_: error handling in StartNodeWithKey

* feat_: added keycard properties to CreateAccount

* feat_: moved KeycardWhisperPrivateKey to LoginAccount

* fix_: LoginAccount during local pairing

* feat_: added chat key handling to loginAccount

* chore_: struct response from generateOrImportAccount

* fix_: do not store keycard account to keystore

* feat_: added Mnemonic parameter to LoginAccount

* chore_: wrap loginAccount errors

* feat_: RestoreKeycardAccountAndLogin endpoint

* chore_: merge RestoreKeycardAccountRequest into RestoreAccountRequest

* fix_: TestRestoreKeycardAccountAndLogin

* fix_: MessengerRawMessageResendTest

* chore_: cleanup

* chore_: cleanup according to pr comments

* chore_: better doc for Login.Mnemonic

* chore_: add/fix comments

* fix_: lint
2024-06-26 13:14:27 +02:00
Sale Djenic 1cdcc0dcc2 chore_: tests for router candidates added 2024-06-26 11:02:13 +01:00
Sale Djenic 68464d949c chore_: calculating multi tx candidates improvements
- router logic splitted into two more logical functions
- locked amount validation improved
- hop and swap processors cached data kept per from/to chain and from/to token
- Clear function which clears the local cache is added
- process of evaluating `amountToSend` if more than a single network is locked is improved
- optimized params for require approval function
2024-06-26 11:02:13 +01:00
Sale Djenic d1f8064437 chore_: typo in `disabledToChaindIDs` parameter name resolved 2024-06-26 11:02:13 +01:00
Sale Djenic e272a0d465 chore_: unnecessary preferred chains input router parameters removed 2024-06-26 11:02:13 +01:00
Mykhailo Prakhov 2cabec66cc
fix(premissions)_: convert balance from GetCachedBalancesByChain (#5415) 2024-06-25 10:14:40 +02:00
Ivan Belyakov ee2330fe5d feat(wallet)_: add CryptoCompare proxy to market manager as a last
resort
2024-06-21 16:39:00 +02:00
Ivan Belyakov 43c9860491 fix(wallet)_: fix rpc limiter to reset counters on timeout
fix rpc limiter to delete limits on account removal
fix rpc limiter to not overwrite existing account limit on startup
fix providers down banner on limit reached error
2024-06-20 16:48:28 +02:00
Anthony fb261e4a0e feat_: change how we compute fees 2024-06-20 10:30:01 +02:00
Ivan Belyakov bd816f1e29 chore(wallet)_: tests for wallet.Reader fetching balances
chore(wallet)_: split getWalletTokenBalances into multiple functions

Removed some unused balances methods from wallet API

chore(wallet)_: refactored FetchOrGetWalletTokenBalances

- getWalletTokenBalances only returns cached ones
- update of balances is done in a separate method

chore(wallet)_: fix isVisible in getWalletTokenBalances is overwritten

It is overwritten and in some cases its value is desrespected

chore(wallet)_: simplify getWalletTokenBalance even further

chore(wallet)_: remove accountsDB from wallet.Reader

Call GetTestNetworkEnabled from NetworkManager instead

chore(wallet)_: remove rpc.Client from wallet.Reader.

Added GetActiveNetworks() method for NetworkManager
Removed adding native tokens from networks, as this is done already
in NetworkManager

chore(wallet)_: moved Persistence to token package

As it works with token_balances table, moved Persistence to token package.
Fixed TokenManager's Mark/Get previously owned tokens to use persistence
storage instead of direct SQL calls.
Introduced StorageToken that aggregates Token type, because when
Persistence moved to token package, names clash

test(wallet)_: tests for wallet.Reader.FetchorGetCachedBalances
2024-06-19 16:57:50 +01:00
Igor Sirotin d2f4cae18f
fix: merge coverage reports from each test rerun (#5360)
* fix_: fix test coverage when rerunning tests

* fix_: make lint-fix

* chore_: change test coverage report artifact name

* chore_: added codeclimate.json to artifacts

* chore_: bring in gocovmerge util

---------

Co-authored-by: Siddarth Kumar <siddarthkay@gmail.com>
2024-06-19 11:40:52 +01:00
Ivan Belyakov b0d103d494 fix(statusd)_: fix panic on nil conversion to interface
Fixes #5371
2024-06-18 19:19:17 +02:00
Dario Gabriel Lipicar 7b38a5b6bd fix_: make use of slippage percentage parameter (#15096) 2024-06-17 09:51:29 -03:00
Sale Djenic f54ed03e50 fix_: incorrect chain set for the destination chain when resolving candidates in router 2024-06-14 15:44:38 +02:00
Sale Djenic 07882d9259 fix_: router crash when packid is nil 2024-06-14 15:44:38 +02:00
Sale Djenic 462013520f chore_: swap via paraswap improvements 2024-06-14 15:44:38 +02:00
Sale Djenic 9c3b49b866 chore_: celer bridge disabled, due to making correct routes using a single (hop) bridge 2024-06-14 15:44:38 +02:00
Stefan 9901ac9b9d feat(dapps)_: expose SignTypedDataV4 API to be used by dapps
Updates: #14927
2024-06-14 10:06:12 +02:00
Godfrain Jacques 892fcffce4
chore(communities)_: make member use wallet tokens during permission checking (#5268)
fixes #14913
2024-06-11 14:00:04 -07:00
Sale Djenic ddc75815eb chore_: stickers buy added to the router 2024-06-11 19:46:43 +02:00
Cuteivist 6a72afce8e
fix_: Fetch pending tx hash (#5319) 2024-06-11 10:36:27 +02:00
Sale Djenic 501b0a06c2 chore_: use the old name for backward compatibility 2024-06-11 10:30:34 +02:00