From 1f75a5918045476b9049795c872a4c5f2b4d5350 Mon Sep 17 00:00:00 2001 From: Tom McGuire Date: Thu, 24 Oct 2024 13:55:33 -0700 Subject: [PATCH 1/2] refactor(earn-types): combine withdraw actions and earn enter mode --- src/analytics/Properties.tsx | 15 +++++-------- src/analytics/types.ts | 1 + src/earn/EarnConfirmationScreen.test.tsx | 22 +++++++++---------- src/earn/EarnConfirmationScreen.tsx | 15 +++++++------ src/earn/EarnDepositBottomSheet.test.tsx | 5 +++-- src/earn/EarnDepositBottomSheet.tsx | 4 ++-- src/earn/EarnEnterAmount.test.tsx | 2 +- src/earn/EarnEnterAmount.tsx | 6 +++-- .../EarnPoolInfoScreen.test.tsx | 8 +++---- .../poolInfoScreen/EarnPoolInfoScreen.tsx | 2 +- .../WithdrawBottomSheet.test.tsx | 22 +++++++++---------- .../poolInfoScreen/WithdrawBottomSheet.tsx | 16 +++++++------- src/earn/prepareTransactions.ts | 8 +++---- src/earn/types.ts | 8 +++---- src/navigator/types.tsx | 6 ++--- 15 files changed, 69 insertions(+), 71 deletions(-) diff --git a/src/analytics/Properties.tsx b/src/analytics/Properties.tsx index 9cbeb42b48e..1b5a731455a 100644 --- a/src/analytics/Properties.tsx +++ b/src/analytics/Properties.tsx @@ -54,12 +54,7 @@ import { ErrorMessages } from 'src/app/ErrorMessages' import { AddAssetsActionType } from 'src/components/AddAssetsBottomSheet' import { TokenPickerOrigin } from 'src/components/TokenBottomSheet' import { DappSection } from 'src/dapps/types' -import { - BeforeDepositActionName, - EarnEnterMode, - SerializableRewardsInfo, - WithdrawActionName, -} from 'src/earn/types' +import { BeforeDepositActionName, EarnActiveAction, SerializableRewardsInfo } from 'src/earn/types' import { ProviderSelectionAnalyticsData } from 'src/fiatExchanges/types' import { CICOFlow, FiatExchangeFlow, PaymentMethod } from 'src/fiatExchanges/utils' import { HomeActionName, NotificationBannerCTATypes, NotificationType } from 'src/home/types' @@ -595,7 +590,7 @@ interface SendEventsProperties { tokenId: string tokenAddress: string | null networkId: NetworkId | null - mode?: EarnEnterMode + mode?: EarnActiveAction } [SendEvents.swap_input_pressed]: { swapToLocalAmount: boolean @@ -1559,7 +1554,7 @@ export interface EarnCommonProperties { interface EarnDepositProperties extends EarnCommonProperties { depositTokenAmount: string - mode: EarnEnterMode + mode: EarnActiveAction // the below are mainly for swap-deposit. For deposit, this would just be // same as the depositTokenAmount and depositTokenId fromTokenAmount: string @@ -1604,7 +1599,7 @@ interface EarnEventsProperties { [EarnEvents.earn_enter_amount_continue_press]: { amountInUsd: string amountEnteredIn: AmountEnteredIn - mode: EarnEnterMode + mode: EarnActiveAction // For deposits these will be the same as the depositTokenId and depositTokenAmount // For swaps these will be the swapFromTokenId and swapFromTokenAmount // For withdrawals this will be in units of the depositToken @@ -1647,7 +1642,7 @@ interface EarnEventsProperties { [EarnEvents.earn_pool_info_tap_safety_details]: EarnCommonProperties & { action: 'expand' | 'collapse' } - [EarnEvents.earn_select_withdraw_type]: EarnCommonProperties & { type: WithdrawActionName } + [EarnEvents.earn_select_withdraw_type]: EarnCommonProperties & { type: EarnActiveAction } } export type AnalyticsPropertiesList = AppEventsProperties & diff --git a/src/analytics/types.ts b/src/analytics/types.ts index db7481da351..36ccbb5011f 100644 --- a/src/analytics/types.ts +++ b/src/analytics/types.ts @@ -38,6 +38,7 @@ export type TransactionOrigin = | 'earn-deposit' | 'earn-swap-deposit' | 'earn-withdraw' + | 'earn-claim-rewards' | 'jumpstart-send' | 'jumpstart-claim' | 'wallet-connect' diff --git a/src/earn/EarnConfirmationScreen.test.tsx b/src/earn/EarnConfirmationScreen.test.tsx index 61fee38b28d..ee1d64379d7 100644 --- a/src/earn/EarnConfirmationScreen.test.tsx +++ b/src/earn/EarnConfirmationScreen.test.tsx @@ -110,7 +110,7 @@ describe('EarnConfirmationScreen', () => { component={EarnConfirmationScreen} params={{ pool: { ...mockEarnPositions[0], balance: '10.75' }, - mode: 'PartialWithdraw', + mode: 'withdraw', }} /> @@ -171,7 +171,7 @@ describe('EarnConfirmationScreen', () => { component={EarnConfirmationScreen} params={{ pool: { ...mockEarnPositions[0], balance: '10.75' }, - mode: 'PartialWithdraw', + mode: 'withdraw', }} /> @@ -208,7 +208,7 @@ describe('EarnConfirmationScreen', () => { component={EarnConfirmationScreen} params={{ pool: mockEarnPositions[0], - mode: 'PartialWithdraw', + mode: 'withdraw', }} /> @@ -238,7 +238,7 @@ describe('EarnConfirmationScreen', () => { component={EarnConfirmationScreen} params={{ pool: mockEarnPositions[0], - mode: 'PartialWithdraw', + mode: 'withdraw', }} /> @@ -263,7 +263,7 @@ describe('EarnConfirmationScreen', () => { component={EarnConfirmationScreen} params={{ pool: { ...mockEarnPositions[0], balance: '10.75' }, - mode: 'PartialWithdraw', + mode: 'withdraw', }} /> @@ -313,7 +313,7 @@ describe('EarnConfirmationScreen', () => { component={EarnConfirmationScreen} params={{ pool: mockEarnPositions[0], - mode: 'PartialWithdraw', + mode: 'withdraw', }} /> @@ -341,7 +341,7 @@ describe('EarnConfirmationScreen', () => { component={EarnConfirmationScreen} params={{ pool: mockEarnPositions[0], - mode: 'PartialWithdraw', + mode: 'withdraw', }} /> @@ -381,7 +381,7 @@ describe('EarnConfirmationScreen', () => { component={EarnConfirmationScreen} params={{ pool: mockEarnPositions[0], - mode: 'PartialWithdraw', + mode: 'withdraw', }} /> @@ -390,9 +390,9 @@ describe('EarnConfirmationScreen', () => { }) it.each([ - ['Claim', 'earnFlow.collect.titleClaim'], - ['PartialWithdraw', 'earnFlow.collect.titleWithdraw'], - ['Exit', 'earnFlow.collect.titleCollect'], + ['claim-rewards', 'earnFlow.collect.titleClaim'], + ['withdraw', 'earnFlow.collect.titleWithdraw'], + ['exit', 'earnFlow.collect.titleCollect'], ])('shows correct header text for %s', async (mode, expectedHeader) => { const { getByText } = render( diff --git a/src/earn/EarnConfirmationScreen.tsx b/src/earn/EarnConfirmationScreen.tsx index adcc0ec4bb9..21a9d159f47 100644 --- a/src/earn/EarnConfirmationScreen.tsx +++ b/src/earn/EarnConfirmationScreen.tsx @@ -13,7 +13,7 @@ import TokenIcon, { IconSize } from 'src/components/TokenIcon' import { usePrepareWithdrawAndClaimTransactions } from 'src/earn/hooks' import { withdrawStatusSelector } from 'src/earn/selectors' import { withdrawStart } from 'src/earn/slice' -import { WithdrawActionName } from 'src/earn/types' +import { EarnActiveAction } from 'src/earn/types' import { getEarnPositionBalanceValues, isGasSubsidizedForNetwork } from 'src/earn/utils' import { CICOFlow } from 'src/fiatExchanges/utils' import { navigate } from 'src/navigator/NavigationService' @@ -74,6 +74,7 @@ export default function EarnConfirmationScreen({ route }: Props) { [withdrawToken, pool.pricePerShare, inputAmount] ) + // Will need this to handle preparing a claim transaction, a withdrawal transaction and a withdrawal and claim transaction const { result: prepareTransactionsResult, loading: isPreparingTransactions, @@ -211,9 +212,9 @@ export default function EarnConfirmationScreen({ route }: Props) { style={styles.button} size={BtnSizes.FULL} text={ - mode === 'PartialWithdraw' + mode === 'withdraw' ? t('earnFlow.collect.ctaWithdraw') - : mode === 'Exit' + : mode === 'exit' ? t('earnFlow.collect.ctaExit') : t('earnFlow.collect.ctaReward') } @@ -316,14 +317,14 @@ function GasFee({ ) } -function Title({ mode }: { mode: WithdrawActionName }) { +function Title({ mode }: { mode: EarnActiveAction }) { const { t } = useTranslation() switch (mode) { - case 'Claim': + case 'claim-rewards': return {t('earnFlow.collect.titleClaim')} - case 'PartialWithdraw': + case 'withdraw': return {t('earnFlow.collect.titleWithdraw')} - case 'Exit': + case 'exit': default: return {t('earnFlow.collect.titleCollect')} } diff --git a/src/earn/EarnDepositBottomSheet.test.tsx b/src/earn/EarnDepositBottomSheet.test.tsx index e1397ec33e6..fd1084dcddf 100644 --- a/src/earn/EarnDepositBottomSheet.test.tsx +++ b/src/earn/EarnDepositBottomSheet.test.tsx @@ -7,6 +7,7 @@ import { EarnEvents } from 'src/analytics/Events' import { openUrl } from 'src/app/actions' import EarnDepositBottomSheet from 'src/earn/EarnDepositBottomSheet' import { depositStart } from 'src/earn/slice' +import { EarnActiveAction } from 'src/earn/types' import * as earnUtils from 'src/earn/utils' import { NetworkId } from 'src/transactions/types' import { PreparedTransactionsPossible } from 'src/viem/prepareTransactions' @@ -57,13 +58,13 @@ const mockDepositProps = { inputAmount: new BigNumber(100), preparedTransaction: mockPreparedTransaction, pool: mockEarnPositions[0], - mode: 'deposit' as const, + mode: 'deposit' as EarnActiveAction, inputTokenId: mockArbUsdcTokenId, } const mockSwapDepositProps = { ...mockDepositProps, - mode: 'swap-deposit' as const, + mode: 'swap-deposit' as EarnActiveAction, inputTokenId: mockArbEthTokenId, inputAmount: new BigNumber(0.041), swapTransaction: { diff --git a/src/earn/EarnDepositBottomSheet.tsx b/src/earn/EarnDepositBottomSheet.tsx index d9f6a097bbc..30bf4d1b098 100644 --- a/src/earn/EarnDepositBottomSheet.tsx +++ b/src/earn/EarnDepositBottomSheet.tsx @@ -11,7 +11,7 @@ import { LabelWithInfo } from 'src/components/LabelWithInfo' import TokenDisplay from 'src/components/TokenDisplay' import { depositStatusSelector } from 'src/earn/selectors' import { depositStart } from 'src/earn/slice' -import { EarnEnterMode } from 'src/earn/types' +import { EarnActiveAction } from 'src/earn/types' import { getSwapToAmountInDecimals, getTotalYieldRate, @@ -50,7 +50,7 @@ export default function EarnDepositBottomSheet({ inputTokenId: string inputAmount: BigNumber pool: EarnPosition - mode: EarnEnterMode + mode: EarnActiveAction swapTransaction?: SwapTransaction }) { const { t } = useTranslation() diff --git a/src/earn/EarnEnterAmount.test.tsx b/src/earn/EarnEnterAmount.test.tsx index 70fbedbc181..f9b22a81fe5 100644 --- a/src/earn/EarnEnterAmount.test.tsx +++ b/src/earn/EarnEnterAmount.test.tsx @@ -491,7 +491,7 @@ describe('EarnEnterAmount', () => { expect(navigate).toHaveBeenCalledWith(Screens.EarnConfirmationScreen, { pool: mockEarnPositions[0], - mode: 'PartialWithdraw', + mode: 'withdraw', inputAmount: '8', useMax: false, }) diff --git a/src/earn/EarnEnterAmount.tsx b/src/earn/EarnEnterAmount.tsx index f03a3e7e345..824a60051e7 100644 --- a/src/earn/EarnEnterAmount.tsx +++ b/src/earn/EarnEnterAmount.tsx @@ -106,6 +106,7 @@ function EarnEnterAmount({ route }: Props) { case 'withdraw': return [depositToken] case 'swap-deposit': + default: return eligibleSwappableTokens } }, [mode]) @@ -169,7 +170,8 @@ function EarnEnterAmount({ route }: Props) { feeCurrencies, pool, hooksApiUrl, - shortcutId: mode, + // Mode is the same and shortcutId, except for exit which is withdraw + shortcutId: mode === 'exit' ? 'withdraw' : mode, useMax: maxPressed, }) } @@ -383,7 +385,7 @@ function EarnEnterAmount({ route }: Props) { if (isWithdrawal) { navigate(Screens.EarnConfirmationScreen, { pool, - mode: 'PartialWithdraw', + mode, inputAmount: tokenAmount.toString(), useMax: maxPressed, }) diff --git a/src/earn/poolInfoScreen/EarnPoolInfoScreen.test.tsx b/src/earn/poolInfoScreen/EarnPoolInfoScreen.test.tsx index 45421ca332e..2b2a77ef0f5 100644 --- a/src/earn/poolInfoScreen/EarnPoolInfoScreen.test.tsx +++ b/src/earn/poolInfoScreen/EarnPoolInfoScreen.test.tsx @@ -668,7 +668,7 @@ describe('EarnPoolInfoScreen', () => { }) expect(navigate).toHaveBeenCalledWith(Screens.EarnConfirmationScreen, { pool: { ...mockEarnPositions[0], balance: '100' }, - mode: 'Exit', + mode: 'exit', }) }) it('open WithdrawBottomSheet when Withdraw button pressed, check that expected options exist', () => { @@ -694,9 +694,9 @@ describe('EarnPoolInfoScreen', () => { ) fireEvent.press(getByTestId('WithdrawButton')) expect(getByTestId('Earn/WithdrawBottomSheet')).toBeVisible() - expect(getByTestId('Earn/ActionCard/PartialWithdraw')).toBeTruthy() - expect(getByTestId('Earn/ActionCard/Claim')).toBeTruthy() - expect(getByTestId('Earn/ActionCard/Exit')).toBeTruthy() + expect(getByTestId('Earn/ActionCard/withdraw')).toBeTruthy() + expect(getByTestId('Earn/ActionCard/claim-rewards')).toBeTruthy() + expect(getByTestId('Earn/ActionCard/exit')).toBeTruthy() }) it('shows the daily yield rate when it is available', () => { diff --git a/src/earn/poolInfoScreen/EarnPoolInfoScreen.tsx b/src/earn/poolInfoScreen/EarnPoolInfoScreen.tsx index c02f299d0e7..77addd562a9 100644 --- a/src/earn/poolInfoScreen/EarnPoolInfoScreen.tsx +++ b/src/earn/poolInfoScreen/EarnPoolInfoScreen.tsx @@ -226,7 +226,7 @@ export default function EarnPoolInfoScreen({ route, navigation }: Props) { if (partialWithdrawalsEnabled) { withdrawBottomSheetRef.current?.snapToIndex(0) } else { - navigate(Screens.EarnConfirmationScreen, { pool, mode: 'Exit' }) + navigate(Screens.EarnConfirmationScreen, { pool, mode: 'exit' }) } } diff --git a/src/earn/poolInfoScreen/WithdrawBottomSheet.test.tsx b/src/earn/poolInfoScreen/WithdrawBottomSheet.test.tsx index 90a312ab0d4..69960003129 100644 --- a/src/earn/poolInfoScreen/WithdrawBottomSheet.test.tsx +++ b/src/earn/poolInfoScreen/WithdrawBottomSheet.test.tsx @@ -55,10 +55,10 @@ describe('WithdrawBottomSheet', () => { /> ) - expect(getByTestId('Earn/ActionCard/PartialWithdraw')).toBeTruthy() - fireEvent.press(getByTestId('Earn/ActionCard/PartialWithdraw')) + expect(getByTestId('Earn/ActionCard/withdraw')).toBeTruthy() + fireEvent.press(getByTestId('Earn/ActionCard/withdraw')) expect(AppAnalytics.track).toHaveBeenCalledWith(EarnEvents.earn_select_withdraw_type, { - type: 'PartialWithdraw', + type: 'withdraw', providerId: mockEarnPositions[0].appId, poolId: mockEarnPositions[0].positionId, networkId: mockEarnPositions[0].networkId, @@ -89,10 +89,10 @@ describe('WithdrawBottomSheet', () => { /> ) - expect(getByTestId('Earn/ActionCard/Claim')).toBeTruthy() - fireEvent.press(getByTestId('Earn/ActionCard/Claim')) + expect(getByTestId('Earn/ActionCard/claim-rewards')).toBeTruthy() + fireEvent.press(getByTestId('Earn/ActionCard/claim-rewards')) expect(AppAnalytics.track).toHaveBeenCalledWith(EarnEvents.earn_select_withdraw_type, { - type: 'Claim', + type: 'claim-rewards', providerId: mockEarnPositions[0].appId, poolId: mockEarnPositions[0].positionId, networkId: mockEarnPositions[0].networkId, @@ -103,7 +103,7 @@ describe('WithdrawBottomSheet', () => { ...mockEarnPositions[0], balance: '100', }, - mode: 'Claim', + mode: 'claim-rewards', }) }) it('tapping exit on WithdrawBottomSheet navigates to enter amount screen', () => { @@ -119,10 +119,10 @@ describe('WithdrawBottomSheet', () => { /> ) - expect(getByTestId('Earn/ActionCard/Exit')).toBeTruthy() - fireEvent.press(getByTestId('Earn/ActionCard/Exit')) + expect(getByTestId('Earn/ActionCard/exit')).toBeTruthy() + fireEvent.press(getByTestId('Earn/ActionCard/exit')) expect(AppAnalytics.track).toHaveBeenCalledWith(EarnEvents.earn_select_withdraw_type, { - type: 'Exit', + type: 'exit', providerId: mockEarnPositions[0].appId, poolId: mockEarnPositions[0].positionId, networkId: mockEarnPositions[0].networkId, @@ -133,7 +133,7 @@ describe('WithdrawBottomSheet', () => { ...mockEarnPositions[0], balance: '100', }, - mode: 'Exit', + mode: 'exit', }) }) it('shows correct copy when ClaimType is Earnings', () => { diff --git a/src/earn/poolInfoScreen/WithdrawBottomSheet.tsx b/src/earn/poolInfoScreen/WithdrawBottomSheet.tsx index f58bc5171c7..76a8fd6ed74 100644 --- a/src/earn/poolInfoScreen/WithdrawBottomSheet.tsx +++ b/src/earn/poolInfoScreen/WithdrawBottomSheet.tsx @@ -29,7 +29,7 @@ function PartialWithdrawAction({ const claimType = pool.dataProps.claimType const action: WithdrawAction = { - name: 'PartialWithdraw', + name: 'withdraw', title: hasRewards && pool.dataProps.withdrawalIncludesClaim ? t('earnFlow.poolInfoScreen.withdrawBottomSheet.withdrawAndClaim') @@ -43,7 +43,7 @@ function PartialWithdrawAction({ iconComponent: QuickActionsWithdraw, onPress: () => { AppAnalytics.track(EarnEvents.earn_select_withdraw_type, { - type: 'PartialWithdraw', + type: 'withdraw', providerId: pool.appId, poolId: pool.positionId, networkId: pool.networkId, @@ -67,7 +67,7 @@ function ClaimAction({ const claimType = pool.dataProps.claimType const action: WithdrawAction = { - name: 'Claim', + name: 'claim-rewards', title: claimType === 'rewards' ? t('earnFlow.poolInfoScreen.withdrawBottomSheet.claimRewards') @@ -79,13 +79,13 @@ function ClaimAction({ iconComponent: Trophy, onPress: () => { AppAnalytics.track(EarnEvents.earn_select_withdraw_type, { - type: 'Claim', + type: 'claim-rewards', providerId: pool.appId, poolId: pool.positionId, networkId: pool.networkId, depositTokenId: pool.dataProps.depositTokenId, }) - navigate(Screens.EarnConfirmationScreen, { pool, mode: action.name }) + navigate(Screens.EarnConfirmationScreen, { pool, mode: 'claim-rewards' }) forwardedRef.current?.close() }, } @@ -111,19 +111,19 @@ function ExitAction({ : t('earnFlow.poolInfoScreen.withdrawBottomSheet.exitDescription') const action: WithdrawAction = { - name: 'Exit', + name: 'exit', title: t('earnFlow.poolInfoScreen.withdrawBottomSheet.exit'), details, iconComponent: Exit, onPress: () => { AppAnalytics.track(EarnEvents.earn_select_withdraw_type, { - type: 'Exit', + type: 'exit', providerId: pool.appId, poolId: pool.positionId, networkId: pool.networkId, depositTokenId: pool.dataProps.depositTokenId, }) - navigate(Screens.EarnConfirmationScreen, { pool, mode: action.name }) + navigate(Screens.EarnConfirmationScreen, { pool, mode: 'exit' }) forwardedRef.current?.close() }, } diff --git a/src/earn/prepareTransactions.ts b/src/earn/prepareTransactions.ts index 7844483c378..c60ba28a936 100644 --- a/src/earn/prepareTransactions.ts +++ b/src/earn/prepareTransactions.ts @@ -1,7 +1,7 @@ import BigNumber from 'bignumber.js' import _ from 'lodash' import { useAsyncCallback } from 'react-async-hook' -import { EarnEnterMode, PrepareWithdrawAndClaimParams } from 'src/earn/types' +import { EarnActiveAction, PrepareWithdrawAndClaimParams } from 'src/earn/types' import { isGasSubsidizedForNetwork } from 'src/earn/utils' import { triggerShortcutRequest } from 'src/positions/saga' import { RawShortcutTransaction } from 'src/positions/slice' @@ -34,7 +34,7 @@ export async function prepareDepositTransactions({ feeCurrencies: TokenBalance[] pool: EarnPosition hooksApiUrl: string - shortcutId: EarnEnterMode + shortcutId: Exclude }) { const { enableAppFee } = getDynamicConfigParams(DynamicConfigs[StatsigDynamicConfigs.SWAP_CONFIG]) const args = @@ -163,7 +163,7 @@ export async function prepareWithdrawTransactions({ feeCurrencies: TokenBalance[] pool: EarnPosition hooksApiUrl: string - shortcutId: EarnEnterMode + shortcutId: Exclude useMax: boolean }) { const { dataProps } = pool @@ -196,7 +196,7 @@ export async function prepareWithdrawTransactions({ } } -export function usePrepareTransactions(mode: EarnEnterMode) { +export function usePrepareTransactions(mode: EarnActiveAction) { const prepareTransactions = useAsyncCallback( mode === 'withdraw' ? prepareWithdrawTransactions : prepareDepositTransactions, { diff --git a/src/earn/types.ts b/src/earn/types.ts index 7c6a4b6e628..b74922282c1 100644 --- a/src/earn/types.ts +++ b/src/earn/types.ts @@ -9,7 +9,7 @@ export interface DepositInfo { amount: string preparedTransactions: SerializableTransactionRequest[] pool: EarnPosition - mode: EarnEnterMode + mode: EarnActiveAction fromTokenId: string fromTokenAmount: string } @@ -58,8 +58,6 @@ export type BeforeDepositActionName = | 'CrossChainSwap' | 'Swap' -export type WithdrawActionName = 'PartialWithdraw' | 'Claim' | 'Exit' - export interface BeforeDepositAction { name: BeforeDepositActionName title: string @@ -69,11 +67,11 @@ export interface BeforeDepositAction { } export interface WithdrawAction { - name: WithdrawActionName + name: EarnActiveAction title: string details: string iconComponent: React.MemoExoticComponent<({ color }: { color: Colors }) => JSX.Element> onPress: () => void } -export type EarnEnterMode = 'deposit' | 'swap-deposit' | 'withdraw' +export type EarnActiveAction = 'withdraw' | 'claim-rewards' | 'deposit' | 'swap-deposit' | 'exit' diff --git a/src/navigator/types.tsx b/src/navigator/types.tsx index 6b741c0d0cd..c601ddf4818 100644 --- a/src/navigator/types.tsx +++ b/src/navigator/types.tsx @@ -1,6 +1,6 @@ import { KycSchema } from '@fiatconnect/fiatconnect-types' import { SendOrigin, WalletConnectPairingOrigin } from 'src/analytics/types' -import { EarnEnterMode, EarnTabType, WithdrawActionName } from 'src/earn/types' +import { EarnActiveAction, EarnTabType } from 'src/earn/types' import { ExternalExchangeProvider } from 'src/fiatExchanges/ExternalExchanges' import FiatConnectQuote from 'src/fiatExchanges/quotes/FiatConnectQuote' import { CICOFlow, FiatExchangeFlow, SimplexQuote } from 'src/fiatExchanges/utils' @@ -81,11 +81,11 @@ export type StackParamList = { [Screens.EarnInfoScreen]: undefined [Screens.EarnEnterAmount]: { pool: EarnPosition - mode?: EarnEnterMode + mode?: EarnActiveAction } [Screens.EarnConfirmationScreen]: { pool: EarnPosition - mode: WithdrawActionName + mode: EarnActiveAction inputAmount?: string useMax?: boolean } From b5fc84e228b11aa73b871b116e34ddea95785b0f Mon Sep 17 00:00:00 2001 From: Tom McGuire Date: Thu, 24 Oct 2024 17:09:05 -0700 Subject: [PATCH 2/2] docs(earn): mapping EarnActiveAction exit to withdraw shortcutId --- src/earn/EarnEnterAmount.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/earn/EarnEnterAmount.tsx b/src/earn/EarnEnterAmount.tsx index 824a60051e7..74192bdefcf 100644 --- a/src/earn/EarnEnterAmount.tsx +++ b/src/earn/EarnEnterAmount.tsx @@ -170,7 +170,7 @@ function EarnEnterAmount({ route }: Props) { feeCurrencies, pool, hooksApiUrl, - // Mode is the same and shortcutId, except for exit which is withdraw + // Mode === shortcutId, except for exit which is withdraw shortcutId: mode === 'exit' ? 'withdraw' : mode, useMax: maxPressed, })