Skip to content

Commit

Permalink
refactor: move BackgroundAction types to shared dir
Browse files Browse the repository at this point in the history
  • Loading branch information
micaelae committed Dec 16, 2024
1 parent 2590085 commit 2047be9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 29 deletions.
13 changes: 2 additions & 11 deletions app/scripts/controllers/bridge/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import {
} from '@metamask/network-controller';
import { SwapsTokenObject } from '../../../../shared/constants/swaps';
import {
BridgeBackgroundAction,
BridgeFeatureFlags,
BridgeUserAction,
L1GasFees,
QuoteRequest,
QuoteResponse,
Expand All @@ -35,17 +37,6 @@ export type BridgeControllerState = {
quotesRefreshCount: number;
};

export enum BridgeUserAction {
SELECT_SRC_NETWORK = 'selectSrcNetwork',
SELECT_DEST_NETWORK = 'selectDestNetwork',
UPDATE_QUOTE_PARAMS = 'updateBridgeQuoteRequestParams',
}
export enum BridgeBackgroundAction {
SET_FEATURE_FLAGS = 'setBridgeFeatureFlags',
RESET_STATE = 'resetState',
GET_BRIDGE_ERC20_ALLOWANCE = 'getBridgeERC20Allowance',
}

type BridgeControllerAction<FunctionName extends keyof BridgeController> = {
type: `${typeof BRIDGE_CONTROLLER_NAME}:${FunctionName}`;
handler: BridgeController[FunctionName];
Expand Down
8 changes: 4 additions & 4 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ import { isSnapId } from '../../ui/helpers/utils/snaps';
import { BridgeStatusAction } from '../../shared/types/bridge-status';
import { ENVIRONMENT } from '../../development/build/constants';
import fetchWithCache from '../../shared/lib/fetch-with-cache';
import {
BridgeUserAction,
BridgeBackgroundAction,
} from '../../shared/types/bridge';
import { BalancesController as MultichainBalancesController } from './lib/accounts/BalancesController';
import {
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
Expand Down Expand Up @@ -365,10 +369,6 @@ import { updateSecurityAlertResponse } from './lib/ppom/ppom-util';
import createEvmMethodsToNonEvmAccountReqFilterMiddleware from './lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware';
import { isEthAddress } from './lib/multichain/address';
import { decodeTransactionData } from './lib/transaction/decode/util';
import {
BridgeUserAction,
BridgeBackgroundAction,
} from './controllers/bridge/types';
import BridgeController from './controllers/bridge/bridge-controller';
import { BRIDGE_CONTROLLER_NAME } from './controllers/bridge/constants';
import {
Expand Down
10 changes: 10 additions & 0 deletions shared/types/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,13 @@ export enum RequestStatus {
FETCHED,
ERROR,
}
export enum BridgeUserAction {
SELECT_SRC_NETWORK = 'selectSrcNetwork',
SELECT_DEST_NETWORK = 'selectDestNetwork',
UPDATE_QUOTE_PARAMS = 'updateBridgeQuoteRequestParams',
}
export enum BridgeBackgroundAction {
SET_FEATURE_FLAGS = 'setBridgeFeatureFlags',
RESET_STATE = 'resetState',
GET_BRIDGE_ERC20_ALLOWANCE = 'getBridgeERC20Allowance',
}
8 changes: 2 additions & 6 deletions ui/ducks/bridge/actions.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// TODO: Remove restricted import
// eslint-disable-next-line import/no-restricted-paths
import { Hex } from '@metamask/utils';
import {
BridgeBackgroundAction,
BridgeUserAction,
// TODO: Remove restricted import
// eslint-disable-next-line import/no-restricted-paths
} from '../../../app/scripts/controllers/bridge/types';
QuoteRequest,
} from '../../../shared/types/bridge';
import { forceUpdateMetamaskState } from '../../store/actions';
import { submitRequestToBackground } from '../../store/background-connection';
import { QuoteRequest } from '../../../shared/types/bridge';
import { MetaMaskReduxDispatch } from '../../store/store';
import {
bridgeSlice,
Expand Down
4 changes: 1 addition & 3 deletions ui/ducks/bridge/bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import { setBackgroundConnection } from '../../store/background-connection';
import {
BridgeBackgroundAction,
BridgeUserAction,
// TODO: Remove restricted import
// eslint-disable-next-line import/no-restricted-paths
} from '../../../app/scripts/controllers/bridge/types';
} from '../../../shared/types/bridge';
import * as util from '../../helpers/utils/util';
import { BRIDGE_DEFAULT_SLIPPAGE } from '../../../shared/constants/bridge';
import bridgeReducer from './bridge';
Expand Down
8 changes: 3 additions & 5 deletions ui/ducks/bridge/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ import {
BRIDGE_PREFERRED_GAS_ESTIMATE,
BRIDGE_QUOTE_MAX_RETURN_DIFFERENCE_PERCENTAGE,
} from '../../../shared/constants/bridge';
import {
BridgeControllerState,
// TODO: Remove restricted import
// eslint-disable-next-line import/no-restricted-paths
} from '../../../app/scripts/controllers/bridge/types';
// TODO: Remove restricted import
// eslint-disable-next-line import/no-restricted-paths
import { BridgeControllerState } from '../../../app/scripts/controllers/bridge/types';
import { createDeepEqualSelector } from '../../../shared/modules/selectors/util';
import { SWAPS_CHAINID_DEFAULT_TOKEN_MAP } from '../../../shared/constants/swaps';
import {
Expand Down

0 comments on commit 2047be9

Please sign in to comment.