-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(positions): multichain positions #5093
Conversation
Looks like there's a schema update needed and some tests that also need to be updated in:
I also see one case where we use |
1 build had no size change
Celo (test) 1.82.0 (147)
|
… and ethereum (#349) Changes made: - updates the api to use Valora's standard network ID's for multichain requests - updates curve hook to actually return some data for multichain requests - seals off all other hooks with comments indicating whether they can be extended or are specific to Celo - uses blockchain api endpoint to get token info (which returns multichain token metadata and prices, rather than just celo token metadata and prices) - refactors to use Valora's standard for token ID's instead of addresses as token identifiers, to work for positions that include native assets lacking a contract address, like ETH BREAKING CHANGE: 'network' becomes 'networkId' in a few places in the API response. Requests can still use legacy 'network' request parameter, with either 'celo' or 'celoAlfajores' recognized. The wallet is updated in [this PR](valora-inc/wallet#5093) to adapt to the change, but old versions should continue to work without changes, since the 'network' request is not used for anything critical (see description on [wallet PR](valora-inc/wallet#5093) for details) test plan: - [x] **Backwards compatibility test**: run manual e2e test with 'main' branch of wallet (which still uses 'network' in requests and expects 'network' in response data) to verify that positions are queried for and displayed correctly for legacy app versions, e.g. that the changes are backwards compatible enough not to break anything. use local hooks endpoint, local wallet build, and hardcoded wallet address in the request. ![Simulator Screen Shot - iPhone 14 - 2024-03-20 at 16 48 20](https://github.com/valora-inc/hooks/assets/7979215/ad048f3a-e379-405c-a504-d673f214ac76) ![image](https://github.com/valora-inc/hooks/assets/7979215/8c48eb0d-353c-4519-9a29-4c87fdc7d9cb) - [x] hunt thru wallet code to make sure the legacy 'network' field on some response data is not used for anything important - [x] **Multichain functionality test**: run manual e2e test with `cajubelt/multichain-positions` branch of wallet, with an account that has a curve position on ethereum. use local hooks endpoint, local wallet build, and hardcoded network id in the request. ![simulator_screenshot_6D05642F-8186-429F-86B1-980122A8FBC4](https://github.com/valora-inc/hooks/assets/7979215/2c72b0cf-5702-4696-8b0a-81f7582aba40) - [x] update existing unit and e2e tests to add coverage for curve on ethereum. sent the address used in e2e tests a curve lp token. cc https://linear.app/valora/issue/RET-941/%5Bhooks%5D-multichain-support
src/analytics/Properties.tsx
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for analytics types I kept the "network" key the same, to avoid adding a column to BQ tables. for application code I migrated to "networkId" for consistency with other features
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5093 +/- ##
=======================================
Coverage 85.78% 85.78%
=======================================
Files 744 744
Lines 30348 30382 +34
Branches 5238 5244 +6
=======================================
+ Hits 26033 26064 +31
- Misses 4076 4079 +3
Partials 239 239
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
@@ -74,6 +74,7 @@ const storeWithPositions = { | |||
...storeWithTokenBalances, | |||
positions: { | |||
positions: mockPositions, // Total value of positions is ~$7.91 or ~₱10.52 | |||
shortcuts: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previously, the mock schema had an empty list in this field, which wasn't ideal imo because it didn't guarantee that we had compile-time checks for the mock data. when I updated the "root" state mock to include a nonemtpy list of shortcuts, I needed this to simulate a store that did not have any claimable positions
} | ||
type UpdatedToken = { networkId: NetworkId; tokens?: UpdatedToken[] } | ||
|
||
function recursivelyUpdateToken(token: LegacyToken): UpdatedToken { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the mock data includes a nested token, so we have test coverage for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome 🚀
### Description gets positions and shortcuts for whichever networks are enabled in our dynamic config, rather than just celo relies on valora-inc/hooks#362 ### Test plan - ci - manual test with local hooks api on wallet with both ethereum and celo positions (also unearthed a redux migration bug with this! hooray for testing!) ### Related issues fixes https://linear.app/valora/issue/RET-941/%5Bhooks%5D-multichain-support ### Backwards compatibility there is only one place where the new API will affect application code for old app versions, which is in the `keyExtractor` function in `AssetList.tsx`. The function returns the following for positions: `${activeTab}-${item.appId}-${item.networkId}-${item.address}-${index}`. I think this is ok, since old app versions only get celo positions right now, so when `item.networkId` evaluates to `undefined` for them, it shouldn't cause collisions with other positions on other networks. the other changes are all in analytics events, which should be something we can live with ### Network scalability If a new NetworkId and/or Network are added in the future, the changes in this PR will: - [x] Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added)
Description
gets positions and shortcuts for whichever networks are enabled in our dynamic config, rather than just celo
relies on valora-inc/hooks#362
Test plan
Related issues
fixes https://linear.app/valora/issue/RET-941/%5Bhooks%5D-multichain-support
Backwards compatibility
there is only one place where the new API will affect application code for old app versions, which is in the
keyExtractor
function inAssetList.tsx
. The function returns the following for positions:${activeTab}-${item.appId}-${item.networkId}-${item.address}-${index}
. I think this is ok, since old app versions only get celo positions right now, so whenitem.networkId
evaluates toundefined
for them, it shouldn't cause collisions with other positions on other networks.the other changes are all in analytics events, which should be something we can live with
Network scalability
If a new NetworkId and/or Network are added in the future, the changes in this PR will: