From 04c12fab91a3695a343c8413defd89d9d6fafb4f Mon Sep 17 00:00:00 2001 From: huhuanming Date: Thu, 12 Dec 2024 19:07:19 +0800 Subject: [PATCH] feat: add trading information to the market trade button. (#6336) --- packages/components/tamagui.config.ts | 2 + .../src/components/TradingView/WebView.tsx | 6 +- .../TradingView/useTradingViewProps.ts | 36 ++- .../kit/src/views/Market/MarketDetail.tsx | 3 - .../views/Market/components/Chart/index.tsx | 1 - .../Market/components/MarketHomeList.tsx | 166 +++++++------ .../components/MarketListTradeButton.tsx | 31 +-- .../views/Market/components/MarketMore.tsx | 11 +- .../Market/components/MarketTradeButton.tsx | 111 +++++++-- .../Market/components/TokenPriceChart.tsx | 21 +- .../src/views/Market/components/tradeHook.tsx | 233 ++++++++++++------ .../kit/src/views/Swap/hooks/useSwapTokens.ts | 14 +- .../Swap/pages/modal/SwapLazyMarketModal.tsx | 62 +++++ packages/kit/src/views/Swap/router/index.tsx | 8 + .../shared/src/locale/enum/translations.ts | 2 + packages/shared/src/locale/json/bn.json | 4 +- packages/shared/src/locale/json/de.json | 4 +- packages/shared/src/locale/json/en.json | 4 +- packages/shared/src/locale/json/en_US.json | 4 +- packages/shared/src/locale/json/es.json | 4 +- packages/shared/src/locale/json/fr_FR.json | 4 +- packages/shared/src/locale/json/hi_IN.json | 4 +- packages/shared/src/locale/json/id.json | 4 +- packages/shared/src/locale/json/it_IT.json | 4 +- packages/shared/src/locale/json/ja_JP.json | 4 +- packages/shared/src/locale/json/ko_KR.json | 4 +- packages/shared/src/locale/json/pt.json | 4 +- packages/shared/src/locale/json/pt_BR.json | 4 +- packages/shared/src/locale/json/ru.json | 4 +- packages/shared/src/locale/json/th_TH.json | 4 +- packages/shared/src/locale/json/uk_UA.json | 4 +- packages/shared/src/locale/json/vi.json | 4 +- packages/shared/src/locale/json/zh_CN.json | 6 +- packages/shared/src/locale/json/zh_HK.json | 6 +- packages/shared/src/locale/json/zh_TW.json | 6 +- .../src/logger/scopes/market/scenes/token.ts | 15 ++ packages/shared/src/routes/swap.ts | 4 + .../types/market/marketProvider.constants.ts | 173 +++---------- 38 files changed, 603 insertions(+), 382 deletions(-) create mode 100644 packages/kit/src/views/Swap/pages/modal/SwapLazyMarketModal.tsx diff --git a/packages/components/tamagui.config.ts b/packages/components/tamagui.config.ts index 401d45f60d1..61b46859505 100644 --- a/packages/components/tamagui.config.ts +++ b/packages/components/tamagui.config.ts @@ -565,6 +565,8 @@ const config = createTamagui({ gtSm: { minWidth: 640 }, md: { maxWidth: 767 }, gtMd: { minWidth: 768 }, + '2md': { maxWidth: 895 }, + 'gt2Md': { minWidth: 896 }, lg: { maxWidth: 1023 }, gtLg: { minWidth: 1024 }, xl: { maxWidth: 1279 }, diff --git a/packages/kit/src/components/TradingView/WebView.tsx b/packages/kit/src/components/TradingView/WebView.tsx index e7a429ae01f..6b6997b88a5 100644 --- a/packages/kit/src/components/TradingView/WebView.tsx +++ b/packages/kit/src/components/TradingView/WebView.tsx @@ -29,6 +29,10 @@ export function WebView({ }, 800); }; } + // Fallback to dismiss loading screen + setTimeout(() => { + onLoadEnd(); + }, 3500); }, [iframeId, onLoadEnd, tradingViewProps.uri]); return (
@@ -48,7 +52,7 @@ export function WebView({ { const { md } = useMedia(); const theme = useThemeVariant(); - const [bgAppColor, bgSubduedColor, textColor, textDisabled, iconColor] = - useThemeValue( - ['$bgApp', '$bgSubdued', '$text', '$textDisabled', '$icon'], - undefined, - true, - ); + const [ + bgAppColor, + bgSubduedColor, + textColor, + textDisabled, + iconColor, + bgBackdropColor, + bgHoverColor, + ] = useThemeValue( + [ + '$bgApp', + '$bgSubdued', + '$text', + '$textDisabled', + '$icon', + '$bgBackdrop', + '$bgHover', + ], + undefined, + true, + ); const systemLocale = useLocaleVariant(); const locale = useMemo( () => localeMap[systemLocale as ILocaleJSONSymbol] || 'en', @@ -100,13 +115,14 @@ export const useTradingViewProps = ({ const text = await res.text(); const style = ` :root { - --tv-color-toolbar-button-text-active: ${textColor} !important; + --tv-color-toolbar-button-text-active: ${textColor} !important; --tv-color-toolbar-button-text-active-hover: ${textColor} !important; --tv-color-pane-background: ${bgAppColor} !important; --tv-color-platform-background: ${bgAppColor} !important; --tv-color-toolbar-button-text: ${textDisabled} !important; --tv-spinner-color: ${iconColor} !important; --tv-color-popup-background: ${bgSubduedColor} !important; + --tv-color-popup-element-background-hover: ${bgHoverColor} !important; } html .chart-page .chart-container-border { background-color: ${bgAppColor} !important; @@ -141,6 +157,10 @@ export const useTradingViewProps = ({ html.theme-dark .chart-page { background: ${bgAppColor} !important; } + + #overlap-manager-root [class*="backdrop-"] { + background-color: ${bgBackdropColor} !important; + } `; const htmlCode = text.replace( '', @@ -175,7 +195,9 @@ export const useTradingViewProps = ({ textDisabled, iconColor, bgSubduedColor, + bgHoverColor, md, + bgBackdropColor, ], { initResult: { diff --git a/packages/kit/src/views/Market/MarketDetail.tsx b/packages/kit/src/views/Market/MarketDetail.tsx index 69a532c5b1c..0371b92987c 100644 --- a/packages/kit/src/views/Market/MarketDetail.tsx +++ b/packages/kit/src/views/Market/MarketDetail.tsx @@ -1,7 +1,6 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import { CommonActions, StackActions } from '@react-navigation/native'; -import { useIntl } from 'react-intl'; import { HeaderIconButton, @@ -42,7 +41,6 @@ import { MarketTokenIcon } from './components/MarketTokenIcon'; import { MarketTokenPrice } from './components/MarketTokenPrice'; import { MarketTradeButton } from './components/MarketTradeButton'; import { PriceChangePercentage } from './components/PriceChangePercentage'; -import { TextCell } from './components/TextCell'; import { TokenDetailTabs } from './components/TokenDetailTabs'; import { TokenPriceChart } from './components/TokenPriceChart'; import { buildMarketFullUrl } from './marketUtils'; @@ -55,7 +53,6 @@ function TokenDetailHeader({ coinGeckoId: string; token: IMarketTokenDetail; }) { - const intl = useIntl(); const { gtMd } = useMedia(); const { result: token } = usePromiseResult( () => backgroundApiProxy.serviceMarket.fetchMarketTokenDetail(coinGeckoId), diff --git a/packages/kit/src/views/Market/components/Chart/index.tsx b/packages/kit/src/views/Market/components/Chart/index.tsx index b5c4062bf4f..339c9d430ef 100644 --- a/packages/kit/src/views/Market/components/Chart/index.tsx +++ b/packages/kit/src/views/Market/components/Chart/index.tsx @@ -162,7 +162,6 @@ export function PriceChart({ {platformEnv.isNative ? chartView : chartViewWithSpinner} - {children} ); } diff --git a/packages/kit/src/views/Market/components/MarketHomeList.tsx b/packages/kit/src/views/Market/components/MarketHomeList.tsx index 4e034dfa4bc..1fe7f17bbf0 100644 --- a/packages/kit/src/views/Market/components/MarketHomeList.tsx +++ b/packages/kit/src/views/Market/components/MarketHomeList.tsx @@ -52,11 +52,13 @@ import platformEnv from '@onekeyhq/shared/src/platformEnv'; import { ETabMarketRoutes } from '@onekeyhq/shared/src/routes'; import { listItemPressStyle } from '@onekeyhq/shared/src/style'; import timerUtils from '@onekeyhq/shared/src/utils/timerUtils'; +import { isSupportStaking } from '@onekeyhq/shared/types/earn/earnProvider.constants'; import type { IMarketCategory, IMarketToken, } from '@onekeyhq/shared/types/market'; +import { useReviewControl } from '../../../components/ReviewControl'; import useAppNavigation from '../../../hooks/useAppNavigation'; import { usePrevious } from '../../../hooks/usePrevious'; import { usePromiseResult } from '../../../hooks/usePromiseResult'; @@ -183,6 +185,11 @@ function MarketMdColumn({ }, [item.coingeckoId, navigation]); const tradeActions = useLazyMarketTradeActions(item.coingeckoId); + const show = useReviewControl(); + const canStaking = useMemo( + () => isSupportStaking(item.symbol), + [item.symbol], + ); const handleMdItemAction = useCallback(async () => { const { coingeckoId, symbol } = item; const isInWatchList = actions.isInWatchList(coingeckoId); @@ -239,38 +246,40 @@ function MarketMdColumn({ { items: [ { - icon: 'SwitchHorOutline', + icon: 'SwitchHorOutline' as const, label: intl.formatMessage({ id: ETranslations.global_swap }), - onPress: tradeActions.onSwap, + onPress: tradeActions.onSwapLazyModal, }, - { - icon: 'CoinsOutline', + canStaking && { + icon: 'CoinsOutline' as const, label: intl.formatMessage({ id: ETranslations.earn_stake }), onPress: tradeActions.onStaking, }, - { - icon: 'PlusLargeSolid', + show && { + icon: 'PlusLargeSolid' as const, label: intl.formatMessage({ id: ETranslations.global_buy }), onPress: tradeActions.onBuy, }, - { - icon: 'MinusLargeSolid', + show && { + icon: 'MinusLargeSolid' as const, label: intl.formatMessage({ id: ETranslations.global_sell }), onPress: tradeActions.onSell, }, - ], + ].filter(Boolean), }, ], }); }, [ actions, + canStaking, intl, item, + show, showMoreAction, tradeActions.onBuy, tradeActions.onSell, tradeActions.onStaking, - tradeActions.onSwap, + tradeActions.onSwapLazyModal, ]); const pressEvents = useMemo( () => ({ @@ -429,7 +438,7 @@ function BasicMarketHomeList({ void fetchCategory(); }, [fetchCategory]); - const { gtMd, md } = useMedia(); + const { md, gtMd, gt2Md, gtLg, gtXl, gt2xl } = useMedia(); const filterCoingeckoIdsListData = useMemo(() => { const filterListData = category.coingeckoIds?.length @@ -600,7 +609,6 @@ function BasicMarketHomeList({ const theme = useThemeVariant(); const lineColors = lineColorMap[theme]; const colors = colorMap[theme]; - const { gtLg, gtXl } = useMedia(); const columns = useMemo( () => @@ -718,7 +726,7 @@ function BasicMarketHomeList({ ), renderSkeleton: () => , }, - gtLg + gtXl ? { title: intl.formatMessage({ id: ETranslations.market_one_hour_percentage, @@ -737,24 +745,26 @@ function BasicMarketHomeList({ renderSkeleton: () => , } : undefined, - { - title: intl.formatMessage({ - id: ETranslations.market_twenty_four_hour_percentage, - }), - columnProps: { - flexGrow: 1, - flexBasis: 0, - }, - align: 'right', - dataIndex: 'priceChangePercentage24H', - render: (priceChangePercentage24H: string) => ( - - {priceChangePercentage24H} - - ), - renderSkeleton: () => , - }, - gtLg + gt2Md + ? { + title: intl.formatMessage({ + id: ETranslations.market_twenty_four_hour_percentage, + }), + columnProps: { + flexGrow: 1, + flexBasis: 0, + }, + align: 'right', + dataIndex: 'priceChangePercentage24H', + render: (priceChangePercentage24H: string) => ( + + {priceChangePercentage24H} + + ), + renderSkeleton: () => , + } + : undefined, + gt2xl ? { title: intl.formatMessage({ id: ETranslations.market_seven_day_percentage, @@ -773,51 +783,55 @@ function BasicMarketHomeList({ renderSkeleton: () => , } : undefined, - { - title: intl.formatMessage({ - id: ETranslations.market_24h_vol_usd, - }), - dataIndex: 'totalVolume', - columnProps: { - flexGrow: 1, - flexBasis: 0, - }, - align: 'right', - render: (totalVolume: string) => ( - - {totalVolume || '-'} - - ), - renderSkeleton: () => , - }, - { - title: intl.formatMessage({ - id: ETranslations.global_market_cap, - }), - dataIndex: 'marketCap', - columnProps: { - flexGrow: 1, - flexBasis: 0, - }, - align: 'right', - render: (marketCap: string) => ( - - {marketCap || '-'} - - ), - renderSkeleton: () => , - }, gtXl + ? { + title: intl.formatMessage({ + id: ETranslations.market_24h_vol_usd, + }), + dataIndex: 'totalVolume', + columnProps: { + flexGrow: 1, + flexBasis: 0, + }, + align: 'right', + render: (totalVolume: string) => ( + + {totalVolume || '-'} + + ), + renderSkeleton: () => , + } + : undefined, + gtLg + ? { + title: intl.formatMessage({ + id: ETranslations.global_market_cap, + }), + dataIndex: 'marketCap', + columnProps: { + flexGrow: 1, + flexBasis: 0, + }, + align: 'right', + render: (marketCap: string) => ( + + {marketCap || '-'} + + ), + renderSkeleton: () => , + } + : undefined, + gt2xl ? { title: intl.formatMessage({ id: ETranslations.market_last_seven_days, @@ -901,6 +915,8 @@ function BasicMarketHomeList({ [ colors, currency, + gt2Md, + gt2xl, gtLg, gtMd, gtXl, diff --git a/packages/kit/src/views/Market/components/MarketListTradeButton.tsx b/packages/kit/src/views/Market/components/MarketListTradeButton.tsx index 970bc1a3405..9c04d015fda 100644 --- a/packages/kit/src/views/Market/components/MarketListTradeButton.tsx +++ b/packages/kit/src/views/Market/components/MarketListTradeButton.tsx @@ -6,6 +6,8 @@ import { Button, XStack } from '@onekeyhq/components'; import { ETranslations } from '@onekeyhq/shared/src/locale'; import { isSupportStaking } from '@onekeyhq/shared/types/earn/earnProvider.constants'; +import { ReviewControl } from '../../../components/ReviewControl'; + import { useLazyMarketTradeActions } from './tradeHook'; export function MarketListTradeButton({ @@ -17,34 +19,21 @@ export function MarketListTradeButton({ }) { const intl = useIntl(); - const { onStaking, onSwap, onBuy, loadingIndicators } = + const { onStaking, onSwapLazyModal, onBuy } = useLazyMarketTradeActions(coinGeckoId); const canStaking = useMemo(() => isSupportStaking(symbol), [symbol]); return ( - - + + + {canStaking ? ( - ) : null} diff --git a/packages/kit/src/views/Market/components/MarketMore.tsx b/packages/kit/src/views/Market/components/MarketMore.tsx index 3500993c6c8..7db5001c29f 100644 --- a/packages/kit/src/views/Market/components/MarketMore.tsx +++ b/packages/kit/src/views/Market/components/MarketMore.tsx @@ -6,6 +6,8 @@ import type { IActionListItemProps, IStackProps } from '@onekeyhq/components'; import { ActionList, IconButton } from '@onekeyhq/components'; import { ETranslations } from '@onekeyhq/shared/src/locale'; +import { useReviewControl } from '../../../components/ReviewControl'; + import { useLazyMarketTradeActions } from './tradeHook'; import { useWatchListAction } from './wachListHooks'; @@ -25,6 +27,7 @@ function BasicMarketMore({ actions.MoveToTop(coingeckoId); }, [actions, coingeckoId]); const tradeActions = useLazyMarketTradeActions(coingeckoId); + const show = useReviewControl(); const sections = useMemo( () => [ @@ -39,7 +42,7 @@ function BasicMarketMore({ }, ] as IActionListItemProps[], }, - { + show && { items: [ { icon: 'MinusLargeSolid', @@ -49,9 +52,9 @@ function BasicMarketMore({ ] as IActionListItemProps[], }, ].filter(Boolean), - [MoveToTop, intl, showMoreAction, tradeActions.onSell], + [MoveToTop, intl, show, showMoreAction, tradeActions.onSell], ); - return ( + return sections.length ? ( - ); + ) : null; } export const MarketMore = memo(BasicMarketMore); diff --git a/packages/kit/src/views/Market/components/MarketTradeButton.tsx b/packages/kit/src/views/Market/components/MarketTradeButton.tsx index 32af9ffbd92..83361c67a3e 100644 --- a/packages/kit/src/views/Market/components/MarketTradeButton.tsx +++ b/packages/kit/src/views/Market/components/MarketTradeButton.tsx @@ -1,4 +1,4 @@ -import { useMemo } from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import { useIntl } from 'react-intl'; @@ -6,8 +6,16 @@ import type { IActionListItemProps } from '@onekeyhq/components'; import { ActionList, Button, IconButton, XStack } from '@onekeyhq/components'; import { ETranslations } from '@onekeyhq/shared/src/locale'; import type { IMarketTokenDetail } from '@onekeyhq/shared/types/market'; +import { getImportFromToken } from '@onekeyhq/shared/types/market/marketProvider.constants'; -import { useMarketTradeActions } from './tradeHook'; +import backgroundApiProxy from '../../../background/instance/backgroundApiProxy'; +import { ReviewControl } from '../../../components/ReviewControl'; + +import { + useMarketTradeActions, + useMarketTradeNetwork, + useMarketTradeNetworkId, +} from './tradeHook'; export function MarketTradeButton({ token, @@ -19,7 +27,13 @@ export function MarketTradeButton({ const { onSwap, onStaking, onBuy, onSell, canStaking } = useMarketTradeActions(token); - + const network = useMarketTradeNetwork(token); + const networkId = useMarketTradeNetworkId(network, token.symbol); + const [disabled, setDisabled] = useState({ + trade: true, + buy: true, + sell: true, + }); const sections = useMemo( () => [ { @@ -28,17 +42,65 @@ export function MarketTradeButton({ icon: 'MinusLargeSolid', label: intl.formatMessage({ id: ETranslations.global_sell }), onPress: onSell, + disabled: disabled.sell, }, ] as IActionListItemProps[], }, ], - [intl, onSell], + [disabled.sell, intl, onSell], ); + const checkDisabled = useCallback(async () => { + if (networkId) { + const { isNative, realContractAddress = '' } = + getImportFromToken({ + networkId, + tokenSymbol: token.symbol, + contractAddress: network?.contract_address || '', + }) || {}; + const contractAddress = isNative ? '' : network?.contract_address || ''; + + const [swapResult, buyResult, sellResult] = await Promise.all([ + backgroundApiProxy.serviceSwap.checkSupportSwap({ + networkId, + contractAddress: isNative ? realContractAddress : contractAddress, + }), + backgroundApiProxy.serviceFiatCrypto.isTokenSupported({ + networkId, + tokenAddress: contractAddress, + type: 'buy', + }), + backgroundApiProxy.serviceFiatCrypto.isTokenSupported({ + networkId, + tokenAddress: contractAddress, + type: 'sell', + }), + ]); + setDisabled({ + trade: !swapResult.isSupportCrossChain && !swapResult.isSupportSwap, + buy: !buyResult, + sell: !sellResult, + }); + } + }, [network, networkId, token.symbol]); + + useEffect(() => { + void checkDisabled(); + }, [checkDisabled]); + + const handleSwap = useCallback(() => { + void onSwap(); + }, [onSwap]); + return ( - {canStaking ? ( @@ -46,22 +108,31 @@ export function MarketTradeButton({ {intl.formatMessage({ id: ETranslations.earn_stake })} ) : null} - + + + - - } - sections={sections} - /> + + + } + sections={sections} + /> + ); } diff --git a/packages/kit/src/views/Market/components/TokenPriceChart.tsx b/packages/kit/src/views/Market/components/TokenPriceChart.tsx index 868a9e371b6..0056369552e 100644 --- a/packages/kit/src/views/Market/components/TokenPriceChart.tsx +++ b/packages/kit/src/views/Market/components/TokenPriceChart.tsx @@ -107,8 +107,17 @@ function NativeTokenPriceChart({ coinGeckoId, height, defer }: IChartProps) { {gtLg ? null : ( - + { const tabHeight = useTabBarHeight(); const fixedHeight = useMemo(() => { - if (platformEnv.isNativeIOS) { - return 280; - } - - if (platformEnv.isNativeAndroid) { - return 280; + if (platformEnv.isNative) { + return 268; } return 300; @@ -161,7 +166,7 @@ function TradingViewChart({ mode="overview" h={height} $gtMd={{ pl: '$5' }} - $md={{ pt: '$6' }} + $md={{ pt: '$3' }} targetToken={targetToken} baseToken={baseToken} identifier={identifier} diff --git a/packages/kit/src/views/Market/components/tradeHook.tsx b/packages/kit/src/views/Market/components/tradeHook.tsx index 5379fa5b6c4..e5a7d3a2369 100644 --- a/packages/kit/src/views/Market/components/tradeHook.tsx +++ b/packages/kit/src/views/Market/components/tradeHook.tsx @@ -1,7 +1,11 @@ import { useCallback, useMemo, useRef, useState } from 'react'; +import { useIntl } from 'react-intl'; + import type { IPageNavigationProp } from '@onekeyhq/components'; import { Dialog, SizableText } from '@onekeyhq/components'; +import { ETranslations } from '@onekeyhq/shared/src/locale'; +import { defaultLogger } from '@onekeyhq/shared/src/logger/logger'; import { EModalStakingRoutes, type IModalSwapParamList, @@ -17,39 +21,99 @@ import { getImportFromToken, getNetworkIdBySymbol, } from '@onekeyhq/shared/types/market/marketProvider.constants'; +import { ESwapTabSwitchType } from '@onekeyhq/shared/types/swap/types'; import backgroundApiProxy from '../../../background/instance/backgroundApiProxy'; import useAppNavigation from '../../../hooks/useAppNavigation'; import { useActiveAccount } from '../../../states/jotai/contexts/accountSelector'; +export const useMarketTradeNetwork = (token: IMarketTokenDetail | null) => { + const { detailPlatforms, name } = token || {}; + const network = useMemo(() => { + if (detailPlatforms && name === 'Toncoin') { + return detailPlatforms['the-open-network']; + } + return detailPlatforms ? Object.values(detailPlatforms)[0] : null; + }, [detailPlatforms, name]); + return network; +}; + +export const useMarketTradeNetworkId = ( + network: { + contract_address: string; + onekeyNetworkId?: string; + hideContractAddress?: boolean; + coingeckoNetworkId?: string; + } | null, + symbol: string, +) => + useMemo(() => { + const { onekeyNetworkId } = network || {}; + return onekeyNetworkId ?? getNetworkIdBySymbol(symbol); + }, [network, symbol]); + export const useMarketTradeActions = (token: IMarketTokenDetail | null) => { - const { detailPlatforms, symbol = '', name } = token || {}; - const network = useMemo( - () => (detailPlatforms ? Object.values(detailPlatforms)[0] : null), - [detailPlatforms], - ); + const { symbol = '', name } = token || {}; + const intl = useIntl(); + const network = useMarketTradeNetwork(token); + const networkId = useMarketTradeNetworkId(network, symbol); const navigation = useAppNavigation>(); const { activeAccount } = useActiveAccount({ num: 0 }); - const networkId = useMemo(() => { - const { onekeyNetworkId } = network || {}; - return onekeyNetworkId ?? getNetworkIdBySymbol(symbol); - }, [network, symbol]); - const contractAddress = useMemo( () => network?.contract_address ?? '', [network], ); + const remindUnsupportedToken = useCallback( + (action: 'buy' | 'sell' | 'trade') => { + defaultLogger.market.token.unsupportedToken({ name: symbol, action }); + Dialog.confirm({ + title: intl.formatMessage({ id: ETranslations.earn_unsupported_token }), + tone: 'warning', + icon: 'ErrorOutline', + renderContent: ( + + {intl.formatMessage({ + id: ETranslations.earn_unsupported_token_desc, + })} + + ), + onConfirmText: intl.formatMessage({ + id: ETranslations.explore_got_it, + }), + }); + }, + [intl, symbol], + ); + const handleBuyOrSell = useCallback( async (type: IFiatCryptoType) => { if (!activeAccount.account || !networkId) { return; } + const { isNative } = + getImportFromToken({ + networkId, + tokenSymbol: symbol, + contractAddress, + }) || {}; + const isSupported = + await backgroundApiProxy.serviceFiatCrypto.isTokenSupported({ + networkId, + tokenAddress: isNative ? '' : contractAddress, + type, + }); + + if (!isSupported) { + remindUnsupportedToken(type); + return; + } + const deriveType = await backgroundApiProxy.serviceNetwork.getGlobalDeriveTypeOfNetwork({ networkId, @@ -69,65 +133,85 @@ export const useMarketTradeActions = (token: IMarketTokenDetail | null) => { type, }); if (!url || !build) { - Dialog.confirm({ - title: 'Unsupported token', - tone: 'warning', - icon: 'ErrorOutline', - renderContent: ( - - Unfortunately, this token is not currently supported for Buy - service. - - ), - onConfirmText: 'Got it!', - }); + remindUnsupportedToken(type); return; } openUrlExternal(url); }, - [activeAccount.account, networkId], + [ + activeAccount.account, + contractAddress, + networkId, + remindUnsupportedToken, + symbol, + ], ); - const handleSwap = useCallback(async () => { - if (!networkId) { - navigation.pushModal(EModalRoutes.SwapModal, { - screen: EModalSwapRoutes.SwapMainLand, - params: {}, - }); - return; - } - const { isSupportSwap } = - await backgroundApiProxy.serviceSwap.checkSupportSwap({ + const handleSwap = useCallback( + async (mode?: 'modal' | 'button') => { + const popPage = () => { + if (mode === 'modal') { + navigation.pop(); + } + }; + if (!networkId) { + remindUnsupportedToken('trade'); + popPage(); + return; + } + const { isNative, realContractAddress = '' } = + getImportFromToken({ + networkId, + tokenSymbol: symbol, + contractAddress, + }) || {}; + const { isSupportSwap, isSupportCrossChain } = + await backgroundApiProxy.serviceSwap.checkSupportSwap({ + networkId, + contractAddress: isNative ? realContractAddress : contractAddress, + }); + + if (!isSupportSwap && !isSupportCrossChain) { + remindUnsupportedToken('trade'); + popPage(); + return; + } + const onekeyNetwork = await backgroundApiProxy.serviceNetwork.getNetwork({ networkId, - contractAddress, }); - const onekeyNetwork = await backgroundApiProxy.serviceNetwork.getNetwork({ - networkId, - }); - const importFromTokenResponse = getImportFromToken({ - networkId, - isSupportSwap, - tokenSymbol: symbol, - contractAddress, - }); - const { importFromToken, swapTabSwitchType, isNative } = - importFromTokenResponse || {}; - navigation.pushModal(EModalRoutes.SwapModal, { - screen: EModalSwapRoutes.SwapMainLand, - params: { - importToToken: { + const params = { + importFromToken: { ...onekeyNetwork, + logoURI: isNative ? onekeyNetwork.logoURI : undefined, contractAddress: isNative ? '' : contractAddress, networkId, + isNative, networkLogoURI: onekeyNetwork.logoURI, symbol: symbol.toUpperCase(), name, }, - importFromToken, - swapTabSwitchType, - }, - }); - }, [contractAddress, name, navigation, networkId, symbol]); + swapTabSwitchType: isSupportSwap + ? ESwapTabSwitchType.SWAP + : ESwapTabSwitchType.BRIDGE, + }; + if (mode === 'modal') { + navigation.replace(EModalSwapRoutes.SwapMainLand, params); + } else { + navigation.pushModal(EModalRoutes.SwapModal, { + screen: EModalSwapRoutes.SwapMainLand, + params, + }); + } + }, + [ + contractAddress, + name, + navigation, + networkId, + remindUnsupportedToken, + symbol, + ], + ); const handleStaking = useCallback(() => { if (networkId && activeAccount.account) { @@ -165,14 +249,6 @@ export const useMarketTradeActions = (token: IMarketTokenDetail | null) => { type IActionName = 'onSwap' | 'onStaking' | 'onBuy' | 'onSell'; export const useLazyMarketTradeActions = (coinGeckoId: string) => { const [token, setToken] = useState(null); - const [loadingIndicators, setLoadingIndicators] = useState< - Record - >({ - onSwap: false, - onStaking: false, - onBuy: false, - onSell: false, - }); const fetchMarketTokenDetail = useCallback(async () => { const response = await backgroundApiProxy.serviceMarket.fetchMarketTokenDetail( @@ -186,28 +262,33 @@ export const useLazyMarketTradeActions = (coinGeckoId: string) => { actionsRef.current = actions; const compose = useCallback( async (actionName: IActionName) => { - const showLoading = !token; - if (showLoading) { - setLoadingIndicators((prev) => ({ ...prev, [actionName]: true })); - await fetchMarketTokenDetail(); - // wait for token detail loaded and actionsRef updated - await timerUtils.wait(80); - } - await actionsRef.current[actionName](); - if (showLoading) { - setLoadingIndicators((prev) => ({ ...prev, [actionName]: false })); - } + await fetchMarketTokenDetail(); + // wait for token detail loaded and actionsRef updated + await timerUtils.wait(80); + await actionsRef.current[actionName]('modal'); }, - [fetchMarketTokenDetail, token], + [fetchMarketTokenDetail], ); + + const navigation = + useAppNavigation>(); + const handleSwapLazyModal = useCallback(() => { + navigation.pushModal(EModalRoutes.SwapModal, { + screen: EModalSwapRoutes.SwapLazyMarketModal, + params: { + coinGeckoId, + }, + }); + }, [coinGeckoId, navigation]); + return useMemo( () => ({ onSwap: () => compose('onSwap'), + onSwapLazyModal: handleSwapLazyModal, onStaking: () => compose('onStaking'), onBuy: () => compose('onBuy'), onSell: () => compose('onSell'), - loadingIndicators, }), - [compose, loadingIndicators], + [compose, handleSwapLazyModal], ); }; diff --git a/packages/kit/src/views/Swap/hooks/useSwapTokens.ts b/packages/kit/src/views/Swap/hooks/useSwapTokens.ts index 90a271edffc..a9dbf1ec943 100644 --- a/packages/kit/src/views/Swap/hooks/useSwapTokens.ts +++ b/packages/kit/src/views/Swap/hooks/useSwapTokens.ts @@ -205,13 +205,13 @@ export function useSwapInit(params?: ISwapInitParams) { setToToken(params?.importToToken); } } - if ( - params?.importFromToken && - !params?.importToToken && - !params?.importFromToken?.isNative - ) { - const defaultToToken = - tokenDetailSwapDefaultToTokens[params?.importFromToken.networkId]; + if (params?.importFromToken && !params?.importToToken) { + const fromNetworkDefault = + swapDefaultSetTokens[params?.importFromToken.networkId]; + + const defaultToToken = !params?.importFromToken?.isNative + ? tokenDetailSwapDefaultToTokens[params?.importFromToken.networkId] + : fromNetworkDefault?.toToken; if (defaultToToken) { const defaultTokenSupportTypes = checkSupportTokenSwapType(defaultToToken); diff --git a/packages/kit/src/views/Swap/pages/modal/SwapLazyMarketModal.tsx b/packages/kit/src/views/Swap/pages/modal/SwapLazyMarketModal.tsx new file mode 100644 index 00000000000..1c6059ffb20 --- /dev/null +++ b/packages/kit/src/views/Swap/pages/modal/SwapLazyMarketModal.tsx @@ -0,0 +1,62 @@ +import { useLayoutEffect } from 'react'; + +import { useIntl } from 'react-intl'; + +import { Page, Spinner, Stack } from '@onekeyhq/components'; +import type { IPageScreenProps } from '@onekeyhq/components'; +import { AccountSelectorProviderMirror } from '@onekeyhq/kit/src/components/AccountSelector'; +import { useLazyMarketTradeActions } from '@onekeyhq/kit/src/views/Market/components/tradeHook'; +import { ETranslations } from '@onekeyhq/shared/src/locale'; +import type { + EModalSwapRoutes, + IModalSwapParamList, +} from '@onekeyhq/shared/src/routes/swap'; +import { EAccountSelectorSceneName } from '@onekeyhq/shared/types'; + +function BaseSwapLazyMarketModalModal({ + route, +}: IPageScreenProps< + IModalSwapParamList, + EModalSwapRoutes.SwapLazyMarketModal +>) { + const { coinGeckoId } = route.params; + const intl = useIntl(); + + const { onSwap } = useLazyMarketTradeActions(coinGeckoId); + + useLayoutEffect(() => { + void onSwap(); + }, [onSwap]); + + return ( + + + + + + + + + ); +} + +export default function SwapLazyMarketModal( + props: IPageScreenProps< + IModalSwapParamList, + EModalSwapRoutes.SwapLazyMarketModal + >, +) { + return ( + + + + ); +} diff --git a/packages/kit/src/views/Swap/router/index.tsx b/packages/kit/src/views/Swap/router/index.tsx index d8160995d1f..4d2020580a4 100644 --- a/packages/kit/src/views/Swap/router/index.tsx +++ b/packages/kit/src/views/Swap/router/index.tsx @@ -26,6 +26,9 @@ const TokenRiskReminderModal = LazyLoadPage( const SwapMainLandModal = LazyLoadPage( () => import('../pages/modal/SwapMainLandModal'), ); +const SwapLazyMarketModal = LazyLoadPage( + () => import('../pages/modal/SwapLazyMarketModal'), +); export const ModalSwapStack: IModalFlowNavigatorConfig< EModalSwapRoutes, @@ -66,4 +69,9 @@ export const ModalSwapStack: IModalFlowNavigatorConfig< component: TokenRiskReminderModal, translationId: ETranslations.token_selector_risk_reminder_title, }, + { + name: EModalSwapRoutes.SwapLazyMarketModal, + component: SwapLazyMarketModal, + translationId: ETranslations.swap_page_swap, + }, ]; diff --git a/packages/shared/src/locale/enum/translations.ts b/packages/shared/src/locale/enum/translations.ts index 02049b84b0a..54aeb413385 100644 --- a/packages/shared/src/locale/enum/translations.ts +++ b/packages/shared/src/locale/enum/translations.ts @@ -467,6 +467,8 @@ earn_unstaking_period_tooltip = 'earn.unstaking_period_tooltip', earn_unsupported_path_desc = 'earn.unsupported_path_desc', earn_unsupported_path_title = 'earn.unsupported_path_title', + earn_unsupported_token = 'earn.unsupported_token', + earn_unsupported_token_desc = 'earn.unsupported_token_desc', earn_until_next_launch = 'earn.until_next_launch', earn_until_next_launch_tooltip = 'earn.until_next_launch_tooltip', earn_up_to_number_days = 'earn.up_to_number_days', diff --git a/packages/shared/src/locale/json/bn.json b/packages/shared/src/locale/json/bn.json index b331f2a85f5..fe86d1a73c2 100644 --- a/packages/shared/src/locale/json/bn.json +++ b/packages/shared/src/locale/json/bn.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "উত্তোলনের অনুরোধ থেকে টোকেন দাবি করা পর্যন্ত আনুমানিক সময়কাল।", "earn.unsupported_path_desc": "ডেরিভেশন পাথটি ট্যাপরুটে স্বিচ করুন", "earn.unsupported_path_title": "এই স্টেক {path} সমর্থন করে না", + "earn.unsupported_token": "অসমর্থিত টোকেন", + "earn.unsupported_token_desc": "এই টোকেনটি বর্তমানে কেনা পরিষেবার জন্য সমর্থিত নয়৷", "earn.until_next_launch": "পরবর্তী লঞ্চ পর্যন্ত", "earn.until_next_launch_tooltip": "একটি পুলকে ব্যবহারকারীদের জন্য পুরস্কার তৈরি করতে শুরু করার জন্য ন্যূনতম ৩২ ETH প্রয়োজন।", "earn.up_to_number_days": "{number} দিন পর্যন্ত", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "ঠিকানা হার্ডওয়্যার ওয়ালেটের সাথে মিলছে না। এই ঠিকানা ব্যবহার করা বন্ধ করুন এবং আমাদের সাথে যোগাযোগ করুন।", "feedback.address_not_activated_message": "ঠিকানা এখনো সক্রিয় করা হয়নি", "feedback.address_not_matched": "ঠিকানা মেলেনি", - "feedback.address_type_does_not_support_sign_method": "নির্বাচিত ঠিকানার জন্য অসমর্থিত স্বাক্ষর পদ্ধতি", + "feedback.address_type_does_not_support_sign_method": "শুধুমাত্র {type} ঠিকানাগুলি এই স্বাক্ষর পদ্ধতিকে সমর্থন করে", "feedback.bluetooth_issue": "ব্লুটুথ সমস্যা", "feedback.bluetooth_pairing_failed": "ব্লুটুথ পেয়ারিং ব্যর্থ হয়েছে", "feedback.bluetooth_unparied": "ব্লুটুথ আনপেয়ার হয়েছে", diff --git a/packages/shared/src/locale/json/de.json b/packages/shared/src/locale/json/de.json index 5934f50fad9..db579a27cf2 100644 --- a/packages/shared/src/locale/json/de.json +++ b/packages/shared/src/locale/json/de.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "Der geschätzte Zeitraum vom Abhebungsantrag bis zur Einlösung der Token.", "earn.unsupported_path_desc": "Wechseln Sie den Ableitungspfad zu Taproot", "earn.unsupported_path_title": "Dieses Staking unterstützt {path} nicht", + "earn.unsupported_token": "Nicht unterstütztes Token", + "earn.unsupported_token_desc": "Dieses Token wird derzeit für den Kaufdienst nicht unterstützt.", "earn.until_next_launch": "Bis zum nächsten Start", "earn.until_next_launch_tooltip": "Ein Minimum von 32 ETH ist erforderlich, damit ein Pool beginnt, Belohnungen für Benutzer zu erzeugen.", "earn.up_to_number_days": "Bis zu {number} Tagen", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "Die Adresse stimmt nicht mit der Hardware-Wallet überein. Hören Sie sofort auf, diese Adresse zu verwenden und kontaktieren Sie uns.", "feedback.address_not_activated_message": "Adresse noch nicht aktiviert", "feedback.address_not_matched": "Adresse nicht zugeordnet", - "feedback.address_type_does_not_support_sign_method": "Nicht unterstützte Signaturmethode für ausgewählte Adresse", + "feedback.address_type_does_not_support_sign_method": "Nur {type} Adressen unterstützen diese Signaturmethode", "feedback.bluetooth_issue": "Bluetooth-Problem", "feedback.bluetooth_pairing_failed": "Bluetooth-Kopplung fehlgeschlagen", "feedback.bluetooth_unparied": "Bluetooth entkoppelt", diff --git a/packages/shared/src/locale/json/en.json b/packages/shared/src/locale/json/en.json index a55b8ea53a3..c70bb7a90be 100644 --- a/packages/shared/src/locale/json/en.json +++ b/packages/shared/src/locale/json/en.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "The estimated period from requesting withdrawal to when tokens can be claimed.", "earn.unsupported_path_desc": "Switch the derivation path to Taproot", "earn.unsupported_path_title": "This stake doesn’t support {path}", + "earn.unsupported_token": "Unsupported token", + "earn.unsupported_token_desc": "This token is not currently supported for Buy service.", "earn.until_next_launch": "Until next launch", "earn.until_next_launch_tooltip": "A minimum of 32 ETH is required for a pool to begin producing rewards for users.", "earn.up_to_number_days": "Up to {number} days", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "The address doesn’t match the hardware wallet. Stop using this address immediately and contact us.", "feedback.address_not_activated_message": "Address not activated yet", "feedback.address_not_matched": "Address not matched", - "feedback.address_type_does_not_support_sign_method": "Unsupported signature method for selected address", + "feedback.address_type_does_not_support_sign_method": "Only {type} addresses support this signature method", "feedback.bluetooth_issue": "Bluetooth issue", "feedback.bluetooth_pairing_failed": "Bluetooth pairing failed", "feedback.bluetooth_unparied": "Bluetooth unpaired", diff --git a/packages/shared/src/locale/json/en_US.json b/packages/shared/src/locale/json/en_US.json index 4e97a57ae0f..3c0bca09741 100644 --- a/packages/shared/src/locale/json/en_US.json +++ b/packages/shared/src/locale/json/en_US.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "The estimated period from requesting withdrawal to when tokens can be claimed.", "earn.unsupported_path_desc": "Switch the derivation path to Taproot", "earn.unsupported_path_title": "This stake doesn’t support {path}", + "earn.unsupported_token": "Unsupported token", + "earn.unsupported_token_desc": "This token is not currently supported for Buy service.", "earn.until_next_launch": "Until next launch", "earn.until_next_launch_tooltip": "A minimum of 32 ETH is required for a pool to begin producing rewards for users.", "earn.up_to_number_days": "Up to {number} days", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "The address doesn’t match the hardware wallet. Stop using this address immediately and contact us.", "feedback.address_not_activated_message": "Address not activated yet", "feedback.address_not_matched": "Address not matched", - "feedback.address_type_does_not_support_sign_method": "Unsupported signature method for selected address", + "feedback.address_type_does_not_support_sign_method": "Only {type} addresses support this signature method", "feedback.bluetooth_issue": "Bluetooth issue", "feedback.bluetooth_pairing_failed": "Bluetooth pairing failed", "feedback.bluetooth_unparied": "Bluetooth unpaired", diff --git a/packages/shared/src/locale/json/es.json b/packages/shared/src/locale/json/es.json index 9754b5ec822..e7794f48009 100644 --- a/packages/shared/src/locale/json/es.json +++ b/packages/shared/src/locale/json/es.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "El período estimado desde la solicitud de retiro hasta cuando se puedan reclamar los tokens.", "earn.unsupported_path_desc": "Cambia la ruta de derivación a Taproot", "earn.unsupported_path_title": "Esta participación no admite {path}", + "earn.unsupported_token": "Token no compatible", + "earn.unsupported_token_desc": "Este token no es compatible actualmente con el servicio de compra.", "earn.until_next_launch": "Hasta el próximo lanzamiento", "earn.until_next_launch_tooltip": "Se requiere un mínimo de 32 ETH para que un pool comience a generar recompensas para los usuarios.", "earn.up_to_number_days": "Hasta {number} días", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "La dirección no coincide con la cartera de hardware. Deje de usar esta dirección inmediatamente y contáctenos.", "feedback.address_not_activated_message": "Dirección aún no activada", "feedback.address_not_matched": "Dirección no coincidente", - "feedback.address_type_does_not_support_sign_method": "Método de firma no compatible para la dirección seleccionada", + "feedback.address_type_does_not_support_sign_method": "Solo las direcciones {type} admiten este método de firma", "feedback.bluetooth_issue": "Problema con Bluetooth", "feedback.bluetooth_pairing_failed": "Falló el emparejamiento Bluetooth", "feedback.bluetooth_unparied": "Bluetooth desemparejado", diff --git a/packages/shared/src/locale/json/fr_FR.json b/packages/shared/src/locale/json/fr_FR.json index 4d2012f0670..8cd35e1ff0d 100644 --- a/packages/shared/src/locale/json/fr_FR.json +++ b/packages/shared/src/locale/json/fr_FR.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "La période estimée entre la demande de retrait et la réclamation des tokens.", "earn.unsupported_path_desc": "Changez le chemin de dérivation en Taproot", "earn.unsupported_path_title": "Ce jalonnement ne prend pas en charge {path}", + "earn.unsupported_token": "Jeton non pris en charge", + "earn.unsupported_token_desc": "Ce jeton n'est actuellement pas pris en charge pour le service d'achat.", "earn.until_next_launch": "Jusqu'au prochain lancement", "earn.until_next_launch_tooltip": "Un minimum de 32 ETH est requis pour qu’un pool commence à générer des récompenses pour les utilisateurs.", "earn.up_to_number_days": "Jusqu'à {number} jours", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "L'adresse ne correspond pas au portefeuille matériel. Arrêtez d'utiliser cette adresse immédiatement et contactez-nous.", "feedback.address_not_activated_message": "Adresse pas encore activée", "feedback.address_not_matched": "Adresse non correspondante", - "feedback.address_type_does_not_support_sign_method": "Méthode de signature non prise en charge pour l'adresse sélectionnée", + "feedback.address_type_does_not_support_sign_method": "Seules les adresses {type} prennent en charge cette méthode de signature", "feedback.bluetooth_issue": "Problème de Bluetooth", "feedback.bluetooth_pairing_failed": "Échec de l'appariement Bluetooth", "feedback.bluetooth_unparied": "Bluetooth désapparié", diff --git a/packages/shared/src/locale/json/hi_IN.json b/packages/shared/src/locale/json/hi_IN.json index 8dc37c5abfb..d54615216f6 100644 --- a/packages/shared/src/locale/json/hi_IN.json +++ b/packages/shared/src/locale/json/hi_IN.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "निकासी का अनुरोध करने से लेकर टोकन का दावा करने तक का अनुमानित समय।", "earn.unsupported_path_desc": "डेरिवेशन पथ को टैपरूट में स्विच करें", "earn.unsupported_path_title": "यह स्टेक {path} का समर्थन नहीं करता है", + "earn.unsupported_token": "असमर्थित टोकन", + "earn.unsupported_token_desc": "यह टोकन वर्तमान में खरीदें सेवा के लिए समर्थित नहीं है।", "earn.until_next_launch": "अगली लॉन्च तक", "earn.until_next_launch_tooltip": "उपयोगकर्ताओं के लिए पुरस्कार उत्पन्न करने के लिए एक पूल में न्यूनतम 32 ETH होना आवश्यक है।", "earn.up_to_number_days": "{number} दिनों तक", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "यह पता हार्डवेयर वॉलेट से मेल नहीं खाता। तुरंत इस पते का उपयोग करना बंद करें और हमसे संपर्क करें।", "feedback.address_not_activated_message": "पता अभी तक सक्रिय नहीं हुआ है", "feedback.address_not_matched": "पता मेल नहीं खाता", - "feedback.address_type_does_not_support_sign_method": "चयनित पते के लिए असमर्थित हस्ताक्षर विधि", + "feedback.address_type_does_not_support_sign_method": "केवल {type} पते इस हस्ताक्षर विधि का समर्थन करते हैं", "feedback.bluetooth_issue": "ब्लूटूथ समस्या", "feedback.bluetooth_pairing_failed": "ब्लूटूथ पेयरिंग विफल रही", "feedback.bluetooth_unparied": "ब्लूटूथ अनपेयर्ड", diff --git a/packages/shared/src/locale/json/id.json b/packages/shared/src/locale/json/id.json index 83a004652a2..b3c4a11a0ce 100644 --- a/packages/shared/src/locale/json/id.json +++ b/packages/shared/src/locale/json/id.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "Perkiraan waktu dari permintaan penarikan hingga token dapat diklaim.", "earn.unsupported_path_desc": "Ganti jalur derivasi ke Taproot", "earn.unsupported_path_title": "Staking ini tidak mendukung {path}", + "earn.unsupported_token": "Token tidak didukung", + "earn.unsupported_token_desc": "Token ini saat ini tidak didukung untuk layanan Beli.", "earn.until_next_launch": "Sampai peluncuran berikutnya", "earn.until_next_launch_tooltip": "Diperlukan minimal 32 ETH agar pool dapat mulai menghasilkan hadiah bagi pengguna.", "earn.up_to_number_days": "Hingga {number} hari", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "Alamat ini tidak cocok dengan dompet hardware. Berhenti menggunakan alamat ini segera dan hubungi kami.", "feedback.address_not_activated_message": "Alamat belum diaktifkan", "feedback.address_not_matched": "Alamat tidak cocok", - "feedback.address_type_does_not_support_sign_method": "Metode tanda tangan tidak didukung untuk alamat yang dipilih", + "feedback.address_type_does_not_support_sign_method": "Hanya alamat {type} yang mendukung metode tanda tangan ini", "feedback.bluetooth_issue": "Masalah Bluetooth", "feedback.bluetooth_pairing_failed": "Pasangan Bluetooth gagal", "feedback.bluetooth_unparied": "Bluetooth tidak dipasangkan", diff --git a/packages/shared/src/locale/json/it_IT.json b/packages/shared/src/locale/json/it_IT.json index 27eba66a494..ae9af3cdfcd 100644 --- a/packages/shared/src/locale/json/it_IT.json +++ b/packages/shared/src/locale/json/it_IT.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "Il periodo stimato dalla richiesta di prelievo al momento in cui i token possono essere reclamati.", "earn.unsupported_path_desc": "Cambia il percorso di derivazione in Taproot", "earn.unsupported_path_title": "Questo staking non supporta {path}", + "earn.unsupported_token": "Token non supportato", + "earn.unsupported_token_desc": "Questo token non è attualmente supportato per il servizio Acquista.", "earn.until_next_launch": "Fino al prossimo lancio", "earn.until_next_launch_tooltip": "È necessario un minimo di 32 ETH affinché un pool inizi a produrre ricompense per gli utenti.", "earn.up_to_number_days": "Fino a {number} giorni", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "L'indirizzo non corrisponde al portafoglio hardware. Smetti immediatamente di utilizzare questo indirizzo e contattaci.", "feedback.address_not_activated_message": "Indirizzo non ancora attivato", "feedback.address_not_matched": "Indirizzo non corrispondente", - "feedback.address_type_does_not_support_sign_method": "Metodo di firma non supportato per l'indirizzo selezionato", + "feedback.address_type_does_not_support_sign_method": "Solo gli indirizzi {type} supportano questo metodo di firma", "feedback.bluetooth_issue": "Problema Bluetooth", "feedback.bluetooth_pairing_failed": "Associazione Bluetooth non riuscita", "feedback.bluetooth_unparied": "Bluetooth non accoppiato", diff --git a/packages/shared/src/locale/json/ja_JP.json b/packages/shared/src/locale/json/ja_JP.json index f41be5aaf68..54af2de7557 100644 --- a/packages/shared/src/locale/json/ja_JP.json +++ b/packages/shared/src/locale/json/ja_JP.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "出金依頼からトークンを受け取るまでの推定期間。", "earn.unsupported_path_desc": "導出パスをTaprootに切り替えてください", "earn.unsupported_path_title": "このステークは {path} をサポートしていません", + "earn.unsupported_token": "サポートされていないトークン", + "earn.unsupported_token_desc": "このトークンは現在、購入サービスではサポートされていません。", "earn.until_next_launch": "次の打ち上げまで", "earn.until_next_launch_tooltip": "プールがユーザーに報酬を生成し始めるには、最低32 ETHが必要です。", "earn.up_to_number_days": "{number}日間まで", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "アドレスがハードウェアウォレットと一致しません。すぐにこのアドレスの使用を停止し、私たちに連絡してください。", "feedback.address_not_activated_message": "アドレスはまだ有効化されていません", "feedback.address_not_matched": "住所が一致しません", - "feedback.address_type_does_not_support_sign_method": "選択されたアドレスに対する署名方法はサポートされていません", + "feedback.address_type_does_not_support_sign_method": "この署名方法をサポートするのは、{type} アドレスのみです", "feedback.bluetooth_issue": "Bluetoothの問題", "feedback.bluetooth_pairing_failed": "Bluetoothのペアリングに失敗しました", "feedback.bluetooth_unparied": "Bluetoothのペアリング解除", diff --git a/packages/shared/src/locale/json/ko_KR.json b/packages/shared/src/locale/json/ko_KR.json index aaa190e9d0c..0e45118ae97 100644 --- a/packages/shared/src/locale/json/ko_KR.json +++ b/packages/shared/src/locale/json/ko_KR.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "출금을 요청한 시점부터 토큰을 청구할 수 있을 때까지의 예상 기간입니다.", "earn.unsupported_path_desc": "파생 경로를 Taproot로 전환하십시오", "earn.unsupported_path_title": "이 스테이킹은 {path} 를 지원하지 않습니다", + "earn.unsupported_token": "지원되지 않는 토큰", + "earn.unsupported_token_desc": "이 토큰은 현재 구매 서비스에서 지원되지 않습니다.", "earn.until_next_launch": "다음 발사까지", "earn.until_next_launch_tooltip": "풀이 사용자에게 보상을 생성하기 시작하려면 최소 32 ETH가 필요합니다.", "earn.up_to_number_days": "{number}일까지", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "주소가 하드웨어 지갑과 일치하지 않습니다. 즉시 이 주소 사용을 중단하고 저희에게 연락하세요.", "feedback.address_not_activated_message": "주소가 아직 활성화되지 않았습니다", "feedback.address_not_matched": "주소가 일치하지 않습니다", - "feedback.address_type_does_not_support_sign_method": "선택된 주소에 대해 지원되지 않는 서명 방법", + "feedback.address_type_does_not_support_sign_method": "오직 {type} 주소만이 이 서명 방식을 지원합니다", "feedback.bluetooth_issue": "블루투스 문제", "feedback.bluetooth_pairing_failed": "블루투스 페어링 실패", "feedback.bluetooth_unparied": "블루투스 연결 해제됨", diff --git a/packages/shared/src/locale/json/pt.json b/packages/shared/src/locale/json/pt.json index 2ad419c982d..91647adf37e 100644 --- a/packages/shared/src/locale/json/pt.json +++ b/packages/shared/src/locale/json/pt.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "O período estimado entre o pedido de retirada e o momento em que os tokens podem ser reivindicados.", "earn.unsupported_path_desc": "Mude o caminho de derivação para Taproot", "earn.unsupported_path_title": "Este staking não suporta {path}", + "earn.unsupported_token": "Token não suportado", + "earn.unsupported_token_desc": "Este token não é suportado atualmente pelo serviço Buy.", "earn.until_next_launch": "Até o próximo lançamento", "earn.until_next_launch_tooltip": "É necessário um mínimo de 32 ETH para que um pool comece a gerar recompensas para os usuários.", "earn.up_to_number_days": "Até {number} dias", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "O endereço não corresponde à carteira de hardware. Pare de usar este endereço imediatamente e entre em contato conosco.", "feedback.address_not_activated_message": "Endereço ainda não ativado", "feedback.address_not_matched": "Endereço não correspondente", - "feedback.address_type_does_not_support_sign_method": "Método de assinatura não suportado para o endereço selecionado", + "feedback.address_type_does_not_support_sign_method": "Apenas endereços {type} suportam este método de assinatura", "feedback.bluetooth_issue": "Problema com o Bluetooth", "feedback.bluetooth_pairing_failed": "Falha no emparelhamento Bluetooth", "feedback.bluetooth_unparied": "Bluetooth desemparelhado", diff --git a/packages/shared/src/locale/json/pt_BR.json b/packages/shared/src/locale/json/pt_BR.json index e835aaa7d1c..700c7bc76d6 100644 --- a/packages/shared/src/locale/json/pt_BR.json +++ b/packages/shared/src/locale/json/pt_BR.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "O período estimado entre o pedido de retirada e o momento em que os tokens podem ser reivindicados.", "earn.unsupported_path_desc": "Mude o caminho de derivação para Taproot", "earn.unsupported_path_title": "Este staking não suporta {path}", + "earn.unsupported_token": "Token não suportado", + "earn.unsupported_token_desc": "Este token não é suportado atualmente pelo serviço Buy.", "earn.until_next_launch": "Até o próximo lançamento", "earn.until_next_launch_tooltip": "É necessário um mínimo de 32 ETH para que um pool comece a gerar recompensas para os usuários.", "earn.up_to_number_days": "Até {number} dias", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "O endereço não corresponde à carteira de hardware. Pare de usar este endereço imediatamente e entre em contato conosco.", "feedback.address_not_activated_message": "Endereço ainda não ativado", "feedback.address_not_matched": "Endereço não correspondente", - "feedback.address_type_does_not_support_sign_method": "Método de assinatura não suportado para o endereço selecionado", + "feedback.address_type_does_not_support_sign_method": "Apenas endereços {type} suportam este método de assinatura", "feedback.bluetooth_issue": "Problema com Bluetooth", "feedback.bluetooth_pairing_failed": "Falha no pareamento Bluetooth", "feedback.bluetooth_unparied": "Bluetooth despareado", diff --git a/packages/shared/src/locale/json/ru.json b/packages/shared/src/locale/json/ru.json index a4cd17d6d68..954055db253 100644 --- a/packages/shared/src/locale/json/ru.json +++ b/packages/shared/src/locale/json/ru.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "Оценочный период с момента запроса на вывод до того, как токены могут быть востребованы.", "earn.unsupported_path_desc": "Переключите путь производного на Taproot", "earn.unsupported_path_title": "Этот стейкинг не поддерживает {path}", + "earn.unsupported_token": "Неподдерживаемый токен", + "earn.unsupported_token_desc": "В настоящее время этот токен не поддерживается сервисом Buy.", "earn.until_next_launch": "До следующего запуска", "earn.until_next_launch_tooltip": "Для того чтобы пул начал приносить вознаграждения пользователям, требуется минимум 32 ETH.", "earn.up_to_number_days": "До {number} дней", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "Адрес не совпадает с аппаратным кошельком. Прекратите использовать этот адрес немедленно и свяжитесь с нами.", "feedback.address_not_activated_message": "Адрес еще не активирован", "feedback.address_not_matched": "Адрес не совпадает", - "feedback.address_type_does_not_support_sign_method": "Неподдерживаемый метод подписи для выбранного адреса", + "feedback.address_type_does_not_support_sign_method": "Только адреса {type} поддерживают этот метод подписи", "feedback.bluetooth_issue": "Проблема с Bluetooth", "feedback.bluetooth_pairing_failed": "Сопряжение Bluetooth не удалось", "feedback.bluetooth_unparied": "Bluetooth отключен", diff --git a/packages/shared/src/locale/json/th_TH.json b/packages/shared/src/locale/json/th_TH.json index 2956a6c5b32..7df73a530a7 100644 --- a/packages/shared/src/locale/json/th_TH.json +++ b/packages/shared/src/locale/json/th_TH.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "ระยะเวลาประมาณการจากการขอถอนจนถึงเวลาที่สามารถเรียกร้องโทเค็นได้", "earn.unsupported_path_desc": "เปลี่ยนเส้นทางการสืบทอดไปยัง Taproot", "earn.unsupported_path_title": "การวางเดิมพันนี้ไม่รองรับ {path}", + "earn.unsupported_token": "โทเค็นที่ไม่รองรับ", + "earn.unsupported_token_desc": "โทเค็นนี้ไม่ได้รับการสนับสนุนสำหรับบริการการซื้อในปัจจุบัน", "earn.until_next_launch": "จนกว่าจะมีการเปิดตัวครั้งถัดไป", "earn.until_next_launch_tooltip": "ต้องใช้ ETH ขั้นต่ำ 32 ETH เพื่อให้พูลเริ่มสร้างรางวัลสำหรับผู้ใช้", "earn.up_to_number_days": "ไม่เกิน {number} วัน", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "ที่อยู่ไม่ตรงกับกระเป๋าสตางค์ฮาร์ดแวร์ หยุดการใช้งานที่อยู่นี้ทันทีและติดต่อเรา", "feedback.address_not_activated_message": "ที่อยู่ยังไม่ได้รับการเปิดใช้งาน", "feedback.address_not_matched": "ไม่พบที่อยู่", - "feedback.address_type_does_not_support_sign_method": "ไม่รองรับวิธีการลงชื่อสำหรับที่อยู่ที่เลือก", + "feedback.address_type_does_not_support_sign_method": "เฉพาะที่อยู่ประเภท {type} เท่านั้นที่รองรับวิธีการลงนามนี้", "feedback.bluetooth_issue": "ปัญหาเกี่ยวกับบลูทูธ", "feedback.bluetooth_pairing_failed": "การจับคู่ Bluetooth ล้มเหลว", "feedback.bluetooth_unparied": "ยกเลิกการเชื่อมต่อ Bluetooth", diff --git a/packages/shared/src/locale/json/uk_UA.json b/packages/shared/src/locale/json/uk_UA.json index df502789032..bd1d0eb241b 100644 --- a/packages/shared/src/locale/json/uk_UA.json +++ b/packages/shared/src/locale/json/uk_UA.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "Орієнтовний період від запиту на виведення до моменту, коли токени можна буде отримати.", "earn.unsupported_path_desc": "Перемкніть шлях похідного на Taproot", "earn.unsupported_path_title": "Ця ставка не підтримує {path}", + "earn.unsupported_token": "Непідтримуваний маркер", + "earn.unsupported_token_desc": "Цей маркер наразі не підтримується службою \"Купити\".", "earn.until_next_launch": "До наступного запуску", "earn.until_next_launch_tooltip": "Для того щоб пул почав приносити винагороди користувачам, потрібно мінімум 32 ETH.", "earn.up_to_number_days": "До {number} днів", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "Адреса не збігається з апаратним гаманцем. Негайно припиніть використовувати цю адресу та зв'яжіться з нами.", "feedback.address_not_activated_message": "Адреса ще не активована", "feedback.address_not_matched": "Адресу не знайдено", - "feedback.address_type_does_not_support_sign_method": "Непідтримуваний метод підпису для обраної адреси", + "feedback.address_type_does_not_support_sign_method": "Цей метод підпису підтримують лише адреси {type}", "feedback.bluetooth_issue": "Проблема з Bluetooth", "feedback.bluetooth_pairing_failed": "Помилка підключення Bluetooth", "feedback.bluetooth_unparied": "Bluetooth роз'єднано", diff --git a/packages/shared/src/locale/json/vi.json b/packages/shared/src/locale/json/vi.json index 63cc6004013..1cd5a93693b 100644 --- a/packages/shared/src/locale/json/vi.json +++ b/packages/shared/src/locale/json/vi.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "Thời gian ước tính từ khi yêu cầu rút tiền đến khi có thể yêu cầu token.", "earn.unsupported_path_desc": "Chuyển đường dẫn xuất phát sang Taproot", "earn.unsupported_path_title": "Khoản stake này không hỗ trợ {path}", + "earn.unsupported_token": "Mã thông báo không được hỗ trợ", + "earn.unsupported_token_desc": "Mã thông báo này hiện không được hỗ trợ cho dịch vụ Mua.", "earn.until_next_launch": "Đến lần khởi động tiếp theo", "earn.until_next_launch_tooltip": "Cần tối thiểu 32 ETH để một pool bắt đầu tạo phần thưởng cho người dùng.", "earn.up_to_number_days": "Đến {number} ngày", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "Địa chỉ không khớp với ví cứng. Ngừng sử dụng địa chỉ này ngay lập tức và liên hệ với chúng tôi.", "feedback.address_not_activated_message": "Địa chỉ chưa được kích hoạt", "feedback.address_not_matched": "Địa chỉ không khớp", - "feedback.address_type_does_not_support_sign_method": "Phương thức chữ ký không được hỗ trợ cho địa chỉ đã chọn", + "feedback.address_type_does_not_support_sign_method": "Chỉ có địa chỉ {type} hỗ trợ phương pháp chữ ký này", "feedback.bluetooth_issue": "Vấn đề Bluetooth", "feedback.bluetooth_pairing_failed": "Kết nối Bluetooth thất bại", "feedback.bluetooth_unparied": "Bluetooth đã hủy kết nối", diff --git a/packages/shared/src/locale/json/zh_CN.json b/packages/shared/src/locale/json/zh_CN.json index ec3d1e6b626..ff5bede0750 100644 --- a/packages/shared/src/locale/json/zh_CN.json +++ b/packages/shared/src/locale/json/zh_CN.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "从请求赎回到可领取代币的估计时间。", "earn.unsupported_path_desc": "将派生路径切换到 Taproot", "earn.unsupported_path_title": "此质押不支持 {path}", + "earn.unsupported_token": "不支持的代币", + "earn.unsupported_token_desc": "此代币目前不支持购买服务。", "earn.until_next_launch": "直到下次启动", "earn.until_next_launch_tooltip": "需至少 32 ETH 才能开始为用户产生收益。", "earn.up_to_number_days": "最多 {number} 天", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "该地址与硬件钱包不匹配。请立即停止使用此地址,并与我们联系。", "feedback.address_not_activated_message": "地址尚未激活", "feedback.address_not_matched": "地址不匹配", - "feedback.address_type_does_not_support_sign_method": "所选地址不支持此签名方式", + "feedback.address_type_does_not_support_sign_method": "只有 {type} 地址支持这种签名方法", "feedback.bluetooth_issue": "蓝牙异常", "feedback.bluetooth_pairing_failed": "蓝牙配对失败", "feedback.bluetooth_unparied": "蓝牙未配对", @@ -1924,7 +1926,7 @@ "transaction__contract_interaction": "合约交互", "transaction__transaction_confirm": "交易确认", "transaction_confirm.batch_swap_tip": "通过提交此订单,您即同意授权 {token} 进行交易,并确认在 {chain} 上完成由 {provider} API 提供支持的兑换操作。如果您对订单有任何疑惑,请联系我们。", - "transaction_confirm.single_swap_tip": "通过提交此订单,您确认在{chain}上进行由{provider} API支持的交换。如果您对订单有任何疑虑,请联系我们。", + "transaction_confirm.single_swap_tip": "通过提交此订单,您即确认在 {chain} 上完成由 {provider} API 提供支持的兑换操作。如果您对订单有任何疑虑,请联系我们。", "troubleshooting.change_usb_port": "换一个电脑上的 USB 端口。", "troubleshooting.check_bluetooth": "请确保 OneKey 设备已启用蓝牙(如果使用 OneKey Pro,请禁用 AirGap)。", "troubleshooting.check_bridge": "检查 Bridge 是否正确安装。在此查看详情。", diff --git a/packages/shared/src/locale/json/zh_HK.json b/packages/shared/src/locale/json/zh_HK.json index 018ccb3c7c8..655a9d66a55 100644 --- a/packages/shared/src/locale/json/zh_HK.json +++ b/packages/shared/src/locale/json/zh_HK.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "從請求贖回到可領取代幣的估計時間。", "earn.unsupported_path_desc": "將派生路徑切換至 Taproot", "earn.unsupported_path_title": "此質押不支援 {path}", + "earn.unsupported_token": "不支援的代幣", + "earn.unsupported_token_desc": "購買服務目前不支援此代幣。", "earn.until_next_launch": "直到下次啟動", "earn.until_next_launch_tooltip": "需至少 32 ETH 才能開始為用戶產生收益。", "earn.up_to_number_days": "最多 {number} 天", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "該地址與硬件錢包不匹配。請立即停止使用此地址,並與我們聯絡。", "feedback.address_not_activated_message": "地址尚未啟動", "feedback.address_not_matched": "地址未能配對", - "feedback.address_type_does_not_support_sign_method": "所選地址不支援此簽名方式", + "feedback.address_type_does_not_support_sign_method": "只有 {type} 地址支持這種簽名方法", "feedback.bluetooth_issue": "藍牙異常", "feedback.bluetooth_pairing_failed": "藍牙配對失敗", "feedback.bluetooth_unparied": "藍牙未配對", @@ -1924,7 +1926,7 @@ "transaction__contract_interaction": "合約交互", "transaction__transaction_confirm": "交易確認", "transaction_confirm.batch_swap_tip": "通過提交此訂單,您即同意授權 {token} 進行交易,並確認在 {chain} 上完成由 {provider} API 提供支持的兌換操作。如果您對訂單有任何疑問,請聯繫我們。", - "transaction_confirm.single_swap_tip": "提交此訂單即表示您確認在{chain}上進行由{provider} API支持的交換。如果您對訂單有任何疑慮,請聯繫我們。", + "transaction_confirm.single_swap_tip": "通過提交此訂單,您即確認在 {chain} 上完成由 {provider} API 提供支持的兌換操作。如果您對訂單有任何疑慮,請聯繫我們。", "troubleshooting.change_usb_port": "更改您電腦上使用的 USB 端口。", "troubleshooting.check_bluetooth": "請確保 OneKey 設備已啟用藍牙(如果使用 OneKey Pro,請禁用 AirGap)。", "troubleshooting.check_bridge": "檢查 Bridge 是否正確安裝。在此查看詳情。", diff --git a/packages/shared/src/locale/json/zh_TW.json b/packages/shared/src/locale/json/zh_TW.json index b79089fa32a..f7d04e03749 100644 --- a/packages/shared/src/locale/json/zh_TW.json +++ b/packages/shared/src/locale/json/zh_TW.json @@ -462,6 +462,8 @@ "earn.unstaking_period_tooltip": "從請求贖回到可領取代幣的估計時間。", "earn.unsupported_path_desc": "將派生路徑切換至 Taproot", "earn.unsupported_path_title": "此質押不支援 {path}", + "earn.unsupported_token": "不支援的代幣", + "earn.unsupported_token_desc": "購買服務目前不支援此代幣。", "earn.until_next_launch": "直到下次啟動", "earn.until_next_launch_tooltip": "需至少 32 ETH 才能開始為用戶產生收益。", "earn.up_to_number_days": "最多 {number} 天", @@ -612,7 +614,7 @@ "feedback.address_mismatch_desc": "該地址與硬體錢包不符。請立即停止使用此地址,並與我們聯繫。", "feedback.address_not_activated_message": "地址尚未啟用", "feedback.address_not_matched": "地址未匹配", - "feedback.address_type_does_not_support_sign_method": "所選地址不支援此簽名方式", + "feedback.address_type_does_not_support_sign_method": "僅有 {type} 地址支援此簽名方法", "feedback.bluetooth_issue": "藍牙異常", "feedback.bluetooth_pairing_failed": "藍牙配對失敗", "feedback.bluetooth_unparied": "藍牙未配對", @@ -1924,7 +1926,7 @@ "transaction__contract_interaction": "合約交互", "transaction__transaction_confirm": "交易確認", "transaction_confirm.batch_swap_tip": "通過提交此訂單,您即同意授權 {token} 進行交易,並確認在 {chain} 上完成由 {provider} API 提供支持的兌換操作。如果您對訂單有任何疑問,請聯繫我們。", - "transaction_confirm.single_swap_tip": "提交此訂單即表示您確認在{chain}上通過{provider} API進行交換。如果您對訂單有任何疑慮,請聯繫我們。", + "transaction_confirm.single_swap_tip": "通過提交此訂單,您即確認在 {chain} 上完成由 {provider} API 提供支持的兌換操作。如果您對訂單有任何疑慮,請聯繫我們。", "troubleshooting.change_usb_port": "更改您電腦上使用的 USB 端口。", "troubleshooting.check_bluetooth": "請確保 OneKey 設備已啟用藍牙(如果使用 OneKey Pro,請禁用 AirGap)。", "troubleshooting.check_bridge": "檢查 Bridge 是否正確安裝。 在此查看詳情。", diff --git a/packages/shared/src/logger/scopes/market/scenes/token.ts b/packages/shared/src/logger/scopes/market/scenes/token.ts index 47e9a76daae..9687a144e9f 100644 --- a/packages/shared/src/logger/scopes/market/scenes/token.ts +++ b/packages/shared/src/logger/scopes/market/scenes/token.ts @@ -42,4 +42,19 @@ export class TokenScene extends BaseScene { ) { return token; } + + @LogToServer() + @LogToLocal({ level: 'info' }) + public unsupportedToken({ + name, + action, + }: { + name: string; + action: 'buy' | 'sell' | 'trade'; + }) { + return { + tokenName: name, + userAction: action, + }; + } } diff --git a/packages/shared/src/routes/swap.ts b/packages/shared/src/routes/swap.ts index cc83d50ff3b..e3c04f555f9 100644 --- a/packages/shared/src/routes/swap.ts +++ b/packages/shared/src/routes/swap.ts @@ -16,6 +16,7 @@ export enum EModalSwapRoutes { SwapHistoryDetail = 'SwapHistoryDetail', SwapToAnotherAddress = 'SwapToAnotherAddress', TokenRiskReminder = 'TokenRiskReminder', + SwapLazyMarketModal = 'SwapLazyMarketModal', } export type IModalSwapParamList = { @@ -48,4 +49,7 @@ export type IModalSwapParamList = { token: ISwapToken; onConfirm: () => void; }; + [EModalSwapRoutes.SwapLazyMarketModal]: { + coinGeckoId: string; + }; }; diff --git a/packages/shared/types/market/marketProvider.constants.ts b/packages/shared/types/market/marketProvider.constants.ts index 7f738be420b..bb44604ea7d 100644 --- a/packages/shared/types/market/marketProvider.constants.ts +++ b/packages/shared/types/market/marketProvider.constants.ts @@ -1,165 +1,68 @@ import { memoizee } from '@onekeyhq/shared/src/utils/cacheUtils'; import { getNetworkIdsMap } from '../../src/config/networkIds'; -import { ESwapTabSwitchType } from '../swap/types'; +// TODO: This token configuration list should be moved to backend service const getSwapTokenMap = memoizee( (): Record< string, { - switchType: ESwapTabSwitchType; contractAddress: string; - default: { - contractAddress: string; - networkId: string; - name: string; - symbol: string; - decimals: number; - isNative: boolean; - networkLogoURI?: string; - }; - target: { - networkId: string; - contractAddress: string; - name: string; - symbol: string; - decimals: number; - isNative: boolean; - networkLogoURI: string; - isPopular?: boolean; - }; + symbol: string; + realContractAddress: string; } > => { const networkIdsMap = getNetworkIdsMap(); return { [networkIdsMap.btc]: { - switchType: ESwapTabSwitchType.BRIDGE, contractAddress: '', - default: { - 'contractAddress': '', - 'networkId': 'btc--0', - 'name': 'Bitcoin', - 'symbol': 'BTC', - 'decimals': 8, - 'isNative': true, - }, - target: { - 'networkId': 'evm--1', - 'contractAddress': '', - 'name': 'Ethereum', - 'symbol': 'ETH', - 'decimals': 18, - 'isNative': true, - 'networkLogoURI': 'https://uni.onekey-asset.com/static/chain/eth.png', - }, + symbol: 'BTC', + realContractAddress: '', }, [networkIdsMap.eth]: { - switchType: ESwapTabSwitchType.SWAP, contractAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', - default: { - 'networkId': 'evm--1', - 'contractAddress': '', - 'name': 'Ethereum', - 'symbol': 'ETH', - 'decimals': 18, - 'isNative': true, - 'networkLogoURI': 'https://uni.onekey-asset.com/static/chain/eth.png', - }, - target: { - 'networkId': 'evm--1', - 'contractAddress': '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', - 'name': 'USD Coin', - 'symbol': 'USDC', - 'decimals': 6, - 'isNative': false, - 'isPopular': true, - 'networkLogoURI': 'https://uni.onekey-asset.com/static/chain/eth.png', - }, + symbol: 'ETH', + realContractAddress: '', }, [networkIdsMap.sol]: { - switchType: ESwapTabSwitchType.SWAP, contractAddress: 'So11111111111111111111111111111111111111112', - default: { - 'networkId': 'sol--101', - 'contractAddress': '', - 'name': 'Solana', - 'symbol': 'SOL', - 'decimals': 9, - 'isNative': true, - }, - target: { - 'networkId': 'sol--101', - 'contractAddress': 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', - 'name': 'USDC', - 'symbol': 'USDC', - 'decimals': 6, - 'isNative': false, - 'networkLogoURI': 'https://uni.onekey-asset.com/static/chain/sol.png', - }, + symbol: 'SOL', + realContractAddress: '', }, [networkIdsMap.bsc]: { - switchType: ESwapTabSwitchType.SWAP, contractAddress: '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c', - default: { - 'networkId': 'evm--56', - 'contractAddress': '', - 'name': 'BNB', - 'symbol': 'BNB', - 'decimals': 18, - 'isNative': true, - }, - target: { - 'networkId': 'evm--56', - 'contractAddress': '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d', - 'name': 'USD Coin', - 'symbol': 'USDC', - 'decimals': 18, - 'networkLogoURI': 'https://uni.onekey-asset.com/static/chain/bsc.png', - 'isNative': false, - }, + symbol: 'BNB', + realContractAddress: '', }, [networkIdsMap.polygon]: { - switchType: ESwapTabSwitchType.SWAP, contractAddress: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270', - default: { - 'contractAddress': '', - 'networkId': 'evm--137', - 'name': 'Polygon', - 'symbol': 'POL', - 'decimals': 18, - 'isNative': true, - }, - target: { - 'contractAddress': '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359', - 'networkId': 'evm--137', - 'name': 'USD Coin', - 'symbol': 'USDC', - 'decimals': 6, - 'networkLogoURI': - 'https://uni.onekey-asset.com/static/chain/polygon.png', - 'isNative': false, - }, + symbol: 'POL', + realContractAddress: '', + }, + [networkIdsMap.avalanche]: { + contractAddress: '0x0000000000000000000000000000000000000000', + symbol: 'AVAX', + realContractAddress: '', }, [networkIdsMap.apt]: { - switchType: ESwapTabSwitchType.BRIDGE, contractAddress: '0x1::aptos_coin::AptosCoin', - default: { - 'contractAddress': '', - 'networkId': 'aptos--1', - 'name': 'Aptos Coin', - 'symbol': 'APT', - 'decimals': 8, - 'isNative': true, - }, - target: { - 'networkId': 'evm--1', - 'contractAddress': '', - 'name': 'Ethereum', - 'symbol': 'ETH', - 'decimals': 18, - 'isNative': true, - 'networkLogoURI': 'https://uni.onekey-asset.com/static/chain/eth.png', - }, + symbol: 'APT', + realContractAddress: '', + }, + [networkIdsMap.kaspa]: { + contractAddress: '', + symbol: 'KAS', + realContractAddress: '', + }, + [networkIdsMap.ton]: { + contractAddress: 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c', + symbol: 'TON', + realContractAddress: '', + }, + [networkIdsMap.sui]: { + contractAddress: '0x2::sui::SUI', + symbol: 'SUI', + realContractAddress: '0x2::sui::SUI', }, }; }, @@ -183,18 +86,16 @@ export function getImportFromToken({ networkId: string; tokenSymbol: string; contractAddress: string; - isSupportSwap: boolean; }) { const map = getSwapTokenMap(); const item = map[networkId]; if (item) { const isNative = - tokenSymbol.toUpperCase() === item.default.symbol && + tokenSymbol.toUpperCase() === item.symbol && item.contractAddress === contractAddress; return { isNative, - importFromToken: isNative ? item.target : item.default, - swapTabSwitchType: item.switchType, + realContractAddress: item.realContractAddress, }; } return undefined;