Skip to content

Commit

Permalink
refactor: type imports
Browse files Browse the repository at this point in the history
  • Loading branch information
micaelae committed Dec 17, 2024
1 parent 49f5a93 commit 3d1be62
Show file tree
Hide file tree
Showing 24 changed files with 51 additions and 45 deletions.
2 changes: 1 addition & 1 deletion app/scripts/controllers/bridge-status/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
StatusRequestWithSrcTxHash,
StatusRequestDto,
} from '../../../../shared/types/bridge-status';
import { Quote } from '../../../../shared/types/bridge';
import type { Quote } from '../../../../shared/types/bridge';
import { validateResponse, validators } from './validators';

const CLIENT_ID_HEADER = { 'X-Client-Id': BRIDGE_CLIENT_ID };
Expand Down
5 changes: 4 additions & 1 deletion app/scripts/controllers/bridge/bridge-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import * as balanceUtils from '../../../../shared/modules/bridge-utils/balance';
import mockBridgeQuotesErc20Native from '../../../../test/data/bridge/mock-quotes-erc20-native.json';
import mockBridgeQuotesNativeErc20 from '../../../../test/data/bridge/mock-quotes-native-erc20.json';
import mockBridgeQuotesNativeErc20Eth from '../../../../test/data/bridge/mock-quotes-native-erc20-eth.json';
import { QuoteResponse, RequestStatus } from '../../../../shared/types/bridge';
import {
type QuoteResponse,
RequestStatus,
} from '../../../../shared/types/bridge';
import { decimalToHex } from '../../../../shared/modules/conversion.utils';
import BridgeController from './bridge-controller';
import { BridgeControllerMessenger } from './types';
Expand Down
8 changes: 4 additions & 4 deletions app/scripts/controllers/bridge/bridge-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import {
sumHexes,
} from '../../../../shared/modules/conversion.utils';
import {
L1GasFees,
QuoteRequest,
QuoteResponse,
TxData,
type L1GasFees,
type QuoteRequest,
type QuoteResponse,
type TxData,
BridgeFeatureFlagsKey,
RequestStatus,
} from '../../../../shared/types/bridge';
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/bridge/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../../../../shared/constants/bridge';
import { CHAIN_IDS } from '../../../../shared/constants/network';
import { BridgeFeatureFlagsKey } from '../../../../shared/types/bridge';
import { BridgeControllerState } from './types';
import type { BridgeControllerState } from './types';

export const BRIDGE_CONTROLLER_NAME = 'BridgeController';
export const DEFAULT_BRIDGE_CONTROLLER_STATE: BridgeControllerState = {
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/bridge/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
NetworkControllerGetSelectedNetworkClientAction,
} from '@metamask/network-controller';
import { SwapsTokenObject } from '../../../../shared/constants/swaps';
import {
import type {
BridgeBackgroundAction,
BridgeFeatureFlags,
BridgeUserAction,
Expand Down
2 changes: 1 addition & 1 deletion shared/modules/bridge-utils/quote.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QuoteRequest } from '../../types/bridge';
import type { QuoteRequest } from '../../types/bridge';

export const isValidQuoteRequest = (
partialRequest: Partial<QuoteRequest>,
Expand Down
2 changes: 1 addition & 1 deletion shared/types/bridge-status.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TransactionMeta } from '@metamask/transaction-controller';
import { ChainId, Quote, QuoteMetadata, QuoteResponse } from './bridge';
import type { ChainId, Quote, QuoteMetadata, QuoteResponse } from './bridge';

// All fields need to be types not interfaces, same with their children fields
// o/w you get a type error
Expand Down
4 changes: 2 additions & 2 deletions shared/types/bridge.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Hex } from '@metamask/utils';
import { BigNumber } from 'bignumber.js';
import type { Hex } from '@metamask/utils';
import type { BigNumber } from 'bignumber.js';
import type { AssetType } from '../constants/transaction';

