Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: exclude goerli from default network state #5094

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1148,14 +1148,7 @@ describe('TokenDetectionController', () => {
await advanceTime({ clock, duration: 1 });

expect(mockTokens).toHaveBeenNthCalledWith(1, {
chainIds: [
'0x1',
'0x5',
'0xaa36a7',
'0xe704',
'0xe705',
'0xe708',
],
chainIds: ['0x1', '0xaa36a7', '0xe705', '0xe708'],
selectedAddress: secondSelectedAccount.address,
});
},
Expand Down Expand Up @@ -2417,14 +2410,14 @@ describe('TokenDetectionController', () => {
mockMultiChainAccountsService();
mockNetworkState({
...getDefaultNetworkControllerState(),
selectedNetworkClientId: NetworkType.goerli,
selectedNetworkClientId: NetworkType.sepolia,
});
triggerPreferencesStateChange({
...getDefaultPreferencesState(),
useTokenDetection: false,
});
await controller.detectTokens({
chainIds: ['0x5'],
chainIds: ['0xaa36a7'],
selectedAddress: selectedAccount.address,
});
expect(callActionSpy).not.toHaveBeenCalledWith(
Expand Down Expand Up @@ -2734,7 +2727,7 @@ describe('TokenDetectionController', () => {
useTokenDetection: false,
});
await controller.detectTokens({
chainIds: ['0x5'],
chainIds: ['0xaa36a7'],
selectedAddress: selectedAccount.address,
});
expect(callActionSpy).not.toHaveBeenCalledWith(
Expand Down
14 changes: 7 additions & 7 deletions packages/assets-controllers/src/TokenListController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -953,16 +953,16 @@ describe('TokenListController', () => {
nock(tokenService.TOKEN_END_POINT_API)
.get(getTokensPath(ChainId.mainnet))
.reply(200, sampleMainnetTokenList)
.get(getTokensPath(ChainId.goerli))
.get(getTokensPath(ChainId.sepolia))
.reply(200, { error: 'ChainId 5 is not supported' })
.get(getTokensPath(toHex(56)))
.reply(200, sampleBinanceTokenList)
.persist();
const selectedCustomNetworkClientId = 'selectedCustomNetworkClientId';
const controllerMessenger = getControllerMessenger();
const getNetworkClientById = buildMockGetNetworkClientById({
[InfuraNetworkType.goerli]: buildInfuraNetworkClientConfiguration(
InfuraNetworkType.goerli,
[InfuraNetworkType.sepolia]: buildInfuraNetworkClientConfiguration(
InfuraNetworkType.sepolia,
),
[selectedCustomNetworkClientId]: buildCustomNetworkClientConfiguration({
chainId: toHex(56),
Expand Down Expand Up @@ -995,7 +995,7 @@ describe('TokenListController', () => {
controllerMessenger.publish(
'NetworkController:stateChange',
{
selectedNetworkClientId: InfuraNetworkType.goerli,
selectedNetworkClientId: InfuraNetworkType.sepolia,
networkConfigurationsByChainId: {},
networksMetadata: {},
// @ts-expect-error This property isn't used and will get removed later.
Expand Down Expand Up @@ -1065,8 +1065,8 @@ describe('TokenListController', () => {
nock(tokenService.TOKEN_END_POINT_API)
.get(getTokensPath(ChainId.mainnet))
.reply(200, sampleMainnetTokenList)
.get(getTokensPath(ChainId.goerli))
.reply(200, { error: 'ChainId 5 is not supported' })
.get(getTokensPath(ChainId.sepolia))
.reply(200, { error: 'ChainId 11155111 is not supported' })
.get(getTokensPath(toHex(56)))
.reply(200, sampleBinanceTokenList)
.persist();
Expand All @@ -1087,7 +1087,7 @@ describe('TokenListController', () => {
);
const messenger = getRestrictedMessenger(controllerMessenger);
const controller = new TokenListController({
chainId: ChainId.goerli,
chainId: ChainId.sepolia,
preventPollingOnNetworkRestart: true,
messenger,
interval: 100,
Expand Down
30 changes: 15 additions & 15 deletions packages/gas-fee-controller/src/GasFeeController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ describe('GasFeeController', () => {
});

await gasFeeController.fetchGasFeeEstimates({
networkClientId: 'goerli',
networkClientId: 'sepolia',
});

expect(mockedDetermineGasFeeCalculations).toHaveBeenCalledWith({
Expand All @@ -1051,12 +1051,12 @@ describe('GasFeeController', () => {
fetchGasEstimates,
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
fetchGasEstimatesUrl: 'https://some-eip-1559-endpoint/5',
fetchGasEstimatesUrl: 'https://some-eip-1559-endpoint/11155111',
fetchLegacyGasPriceEstimates,
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
fetchLegacyGasPriceEstimatesUrl: `https://some-legacy-endpoint/${convertHexToDecimal(
ChainId.goerli,
ChainId.sepolia,
)}`,
fetchEthGasPriceEstimate,
calculateTimeEstimate,
Expand All @@ -1070,12 +1070,12 @@ describe('GasFeeController', () => {
it('should update the globally selected network state with a fetched set of estimates', async () => {
await setupGasFeeController({
...getDefaultOptions(),
getChainId: jest.fn().mockReturnValue(ChainId.goerli),
getChainId: jest.fn().mockReturnValue(ChainId.sepolia),
onNetworkDidChange: jest.fn(),
});

await gasFeeController.fetchGasFeeEstimates({
networkClientId: 'goerli',
networkClientId: 'sepolia',
});

expect(gasFeeController.state).toMatchObject(
Expand All @@ -1086,16 +1086,16 @@ describe('GasFeeController', () => {
it('should update the gasFeeEstimatesByChainId state with a fetched set of estimates', async () => {
await setupGasFeeController({
...getDefaultOptions(),
getChainId: jest.fn().mockReturnValue(ChainId.goerli),
getChainId: jest.fn().mockReturnValue(ChainId.sepolia),
onNetworkDidChange: jest.fn(),
});

await gasFeeController.fetchGasFeeEstimates({
networkClientId: 'goerli',
networkClientId: 'sepolia',
});

expect(
gasFeeController.state.gasFeeEstimatesByChainId?.[ChainId.goerli],
gasFeeController.state.gasFeeEstimatesByChainId?.[ChainId.sepolia],
).toMatchObject(mockDetermineGasFeeCalculations);
});
});
Expand All @@ -1109,7 +1109,7 @@ describe('GasFeeController', () => {
});

await gasFeeController.fetchGasFeeEstimates({
networkClientId: 'goerli',
networkClientId: 'sepolia',
});

expect(gasFeeController.state).toMatchObject({
Expand All @@ -1127,11 +1127,11 @@ describe('GasFeeController', () => {
});

await gasFeeController.fetchGasFeeEstimates({
networkClientId: 'goerli',
networkClientId: 'sepolia',
});

expect(
gasFeeController.state.gasFeeEstimatesByChainId?.[ChainId.goerli],
gasFeeController.state.gasFeeEstimatesByChainId?.[ChainId.sepolia],
).toMatchObject(mockDetermineGasFeeCalculations);
});
});
Expand Down Expand Up @@ -1200,7 +1200,7 @@ describe('GasFeeController', () => {
});

gasFeeController.startPolling({
networkClientId: 'goerli',
networkClientId: 'sepolia',
});
await clock.tickAsync(0);
expect(mockedDetermineGasFeeCalculations).toHaveBeenNthCalledWith(
Expand All @@ -1209,7 +1209,7 @@ describe('GasFeeController', () => {
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
fetchGasEstimatesUrl: `https://some-eip-1559-endpoint/${convertHexToDecimal(
ChainId.goerli,
ChainId.sepolia,
)}`,
}),
);
Expand All @@ -1222,12 +1222,12 @@ describe('GasFeeController', () => {
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
fetchGasEstimatesUrl: `https://some-eip-1559-endpoint/${convertHexToDecimal(
ChainId.goerli,
ChainId.sepolia,
)}`,
}),
);
expect(
gasFeeController.state.gasFeeEstimatesByChainId?.['0x5'],
gasFeeController.state.gasFeeEstimatesByChainId?.['0xaa36a7'],
).toStrictEqual(buildMockGasFeeStateFeeMarket());

gasFeeController.startPolling({
Expand Down
7 changes: 7 additions & 0 deletions packages/network-controller/src/NetworkController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,13 @@ function getDefaultNetworkConfigurationsByChainId(): Record<
return Object.values(InfuraNetworkType).reduce<
Record<Hex, NetworkConfiguration>
>((obj, infuraNetworkType) => {
if (
infuraNetworkType === InfuraNetworkType.goerli ||
infuraNetworkType === InfuraNetworkType['linea-goerli']
) {
return obj;
}

const chainId = ChainId[infuraNetworkType];
const rpcEndpointUrl =
// This ESLint rule mistakenly produces an error.
Expand Down
Loading
Loading