-
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 earn withdraw bottom sheet #6142
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6142 +/- ##
==========================================
+ Coverage 88.87% 88.89% +0.01%
==========================================
Files 730 734 +4
Lines 31029 31136 +107
Branches 5693 5413 -280
==========================================
+ Hits 27577 27678 +101
- Misses 3256 3415 +159
+ Partials 196 43 -153
... and 71 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
@@ -25,14 +25,14 @@ import { Spacing } from 'src/styles/styles' | |||
import { TokenBalance } from 'src/tokens/slice' | |||
import { getTokenAnalyticsProps } from 'src/tokens/utils' | |||
|
|||
function ActionCard({ action }: { action: BeforeDepositAction }) { | |||
export function ActionCard({ action }: { action: BeforeDepositAction | WithdrawAction }) { |
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.
Might be worth moving this into its own file. Maybe even share with other parts of the app (token details, etc), seems like it's something we use throughout the app and would be nice to change styles in a single place for mobile stack apps
src/earn/EarnPoolInfoScreen.test.tsx
Outdated
expect(getByTestId('Earn/ActionCard/Claim')).toBeTruthy() | ||
expect(getByTestId('Earn/ActionCard/Exit')).toBeTruthy() | ||
}) | ||
it('tapping withdraw on WithdrawBottomSheet navigates to enter amount screen', () => { |
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 file is getting too big, I've started breaking EarnPoolInfoScreen into multiple files on #6176, haven't broken out tests yet. But would it be possible to have all the bottom sheet specific tests in a WithdrawBottomSheet.test.tsx
? and then EarnPoolInfoScreen.test.tsx
can have a single test to ensure bottom sheet is opened.
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.
@satish-ravi yeah I can do that, for having the bottom sheet tests in their own file, would I still render the pool info screen and then have it tap to open the bottom sheet, or is there a way to render just the bottoms sheet?
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 their own file in 5ceadc2, did it similar to EarnDepositBottomSheet.test.tsx
where I could just render the bottom sheet and seems to work as expected!
src/icons/Claim.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.
Can we name the icon Trophy? Would be good to keep it in sync with the name in the design system https://www.figma.com/design/erFfzHvSTm5g1sjK6jWyEH/Working-Design-System?node-id=2100-5070&node-type=frame&t=lvQvczdzHRWQBGKn-0
src/positions/types.ts
Outdated
@@ -25,6 +25,11 @@ export interface EarningItem { | |||
includedInPoolBalance?: boolean | |||
} | |||
|
|||
export enum ClaimType { |
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 this just be a string literal type instead of an enum?
src/analytics/Properties.tsx
Outdated
@@ -1639,6 +1639,7 @@ interface EarnEventsProperties { | |||
hasTokensOnSameNetwork: boolean | |||
hasTokensOnOtherNetworks: boolean | |||
} | |||
[EarnEvents.earn_select_withdraw_type]: { type: 'partialWithdraw' | 'claim' | 'exit' } |
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.
nit: keep all the pool_info_tap ones together
src/analytics/docs.ts
Outdated
@@ -609,6 +609,7 @@ export const eventDocs: Record<AnalyticsEventType, string> = { | |||
[EarnEvents.earn_pool_info_tap_info_icon]: `When the user taps an info icon on the earn pool info screen`, | |||
[EarnEvents.earn_pool_info_tap_withdraw]: `When the user taps the withdraw button on the pool info screen`, | |||
[EarnEvents.earn_pool_info_tap_deposit]: `When the user taps the deposit button on the pool info screen`, | |||
[EarnEvents.earn_select_withdraw_type]: `When a use selects a withdraw type on the withdraw bottom sheet`, |
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.
same as above
Co-authored-by: Tom McGuire <Mcgtom10@gmail.com>
Co-authored-by: Tom McGuire <Mcgtom10@gmail.com>
src/utils/ActionCard.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.
we generally don't put components in utils, you can leave this at src/earn. I believe eventually this should go to src/components and reused across the other bottom sheets. Can you make an issue for it?
{canPartialWithdraw && ( | ||
<PartialWithdrawAction forwardedRef={forwardedRef} pool={pool} hasRewards={canClaim} /> | ||
)} |
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 the gate check needed here? this bottom sheet will never show up if the gate is disabled per changes in EarnPoolInfoScreen 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.
I think it is needed, in EarnPoolInfoScreen, we show the bottom sheet if (hasRewards || partialWithdrawalsEnabled)
, so if the user has rewards but the gate is disabled, then the bottom sheet will still be shown with the options to claim rewards or exit.
}, | ||
}) | ||
|
||
it('tapping withdraw on WithdrawBottomSheet navigates to enter amount screen', () => { |
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.
wrap these in a describe
expect(AppAnalytics.track).toHaveBeenCalledWith(EarnEvents.earn_select_withdraw_type, { | ||
type: 'PartialWithdraw', | ||
}) | ||
expect(navigate).toHaveBeenCalledWith(Screens.EarnEnterAmount, { |
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 a jest.clearAllMocks in a beforeEach
to ensure clean assertions
const rewardsPositions = useSelector(positionsWithBalanceSelector).filter((position) => | ||
pool.dataProps.rewardsPositionIds?.includes(position.positionId) | ||
) | ||
const hasRewards = useMemo(() => rewardsPositions.length > 0, [rewardsPositions]) |
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 the filter also go inside the useMemo?
src/analytics/Properties.tsx
Outdated
@@ -1642,6 +1647,7 @@ interface EarnEventsProperties { | |||
[EarnEvents.earn_pool_info_tap_safety_details]: EarnCommonProperties & { | |||
action: 'expand' | 'collapse' | |||
} | |||
[EarnEvents.earn_select_withdraw_type]: { type: WithdrawActionName } |
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 include EarnCommonProperties here?
Description
Add bottom sheet for different withdraw options, show if >=2 of those options exist for a user.
Test plan
Unit tests added and updated
Manual:
Can partial withdraw:
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-10-14.at.11.09.25.mp4
Can't partial withdraw:
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-10-14.at.11.12.22.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: