@@ -17,11 +17,7 @@ import {
1717 type GasFeeEstimates ,
1818} from '@metamask/gas-fee-controller' ;
1919import type { NetworkClientId } from '@metamask/network-controller' ;
20- import {
21- getKnownPropertyNames ,
22- isErrorWithMessage ,
23- type Hex ,
24- } from '@metamask/utils' ;
20+ import { isErrorWithMessage , type Hex } from '@metamask/utils' ;
2521import { Mutex } from 'async-mutex' ;
2622import { BigNumber } from 'bignumber.js' ;
2723import abiERC20 from 'human-standard-token-abi' ;
@@ -1260,22 +1256,25 @@ export default class SwapsController extends BaseController<
12601256 this . #handle && clearTimeout ( this . #handle) ;
12611257 this . #pollCount = Number ( this . #pollCountLimit) + 1 ;
12621258 this . update ( ( _state ) => {
1263- const currentState = { ..._state } ;
1264- const defaultState = getDefaultSwapsControllerState ( ) ;
1265- getKnownPropertyNames ( defaultState ) . forEach ( ( key ) => {
1266- const typedKey = key ;
1267- ( _state as any ) [ typedKey ] = defaultState [ typedKey ] ;
1268- } ) ;
12691259 _state . isInPolling = false ;
1270- _state . tokensLastFetched = currentState . tokensLastFetched ;
1271- _state . aggregatorMetadataLastFetched =
1272- currentState . aggregatorMetadataLastFetched ;
1273- _state . tokens = currentState . tokens ;
1274- _state . topAssets = currentState . topAssets ;
1275- _state . aggregatorMetadata = currentState . aggregatorMetadata ;
1276- _state . chainCache = currentState . chainCache ;
12771260 _state . error . key = error . key ;
12781261 _state . error . description = error . description ;
1262+
1263+ // Partially reset state
1264+ const defaultState = getDefaultSwapsControllerState ( ) ;
1265+ _state . quotes = defaultState . quotes ;
1266+ _state . quoteValues = defaultState . quoteValues ;
1267+ _state . fetchParams = defaultState . fetchParams ;
1268+ _state . fetchParamsMetaData = defaultState . fetchParamsMetaData ;
1269+ _state . topAggSavings = defaultState . topAggSavings ;
1270+ _state . approvalTransaction = defaultState . approvalTransaction ;
1271+ _state . quotesLastFetched = defaultState . quotesLastFetched ;
1272+ _state . topAggId = defaultState . topAggId ;
1273+ _state . isInPolling = defaultState . isInPolling ;
1274+ _state . pollingCyclesLeft = defaultState . pollingCyclesLeft ;
1275+ _state . quoteRefreshSeconds = defaultState . quoteRefreshSeconds ;
1276+ _state . usedGasEstimate = defaultState . usedGasEstimate ;
1277+ _state . usedCustomGas = defaultState . usedCustomGas ;
12791278 } ) ;
12801279 }
12811280
0 commit comments