Skip to content

Commit 0ea6447

Browse files
committed
fix type errors
1 parent 767699b commit 0ea6447

4 files changed

Lines changed: 99 additions & 71 deletions

File tree

app/components/UI/Perps/Views/PerpsOrderView/PerpsOrderView.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ const PerpsOrderViewContentBase: React.FC<PerpsOrderViewContentProps> = ({
944944
initialTakeProfitPrice: orderForm.takeProfitPrice,
945945
initialStopLossPrice: orderForm.stopLossPrice,
946946
amount: orderForm.amount,
947-
szDecimals,
947+
szDecimals: szDecimals ?? undefined,
948948
onConfirm: async (
949949
_position?: Position,
950950
takeProfitPrice?: string,
@@ -1106,7 +1106,10 @@ const PerpsOrderViewContentBase: React.FC<PerpsOrderViewContentProps> = ({
11061106
{
11071107
name: Routes.PERPS.MARKET_DETAILS,
11081108
params: {
1109-
market: navigationMarketData,
1109+
market: navigationMarketData ?? {
1110+
symbol: orderForm.asset,
1111+
name: orderForm.asset,
1112+
},
11101113
monitoringIntent: {
11111114
asset: orderForm.asset,
11121115
monitorOrders: true,
@@ -1198,7 +1201,10 @@ const PerpsOrderViewContentBase: React.FC<PerpsOrderViewContentProps> = ({
11981201
navigation.navigate(Routes.PERPS.ROOT, {
11991202
screen: Routes.PERPS.MARKET_DETAILS,
12001203
params: {
1201-
market: navigationMarketData,
1204+
market: navigationMarketData ?? {
1205+
symbol: orderForm.asset,
1206+
name: orderForm.asset,
1207+
},
12021208
// Pass monitoring intent to destination screen for data-driven tab selection
12031209
monitoringIntent: {
12041210
asset: orderForm.asset,

app/components/UI/Perps/routes/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@ const styles = StyleSheet.create({
6868
},
6969
});
7070

71-
export function getRedesignedConfirmationsHeaderOptions({
72-
showPerpsHeader = CONFIRMATION_HEADER_CONFIG.DefaultShowPerpsHeader,
73-
}: PerpsNavigationParamList['RedesignedConfirmations'] = {}): NativeStackNavigationOptions {
71+
export function getRedesignedConfirmationsHeaderOptions(
72+
params: PerpsNavigationParamList['RedesignedConfirmations'] = {},
73+
): NativeStackNavigationOptions {
74+
const showPerpsHeader =
75+
params?.showPerpsHeader ??
76+
CONFIRMATION_HEADER_CONFIG.DefaultShowPerpsHeader;
7477
if (showPerpsHeader) {
7578
return {
7679
...getEmptyNavHeader(),

app/components/UI/Perps/types/navigation.ts

Lines changed: 78 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,34 @@ export type PerpsClosePositionModalsNavigationParamList = {
4242
PerpsTooltip: PerpsTooltipViewRouteParams;
4343
};
4444

45+
/** Shared order / redesigned-confirmation params for the Perps trade flow. */
46+
// Object-literal type (not interface) so it retains an implicit index signature
47+
// and stays assignable to `Record<string, unknown>` (e.g. redirect params).
48+
export interface PerpsOrderRouteParams {
49+
direction: 'long' | 'short';
50+
asset: string;
51+
defaultSzDecimals?: number;
52+
defaultMaxLeverage?: number;
53+
leverage?: number;
54+
amount?: string;
55+
price?: string;
56+
orderType?: OrderType;
57+
existingPosition?: Position; // Pass existing position for leverage consistency when adding to position
58+
hideTPSL?: boolean; // Hide TP/SL row when modifying existing position
59+
/** When false, confirmation screen uses header: () => null; when true/undefined uses headerLeft/title options */
60+
showPerpsHeader?: boolean;
61+
/** Analytics: how the user got to the order screen (e.g. trade_action, order_book_long_button, asset_detail_screen) */
62+
source?: string;
63+
/** Analytics: chart library active when the order flow started */
64+
chartLibrary?: string;
65+
transactionActiveAbTests?: TransactionActiveAbTestEntry[];
66+
}
67+
4568
// ParamListBase requires `type`; `interface` cannot satisfy it.
4669
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
4770
export type PerpsStackParamList = {
4871
// Order flow routes
49-
PerpsOrder: {
50-
direction: 'long' | 'short';
51-
asset: string;
52-
defaultSzDecimals?: number;
53-
defaultMaxLeverage?: number;
54-
leverage?: number;
55-
amount?: string;
56-
price?: string;
57-
orderType?: OrderType;
58-
existingPosition?: Position; // Pass existing position for leverage consistency when adding to position
59-
hideTPSL?: boolean; // Hide TP/SL row when modifying existing position
60-
/** When false, confirmation screen uses header: () => null; when true/undefined uses headerLeft/title options */
61-
showPerpsHeader?: boolean;
62-
/** Analytics: how the user got to the order screen (e.g. trade_action, order_book_long_button, asset_detail_screen) */
63-
source?: string;
64-
/** Analytics: chart library active when the order flow started */
65-
chartLibrary?: string;
66-
transactionActiveAbTests?: TransactionActiveAbTestEntry[];
67-
};
72+
PerpsOrder: PerpsOrderRouteParams;
6873

6974
PerpsOrderSuccess: {
7075
orderId: string;
@@ -108,24 +113,27 @@ export type PerpsStackParamList = {
108113
// Market and position management routes
109114
PerpsMarketList: undefined;
110115

111-
PerpsMarketListView: {
112-
source?: string;
113-
variant?: 'full' | 'minimal';
114-
title?: string;
115-
showBalanceActions?: boolean;
116-
showBottomNav?: boolean;
117-
showWatchlistOnly?: boolean;
118-
defaultMarketTypeFilter?: MarketTypeFilter;
119-
defaultSortOptionId?: SortOptionId;
120-
defaultSortDirection?: SortDirection;
121-
fromHome?: boolean;
122-
button_clicked?: string;
123-
button_location?: string;
124-
transactionActiveAbTests?: TransactionActiveAbTestEntry[];
125-
};
116+
PerpsMarketListView:
117+
| {
118+
source?: string;
119+
variant?: 'full' | 'minimal';
120+
title?: string;
121+
showBalanceActions?: boolean;
122+
showBottomNav?: boolean;
123+
showWatchlistOnly?: boolean;
124+
defaultMarketTypeFilter?: MarketTypeFilter;
125+
defaultSortOptionId?: SortOptionId;
126+
defaultSortDirection?: SortDirection;
127+
fromHome?: boolean;
128+
button_clicked?: string;
129+
button_location?: string;
130+
transactionActiveAbTests?: TransactionActiveAbTestEntry[];
131+
}
132+
| undefined;
126133

127134
PerpsMarketDetails: {
128-
market: PerpsMarketData;
135+
/** Full market when available; Partial is accepted for trade-details deep entries. */
136+
market: PerpsMarketData | Partial<PerpsMarketData>;
129137
initialTab?: 'position' | 'orders' | 'info';
130138
monitoringIntent?: Partial<DataMonitorParams>;
131139
source?: string;
@@ -190,16 +198,18 @@ export type PerpsStackParamList = {
190198
transaction: PerpsTransaction;
191199
};
192200

193-
PerpsTutorial: {
194-
isFromDeeplink?: boolean;
195-
isFromGTMModal?: boolean;
196-
/** Analytics: how the user got to the tutorial (e.g. homescreen_tab, main_action_button) */
197-
source?: string;
198-
/** Screen to navigate to after tutorial completion instead of the default PerpsHome */
199-
redirectScreen?: string;
200-
/** Params to pass to the redirect screen */
201-
redirectParams?: Record<string, unknown>;
202-
};
201+
PerpsTutorial:
202+
| {
203+
isFromDeeplink?: boolean;
204+
isFromGTMModal?: boolean;
205+
/** Analytics: how the user got to the tutorial (e.g. homescreen_tab, main_action_button) */
206+
source?: string;
207+
/** Screen to navigate to after tutorial completion instead of the default PerpsHome */
208+
redirectScreen?: string;
209+
/** Params to pass to the redirect screen */
210+
redirectParams?: Record<string, unknown>;
211+
}
212+
| undefined;
203213

204214
// TP/SL screen
205215
PerpsTPSL: {
@@ -230,6 +240,7 @@ export type PerpsStackParamList = {
230240
PerpsPnlHeroCard: {
231241
position: Position;
232242
marketPrice?: string;
243+
source?: string;
233244
};
234245

235246
// Order Book view - Full depth order book display
@@ -255,10 +266,11 @@ export type PerpsStackParamList = {
255266
showBackButton?: boolean;
256267
};
257268

258-
/** Params for RedesignedConfirmations when shown in Perps stack (header options) */
259-
RedesignedConfirmations: {
260-
showPerpsHeader?: boolean;
261-
};
269+
/**
270+
* Params for RedesignedConfirmations when opened from Perps order flow.
271+
* Partial so header-option helpers can take only `showPerpsHeader`.
272+
*/
273+
RedesignedConfirmations: Partial<PerpsOrderRouteParams> | undefined;
262274

263275
/** Params for PerpsOrderRedirect - handles one-click trade from token details */
264276
PerpsOrderRedirect: {
@@ -270,21 +282,23 @@ export type PerpsStackParamList = {
270282
};
271283

272284
// Screen names registered in the Perps stack (may differ from legacy aliases above)
273-
PerpsTrendingView: {
274-
source?: string;
275-
variant?: 'full' | 'minimal';
276-
title?: string;
277-
showBalanceActions?: boolean;
278-
showBottomNav?: boolean;
279-
showWatchlistOnly?: boolean;
280-
defaultMarketTypeFilter?: MarketTypeFilter;
281-
defaultSortOptionId?: SortOptionId;
282-
defaultSortDirection?: SortDirection;
283-
fromHome?: boolean;
284-
button_clicked?: string;
285-
button_location?: string;
286-
transactionActiveAbTests?: TransactionActiveAbTestEntry[];
287-
};
285+
PerpsTrendingView:
286+
| {
287+
source?: string;
288+
variant?: 'full' | 'minimal';
289+
title?: string;
290+
showBalanceActions?: boolean;
291+
showBottomNav?: boolean;
292+
showWatchlistOnly?: boolean;
293+
defaultMarketTypeFilter?: MarketTypeFilter;
294+
defaultSortOptionId?: SortOptionId;
295+
defaultSortDirection?: SortDirection;
296+
fromHome?: boolean;
297+
button_clicked?: string;
298+
button_location?: string;
299+
transactionActiveAbTests?: TransactionActiveAbTestEntry[];
300+
}
301+
| undefined;
288302
PerpsOrderDetailsView: {
289303
order: Order;
290304
action?: 'view' | 'edit' | 'cancel';

app/core/NavigationService/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ import type { QRTabSwitcherParams } from '../../components/Views/QRTabSwitcher/Q
5454
// Perps navigation params
5555
import type {
5656
PerpsNavigationParamList,
57+
PerpsOrderRouteParams,
5758
PerpsStackParamList,
5859
} from '../../components/UI/Perps/types/navigation';
60+
import type { ConfirmationParams } from '../../components/Views/confirmations/components/confirm/confirm-component';
5961
import type { MoneyNavigationParamList } from '../../components/UI/Money/types/navigation';
6062
import type {
6163
CardModalsNavigationParamList,
@@ -872,7 +874,10 @@ export type RootStackParamList = {
872874
EarnLendingLearnMoreModal: undefined;
873875

874876
// Full screen confirmation routes
875-
RedesignedConfirmations: undefined;
877+
RedesignedConfirmations:
878+
| ConfirmationParams
879+
| Partial<PerpsOrderRouteParams>
880+
| undefined;
876881
NoHeaderConfirmations: undefined;
877882

878883
// Identity routes

0 commit comments

Comments
 (0)