Turning OFF token detection for test nets (#12232)

feature/default_network_editable
Niranjana Binoy 3 years ago committed by ryanml
parent 47dbb22024
commit eaf67a20fa
  1. 9
      app/scripts/controllers/detect-tokens.js
  2. 1
      app/scripts/controllers/detect-tokens.test.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 { SINGLE_CALL_BALANCES_ADDRESS } from '../constants/contracts';
import { MINUTE } from '../../../shared/constants/time'; import { MINUTE } from '../../../shared/constants/time';
import { isEqualCaseInsensitive } from '../../../ui/helpers/utils/util'; import { isEqualCaseInsensitive } from '../../../ui/helpers/utils/util';
import { MAINNET_CHAIN_ID } from '../../../shared/constants/network';
// By default, poll every 3 minutes // By default, poll every 3 minutes
const DEFAULT_INTERVAL = MINUTE * 3; const DEFAULT_INTERVAL = MINUTE * 3;
@ -79,7 +80,13 @@ export default class DetectTokensController {
} }
const { tokenList } = this._tokenList.state; 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; return;
} }

@ -42,6 +42,7 @@ describe('DetectTokensController', function () {
'0x7e57e2', '0x7e57e2',
'0xbc86727e770de68b1060c91f6bb6945c73e10388', '0xbc86727e770de68b1060c91f6bb6945c73e10388',
]); ]);
preferences.setUseTokenDetection(true);
sandbox sandbox
.stub(network, 'getLatestBlock') .stub(network, 'getLatestBlock')
.callsFake(() => Promise.resolve({})); .callsFake(() => Promise.resolve({}));

Loading…
Cancel
Save