-
Notifications
You must be signed in to change notification settings - Fork 97
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(earn): Add EarnHome screen #5656
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5656 +/- ##
==========================================
+ Coverage 86.78% 86.83% +0.04%
==========================================
Files 774 780 +6
Lines 31862 32075 +213
Branches 5525 5257 -268
==========================================
+ Hits 27653 27853 +200
- Misses 3975 4173 +198
+ Partials 234 49 -185
... and 77 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
src/dapps/DappsScreen.tsx
Outdated
@@ -240,8 +240,6 @@ function DappsScreen({ navigation }: Props) { | |||
<FilterChipsCarousel | |||
chips={filterChips} | |||
onSelectChip={handleToggleFilterChip} | |||
primaryColor={Colors.successDark} |
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.
This defaults to gray/black buttons, Kayla mentioned wanting this standard across the app here
primaryColor?: colors | ||
primaryBorderColor?: colors | ||
primaryTextColor?: colors | ||
secondaryColor?: colors | ||
secondaryBorderColor?: colors | ||
secondaryTextColor?: colors |
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.
can we drop these params if there's no usage of customizing? The less options the better. Also, would be nice if the styling change for this component is in a separate PR
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.
moved to #5672
src/components/TokenBottomSheet.tsx
Outdated
@@ -33,6 +34,7 @@ export enum TokenPickerOrigin { | |||
CashIn = 'CashIn', | |||
CashOut = 'CashOut', | |||
Spend = 'Spend', | |||
EarnFilter = 'EarnFilter', |
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.
EarnFilter = 'EarnFilter', | |
Earn = 'Earn', |
?
src/earn/EarnHome.test.tsx
Outdated
] | ||
|
||
describe('EarnHome', () => { | ||
it('renders correctly', () => { |
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.
needs tests for changing tabs / filtering
@@ -538,6 +539,7 @@ const generalScreens = (Navigator: typeof Stack) => ( | |||
|
|||
const earnScreens = (Navigator: typeof Stack) => ( | |||
<> | |||
<Navigator.Screen name={Screens.EarnHome} component={EarnHome} options={headerWithBackButton} /> |
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.
use custom header over nav header to avoid the header not greying out when the bottom sheet is open
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.
I'm having some trouble getting a custom header to work with the useScrollAwareHeader
to have scrolling work and the title show up on the top. Is there any example of getting these to work together that we have, I'm having trouble finding one. @satish-ravi @MuckT
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.
useScrollAwareHeader
is meant to work with nav header and not custom header. We'll likely need a new wrapper for custom headers, which is beyond the scope of this. Let's make an issue
src/earn/EarnHome.tsx
Outdated
{ | ||
poolId: 'aArbUSDCn', | ||
networkId: NetworkId['arbitrum-one'], | ||
tokens: [`${NetworkId['arbitrum-one']}:0xaf88d065e77c8cc2239327c5edb3a432268e5831`], |
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 now I think we are going to support pools where this list is going to be the same as the deposit token id. I guess this is needed for more complex pools, @jeanregisser do you see value in keeping 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.
It's fine, it'll be part of the position anyway. I'll update this as I start working on the task to connect it to getEarnPositions.
src/earn/EarnTabBar.test.tsx
Outdated
import { EarnTabType } from 'src/earn/types' | ||
import Colors from 'src/styles/colors' | ||
|
||
describe('AssetTabBar', () => { |
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.
EarnTabBar
src/earn/EarnTabBar.test.tsx
Outdated
jest.clearAllMocks() | ||
}) | ||
|
||
it('renders all items if positions is enabled', () => { |
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.
this test name doesn't seem right
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.
updated, had copied over these tests from AssetTabBar and missed updating title
<View style={styles.buttonContainer}> | ||
<Button | ||
onPress={() => { | ||
navigate(Screens.EarnCollectScreen, { depositTokenId, poolTokenId }) |
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.
needs test
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.
added in 1a14ebd
/> | ||
<Button | ||
onPress={() => { | ||
navigate(Screens.EarnEnterAmount, { tokenId: depositTokenId }) |
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.
needs test
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.
added in 1a14ebd
expect(getByTestId(`PoolCard/${pools[0].poolId}`)).toBeTruthy() | ||
}) | ||
|
||
it('correctly shows correct networks, tokens under filters', () => { |
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.
can we also add tests for changing filters?
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.
This might be difficult with the current hardcoded single pool. There isn't any way to specify for the home screen to show more pools, so the pools being shown wouldn't change at all.
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.
you can mock the pools by moving them to a separate file right?
@@ -215,6 +217,9 @@ function TokenBottomSheet({ | |||
if (isNetworkChip(filter)) { | |||
return filter.filterFn(token, filter.selectedNetworkIds) | |||
} | |||
if (isTokenSelectChip(filter)) { |
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.
is this just to make TS happy? the token bottom sheet itself isn't going to have a token filter chip right?
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.
This is just copied over from Jacob's implementation in Troopo, I can remove if not necessary, the token bottom sheet won't have filters I don't think
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.
looks like TS gets mad if this is removed
@@ -538,6 +539,7 @@ const generalScreens = (Navigator: typeof Stack) => ( | |||
|
|||
const earnScreens = (Navigator: typeof Stack) => ( | |||
<> | |||
<Navigator.Screen name={Screens.EarnHome} component={EarnHome} options={headerWithBackButton} /> |
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.
useScrollAwareHeader
is meant to work with nav header and not custom header. We'll likely need a new wrapper for custom headers, which is beyond the scope of this. Let's make an issue
|
||
expect(getByText('earnFlow.poolCard.addToPool')).toBeTruthy() | ||
fireEvent.press(getByText('earnFlow.poolCard.addToPool')) | ||
expect(navigate).toHaveBeenCalledWith(Screens.EarnEnterAmount, { tokenId: mockArbUsdcTokenId }) |
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.
Will add check for analytics event in follow-up when analytics added
/> | ||
<Button | ||
onPress={() => { | ||
navigate(Screens.EarnEnterAmount, { tokenId: depositTokenId }) |
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.
Adding analytics to all button presses in follow up.
Co-authored-by: Satish Ravi <[email protected]>
### Description Fetch and store earn positions. Also add a selector to list them. User and earn positions are fetched and stored together. For each returned earn position: - if the user already holds the earn position, it is ignored (since it's already present as a user position) - if not it's added to the list Next up: use earn positions to drive the earn screen (which was added in #5656) ### Test plan - Updated tests ### Related issues - Fixes RET-1121 ### Backwards compatibility Yes ### 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
Move over necessary multi-pool earn stuff from earnV2. Two pools shown for testing purposes but the PR only includes the single Aave pool currently supported.
Will add analytics and hook stuff up in follow-up PRs
Test plan
all.mp4
Related issues
Backwards compatibility
Yes
Network scalability
If a new NetworkId and/or Network are added in the future, the changes in this PR will: