Skip to content

Commit

Permalink
refactor(trading): delete dead code of cached account
Browse files Browse the repository at this point in the history
  • Loading branch information
adderpositive authored and tomasklim committed Feb 3, 2025
1 parent f154f61 commit c8f5f48
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ export const SAVE_QUOTE = '@trading-buy/save_buy_quote';
export const CLEAR_QUOTES = '@trading-buy/clear_buy_quotes';
export const VERIFY_ADDRESS = '@trading-buy/verify_address';
export const SAVE_TRANSACTION_ID = '@trading-buy/save_transaction_id';
export const SAVE_CACHED_ACCOUNT_INFO = '@trading-buy/save_cached_account_info';
export const DISPOSE = '@trading-buy/dispose';
20 changes: 0 additions & 20 deletions packages/suite/src/actions/wallet/tradingBuyActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ export type TradingBuyAction =
| { type: typeof TRADING_BUY.SAVE_TRANSACTION_DETAIL_ID; transactionId: string }
| { type: typeof TRADING_BUY.SAVE_QUOTE_REQUEST; request: BuyTradeQuoteRequest }
| { type: typeof TRADING_BUY.VERIFY_ADDRESS; addressVerified: string | undefined }
| {
type: typeof TRADING_BUY.SAVE_CACHED_ACCOUNT_INFO;
symbol: Account['symbol'];
index: Account['index'];
accountType: Account['accountType'];
shouldSubmit?: boolean;
}
| {
type: typeof TRADING_BUY.SAVE_QUOTES;
quotes: BuyTrade[];
Expand Down Expand Up @@ -161,19 +154,6 @@ export const saveTransactionDetailId = (transactionId: string): TradingBuyAction
transactionId,
});

export const saveCachedAccountInfo = (
symbol: Account['symbol'],
index: number,
accountType: Account['accountType'],
shouldSubmit = false,
): TradingBuyAction => ({
type: TRADING_BUY.SAVE_CACHED_ACCOUNT_INFO,
symbol,
index,
accountType,
shouldSubmit,
});

export const saveQuotes = (quotes: BuyTrade[]): TradingBuyAction => ({
type: TRADING_BUY.SAVE_QUOTES,
quotes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,6 @@ export const useTradingBuyForm = ({
const goToOffers = async () => {
await handleChange();

dispatch(
tradingBuyActions.saveCachedAccountInfo(
account.symbol,
account.index,
account.accountType,
),
);
navigateToBuyOffers();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,22 +244,6 @@ describe('settings reducer', () => {
).toEqual(initialState);
});

it('TRADING_BUY.SAVE_CACHED_ACCOUNT_INFO', () => {
const cachedAccountInfo = {
symbol: 'btc',
index: 1,
accountType: 'segwit',
shouldSubmit: true,
};

expect(
tradingReducer(undefined, {
type: TRADING_BUY.SAVE_CACHED_ACCOUNT_INFO,
...cachedAccountInfo,
} as any),
).toEqual({ ...initialState, buy: { ...initialState.buy, cachedAccountInfo } });
});

it('TRADING_EXCHANGE.SAVE_EXCHANGE_INFO', () => {
const exchangeInfo: ExchangeInfo = {
providerInfos: {},
Expand Down
22 changes: 1 addition & 21 deletions packages/suite/src/reducers/wallet/tradingReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import type { ExchangeInfo } from 'src/actions/wallet/tradingExchangeActions';
import type { SellInfo } from 'src/actions/wallet/tradingSellActions';
import type { AppState, Action as SuiteAction } from 'src/types/suite';
import { TradingPaymentMethodListProps } from 'src/types/trading/trading';
import type { Account, WalletAction } from 'src/types/wallet';
import type { WalletAction } from 'src/types/wallet';
import type { Trade } from 'src/types/wallet/tradingCommonTypes';

export interface ComposedTransactionInfo {
Expand All @@ -55,12 +55,6 @@ interface Buy extends TradingTradeCommonProps {
quotesRequest?: BuyTradeQuoteRequest;
quotes: BuyTrade[] | undefined;
selectedQuote: BuyTrade | undefined;
cachedAccountInfo: {
accountType?: Account['accountType'];
index?: Account['index'];
symbol?: Account['symbol'];
shouldSubmit?: boolean;
};
addressVerified: string | undefined;
}

Expand Down Expand Up @@ -113,12 +107,6 @@ export const initialState: State = {
buyInfo: undefined,
quotesRequest: undefined,
selectedQuote: undefined,
cachedAccountInfo: {
accountType: undefined,
index: undefined,
symbol: undefined,
shouldSubmit: false,
},
quotes: [],
addressVerified: undefined,
},
Expand Down Expand Up @@ -191,14 +179,6 @@ export const tradingReducer = (
case TRADING_BUY.VERIFY_ADDRESS:
draft.buy.addressVerified = action.addressVerified;
break;
case TRADING_BUY.SAVE_CACHED_ACCOUNT_INFO:
draft.buy.cachedAccountInfo = {
symbol: action.symbol,
index: action.index,
accountType: action.accountType,
shouldSubmit: action.shouldSubmit,
};
break;
case TRADING_BUY.DISPOSE:
draft.buy.addressVerified = undefined;
break;
Expand Down

0 comments on commit c8f5f48

Please sign in to comment.