export type ChainConfiguration = {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/bridge/bridge-test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { SMART_CONTRACTS } from '../../seeder/smart-contracts';
import { CHAIN_IDS } from '../../../../shared/constants/network';
import { Driver } from '../../webdriver/driver';
import { isManifestV3 } from '../../../../shared/modules/mv3.utils';
import { FeatureFlagResponse } from '../../../../shared/types/bridge';
import type { FeatureFlagResponse } from '../../../../shared/types/bridge';
import {
DEFAULT_FEATURE_FLAGS_RESPONSE,
ETH_CONVERSION_RATE_USD,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/bridge/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FeatureFlagResponse } from '../../../../shared/types/bridge';
import type { FeatureFlagResponse } from '../../../../shared/types/bridge';

export const DEFAULT_FEATURE_FLAGS_RESPONSE: FeatureFlagResponse = {
'extension-config': {
Expand Down
4 changes: 2 additions & 2 deletions ui/ducks/bridge/actions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Hex } from '@metamask/utils';
import type { Hex } from '@metamask/utils';
import {
BridgeBackgroundAction,
BridgeUserAction,
QuoteRequest,
} from '../../../shared/types/bridge';
import { forceUpdateMetamaskState } from '../../store/actions';
import { submitRequestToBackground } from '../../store/background-connection';
import { MetaMaskReduxDispatch } from '../../store/store';
import type { MetaMaskReduxDispatch } from '../../store/store';
import {
bridgeSlice,
setDestTokenExchangeRates,
Expand Down
6 changes: 3 additions & 3 deletions ui/ducks/bridge/bridge.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
import { Hex } from '@metamask/utils';
import {
BridgeToken,
QuoteMetadata,
QuoteResponse,
type BridgeToken,
type QuoteMetadata,
type QuoteResponse,
SortOrder,
} from '../../../shared/types/bridge';
import { BRIDGE_DEFAULT_SLIPPAGE } from '../../../shared/constants/bridge';
Expand Down
4 changes: 2 additions & 2 deletions ui/ducks/bridge/selectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { mockNetworkState } from '../../../test/stub/networks';
import mockErc20Erc20Quotes from '../../../test/data/bridge/mock-quotes-erc20-erc20.json';
import mockBridgeQuotesNativeErc20 from '../../../test/data/bridge/mock-quotes-native-erc20.json';
import {
QuoteMetadata,
QuoteResponse,
type QuoteMetadata,
type QuoteResponse,
SortOrder,
} from '../../../shared/types/bridge';
import {
Expand Down
16 changes: 8 additions & 8 deletions ui/ducks/bridge/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
import type {
AddNetworkFields,
NetworkConfiguration,
NetworkState,
} from '@metamask/network-controller';
import { orderBy, uniqBy } from 'lodash';
import { createSelector } from 'reselect';
import { GasFeeEstimates } from '@metamask/gas-fee-controller';
import type { GasFeeEstimates } from '@metamask/gas-fee-controller';
import { BigNumber } from 'bignumber.js';
import { calcTokenAmount } from '@metamask/notification-services-controller/push-services';
import {
Expand All @@ -22,7 +22,7 @@ import {
} from '../../../shared/constants/bridge';
// TODO: Remove restricted import
// eslint-disable-next-line import/no-restricted-paths
import { BridgeControllerState } from '../../../app/scripts/controllers/bridge/types';
import type { 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 All @@ -31,10 +31,10 @@ import {
} from '../../../shared/modules/selectors/networks';
import { getConversionRate, getGasFeeEstimates } from '../metamask/metamask';
import {
L1GasFees,
BridgeToken,
QuoteMetadata,
QuoteResponse,
type L1GasFees,
type BridgeToken,
type QuoteMetadata,
type QuoteResponse,
SortOrder,
BridgeFeatureFlagsKey,
RequestStatus,
Expand All @@ -60,7 +60,7 @@ import {
exchangeRateFromMarketData,
tokenPriceInNativeAsset,
} from './utils';
import { BridgeState } from './bridge';
import type { BridgeState } from './bridge';

type BridgeAppState = {
metamask: { bridgeState: BridgeControllerState } & NetworkState & {
Expand Down
6 changes: 3 additions & 3 deletions ui/ducks/bridge/utils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Hex } from '@metamask/utils';
import type { Hex } from '@metamask/utils';
import { BigNumber } from 'bignumber.js';
import { getAddress } from 'ethers/lib/utils';
import { ContractMarketData } from '@metamask/assets-controllers';
import type { ContractMarketData } from '@metamask/assets-controllers';
import {
AddNetworkFields,
NetworkConfiguration,
} from '@metamask/network-controller';
import { decGWEIToHexWEI } from '../../../shared/modules/conversion.utils';
import { Numeric } from '../../../shared/modules/Numeric';
import { TxData } from '../../../shared/types/bridge';
import type { TxData } from '../../../shared/types/bridge';
import { getTransaction1559GasFeeEstimates } from '../../pages/swaps/swaps.util';
import { fetchTokenExchangeRates as fetchTokenExchangeRatesUtil } from '../../helpers/utils/util';

Expand Down
4 changes: 2 additions & 2 deletions ui/pages/bridge/hooks/useAddToken.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useDispatch, useSelector } from 'react-redux';
import { NetworkConfiguration } from '@metamask/network-controller';
import { QuoteResponse } from '../../../../shared/types/bridge';
import type { NetworkConfiguration } from '@metamask/network-controller';
import type { QuoteResponse } from '../../../../shared/types/bridge';
import { FEATURED_RPCS } from '../../../../shared/constants/network';
import { addToken, addNetwork } from '../../../store/actions';
import {
Expand Down
6 changes: 3 additions & 3 deletions ui/pages/bridge/hooks/useHandleApprovalTx.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { TransactionType } from '@metamask/transaction-controller';
import { Hex } from '@metamask/utils';
import type { Hex } from '@metamask/utils';
import { BigNumber } from 'bignumber.js';
import {
TxData,
QuoteResponse,
type TxData,
type QuoteResponse,
FeeType,
} from '../../../../shared/types/bridge';
import {
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/bridge/hooks/useHandleBridgeTx.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BigNumber } from 'bignumber.js';
import { TransactionType } from '@metamask/transaction-controller';
import { Numeric } from '../../../../shared/modules/Numeric';
import { FeeType, QuoteResponse } from '../../../../shared/types/bridge';
import { FeeType, type QuoteResponse } from '../../../../shared/types/bridge';
import useHandleTx from './useHandleTx';

export default function useHandleBridgeTx() {
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/bridge/hooks/useHandleTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '../../../ducks/bridge/utils';
import { getGasFeeEstimates } from '../../../ducks/metamask/metamask';
import { checkNetworkAndAccountSupports1559 } from '../../../selectors';
import { ChainId } from '../../../../shared/types/bridge';
import type { ChainId } from '../../../../shared/types/bridge';
import { decimalToPrefixedHex } from '../../../../shared/modules/conversion.utils';
import { getIsSmartTransaction } from '../../../../shared/modules/selectors';

Expand Down
5 changes: 4 additions & 1 deletion ui/pages/bridge/hooks/useSubmitBridgeTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { zeroAddress } from 'ethereumjs-util';
import { useHistory } from 'react-router-dom';
import { TransactionMeta } from '@metamask/transaction-controller';
import { createProjectLogger, Hex } from '@metamask/utils';
import { QuoteMetadata, QuoteResponse } from '../../../../shared/types/bridge';
import type {
QuoteMetadata,
QuoteResponse,
} from '../../../../shared/types/bridge';
import {
AWAITING_SIGNATURES_ROUTE,
CROSS_CHAIN_SWAP_ROUTE,
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/bridge/prepare/bridge-input-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
getValidationErrors,
} from '../../../ducks/bridge/selectors';
import { shortenString } from '../../../helpers/utils/util';
import { BridgeToken } from '../../../../shared/types/bridge';
import type { BridgeToken } from '../../../../shared/types/bridge';
import { useCopyToClipboard } from '../../../hooks/useCopyToClipboard';
import { MINUTE } from '../../../../shared/constants/time';
import { BridgeAssetPickerButton } from './components/bridge-asset-picker-button';
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/bridge/prepare/prepare-bridge-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import { SWAPS_CHAINID_DEFAULT_TOKEN_MAP } from '../../../../shared/constants/sw
import { useTokensWithFiltering } from '../../../hooks/bridge/useTokensWithFiltering';
import { setActiveNetwork } from '../../../store/actions';
import { hexToDecimal } from '../../../../shared/modules/conversion.utils';
import { QuoteRequest } from '../../../../shared/types/bridge';
import type { QuoteRequest } from '../../../../shared/types/bridge';
import { calcTokenValue } from '../../../../shared/lib/swaps-utils';
import { BridgeQuoteCard } from '../quotes/bridge-quote-card';
import { formatTokenAmount } from '../utils/quote';
Expand Down
4 changes: 2 additions & 2 deletions ui/pages/bridge/quotes/bridge-quotes-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import { useI18nContext } from '../../../hooks/useI18nContext';
import { getCurrentCurrency, getLocale } from '../../../selectors';
import { setSelectedQuote, setSortOrder } from '../../../ducks/bridge/actions';
import {
QuoteMetadata,
QuoteResponse,
type QuoteMetadata,
type QuoteResponse,
SortOrder,
} from '../../../../shared/types/bridge';
import {
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/bridge/utils/quote.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { zeroAddress } from 'ethereumjs-util';
import { BigNumber } from 'bignumber.js';
import { calcTokenAmount } from '../../../../shared/lib/transactions-controller-utils';
import {
import type {
QuoteResponse,
Quote,
L1GasFees,
Expand Down

0 comments on commit 3d1be62

Please sign in to comment.