Compare commits

..
Author SHA1 Message Date
Aleka Cheung 91bedd9fec update switch chain error requirements check 2024-02-12 13:01:24 -05:00
Aleka Cheung 8818d64c3e skip logging more expected errors 2024-02-12 12:44:45 -05:00
Aleka Cheung 949a1bfd6c avoid logging expected switch chain error 2024-02-08 15:00:04 -05:00
Jared Vu 5fb2f278da Liquid staking language and localization (#289)
* ✏️ Liquid staking language and localization

* import nits
2024-02-08 06:44:50 -08:00
Jared Vu bd788f22e8 Restore env format (#288)
* restore formatting

* copy from prev commit
2024-02-07 14:22:12 -08:00
26 changed files with 1483 additions and 1626 deletions
+1 -1
View File
@@ -42,7 +42,7 @@
"@cosmjs/tendermint-rpc": "^0.32.1", "@cosmjs/tendermint-rpc": "^0.32.1",
"@dydxprotocol/v4-abacus": "^1.4.2", "@dydxprotocol/v4-abacus": "^1.4.2",
"@dydxprotocol/v4-client-js": "^1.0.20", "@dydxprotocol/v4-client-js": "^1.0.20",
"@dydxprotocol/v4-localization": "^1.1.25", "@dydxprotocol/v4-localization": "^1.1.26",
"@ethersproject/providers": "^5.7.2", "@ethersproject/providers": "^5.7.2",
"@js-joda/core": "^5.5.3", "@js-joda/core": "^5.5.3",
"@radix-ui/react-accordion": "^1.1.2", "@radix-ui/react-accordion": "^1.1.2",
+9 -5
View File
@@ -36,8 +36,8 @@ dependencies:
specifier: ^1.0.20 specifier: ^1.0.20
version: 1.0.20 version: 1.0.20
'@dydxprotocol/v4-localization': '@dydxprotocol/v4-localization':
specifier: ^1.1.25 specifier: ^1.1.26
version: 1.1.25 version: 1.1.26
'@ethersproject/providers': '@ethersproject/providers':
specifier: ^5.7.2 specifier: ^5.7.2
version: 5.7.2 version: 5.7.2
@@ -1323,8 +1323,8 @@ packages:
- utf-8-validate - utf-8-validate
dev: false dev: false
/@dydxprotocol/v4-localization@1.1.25: /@dydxprotocol/v4-localization@1.1.26:
resolution: {integrity: sha512-84BJMybnZBrRnDpnHlMUcOYT1r0ODtgcdgrjdzTw8b0sViTY6ne9ob690fcn/vQO+6sEdDsdt+08ud0H+ZvyYg==} resolution: {integrity: sha512-u+J1J5Up8McwZOcDaG9GrH/A8p4vD2NU2CT2hPdYyKgEd28XeAYvv7bNAQRKdiBaqTePbbF5uB6TMAQnEGnb1A==}
dev: false dev: false
/@dydxprotocol/v4-proto@4.0.0-dev.0: /@dydxprotocol/v4-proto@4.0.0-dev.0:
@@ -8882,7 +8882,7 @@ packages:
resolution: {integrity: sha512-WIdaQ8uW1vIbYvNnAVunkC6yxTrneJC7VQ5UUQ0kuw8b0C0A39KTIpoQHCfc8tV7o9vF4niwRhdXEdfAgQEsQQ==} resolution: {integrity: sha512-WIdaQ8uW1vIbYvNnAVunkC6yxTrneJC7VQ5UUQ0kuw8b0C0A39KTIpoQHCfc8tV7o9vF4niwRhdXEdfAgQEsQQ==}
dependencies: dependencies:
cosmos-directory-types: 0.0.6 cosmos-directory-types: 0.0.6
node-fetch-native: 1.6.1 node-fetch-native: 1.6.2
dev: false dev: false
/cosmos-directory-types@0.0.6: /cosmos-directory-types@0.0.6:
@@ -12892,6 +12892,10 @@ packages:
resolution: {integrity: sha512-bW9T/uJDPAJB2YNYEpWzE54U5O3MQidXsOyTfnbKYtTtFexRvGzb1waphBN4ZwP6EcIvYYEOwW0b72BpAqydTw==} resolution: {integrity: sha512-bW9T/uJDPAJB2YNYEpWzE54U5O3MQidXsOyTfnbKYtTtFexRvGzb1waphBN4ZwP6EcIvYYEOwW0b72BpAqydTw==}
dev: false dev: false
/node-fetch-native@1.6.2:
resolution: {integrity: sha512-69mtXOFZ6hSkYiXAVB5SqaRvrbITC/NPyqv7yuu/qw0nmgPyYbIMYYNIDhNtwPrzk0ptrimrLz/hhjvm4w5Z+w==}
dev: false
/node-fetch@2.6.12: /node-fetch@2.6.12:
resolution: {integrity: sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==} resolution: {integrity: sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==}
engines: {node: 4.x || >=6.0.0} engines: {node: 4.x || >=6.0.0}
+1319 -1302
View File
File diff suppressed because it is too large Load Diff
+20 -54
View File
@@ -4,6 +4,7 @@ import { AlertType } from '@/constants/alerts';
import { STRING_KEYS } from '@/constants/localization'; import { STRING_KEYS } from '@/constants/localization';
import { TimeUnitShort } from '@/constants/time'; import { TimeUnitShort } from '@/constants/time';
// TODO: rename to OrderType
export enum TradeTypes { export enum TradeTypes {
MARKET = 'MARKET', MARKET = 'MARKET',
LIMIT = 'LIMIT', LIMIT = 'LIMIT',
@@ -14,16 +15,6 @@ export enum TradeTypes {
TRAILING_STOP = 'TRAILING_STOP', TRAILING_STOP = 'TRAILING_STOP',
} }
enum ClosingTradeTypes {
LIQUIDATED = 'LIQUIDATED',
LIQUIDATION = 'LIQUIDATION',
OFFSETTING = 'OFFSETTING',
DELEVERAGED = 'DELEVERAGED',
FINAL_SETTLEMENT = 'FINAL_SETTLEMENT',
}
export type OrderType = TradeTypes | ClosingTradeTypes;
export enum TimeInForceOptions { export enum TimeInForceOptions {
GTT = 'GTT', GTT = 'GTT',
FOK = 'FOK', FOK = 'FOK',
@@ -49,74 +40,49 @@ export const POSITION_SIDE_STRINGS: Record<PositionSide, string> = {
[PositionSide.Short]: STRING_KEYS.SHORT_POSITION_SHORT, [PositionSide.Short]: STRING_KEYS.SHORT_POSITION_SHORT,
}; };
export const ORDER_TYPE_STRINGS: Record< export const TRADE_TYPE_STRINGS: Record<
OrderType, TradeTypes,
{ {
orderTypeKeyShort: string; tradeTypeKeyShort: string;
orderTypeKey: string; tradeTypeKey: string;
descriptionKey: string | null; descriptionKey: string;
} }
> = { > = {
[TradeTypes.LIMIT]: { [TradeTypes.LIMIT]: {
orderTypeKeyShort: STRING_KEYS.LIMIT_ORDER_SHORT, tradeTypeKeyShort: STRING_KEYS.LIMIT_ORDER_SHORT,
orderTypeKey: STRING_KEYS.LIMIT_ORDER, tradeTypeKey: STRING_KEYS.LIMIT_ORDER,
descriptionKey: STRING_KEYS.LIMIT_ORDER_DESCRIPTION, descriptionKey: STRING_KEYS.LIMIT_ORDER_DESCRIPTION,
}, },
[TradeTypes.MARKET]: { [TradeTypes.MARKET]: {
orderTypeKeyShort: STRING_KEYS.MARKET_ORDER_SHORT, tradeTypeKeyShort: STRING_KEYS.MARKET_ORDER_SHORT,
orderTypeKey: STRING_KEYS.MARKET_ORDER, tradeTypeKey: STRING_KEYS.MARKET_ORDER,
descriptionKey: STRING_KEYS.MARKET_ORDER_DESCRIPTION, descriptionKey: STRING_KEYS.MARKET_ORDER_DESCRIPTION,
}, },
[TradeTypes.STOP_LIMIT]: { [TradeTypes.STOP_LIMIT]: {
orderTypeKeyShort: STRING_KEYS.STOP_LIMIT, tradeTypeKeyShort: STRING_KEYS.STOP_LIMIT,
orderTypeKey: STRING_KEYS.STOP_LIMIT, tradeTypeKey: STRING_KEYS.STOP_LIMIT,
descriptionKey: STRING_KEYS.STOP_LIMIT_DESCRIPTION, descriptionKey: STRING_KEYS.STOP_LIMIT_DESCRIPTION,
}, },
[TradeTypes.STOP_MARKET]: { [TradeTypes.STOP_MARKET]: {
orderTypeKeyShort: STRING_KEYS.STOP_MARKET, tradeTypeKeyShort: STRING_KEYS.STOP_MARKET,
orderTypeKey: STRING_KEYS.STOP_MARKET, tradeTypeKey: STRING_KEYS.STOP_MARKET,
descriptionKey: STRING_KEYS.STOP_MARKET_DESCRIPTION, descriptionKey: STRING_KEYS.STOP_MARKET_DESCRIPTION,
}, },
[TradeTypes.TAKE_PROFIT]: { [TradeTypes.TAKE_PROFIT]: {
orderTypeKeyShort: STRING_KEYS.TAKE_PROFIT_LIMIT, tradeTypeKeyShort: STRING_KEYS.TAKE_PROFIT_LIMIT,
orderTypeKey: STRING_KEYS.TAKE_PROFIT_LIMIT, tradeTypeKey: STRING_KEYS.TAKE_PROFIT_LIMIT,
descriptionKey: STRING_KEYS.TAKE_PROFIT_LIMIT_DESCRIPTION, descriptionKey: STRING_KEYS.TAKE_PROFIT_LIMIT_DESCRIPTION,
}, },
[TradeTypes.TAKE_PROFIT_MARKET]: { [TradeTypes.TAKE_PROFIT_MARKET]: {
orderTypeKeyShort: STRING_KEYS.TAKE_PROFIT_MARKET, tradeTypeKeyShort: STRING_KEYS.TAKE_PROFIT_MARKET,
orderTypeKey: STRING_KEYS.TAKE_PROFIT_MARKET, tradeTypeKey: STRING_KEYS.TAKE_PROFIT_MARKET,
descriptionKey: STRING_KEYS.TAKE_PROFIT_MARKET_DESCRIPTION, descriptionKey: STRING_KEYS.TAKE_PROFIT_MARKET_DESCRIPTION,
}, },
[TradeTypes.TRAILING_STOP]: { [TradeTypes.TRAILING_STOP]: {
orderTypeKeyShort: STRING_KEYS.TRAILING_STOP, tradeTypeKeyShort: STRING_KEYS.TRAILING_STOP,
orderTypeKey: STRING_KEYS.TRAILING_STOP, tradeTypeKey: STRING_KEYS.TRAILING_STOP,
descriptionKey: STRING_KEYS.TRAILING_STOP_DESCRIPTION, descriptionKey: STRING_KEYS.TRAILING_STOP_DESCRIPTION,
}, },
[ClosingTradeTypes.LIQUIDATED]: {
orderTypeKeyShort: STRING_KEYS.LIQUIDATED,
orderTypeKey: STRING_KEYS.LIQUIDATED,
descriptionKey: null,
},
[ClosingTradeTypes.LIQUIDATION]: {
orderTypeKeyShort: STRING_KEYS.LIQUIDATION,
orderTypeKey: STRING_KEYS.LIQUIDATION,
descriptionKey: null,
},
[ClosingTradeTypes.OFFSETTING]: {
orderTypeKeyShort: STRING_KEYS.OFFSETTING,
orderTypeKey: STRING_KEYS.OFFSETTING,
descriptionKey: null,
},
[ClosingTradeTypes.DELEVERAGED]: {
orderTypeKeyShort: STRING_KEYS.DELEVERAGED,
orderTypeKey: STRING_KEYS.DELEVERAGED,
descriptionKey: null,
},
[ClosingTradeTypes.FINAL_SETTLEMENT]: {
orderTypeKeyShort: STRING_KEYS.FINAL_SETTLEMENT,
orderTypeKey: STRING_KEYS.FINAL_SETTLEMENT,
descriptionKey: null,
},
}; };
export const GOOD_TIL_TIME_TIMESCALE_STRINGS: Record<TimeUnitShort, string> = { export const GOOD_TIL_TIME_TIMESCALE_STRINGS: Record<TimeUnitShort, string> = {
+1
View File
@@ -40,6 +40,7 @@ export enum WalletErrorType {
// General // General
ChainMismatch, ChainMismatch,
UserCanceled, UserCanceled,
SwitchChainMethodMissing,
// Non-Deterministic // Non-Deterministic
NonDeterministicWallet, NonDeterministicWallet,
+4 -23
View File
@@ -5,11 +5,9 @@ import isEmpty from 'lodash/isEmpty';
import { LanguageCode, ResolutionString, widget } from 'public/tradingview/charting_library'; import { LanguageCode, ResolutionString, widget } from 'public/tradingview/charting_library';
import { DEFAULT_RESOLUTION } from '@/constants/candles'; import { DEFAULT_RESOLUTION } from '@/constants/candles';
import { SUPPORTED_LOCALE_BASE_TAGS, STRING_KEYS } from '@/constants/localization'; import { SUPPORTED_LOCALE_BASE_TAGS } from '@/constants/localization';
import { LocalStorageKey } from '@/constants/localStorage'; import { LocalStorageKey } from '@/constants/localStorage';
import { useDydxClient, useLocalStorage } from '@/hooks';
import { useDydxClient, useLocalStorage, useStringGetter } from '@/hooks';
import { store } from '@/state/_store'; import { store } from '@/state/_store';
import { getSelectedNetwork } from '@/state/appSelectors'; import { getSelectedNetwork } from '@/state/appSelectors';
@@ -25,19 +23,14 @@ import { getSavedResolution, getWidgetOptions, getWidgetOverrides } from '@/lib/
*/ */
export const useTradingView = ({ export const useTradingView = ({
tvWidgetRef, tvWidgetRef,
displayButtonRef,
setIsChartReady, setIsChartReady,
}: { }: {
tvWidgetRef: React.MutableRefObject<any>; tvWidgetRef: React.MutableRefObject<any>;
displayButtonRef: React.MutableRefObject<any>;
setIsChartReady: React.Dispatch<React.SetStateAction<boolean>>; setIsChartReady: React.Dispatch<React.SetStateAction<boolean>>;
}) => { }) => {
const stringGetter = useStringGetter(); const marketId = useSelector(getCurrentMarketId);
const appTheme = useSelector(getAppTheme); const appTheme = useSelector(getAppTheme);
const appColorMode = useSelector(getAppColorMode); const appColorMode = useSelector(getAppColorMode);
const marketId = useSelector(getCurrentMarketId);
const marketIds = useSelector(getMarketIds, shallowEqual); const marketIds = useSelector(getMarketIds, shallowEqual);
const selectedLocale = useSelector(getSelectedLocale); const selectedLocale = useSelector(getSelectedLocale);
const selectedNetwork = useSelector(getSelectedNetwork); const selectedNetwork = useSelector(getSelectedNetwork);
@@ -56,6 +49,7 @@ export const useTradingView = ({
const widgetOptions = getWidgetOptions(); const widgetOptions = getWidgetOptions();
const widgetOverrides = getWidgetOverrides({ appTheme, appColorMode }); const widgetOverrides = getWidgetOverrides({ appTheme, appColorMode });
const options = { const options = {
// debug: true,
...widgetOptions, ...widgetOptions,
...widgetOverrides, ...widgetOverrides,
datafeed: getDydxDatafeed(store, getCandlesForDatafeed), datafeed: getDydxDatafeed(store, getCandlesForDatafeed),
@@ -69,17 +63,6 @@ export const useTradingView = ({
tvWidgetRef.current = tvChartWidget; tvWidgetRef.current = tvChartWidget;
tvWidgetRef.current.onChartReady(() => { tvWidgetRef.current.onChartReady(() => {
tvWidgetRef?.current?.headerReady().then(() => {
displayButtonRef.current = tvWidgetRef?.current?.createButton();
displayButtonRef.current.innerHTML = `<span>${stringGetter({
key: STRING_KEYS.ORDER_LINES,
})}</span> <div class="displayOrdersButton-toggle"></div>`;
displayButtonRef.current.setAttribute(
'title',
stringGetter({ key: STRING_KEYS.ORDER_LINES_TOOLTIP })
);
});
tvWidgetRef?.current?.subscribe('onAutoSaveNeeded', () => tvWidgetRef?.current?.subscribe('onAutoSaveNeeded', () =>
tvWidgetRef?.current?.save((chartConfig: object) => setTvChartConfig(chartConfig)) tvWidgetRef?.current?.save((chartConfig: object) => setTvChartConfig(chartConfig))
); );
@@ -89,8 +72,6 @@ export const useTradingView = ({
} }
return () => { return () => {
displayButtonRef.current?.remove();
displayButtonRef.current = null;
tvWidgetRef.current?.remove(); tvWidgetRef.current?.remove();
tvWidgetRef.current = null; tvWidgetRef.current = null;
setIsChartReady(false); setIsChartReady(false);
+8 -37
View File
@@ -1,16 +1,12 @@
import { useEffect } from 'react'; import { useEffect } from 'react';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import type { import type { IChartingLibraryWidget, ThemeName } from 'public/tradingview/charting_library';
IChartingLibraryWidget,
IOrderLineAdapter,
ThemeName,
} from 'public/tradingview/charting_library';
import { AppColorMode, AppTheme } from '@/state/configs'; import { AppColorMode, AppTheme } from '@/state/configs';
import { getAppTheme, getAppColorMode } from '@/state/configsSelectors'; import { getAppTheme, getAppColorMode } from '@/state/configsSelectors';
import { getWidgetOverrides, getOrderLineColors } from '@/lib/tradingView/utils'; import { getWidgetOverrides } from '@/lib/tradingView/utils';
/** /**
* @description Method to define a type guard and check that an element is an IFRAME * @description Method to define a type guard and check that an element is an IFRAME
@@ -26,11 +22,9 @@ const isIFrame = (element: HTMLElement | null): element is HTMLIFrameElement =>
* In order to support our Classic along with Dark/Light, we are directly accessing the <html> within the iFrame. * In order to support our Classic along with Dark/Light, we are directly accessing the <html> within the iFrame.
*/ */
export const useTradingViewTheme = ({ export const useTradingViewTheme = ({
orderLines,
tvWidget, tvWidget,
isWidgetReady, isWidgetReady,
}: { }: {
orderLines: Record<string, IOrderLineAdapter>;
tvWidget: (IChartingLibraryWidget & { _id?: string; _ready?: boolean }) | null; tvWidget: (IChartingLibraryWidget & { _id?: string; _ready?: boolean }) | null;
isWidgetReady?: boolean; isWidgetReady?: boolean;
}) => { }) => {
@@ -43,8 +37,8 @@ export const useTradingViewTheme = ({
.changeTheme?.( .changeTheme?.(
{ {
[AppTheme.Classic]: '', [AppTheme.Classic]: '',
[AppTheme.Dark]: 'dark', [AppTheme.Dark]: 'Dark',
[AppTheme.Light]: 'light', [AppTheme.Light]: 'Light',
}[appTheme] as ThemeName }[appTheme] as ThemeName
) )
.then(() => { .then(() => {
@@ -55,17 +49,9 @@ export const useTradingViewTheme = ({
if (isIFrame(frame) && frame.contentWindow) { if (isIFrame(frame) && frame.contentWindow) {
const innerHtml = frame.contentWindow.document.documentElement; const innerHtml = frame.contentWindow.document.documentElement;
switch (appTheme) {
case AppTheme.Classic: if (appTheme === AppTheme.Classic) {
innerHtml?.classList.remove('theme-dark', 'theme-light'); innerHtml?.classList.remove('theme-dark', 'theme-light');
break;
case AppTheme.Dark:
innerHtml?.classList.remove('theme-light');
innerHtml?.classList.add('theme-dark');
break;
case AppTheme.Light:
innerHtml?.classList.remove('theme-dark');
innerHtml?.classList.add('theme-light');
} }
} }
} }
@@ -87,22 +73,7 @@ export const useTradingViewTheme = ({
'volume.color.1': studies_overrides['volume.volume.color.1'], 'volume.color.1': studies_overrides['volume.volume.color.1'],
}); });
} }
// Necessary to update existing chart lines
Object.entries(orderLines).forEach(([key, line]) => {
const { orderColor, borderColor, backgroundColor, textColor, textButtonColor } =
getOrderLineColors({ side: key.split('-')[0], appTheme, appColorMode });
line
.setLineColor(orderColor)
.setQuantityBackgroundColor(orderColor)
.setQuantityBorderColor(borderColor)
.setBodyBackgroundColor(backgroundColor)
.setBodyBorderColor(borderColor)
.setBodyTextColor(textColor)
.setQuantityTextColor(textButtonColor);
});
}); });
} }
}, [appTheme, appColorMode, isWidgetReady]); }, [appTheme, appColorMode]);
}; };
+1 -1
View File
@@ -88,7 +88,7 @@ export const usePotentialMarketsContext = () => {
impactNotional: 10_000, impactNotional: 10_000,
}, },
1: { 1: {
label: 'Mid-cap', label: stringGetter({ key: STRING_KEYS.MID_CAP }),
initialMarginFraction: 0.1, initialMarginFraction: 0.1,
maintenanceMarginFraction: 0.05, maintenanceMarginFraction: 0.05,
impactNotional: 5_000, impactNotional: 5_000,
+10 -7
View File
@@ -163,17 +163,20 @@ export const useWalletConnection = () => {
} }
} }
} catch (error) { } catch (error) {
throw Object.assign( const { isErrorExpected } = parseWalletError({ error, stringGetter });
new Error([error.message, error.cause?.message].filter(Boolean).join('\n')), if (!isErrorExpected) {
{ throw Object.assign(
walletConnectionType: walletConnection?.type, new Error([error.message, error.cause?.message].filter(Boolean).join('\n')),
} {
); walletConnectionType: walletConnection?.type,
}
);
}
} }
return { return {
walletType, walletType,
walletConnectionType: walletConnection.type, walletConnectionType: walletConnection?.type,
}; };
}, },
[isConnectedGraz, signerGraz, isConnectedWagmi, signerWagmi] [isConnectedGraz, signerGraz, isConnectedWagmi, signerWagmi]
+1 -28
View File
@@ -1,8 +1,6 @@
import { OrderSide } from '@dydxprotocol/v4-client-js';
import { Candle, TradingViewBar, TradingViewSymbol } from '@/constants/candles'; import { Candle, TradingViewBar, TradingViewSymbol } from '@/constants/candles';
import { AppTheme, type AppColorMode } from '@/state/configs'; import type { AppTheme, AppColorMode } from '@/state/configs';
import { Themes } from '@/styles/themes'; import { Themes } from '@/styles/themes';
@@ -49,30 +47,6 @@ export const getHistorySlice = ({
return bars.filter(({ time }) => time >= fromMs); return bars.filter(({ time }) => time >= fromMs);
}; };
export const getOrderLineColors = ({
appTheme,
appColorMode,
side,
}: {
appTheme: AppTheme;
appColorMode: AppColorMode;
side: OrderSide;
}) => {
const theme = Themes[appTheme][appColorMode];
const orderColor = {
[OrderSide.BUY]: theme.positive,
[OrderSide.SELL]: theme.negative,
}[side];
return {
orderColor,
borderColor: theme.borderDefault,
backgroundColor: theme.layer1,
textColor: theme.textTertiary,
textButtonColor: theme.textButton,
};
};
export const getWidgetOverrides = ({ export const getWidgetOverrides = ({
appTheme, appTheme,
appColorMode, appColorMode,
@@ -83,7 +57,6 @@ export const getWidgetOverrides = ({
const theme = Themes[appTheme][appColorMode]; const theme = Themes[appTheme][appColorMode];
return { return {
theme: appTheme === AppTheme.Dark ? 'dark' : AppTheme.Light ? 'light' : '',
overrides: { overrides: {
'paneProperties.background': theme.layer2, 'paneProperties.background': theme.layer2,
'paneProperties.horzGridProperties.color': theme.layer3, 'paneProperties.horzGridProperties.color': theme.layer3,
+11 -1
View File
@@ -92,6 +92,10 @@ export const getWalletErrorType = ({ error }: { error: Error }) => {
return WalletErrorType.ChainMismatch; return WalletErrorType.ChainMismatch;
} }
if (messageLower.includes('Missing or invalid. request() method: wallet_switchEthereumChain')) {
return WalletErrorType.SwitchChainMethodMissing;
}
// ImToken - User canceled // ImToken - User canceled
if (messageLower.includes('用户取消了操作')) { if (messageLower.includes('用户取消了操作')) {
return WalletErrorType.UserCanceled; return WalletErrorType.UserCanceled;
@@ -113,13 +117,18 @@ export const parseWalletError = ({
}) => { }) => {
const walletErrorType = getWalletErrorType({ error }); const walletErrorType = getWalletErrorType({ error });
let message; let message;
let isErrorExpected;
switch (walletErrorType) { switch (walletErrorType) {
case WalletErrorType.ChainMismatch: case WalletErrorType.ChainMismatch:
case WalletErrorType.UserCanceled: { case WalletErrorType.UserCanceled:
case WalletErrorType.SwitchChainMethodMissing: {
isErrorExpected = true;
message = error.message;
break; break;
} }
default: { default: {
isErrorExpected = false;
message = stringGetter({ message = stringGetter({
key: STRING_KEYS.SOMETHING_WENT_WRONG_WITH_MESSAGE, key: STRING_KEYS.SOMETHING_WENT_WRONG_WITH_MESSAGE,
params: { params: {
@@ -132,5 +141,6 @@ export const parseWalletError = ({
return { return {
walletErrorType, walletErrorType,
message, message,
isErrorExpected,
}; };
}; };
+1 -1
View File
@@ -19,7 +19,7 @@ export default () => {
<Styled.HeaderSection> <Styled.HeaderSection>
<ContentSectionHeader <ContentSectionHeader
title={stringGetter({ key: STRING_KEYS.GOVERNANCE })} title={stringGetter({ key: STRING_KEYS.GOVERNANCE })}
subtitle="Participate in the ecosystem by voting on Governance proposals or submitting your own." subtitle={stringGetter({ key: STRING_KEYS.GOVERNANCE_PAGE_SUBTITLE })}
/> />
</Styled.HeaderSection> </Styled.HeaderSection>
+1 -1
View File
@@ -59,7 +59,7 @@ export default () => {
<Icon iconName={IconName.CurrencySign} /> <Icon iconName={IconName.CurrencySign} />
</Styled.IconContainer> </Styled.IconContainer>
), ),
label: 'Staking Rewards', // stringGetter({ key: STRING_KEYS.STAKING_REWARDS }), label: stringGetter({ key: STRING_KEYS.STAKING_REWARDS }),
href: TokenRoute.StakingRewards, href: TokenRoute.StakingRewards,
tag: stringGetter({ key: STRING_KEYS.NEW }), tag: stringGetter({ key: STRING_KEYS.NEW }),
}, },
+5 -2
View File
@@ -5,18 +5,21 @@ import { layoutMixins } from '@/styles/layoutMixins';
import { DetachedSection } from '@/components/ContentSection'; import { DetachedSection } from '@/components/ContentSection';
import { ContentSectionHeader } from '@/components/ContentSectionHeader'; import { ContentSectionHeader } from '@/components/ContentSectionHeader';
import { useStringGetter } from '@/hooks';
import { StakingPanel } from './StakingPanel'; import { StakingPanel } from './StakingPanel';
import { StrideStakingPanel } from './StrideStakingPanel'; import { StrideStakingPanel } from './StrideStakingPanel';
import { DYDXBalancePanel } from '../rewards/DYDXBalancePanel'; import { DYDXBalancePanel } from '../rewards/DYDXBalancePanel';
import { STRING_KEYS } from '@/constants/localization';
export default () => { export default () => {
const stringGetter = useStringGetter();
return ( return (
<DetachedSection> <DetachedSection>
<Styled.HeaderSection> <Styled.HeaderSection>
<ContentSectionHeader <ContentSectionHeader
title="Staking Rewards" title={stringGetter({ key: STRING_KEYS.STAKING_REWARDS })}
subtitle="Stake to earn APR. Unstaking can take up to 30 days." subtitle={stringGetter({ key: STRING_KEYS.STAKING_PAGE_SUBTITLE })}
/> />
</Styled.HeaderSection> </Styled.HeaderSection>
+1 -1
View File
@@ -23,7 +23,7 @@ export const StakingPanel = ({ className }: { className?: string }) => {
className={className} className={className}
slotHeaderContent={ slotHeaderContent={
<Styled.Header> <Styled.Header>
<Styled.Title>Stake with Keplr</Styled.Title> <Styled.Title>{stringGetter({ key: STRING_KEYS.STAKE_WITH_KEPLR })}</Styled.Title>
<Styled.Img src="/third-party/keplr.png" alt={stringGetter({ key: STRING_KEYS.KEPLR })} /> <Styled.Img src="/third-party/keplr.png" alt={stringGetter({ key: STRING_KEYS.KEPLR })} />
</Styled.Header> </Styled.Header>
} }
@@ -24,7 +24,7 @@ export const StrideStakingPanel = ({ className }: { className?: string }) => {
slotHeaderContent={ slotHeaderContent={
<Styled.Header> <Styled.Header>
<Styled.Title> <Styled.Title>
Liquid Stake with Stride {stringGetter({ key: STRING_KEYS.LIQUID_STAKE_W_STRIDE })}
<Tag isHighlighted>{stringGetter({ key: STRING_KEYS.NEW })}</Tag> <Tag isHighlighted>{stringGetter({ key: STRING_KEYS.NEW })}</Tag>
</Styled.Title> </Styled.Title>
<Styled.Img src="/third-party/stride.png" alt="Stride" /> <Styled.Img src="/third-party/stride.png" alt="Stride" />
@@ -33,7 +33,10 @@ export const StrideStakingPanel = ({ className }: { className?: string }) => {
onClick={() => dispatch(openDialog({ type: DialogTypes.ExternalNavStride }))} onClick={() => dispatch(openDialog({ type: DialogTypes.ExternalNavStride }))}
> >
<Styled.Description> <Styled.Description>
{`Stake your ${chainTokenLabel} tokens for st${chainTokenLabel} which you can deploy around the ecosystem.`} {stringGetter({
key: STRING_KEYS.LIQUID_STAKE_STRIDE_DESCRIPTION,
params: { TOKEN_DENOM: chainTokenLabel },
})}
<Link href={stakingLearnMore} onClick={(e) => e.stopPropagation()}> <Link href={stakingLearnMore} onClick={(e) => e.stopPropagation()}>
{stringGetter({ key: STRING_KEYS.LEARN_MORE })} {stringGetter({ key: STRING_KEYS.LEARN_MORE })}
</Link> </Link>
+2 -2
View File
@@ -3,7 +3,7 @@ import { useSelector, shallowEqual } from 'react-redux';
import styled, { AnyStyledComponent } from 'styled-components'; import styled, { AnyStyledComponent } from 'styled-components';
import { STRING_KEYS } from '@/constants/localization'; import { STRING_KEYS } from '@/constants/localization';
import { ORDER_TYPE_STRINGS } from '@/constants/trade'; import { TRADE_TYPE_STRINGS } from '@/constants/trade';
import { layoutMixins } from '@/styles/layoutMixins'; import { layoutMixins } from '@/styles/layoutMixins';
@@ -43,7 +43,7 @@ export const TradeDialogTrigger = () => {
<Styled.TradeSummary> <Styled.TradeSummary>
<Styled.TradeType> <Styled.TradeType>
<span> <span>
{stringGetter({ key: ORDER_TYPE_STRINGS[selectedTradeType].orderTypeKey })} {stringGetter({ key: TRADE_TYPE_STRINGS[selectedTradeType].tradeTypeKey })}
</span> </span>
<OrderSideTag size={TagSize.Medium} orderSide={selectedOrderSide} /> <OrderSideTag size={TagSize.Medium} orderSide={selectedOrderSide} />
</Styled.TradeType> </Styled.TradeType>
+7 -139
View File
@@ -1,52 +1,28 @@
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
import styled, { type AnyStyledComponent, css } from 'styled-components'; import styled, { type AnyStyledComponent, css } from 'styled-components';
import { useDispatch, useSelector } from 'react-redux';
import type { import type { IChartingLibraryWidget, ResolutionString } from 'public/tradingview/charting_library';
IChartingLibraryWidget,
IOrderLineAdapter,
ResolutionString,
} from 'public/tradingview/charting_library';
import { AbacusOrderStatus } from '@/constants/abacus';
import { DEFAULT_RESOLUTION, RESOLUTION_CHART_CONFIGS } from '@/constants/candles';
import { DEFAULT_MARKETID } from '@/constants/markets'; import { DEFAULT_MARKETID } from '@/constants/markets';
import { type OrderType, ORDER_TYPE_STRINGS } from '@/constants/trade'; import { DEFAULT_RESOLUTION, RESOLUTION_CHART_CONFIGS } from '@/constants/candles';
import { useStringGetter } from '@/hooks';
import { useTradingView, useTradingViewTheme } from '@/hooks/tradingView'; import { useTradingView, useTradingViewTheme } from '@/hooks/tradingView';
import { LoadingSpace } from '@/components/Loading/LoadingSpinner'; import { LoadingSpace } from '@/components/Loading/LoadingSpinner';
import { getCurrentMarketOrders } from '@/state/accountSelectors';
import { getAppTheme, getAppColorMode } from '@/state/configsSelectors';
import { setTvChartResolution } from '@/state/perpetuals'; import { setTvChartResolution } from '@/state/perpetuals';
import { getCurrentMarketId, getSelectedResolutionForMarket } from '@/state/perpetualsSelectors'; import { getCurrentMarketId, getSelectedResolutionForMarket } from '@/state/perpetualsSelectors';
import { layoutMixins } from '@/styles/layoutMixins'; import { layoutMixins } from '@/styles/layoutMixins';
import { MustBigNumber } from '@/lib/numbers';
import { getOrderLineColors } from '@/lib/tradingView/utils';
type TvWidget = IChartingLibraryWidget & { _id?: string; _ready?: boolean }; type TvWidget = IChartingLibraryWidget & { _id?: string; _ready?: boolean };
let orderLines: Record<string, IOrderLineAdapter> = {};
export const TvChart = () => { export const TvChart = () => {
const dispatch = useDispatch();
const stringGetter = useStringGetter();
const [isChartReady, setIsChartReady] = useState(false); const [isChartReady, setIsChartReady] = useState(false);
const [showOrderLines, setShowOrderLines] = useState(false);
const displayButtonRef = useRef<HTMLElement | null>(null);
const appTheme = useSelector(getAppTheme);
const appColorMode = useSelector(getAppColorMode);
const dispatch = useDispatch();
const currentMarketId: string = useSelector(getCurrentMarketId) || DEFAULT_MARKETID; const currentMarketId: string = useSelector(getCurrentMarketId) || DEFAULT_MARKETID;
const currentMarketOrders = useSelector(getCurrentMarketOrders, shallowEqual);
const selectedResolution: string = const selectedResolution: string =
useSelector(getSelectedResolutionForMarket(currentMarketId)) || DEFAULT_RESOLUTION; useSelector(getSelectedResolutionForMarket(currentMarketId)) || DEFAULT_RESOLUTION;
@@ -57,8 +33,8 @@ export const TvChart = () => {
const chart = isWidgetReady ? tvWidget?.chart() : undefined; const chart = isWidgetReady ? tvWidget?.chart() : undefined;
const chartResolution = chart?.resolution?.(); const chartResolution = chart?.resolution?.();
const { savedResolution } = useTradingView({ tvWidgetRef, displayButtonRef, setIsChartReady }); const { savedResolution } = useTradingView({ tvWidgetRef, setIsChartReady });
useTradingViewTheme({ tvWidget, isWidgetReady, orderLines }); useTradingViewTheme({ tvWidget, isWidgetReady });
const setVisibleRangeForResolution = ({ resolution }: { resolution: ResolutionString }) => { const setVisibleRangeForResolution = ({ resolution }: { resolution: ResolutionString }) => {
// Different resolutions have different timeframes to display data efficiently. // Different resolutions have different timeframes to display data efficiently.
@@ -73,9 +49,6 @@ export const TvChart = () => {
tvWidget?.activeChart().setVisibleRange(newRange, { percentRightMargin: 10 }); tvWidget?.activeChart().setVisibleRange(newRange, { percentRightMargin: 10 });
}; };
/**
* @description Hook to handle changing chart resolution
*/
useEffect(() => { useEffect(() => {
if (chartResolution) { if (chartResolution) {
if (chartResolution !== selectedResolution) { if (chartResolution !== selectedResolution) {
@@ -96,111 +69,6 @@ export const TvChart = () => {
} }
}, [currentMarketId, isWidgetReady]); }, [currentMarketId, isWidgetReady]);
/**
* @description Hook to handle order line toggle state
*/
useEffect(() => {
if (isChartReady && displayButtonRef && displayButtonRef.current) {
displayButtonRef.current.onclick = () => {
const newShowOrderLinesState = !showOrderLines;
if (newShowOrderLinesState) {
displayButtonRef.current?.classList?.add('order-lines-active');
} else {
displayButtonRef.current?.classList?.remove('order-lines-active');
}
setShowOrderLines(newShowOrderLinesState);
};
}
}, [isChartReady, showOrderLines]);
/**
* @description Hook to handle drawing order lines
*/
useEffect(() => {
if (tvWidget && isChartReady) {
tvWidget.onChartReady(() => {
tvWidget.chart().dataReady(() => {
if (showOrderLines) {
drawOrderLines();
} else {
deleteOrderLines();
}
});
});
}
}, [isChartReady, showOrderLines, currentMarketOrders, currentMarketId]);
const drawOrderLines = () => {
if (!currentMarketOrders) return;
currentMarketOrders.forEach(
({
id,
type,
status,
side,
cancelReason,
remainingSize,
size,
triggerPrice,
price,
trailingPercent,
}) => {
const key = `${side.rawValue}-${id}`;
const quantity = (remainingSize ?? size).toString();
const orderType = type.rawValue as OrderType;
const orderLabel = stringGetter({
key: ORDER_TYPE_STRINGS[orderType].orderTypeKey,
});
const orderString = trailingPercent ? `${orderLabel} ${trailingPercent}%` : orderLabel;
const shouldShow =
!cancelReason &&
(status === AbacusOrderStatus.open || status === AbacusOrderStatus.untriggered);
const maybeOrderLine = key in orderLines ? orderLines[key] : null;
if (maybeOrderLine) {
if (!shouldShow) {
maybeOrderLine.remove();
delete orderLines[key];
return;
} else if (maybeOrderLine.getQuantity() !== quantity) {
maybeOrderLine.setQuantity(quantity);
return;
}
} else if (shouldShow) {
const { orderColor, borderColor, backgroundColor, textColor, textButtonColor } =
getOrderLineColors({ side: side.rawValue, appTheme, appColorMode });
const orderLine = tvWidget
?.chart()
.createOrderLine({ disableUndo: false })
.setPrice(MustBigNumber(triggerPrice ?? price).toNumber())
.setQuantity(quantity)
.setText(orderString)
.setLineColor(orderColor)
.setQuantityBackgroundColor(orderColor)
.setQuantityBorderColor(borderColor)
.setBodyBackgroundColor(backgroundColor)
.setBodyBorderColor(borderColor)
.setBodyTextColor(textColor)
.setQuantityTextColor(textButtonColor);
if (orderLine) {
orderLines[key] = orderLine;
}
}
}
);
};
const deleteOrderLines = () => {
Object.values(orderLines).forEach((line) => {
line.remove();
});
orderLines = {};
};
return ( return (
<Styled.PriceChart isChartReady={isChartReady}> <Styled.PriceChart isChartReady={isChartReady}>
{!isChartReady && <LoadingSpace id="tv-chart-loading" />} {!isChartReady && <LoadingSpace id="tv-chart-loading" />}
+3
View File
@@ -15,6 +15,7 @@ type ElementProps = {
link: string; link: string;
linkDescription?: string; linkDescription?: string;
title?: ReactNode; title?: ReactNode;
slotContent?: ReactNode;
setIsOpen: (open: boolean) => void; setIsOpen: (open: boolean) => void;
}; };
@@ -24,6 +25,7 @@ export const ExternalLinkDialog = ({
link, link,
linkDescription, linkDescription,
title, title,
slotContent,
}: ElementProps) => { }: ElementProps) => {
const stringGetter = useStringGetter(); const stringGetter = useStringGetter();
return ( return (
@@ -36,6 +38,7 @@ export const ExternalLinkDialog = ({
} }
> >
<Styled.Content> <Styled.Content>
{slotContent}
<p>{stringGetter({ key: STRING_KEYS.LEAVING_WEBSITE_DISCLAIMER })}.</p> <p>{stringGetter({ key: STRING_KEYS.LEAVING_WEBSITE_DISCLAIMER })}.</p>
<Button type={ButtonType.Link} action={ButtonAction.Primary} href={link}> <Button type={ButtonType.Link} action={ButtonAction.Primary} href={link}>
{buttonText ?? stringGetter({ key: STRING_KEYS.CONTINUE })} {buttonText ?? stringGetter({ key: STRING_KEYS.CONTINUE })}
+28 -3
View File
@@ -1,6 +1,9 @@
import { useCallback } from 'react';
import styled, { type AnyStyledComponent } from 'styled-components'; import styled, { type AnyStyledComponent } from 'styled-components';
import { useDispatch } from 'react-redux';
import { ButtonAction, ButtonSize, ButtonType } from '@/constants/buttons'; import { ButtonAction, ButtonSize, ButtonType } from '@/constants/buttons';
import { DialogTypes } from '@/constants/dialogs';
import { STRING_KEYS } from '@/constants/localization'; import { STRING_KEYS } from '@/constants/localization';
import { useBreakpoints, useStringGetter, useURLConfigs } from '@/hooks'; import { useBreakpoints, useStringGetter, useURLConfigs } from '@/hooks';
@@ -9,6 +12,8 @@ import { Dialog, DialogPlacement } from '@/components/Dialog';
import { IconName } from '@/components/Icon'; import { IconName } from '@/components/Icon';
import { IconButton } from '@/components/IconButton'; import { IconButton } from '@/components/IconButton';
import { closeDialog, openDialog } from '@/state/dialogs';
import { layoutMixins } from '@/styles/layoutMixins'; import { layoutMixins } from '@/styles/layoutMixins';
type ElementProps = { type ElementProps = {
@@ -18,9 +23,21 @@ type ElementProps = {
export const ExternalNavKeplrDialog = ({ setIsOpen }: ElementProps) => { export const ExternalNavKeplrDialog = ({ setIsOpen }: ElementProps) => {
const stringGetter = useStringGetter(); const stringGetter = useStringGetter();
const { keplrDashboard, accountExportLearnMore } = useURLConfigs(); const { keplrDashboard, accountExportLearnMore } = useURLConfigs();
const dispatch = useDispatch();
const { isTablet } = useBreakpoints(); const { isTablet } = useBreakpoints();
const onExternalNavDialog = useCallback(() => {
dispatch(closeDialog());
dispatch(
openDialog({
type: DialogTypes.ExternalLink,
dialogProps: {
link: keplrDashboard,
},
})
);
}, [dispatch]);
return ( return (
<Dialog <Dialog
isOpen isOpen
@@ -29,7 +46,11 @@ export const ExternalNavKeplrDialog = ({ setIsOpen }: ElementProps) => {
placement={isTablet ? DialogPlacement.FullScreen : DialogPlacement.Default} placement={isTablet ? DialogPlacement.FullScreen : DialogPlacement.Default}
> >
<Styled.Content> <Styled.Content>
<Styled.Button type={ButtonType.Link} size={ButtonSize.XLarge} href={keplrDashboard}> <Styled.Button
type={ButtonType.Button}
size={ButtonSize.XLarge}
onClick={onExternalNavDialog}
>
<span> <span>
{stringGetter({ {stringGetter({
key: STRING_KEYS.NAVIGATE_TO_KEPLR, key: STRING_KEYS.NAVIGATE_TO_KEPLR,
@@ -46,7 +67,11 @@ export const ExternalNavKeplrDialog = ({ setIsOpen }: ElementProps) => {
/> />
</Styled.Button> </Styled.Button>
<Styled.Button type={ButtonType.Link} size={ButtonSize.XLarge} href={accountExportLearnMore}> <Styled.Button
type={ButtonType.Link}
size={ButtonSize.XLarge}
href={accountExportLearnMore}
>
<span> <span>
{stringGetter({ {stringGetter({
key: STRING_KEYS.LEARN_TO_EXPORT, key: STRING_KEYS.LEARN_TO_EXPORT,
+16 -4
View File
@@ -33,15 +33,22 @@ export const ExternalNavStrideDialog = ({ setIsOpen }: ElementProps) => {
dialogProps: { dialogProps: {
buttonText: ( buttonText: (
<Styled.Span> <Styled.Span>
Liquid Stake on Stride <Icon iconName={IconName.LinkOut} /> {stringGetter({ key: STRING_KEYS.LIQUID_STAKE_ON_STRIDE })}
<Icon iconName={IconName.LinkOut} />
</Styled.Span> </Styled.Span>
), ),
link: strideZoneApp, link: strideZoneApp,
title: 'Liquid staking and leaving website', title: stringGetter({ key: STRING_KEYS.LIQUID_STAKING_AND_LEAVING }),
slotContent: stringGetter({
key: STRING_KEYS.LIQUID_STAKING_AND_LEAVING_DESCRIPTION,
params: {
CTA: stringGetter({ key: STRING_KEYS.LIQUID_STAKE_ON_STRIDE }),
},
}),
}, },
}) })
); );
}, [dispatch]); }, [dispatch, stringGetter]);
return ( return (
<Dialog <Dialog
@@ -57,7 +64,12 @@ export const ExternalNavStrideDialog = ({ setIsOpen }: ElementProps) => {
onClick={openExternalNavDialog} onClick={openExternalNavDialog}
> >
<span> <span>
<strong>{stringGetter({ key: STRING_KEYS.YES })}</strong>, Navigate to Stride Zone. {stringGetter({
key: STRING_KEYS.NAVIGATE_TO_STRIDE,
params: {
STRONG_YES: <strong>{stringGetter({ key: STRING_KEYS.YES })}</strong>,
},
})}
</span> </span>
<Styled.IconButton <Styled.IconButton
@@ -44,7 +44,6 @@ export const GenerateKeys = ({
onKeysDerived = () => {}, onKeysDerived = () => {},
}: ElementProps) => { }: ElementProps) => {
const stringGetter = useStringGetter(); const stringGetter = useStringGetter();
const { isMobile } = useBreakpoints();
const [shouldRememberMe, setShouldRememberMe] = useState(false); const [shouldRememberMe, setShouldRememberMe] = useState(false);
@@ -66,17 +65,30 @@ export const GenerateKeys = ({
try { try {
await matchNetwork?.(); await matchNetwork?.();
return true;
} catch (error) { } catch (error) {
const { message, walletErrorType } = parseWalletError({ error, stringGetter }); const { message, walletErrorType, isErrorExpected } = parseWalletError({
error,
stringGetter,
});
if (!isErrorExpected) {
log('GenerateKeys/switchNetwork', error, { walletErrorType });
}
if (message) { if (message) {
log('GenerateKeys/switchNetwork', error, { walletErrorType });
setError(message); setError(message);
throw error;
} }
return false;
} }
}; };
const switchNetworkAndDeriveKeys = async () => {
const networkSwitched = await switchNetwork();
if (networkSwitched) await deriveKeys();
};
// 2. Derive keys from EVM account // 2. Derive keys from EVM account
const { getWalletFromEvmSignature } = useDydxClient(); const { getWalletFromEvmSignature } = useDydxClient();
const { getSubaccounts } = useAccounts(); const { getSubaccounts } = useAccounts();
@@ -154,11 +166,16 @@ export const GenerateKeys = ({
setStatus(EvmDerivedAccountStatus.Derived); setStatus(EvmDerivedAccountStatus.Derived);
} catch (error) { } catch (error) {
setStatus(EvmDerivedAccountStatus.NotDerived); setStatus(EvmDerivedAccountStatus.NotDerived);
const { message, walletErrorType } = parseWalletError({ error, stringGetter }); const { message, walletErrorType, isErrorExpected } = parseWalletError({
error,
stringGetter,
});
if (message) { if (message) {
setError(message); setError(message);
log('GenerateKeys/deriveKeys', error, { walletErrorType }); if (!isErrorExpected) {
log('GenerateKeys/deriveKeys', error, { walletErrorType });
}
} }
} }
}; };
@@ -231,7 +248,7 @@ export const GenerateKeys = ({
{!isMatchingNetwork ? ( {!isMatchingNetwork ? (
<Button <Button
action={ButtonAction.Primary} action={ButtonAction.Primary}
onClick={() => switchNetwork().then(deriveKeys).then(onKeysDerived)} onClick={() => switchNetworkAndDeriveKeys().then(onKeysDerived)}
state={{ isLoading: isSwitchingNetwork }} state={{ isLoading: isSwitchingNetwork }}
> >
{stringGetter({ key: STRING_KEYS.SWITCH_NETWORK })} {stringGetter({ key: STRING_KEYS.SWITCH_NETWORK })}
+1 -1
View File
@@ -4,7 +4,7 @@ import styled, { AnyStyledComponent, css } from 'styled-components';
import { TradeInputField } from '@/constants/abacus'; import { TradeInputField } from '@/constants/abacus';
import { STRING_KEYS, StringKey } from '@/constants/localization'; import { STRING_KEYS, StringKey } from '@/constants/localization';
import { TradeTypes, ORDER_TYPE_STRINGS, MobilePlaceOrderSteps } from '@/constants/trade'; import { TradeTypes, TRADE_TYPE_STRINGS, MobilePlaceOrderSteps } from '@/constants/trade';
import { useBreakpoints, useStringGetter } from '@/hooks'; import { useBreakpoints, useStringGetter } from '@/hooks';
import { layoutMixins } from '@/styles/layoutMixins'; import { layoutMixins } from '@/styles/layoutMixins';
@@ -5,7 +5,7 @@ import type { TradeInputSummary } from '@/constants/abacus';
import { ButtonAction, ButtonSize, ButtonType } from '@/constants/buttons'; import { ButtonAction, ButtonSize, ButtonType } from '@/constants/buttons';
import { DialogTypes } from '@/constants/dialogs'; import { DialogTypes } from '@/constants/dialogs';
import { STRING_KEYS } from '@/constants/localization'; import { STRING_KEYS } from '@/constants/localization';
import { ORDER_TYPE_STRINGS, MobilePlaceOrderSteps } from '@/constants/trade'; import { TRADE_TYPE_STRINGS, MobilePlaceOrderSteps } from '@/constants/trade';
import { useStringGetter, useTokenConfigs } from '@/hooks'; import { useStringGetter, useTokenConfigs } from '@/hooks';
@@ -184,7 +184,7 @@ export const PlaceOrderButtonAndReceipt = ({
ORDER: stringGetter({ ORDER: stringGetter({
key: isClosePosition key: isClosePosition
? STRING_KEYS.CLOSE_ORDER ? STRING_KEYS.CLOSE_ORDER
: ORDER_TYPE_STRINGS[selectedTradeType].orderTypeKey, : TRADE_TYPE_STRINGS[selectedTradeType].tradeTypeKey,
}), }),
}, },
})} })}
@@ -11,7 +11,7 @@ import {
} from '@/constants/abacus'; } from '@/constants/abacus';
import { STRING_KEYS } from '@/constants/localization'; import { STRING_KEYS } from '@/constants/localization';
import { ORDER_TYPE_STRINGS, TradeTypes } from '@/constants/trade'; import { TRADE_TYPE_STRINGS, TradeTypes } from '@/constants/trade';
import { useStringGetter } from '@/hooks'; import { useStringGetter } from '@/hooks';
import { layoutMixins } from '@/styles/layoutMixins'; import { layoutMixins } from '@/styles/layoutMixins';
@@ -48,7 +48,7 @@ export const TradeNotification = ({ isToast, data, notification }: TradeNotifica
const { assetId } = marketData ?? {}; const { assetId } = marketData ?? {};
const orderType = ORDER_TYPE as KotlinIrEnumValues<typeof AbacusOrderType>; const orderType = ORDER_TYPE as KotlinIrEnumValues<typeof AbacusOrderType>;
const tradeType = TRADE_TYPES[orderType]; const tradeType = TRADE_TYPES[orderType];
const titleKey = tradeType && ORDER_TYPE_STRINGS[tradeType]?.orderTypeKey; const titleKey = tradeType && TRADE_TYPE_STRINGS[tradeType]?.tradeTypeKey;
const orderStatus = ORDER_STATUS as KotlinIrEnumValues<typeof AbacusOrderStatus>; const orderStatus = ORDER_STATUS as KotlinIrEnumValues<typeof AbacusOrderStatus>;
return ( return (
Binary file not shown.