Skip to content

Commit

Permalink
chore(trading): move common types to suite-common
Browse files Browse the repository at this point in the history
  • Loading branch information
adderpositive committed Jan 28, 2025
1 parent 7a03976 commit 6ffff75
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ import {
WatchSellTradeResponse,
} from 'invity-api';

import { invityAPI, type TradingType } from '@suite-common/trading';
import { invityAPI, type TradingTradeStatusType, type TradingType } from '@suite-common/trading';

import { Trade, TradeType } from 'src/types/wallet/tradingCommonTypes';
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 {
TradingTradeStatusType,
TradingUseWatchTradeProps,
TradingWatchTradeProps,
} from 'src/types/trading/trading';
import { TradingUseWatchTradeProps, TradingWatchTradeProps } from 'src/types/trading/trading';
import { useFormDraft } from 'src/hooks/wallet/useFormDraft';

export const tradeFinalStatuses: Record<TradeType, TradingTradeStatusType[]> = {
Expand Down
13 changes: 0 additions & 13 deletions packages/suite/src/types/trading/trading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ import {
BuyCryptoPaymentMethod,
BuyProviderInfo,
BuyTrade,
BuyTradeStatus,
CryptoId,
ExchangeProviderInfo,
ExchangeTrade,
ExchangeTradeStatus,
FiatCurrencyCode,
SellFiatTrade,
SellProviderInfo,
SellTradeStatus,
} from 'invity-api';
import { AnyAction, Dispatch } from 'redux';

Expand Down Expand Up @@ -100,8 +97,6 @@ export interface TradingGetTypedTradeProps {
transactionId: string | undefined;
}

export type TradingTradeStatusType = BuyTradeStatus | SellTradeStatus | ExchangeTradeStatus;

export interface TradingGetDetailDataProps {
trading: State;
tradeType: TradeType;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { TradingTradeType } from '@suite-common/trading';
import type { TradingTradeType, TradingUtilsProvidersProps } from '@suite-common/trading';
import { Row, Spinner, Card, Paragraph } 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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { spacings } from '@trezor/theme';
import { Row, Card, Column, Spinner, Paragraph } from '@trezor/components';
import type { TradingTradeType } from '@suite-common/trading';
import type { TradingTradeType, TradingUtilsProvidersProps } from '@suite-common/trading';

import { Translation } from 'src/components/suite';
import { TradingUtilsProvidersProps } from 'src/types/trading/trading';
import { TradingExchangeFormContextProps } from 'src/types/trading/tradingForm';
import {
FORM_EXCHANGE_CEX,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import styled from 'styled-components';

import { Badge, Radio, Tooltip, Row, Text, useElevation } from '@trezor/components';
import { borders, spacings, spacingsPx, mapElevationToBackground, Elevation } from '@trezor/theme';
import type { TradingUtilsProvidersProps } from '@suite-common/trading';

import { TradingUtilsProvidersProps } from 'src/types/trading/trading';
import { Translation } from 'src/components/suite';
import { ExchangeType } from 'src/types/trading/tradingForm';
import { FORM_EXCHANGE_CEX, FORM_EXCHANGE_DEX } from 'src/constants/wallet/trading/form';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import styled from 'styled-components';

import { spacings } from '@trezor/theme';
import { Row } from '@trezor/components';
import { invityAPI } from '@suite-common/trading';
import { invityAPI, type TradingUtilsProvidersProps } from '@suite-common/trading';

import { Translation } from 'src/components/suite';
import { TradingUtilsProvidersProps } from 'src/types/trading/trading';

const Icon = styled.img`
flex: none;
Expand Down
11 changes: 11 additions & 0 deletions suite-common/trading/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import type {
BuyCryptoPaymentMethod,
BuyTrade,
BuyTradeStatus,
ExchangeTrade,
ExchangeTradeStatus,
SellCryptoPaymentMethod,
SellFiatTrade,
SellTradeStatus,
WatchBuyTradeResponse,
WatchExchangeTradeResponse,
WatchSellTradeResponse,
Expand All @@ -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;
};
};

0 comments on commit 6ffff75

Please sign in to comment.