@@ -20,17 +20,6 @@ import {
2020import type { IPerpsProvider } from './types' ;
2121import { HyperLiquidProvider } from './providers/HyperLiquidProvider' ;
2222import { createMockHyperLiquidProvider } from '../__mocks__/providerMocks' ;
23- import Logger from '../../../../util/Logger' ;
24- import { FeatureFlagConfigurationService } from './services/FeatureFlagConfigurationService' ;
25- import { DepositService } from './services/DepositService' ;
26- import { MarketDataService } from './services/MarketDataService' ;
27- import { TradingService } from './services/TradingService' ;
28- import { AccountService } from './services/AccountService' ;
29- import { DataLakeService } from './services/DataLakeService' ;
30- import {
31- ARBITRUM_MAINNET_CHAIN_ID_HEX ,
32- USDC_ARBITRUM_MAINNET_ADDRESS ,
33- } from '../constants/hyperLiquidConfig' ;
3423import Engine from '../../../../core/Engine' ;
3524
3625jest . mock ( './providers/HyperLiquidProvider' ) ;
@@ -102,6 +91,7 @@ jest.mock('../../../../core/Engine', () => {
10291 getNetworkClientById : jest . fn ( ) . mockReturnValue ( {
10392 configuration : { chainId : '0x1' } ,
10493 } ) ,
94+ findNetworkClientIdByChainId : jest . fn ( ) . mockReturnValue ( 'mainnet' ) ,
10595 } ;
10696
10797 const mockAccountTreeController = {
@@ -116,6 +106,10 @@ jest.mock('../../../../core/Engine', () => {
116106 const mockTransactionController = {
117107 estimateGasFee : jest . fn ( ) ,
118108 estimateGas : jest . fn ( ) ,
109+ addTransaction : jest . fn ( ) . mockResolvedValue ( {
110+ result : Promise . resolve ( '0xmocktxhash' ) ,
111+ transactionMeta : { id : 'mock-tx-id' , hash : '0xmocktxhash' } ,
112+ } ) ,
119113 } ;
120114
121115 const mockAccountTrackerController = {
@@ -286,6 +280,15 @@ jest.mock('./services/FeatureFlagConfigurationService', () => ({
286280 } ,
287281} ) ) ;
288282
283+ // Import mocked modules - these imports get the mocked versions
284+ import Logger from '../../../../util/Logger' ;
285+ import { DepositService } from './services/DepositService' ;
286+ import { MarketDataService } from './services/MarketDataService' ;
287+ import { TradingService } from './services/TradingService' ;
288+ import { AccountService } from './services/AccountService' ;
289+ import { DataLakeService } from './services/DataLakeService' ;
290+ import { FeatureFlagConfigurationService } from './services/FeatureFlagConfigurationService' ;
291+
289292/**
290293 * Testable version of PerpsController that exposes protected methods for testing.
291294 * This follows the pattern used in RewardsController.test.ts
@@ -2348,50 +2351,9 @@ describe('PerpsController', () => {
23482351 origin : 'metamask' ,
23492352 type : 'perpsDeposit' ,
23502353 skipInitialGasEstimate : true ,
2351- gasFeeToken : undefined ,
23522354 } ) ;
23532355 } ) ;
23542356
2355- it ( 'adds gasFeeToken for Arbitrum USDC deposits' , async ( ) => {
2356- markControllerAsInitialized ( ) ;
2357- controller . testSetProviders ( new Map ( [ [ 'hyperliquid' , mockProvider ] ] ) ) ;
2358-
2359- Engine . context . AccountTrackerController . state . accountsByChainId = {
2360- [ ARBITRUM_MAINNET_CHAIN_ID_HEX ] : {
2361- [ mockTransaction . from . toLowerCase ( ) ] : {
2362- balance : '0x0' ,
2363- } ,
2364- } ,
2365- } ;
2366-
2367- jest . spyOn ( DepositService , 'prepareTransaction' ) . mockResolvedValueOnce ( {
2368- transaction : {
2369- ...mockTransaction ,
2370- to : USDC_ARBITRUM_MAINNET_ADDRESS ,
2371- } ,
2372- assetChainId : ARBITRUM_MAINNET_CHAIN_ID_HEX ,
2373- currentDepositId : mockDepositId ,
2374- } ) ;
2375-
2376- await controller . depositWithConfirmation ( '100' ) ;
2377-
2378- expect (
2379- Engine . context . TransactionController . addTransaction ,
2380- ) . toHaveBeenCalledWith (
2381- {
2382- ...mockTransaction ,
2383- to : USDC_ARBITRUM_MAINNET_ADDRESS ,
2384- } ,
2385- {
2386- networkClientId : mockNetworkClientId ,
2387- origin : 'metamask' ,
2388- type : 'perpsDeposit' ,
2389- skipInitialGasEstimate : true ,
2390- gasFeeToken : USDC_ARBITRUM_MAINNET_ADDRESS ,
2391- } ,
2392- ) ;
2393- } ) ;
2394-
23952357 it ( 'throws error when controller not initialized' , async ( ) => {
23962358 controller . testSetInitialized ( false ) ;
23972359
0 commit comments