diff --git a/packages/suite-desktop-core/e2e/support/pageActions/marketActions.ts b/packages/suite-desktop-core/e2e/support/pageActions/marketActions.ts index dd31f7d7caea..1b92e08572a9 100644 --- a/packages/suite-desktop-core/e2e/support/pageActions/marketActions.ts +++ b/packages/suite-desktop-core/e2e/support/pageActions/marketActions.ts @@ -1,7 +1,7 @@ import { Locator, Page } from '@playwright/test'; -import { regional } from '@suite-common/trading'; import { FiatCurrencyCode } from '@suite-common/suite-config'; +import { regional } from '@suite-common/trading'; import { NetworkSymbol } from '@suite-common/wallet-config'; import { diff --git a/packages/suite/src/actions/wallet/trading/tradingCommonActions.ts b/packages/suite/src/actions/wallet/trading/tradingCommonActions.ts index 96de34c75e44..7433cf80084f 100644 --- a/packages/suite/src/actions/wallet/trading/tradingCommonActions.ts +++ b/packages/suite/src/actions/wallet/trading/tradingCommonActions.ts @@ -1,7 +1,7 @@ import { CryptoId } from 'invity-api'; -import { isDesktop } from '@trezor/env-utils'; import { notificationsActions } from '@suite-common/toast-notifications'; +import type { TradingType } from '@suite-common/trading'; import { confirmAddressOnDeviceThunk, selectSelectedDevice, @@ -15,8 +15,8 @@ import { hasNetworkFeatures, parseFormDraftKey, } from '@suite-common/wallet-utils'; -import type { TradingType } from '@suite-common/trading'; import { PROTO } from '@trezor/connect'; +import { isDesktop } from '@trezor/env-utils'; import * as modalActions from 'src/actions/suite/modalActions'; import { TRADING_BUY, TRADING_COMMON, TRADING_EXCHANGE } from 'src/actions/wallet/constants'; diff --git a/packages/suite/src/hooks/wallet/trading/form/useTradingBuyForm.tsx b/packages/suite/src/hooks/wallet/trading/form/useTradingBuyForm.tsx index f8835b9f73f9..1d0ef7abd569 100644 --- a/packages/suite/src/hooks/wallet/trading/form/useTradingBuyForm.tsx +++ b/packages/suite/src/hooks/wallet/trading/form/useTradingBuyForm.tsx @@ -4,13 +4,13 @@ import { useForm, useWatch } from 'react-hook-form'; import type { BuyTrade, BuyTradeQuoteRequest, CryptoId } from 'invity-api'; import useDebounce from 'react-use/lib/useDebounce'; -import { type TradingBuyType, invityAPI } from '@suite-common/trading'; import { isChanged } from '@suite-common/suite-utils'; import { notificationsActions } from '@suite-common/toast-notifications'; +import { type TradingBuyType, invityAPI } from '@suite-common/trading'; import { networks } from '@suite-common/wallet-config'; import { formatAmount } from '@suite-common/wallet-utils'; import { isDesktop } from '@trezor/env-utils'; -import { analytics, EventType } from '@trezor/suite-analytics'; +import { EventType, analytics } from '@trezor/suite-analytics'; import * as routerActions from 'src/actions/suite/routerActions'; import * as tradingCommonActions from 'src/actions/wallet/trading/tradingCommonActions'; diff --git a/packages/suite/src/hooks/wallet/trading/form/useTradingExchangeForm.ts b/packages/suite/src/hooks/wallet/trading/form/useTradingExchangeForm.ts index f75d4c0aad31..d77f97b7bdb6 100644 --- a/packages/suite/src/hooks/wallet/trading/form/useTradingExchangeForm.ts +++ b/packages/suite/src/hooks/wallet/trading/form/useTradingExchangeForm.ts @@ -9,9 +9,9 @@ import type { } from 'invity-api'; import useDebounce from 'react-use/lib/useDebounce'; -import { type TradingExchangeType, invityAPI } from '@suite-common/trading'; import { isChanged } from '@suite-common/suite-utils'; import { notificationsActions } from '@suite-common/toast-notifications'; +import { type TradingExchangeType, invityAPI } from '@suite-common/trading'; import { networks } from '@suite-common/wallet-config'; import { Account } from '@suite-common/wallet-types'; import { amountToSmallestUnit, formatAmount, toFiatCurrency } from '@suite-common/wallet-utils'; diff --git a/packages/suite/src/hooks/wallet/trading/form/useTradingSellForm.ts b/packages/suite/src/hooks/wallet/trading/form/useTradingSellForm.ts index 8ac87751acbe..a919b4255081 100644 --- a/packages/suite/src/hooks/wallet/trading/form/useTradingSellForm.ts +++ b/packages/suite/src/hooks/wallet/trading/form/useTradingSellForm.ts @@ -4,9 +4,9 @@ import { useForm, useWatch } from 'react-hook-form'; import type { BankAccount, CryptoId, SellFiatTrade, SellFiatTradeQuoteRequest } from 'invity-api'; import useDebounce from 'react-use/lib/useDebounce'; -import { type TradingSellType, invityAPI } from '@suite-common/trading'; import { isChanged } from '@suite-common/suite-utils'; import { notificationsActions } from '@suite-common/toast-notifications'; +import { type TradingSellType, invityAPI } from '@suite-common/trading'; import { networks } from '@suite-common/wallet-config'; import { amountToSmallestUnit, formatAmount } from '@suite-common/wallet-utils'; import { EventType, analytics } from '@trezor/suite-analytics'; diff --git a/packages/suite/src/hooks/wallet/trading/useTradingWatchTrade.ts b/packages/suite/src/hooks/wallet/trading/useTradingWatchTrade.ts index ee89fca2a0b2..8e3489cdf48c 100644 --- a/packages/suite/src/hooks/wallet/trading/useTradingWatchTrade.ts +++ b/packages/suite/src/hooks/wallet/trading/useTradingWatchTrade.ts @@ -11,17 +11,13 @@ import { WatchSellTradeResponse, } from 'invity-api'; -import { type TradingType, invityAPI } from '@suite-common/trading'; +import { type TradingTradeStatusType, type TradingType, invityAPI } from '@suite-common/trading'; import { saveTrade as saveBuyTrade } from 'src/actions/wallet/tradingBuyActions'; import { saveTrade as saveExchangeTrade } from 'src/actions/wallet/tradingExchangeActions'; import { saveTrade as saveSellTrade } from 'src/actions/wallet/tradingSellActions'; import { useFormDraft } from 'src/hooks/wallet/useFormDraft'; -import { - TradingTradeStatusType, - TradingUseWatchTradeProps, - TradingWatchTradeProps, -} from 'src/types/trading/trading'; +import { TradingUseWatchTradeProps, TradingWatchTradeProps } from 'src/types/trading/trading'; import { Trade, TradeType } from 'src/types/wallet/tradingCommonTypes'; export const tradeFinalStatuses: Record = { diff --git a/packages/suite/src/reducers/suite/suiteReducer.ts b/packages/suite/src/reducers/suite/suiteReducer.ts index 04546abc4ba7..b07bb5f45099 100644 --- a/packages/suite/src/reducers/suite/suiteReducer.ts +++ b/packages/suite/src/reducers/suite/suiteReducer.ts @@ -1,8 +1,8 @@ import produce from 'immer'; -import type { InvityServerEnvironment } from '@suite-common/trading'; import { Feature, selectIsFeatureDisabled } from '@suite-common/message-system'; import { isDeviceAcquired } from '@suite-common/suite-utils'; +import type { InvityServerEnvironment } from '@suite-common/trading'; import { NetworkSymbol } from '@suite-common/wallet-config'; import { DeviceRootState, discoveryActions, selectSelectedDevice } from '@suite-common/wallet-core'; import { AddressDisplayOptions, WalletType } from '@suite-common/wallet-types'; diff --git a/packages/suite/src/types/trading/trading.ts b/packages/suite/src/types/trading/trading.ts index 511c0efc2da5..6664da93acd0 100644 --- a/packages/suite/src/types/trading/trading.ts +++ b/packages/suite/src/types/trading/trading.ts @@ -2,18 +2,16 @@ import { BuyCryptoPaymentMethod, BuyProviderInfo, BuyTrade, - BuyTradeStatus, CryptoId, ExchangeProviderInfo, ExchangeTrade, - ExchangeTradeStatus, FiatCurrencyCode, SellFiatTrade, SellProviderInfo, - SellTradeStatus, } from 'invity-api'; import { AnyAction, Dispatch } from 'redux'; +import { TokenDefinitionsState } from '@suite-common/token-definitions'; import type { TradingBuyType, TradingExchangeType, @@ -21,7 +19,6 @@ import type { TradingSellType, TradingType, } from '@suite-common/trading'; -import { TokenDefinitionsState } from '@suite-common/token-definitions'; import { AccountType, NetworkSymbolExtended } from '@suite-common/wallet-config'; import { AccountsState } from '@suite-common/wallet-core'; import { Account, SelectedAccountLoaded } from '@suite-common/wallet-types'; @@ -100,8 +97,6 @@ export interface TradingGetTypedTradeProps { transactionId: string | undefined; } -export type TradingTradeStatusType = BuyTradeStatus | SellTradeStatus | ExchangeTradeStatus; - export interface TradingGetDetailDataProps { trading: State; tradeType: TradeType; @@ -138,14 +133,6 @@ export interface TradingCryptoListProps { cryptoName?: string | undefined; // full name } -export type TradingUtilsProvidersProps = { - [name: string]: { - logo: string; - companyName: string; - brandName?: string; - }; -}; - export interface TradingInfoProps { cryptoIdToPlatformName: (cryptoId: CryptoId) => string | undefined; cryptoIdToCoinName: (cryptoId: CryptoId) => string | undefined; diff --git a/packages/suite/src/utils/wallet/trading/tradingUtils.ts b/packages/suite/src/utils/wallet/trading/tradingUtils.ts index 1f669017d90a..356a72b4d309 100644 --- a/packages/suite/src/utils/wallet/trading/tradingUtils.ts +++ b/packages/suite/src/utils/wallet/trading/tradingUtils.ts @@ -1,8 +1,8 @@ import { BuyTrade, CryptoId, ExchangeTrade, SellFiatTrade } from 'invity-api'; import { v4 as uuidv4 } from 'uuid'; -import { type TradingTradeType, type TradingType, regional } from '@suite-common/trading'; import { DefinitionType, isTokenDefinitionKnown } from '@suite-common/token-definitions'; +import { type TradingTradeType, type TradingType, regional } from '@suite-common/trading'; import { Network, NetworkSymbol, diff --git a/packages/suite/src/views/wallet/trading/common/TradingForm/TradingFormOfferItem.tsx b/packages/suite/src/views/wallet/trading/common/TradingForm/TradingFormOfferItem.tsx index afbbce06c762..8d5ccb6fe6d4 100644 --- a/packages/suite/src/views/wallet/trading/common/TradingForm/TradingFormOfferItem.tsx +++ b/packages/suite/src/views/wallet/trading/common/TradingForm/TradingFormOfferItem.tsx @@ -1,9 +1,8 @@ -import type { TradingTradeType } from '@suite-common/trading'; +import type { TradingTradeType, TradingUtilsProvidersProps } from '@suite-common/trading'; import { Card, Paragraph, Row, Spinner } from '@trezor/components'; import { spacings } from '@trezor/theme'; import { Translation } from 'src/components/suite'; -import { TradingUtilsProvidersProps } from 'src/types/trading/trading'; import { TradingUtilsProvider } from 'src/views/wallet/trading/common/TradingUtils/TradingUtilsProvider'; interface TradingFormOfferItemProps { diff --git a/packages/suite/src/views/wallet/trading/common/TradingForm/TradingFormOffersSwitcher.tsx b/packages/suite/src/views/wallet/trading/common/TradingForm/TradingFormOffersSwitcher.tsx index 8fd2930a3cb8..d8f9deb47cfc 100644 --- a/packages/suite/src/views/wallet/trading/common/TradingForm/TradingFormOffersSwitcher.tsx +++ b/packages/suite/src/views/wallet/trading/common/TradingForm/TradingFormOffersSwitcher.tsx @@ -1,4 +1,4 @@ -import type { TradingTradeType } from '@suite-common/trading'; +import type { TradingTradeType, TradingUtilsProvidersProps } from '@suite-common/trading'; import { Card, Column, Paragraph, Row, Spinner } from '@trezor/components'; import { spacings } from '@trezor/theme'; @@ -10,7 +10,6 @@ import { FORM_RATE_FLOATING, FORM_RATE_TYPE, } from 'src/constants/wallet/trading/form'; -import { TradingUtilsProvidersProps } from 'src/types/trading/trading'; import { TradingExchangeFormContextProps } from 'src/types/trading/tradingForm'; import { TradingFormOffersSwitcherItem } from 'src/views/wallet/trading/common/TradingForm/TradingFormOffersSwitcherItem'; diff --git a/packages/suite/src/views/wallet/trading/common/TradingForm/TradingFormOffersSwitcherItem.tsx b/packages/suite/src/views/wallet/trading/common/TradingForm/TradingFormOffersSwitcherItem.tsx index 11d72817c3b0..618bac2d2b06 100644 --- a/packages/suite/src/views/wallet/trading/common/TradingForm/TradingFormOffersSwitcherItem.tsx +++ b/packages/suite/src/views/wallet/trading/common/TradingForm/TradingFormOffersSwitcherItem.tsx @@ -1,12 +1,12 @@ import { ExchangeTrade } from 'invity-api'; import styled from 'styled-components'; +import { TradingUtilsProvidersProps } from '@suite-common/trading'; import { Badge, Radio, Row, Text, Tooltip, useElevation } from '@trezor/components'; import { Elevation, borders, mapElevationToBackground, spacings, spacingsPx } from '@trezor/theme'; import { Translation } from 'src/components/suite'; import { FORM_EXCHANGE_CEX, FORM_EXCHANGE_DEX } from 'src/constants/wallet/trading/form'; -import { TradingUtilsProvidersProps } from 'src/types/trading/trading'; import { ExchangeType } from 'src/types/trading/tradingForm'; import { TradingUtilsProvider } from 'src/views/wallet/trading/common/TradingUtils/TradingUtilsProvider'; diff --git a/packages/suite/src/views/wallet/trading/common/TradingLayout/TradingLayoutHeader.tsx b/packages/suite/src/views/wallet/trading/common/TradingLayout/TradingLayoutHeader.tsx index d57bb0083ad3..3b3f5a8cf816 100644 --- a/packages/suite/src/views/wallet/trading/common/TradingLayout/TradingLayoutHeader.tsx +++ b/packages/suite/src/views/wallet/trading/common/TradingLayout/TradingLayoutHeader.tsx @@ -1,7 +1,7 @@ import { PropsWithChildren, useMemo } from 'react'; -import type { TradingType } from '@suite-common/trading'; import { Route } from '@suite-common/suite-types'; +import type { TradingType } from '@suite-common/trading'; import { Box, Button, IconButton, Row } from '@trezor/components'; import { spacings } from '@trezor/theme'; diff --git a/packages/suite/src/views/wallet/trading/common/TradingUtils/TradingUtilsProvider.tsx b/packages/suite/src/views/wallet/trading/common/TradingUtils/TradingUtilsProvider.tsx index 1c60eafd0f7a..6410ab2c80a4 100644 --- a/packages/suite/src/views/wallet/trading/common/TradingUtils/TradingUtilsProvider.tsx +++ b/packages/suite/src/views/wallet/trading/common/TradingUtils/TradingUtilsProvider.tsx @@ -1,11 +1,10 @@ import styled from 'styled-components'; -import { invityAPI } from '@suite-common/trading'; +import { TradingUtilsProvidersProps, invityAPI } from '@suite-common/trading'; import { Row } from '@trezor/components'; import { spacings } from '@trezor/theme'; import { Translation } from 'src/components/suite'; -import { TradingUtilsProvidersProps } from 'src/types/trading/trading'; const Icon = styled.img` flex: none; diff --git a/suite-common/trading/src/types.ts b/suite-common/trading/src/types.ts index 7c0d37bf7f72..4c83725f9d87 100644 --- a/suite-common/trading/src/types.ts +++ b/suite-common/trading/src/types.ts @@ -1,9 +1,12 @@ import type { BuyCryptoPaymentMethod, BuyTrade, + BuyTradeStatus, ExchangeTrade, + ExchangeTradeStatus, SellCryptoPaymentMethod, SellFiatTrade, + SellTradeStatus, WatchBuyTradeResponse, WatchExchangeTradeResponse, WatchSellTradeResponse, @@ -27,3 +30,11 @@ export type TradingWatchTradeResponsePropsMap = { }; export type TradingPaymentMethodType = BuyCryptoPaymentMethod | SellCryptoPaymentMethod; +export type TradingTradeStatusType = BuyTradeStatus | SellTradeStatus | ExchangeTradeStatus; +export type TradingUtilsProvidersProps = { + [name: string]: { + logo: string; + companyName: string; + brandName?: string; + }; +};