From e238cbc568c2ab3461f2596ae2cf9e0a78274679 Mon Sep 17 00:00:00 2001 From: Niranjana Binoy <43930900+NiranjanaBinoy@users.noreply.github.com> Date: Wed, 29 Sep 2021 14:53:56 -0400 Subject: [PATCH] Turning OFF token detection for test nets (#12232) --- app/scripts/controllers/detect-tokens.js | 9 ++++++++- app/scripts/controllers/detect-tokens.test.js | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/scripts/controllers/detect-tokens.js b/app/scripts/controllers/detect-tokens.js index 246114657..ea647b59f 100644 --- a/app/scripts/controllers/detect-tokens.js +++ b/app/scripts/controllers/detect-tokens.js @@ -4,6 +4,7 @@ import SINGLE_CALL_BALANCES_ABI from 'single-call-balance-checker-abi'; import { SINGLE_CALL_BALANCES_ADDRESS } from '../constants/contracts'; import { MINUTE } from '../../../shared/constants/time'; import { isEqualCaseInsensitive } from '../../../ui/helpers/utils/util'; +import { MAINNET_CHAIN_ID } from '../../../shared/constants/network'; // By default, poll every 3 minutes const DEFAULT_INTERVAL = MINUTE * 3; @@ -79,7 +80,13 @@ export default class DetectTokensController { } const { tokenList } = this._tokenList.state; - if (Object.keys(tokenList).length === 0) { + // since the token detection is currently enabled only on Mainnet + // we can use the chainId check to ensure token detection is not triggered for any other network + // but once the balance check contract for other networks are deploayed and ready to use, we need to update this check. + if ( + this._network.store.getState().provider.chainId !== MAINNET_CHAIN_ID || + Object.keys(tokenList).length === 0 + ) { return; } diff --git a/app/scripts/controllers/detect-tokens.test.js b/app/scripts/controllers/detect-tokens.test.js index 4a739aff1..4fd5605b0 100644 --- a/app/scripts/controllers/detect-tokens.test.js +++ b/app/scripts/controllers/detect-tokens.test.js @@ -42,6 +42,7 @@ describe('DetectTokensController', function () { '0x7e57e2', '0xbc86727e770de68b1060c91f6bb6945c73e10388', ]); + preferences.setUseTokenDetection(true); sandbox .stub(network, 'getLatestBlock') .callsFake(() => Promise.resolve({}));