Skip to content

Commit

Permalink
fix: apply review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptodev-2s committed Oct 31, 2024
1 parent 9dfe213 commit d0b8a4e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/assets-controllers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Add `resetState` method to `NftController`, `TokensController`, `TokenBalancesController` and `TokenRatesController` to reset the controller's state back to their initial state ([#4880](https://github.com/MetaMask/core/pull/4880))
- Add `resetState` method to `NftController`, `TokensController`, `TokenBalancesController` and `TokenRatesController` to reset the controller's state back to their default state ([#4880](https://github.com/MetaMask/core/pull/4880))

## [41.0.0]

Expand Down
6 changes: 2 additions & 4 deletions packages/assets-controllers/src/NftController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2065,10 +2065,8 @@ export class NftController extends BaseController<
* Reset the controller state to the initial state.
*/
resetState() {
this.update((state) => {
state.allNftContracts = {};
state.allNfts = {};
state.ignoredNfts = [];
this.update(() => {
return getDefaultNftControllerState();
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/assets-controllers/src/TokenBalancesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ export class TokenBalancesController extends BaseController<
* Reset the controller state to the initial state.
*/
resetState() {
this.update((state) => {
state.contractBalances = {};
this.update(() => {
return getDefaultTokenBalancesState();
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/assets-controllers/src/TokenRatesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,8 @@ export class TokenRatesController extends StaticIntervalPollingController<TokenR
* Reset the controller state to the initial state.
*/
resetState() {
this.update((state) => {
state.marketData = {};
this.update(() => {
return getDefaultTokenRatesControllerState();
});
}
}
Expand Down
9 changes: 2 additions & 7 deletions packages/assets-controllers/src/TokensController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1082,13 +1082,8 @@ export class TokensController extends BaseController<
* Reset the controller state to the initial state.
*/
resetState() {
this.update((state) => {
state.tokens = [];
state.ignoredTokens = [];
state.detectedTokens = [];
state.allTokens = {};
state.allIgnoredTokens = {};
state.allDetectedTokens = {};
this.update(() => {
return getDefaultTokensState();
});
}
}
Expand Down

0 comments on commit d0b8a4e

Please sign in to comment.