diff --git a/development/circular-deps.jsonc b/development/circular-deps.jsonc index dcd08ec5b46d..7ea427014b98 100644 --- a/development/circular-deps.jsonc +++ b/development/circular-deps.jsonc @@ -62,9 +62,5 @@ "ui/pages/snap-account-redirect/components/snap-account-redirect-message.tsx", "ui/pages/snap-account-redirect/components/url-display-box.tsx", "ui/pages/snap-account-redirect/snap-account-redirect.tsx" - ], - [ - "ui/pages/swaps/swaps.util.ts", - "ui/store/actions.ts" ] ] diff --git a/ui/pages/swaps/swaps.util.gas.ts b/ui/pages/swaps/swaps.util.gas.ts new file mode 100644 index 000000000000..bc81b547c82b --- /dev/null +++ b/ui/pages/swaps/swaps.util.gas.ts @@ -0,0 +1,15 @@ +import { NetworkClientId } from '@metamask/network-controller'; +import { + GasFeeEstimates, + TransactionParams, +} from '@metamask/transaction-controller'; +import { Hex } from '@metamask/utils'; +import { submitRequestToBackground } from '../../store/background-connection'; + +export function estimateGasFee(request: { + transactionParams: TransactionParams; + chainId?: Hex; + networkClientId?: NetworkClientId; +}): Promise<{ estimates: GasFeeEstimates }> { + return submitRequestToBackground('estimateGasFee', [request]); +} diff --git a/ui/pages/swaps/swaps.util.test.js b/ui/pages/swaps/swaps.util.test.js index d081e8d58ee1..0973577638de 100644 --- a/ui/pages/swaps/swaps.util.test.js +++ b/ui/pages/swaps/swaps.util.test.js @@ -18,13 +18,6 @@ import { LINEA, BASE, } from '../../../shared/constants/swaps'; -import { estimateGasFee } from '../../store/actions'; -import { - TOKENS, - EXPECTED_TOKENS_RESULT, - AGGREGATOR_METADATA, - TOP_ASSETS, -} from './swaps-util-test-constants'; import { fetchTokens, fetchAggregatorMetadata, @@ -39,13 +32,20 @@ import { fetchTopAssetsList, getSwap1559GasFeeEstimates, } from './swaps.util'; +import { estimateGasFee } from './swaps.util.gas'; +import { + TOKENS, + EXPECTED_TOKENS_RESULT, + AGGREGATOR_METADATA, + TOP_ASSETS, +} from './swaps-util-test-constants'; jest.mock('../../../shared/lib/storage-helpers', () => ({ getStorageItem: jest.fn(), setStorageItem: jest.fn(), })); -jest.mock('../../store/actions', () => ({ +jest.mock('./swaps.util.gas', () => ({ estimateGasFee: jest.fn(), })); diff --git a/ui/pages/swaps/swaps.util.ts b/ui/pages/swaps/swaps.util.ts index 7beb613bce58..0ccb2dcc99f7 100644 --- a/ui/pages/swaps/swaps.util.ts +++ b/ui/pages/swaps/swaps.util.ts @@ -50,7 +50,7 @@ import { sumHexes, } from '../../../shared/modules/conversion.utils'; import { EtherDenomination } from '../../../shared/constants/common'; -import { estimateGasFee } from '../../store/actions'; +import { estimateGasFee } from './swaps.util.gas'; const CACHE_REFRESH_FIVE_MINUTES = 300000; const USD_CURRENCY_CODE = 'usd'; diff --git a/ui/store/actions.ts b/ui/store/actions.ts index deb1c10650e2..033cf0185161 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -29,7 +29,6 @@ import { UpdateProposedNamesResult, } from '@metamask/name-controller'; import { - GasFeeEstimates, TransactionMeta, TransactionParams, TransactionType, @@ -4511,14 +4510,6 @@ export function estimateGas(params: TransactionParams): Promise { return submitRequestToBackground('estimateGas', [params]); } -export function estimateGasFee(request: { - transactionParams: TransactionParams; - chainId?: Hex; - networkClientId?: NetworkClientId; -}): Promise<{ estimates: GasFeeEstimates }> { - return submitRequestToBackground('estimateGasFee', [request]); -} - export async function updateTokenType( tokenAddress: string, ): Promise {