Skip to content

Commit

Permalink
fix: token detection during account change (#4133)
Browse files Browse the repository at this point in the history
## Explanation

During account change, the token detection trigger was guarded by the
`useTokenDetection` setting. But on mainnet, detection should run
against the static token list even if the setting is disabled. So remove
the guard.

## References

MetaMask/metamask-extension#23798

## Changelog

### `@metamask/assets-controllers`

- **FIXED**: Token detection during account change 

## Checklist

- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
  • Loading branch information
bergeron authored Apr 3, 2024
1 parent bb81647 commit 8769bd8
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions packages/assets-controllers/src/TokenDetectionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,7 @@ export class TokenDetectionController extends StaticIntervalPollingController<
this.#selectedAddress = newSelectedAddress;
this.#isDetectionEnabledFromPreferences = useTokenDetection;

if (
useTokenDetection &&
(isSelectedAddressChanged || isDetectionChangedFromPreferences)
) {
if (isSelectedAddressChanged || isDetectionChangedFromPreferences) {
await this.#restartTokenDetection({
selectedAddress: this.#selectedAddress,
});
Expand All @@ -302,10 +299,7 @@ export class TokenDetectionController extends StaticIntervalPollingController<
async ({ address: newSelectedAddress }) => {
const isSelectedAddressChanged =
this.#selectedAddress !== newSelectedAddress;
if (
isSelectedAddressChanged &&
this.#isDetectionEnabledFromPreferences
) {
if (isSelectedAddressChanged) {
this.#selectedAddress = newSelectedAddress;
await this.#restartTokenDetection({
selectedAddress: this.#selectedAddress,
Expand Down

0 comments on commit 8769bd8

Please sign in to comment.