Skip to content

Commit ef35512

Browse files
authored
refactor: Remove duplicated code in setProviderType (#3813)
## Explanation The method `setProviderType` has been updated to use `setActiveNetwork` internally, allowing us to remove a bunch of code that was duplicated between both methods. ## References N/A ## Changelog None ## 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
1 parent ed8423e commit ef35512

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

packages/network-controller/jest.config.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ module.exports = merge(baseConfig, {
1717
// An object that configures minimum threshold enforcement for coverage results
1818
coverageThreshold: {
1919
global: {
20-
branches: 76.53,
21-
functions: 95,
22-
lines: 92,
23-
statements: 91.58,
20+
branches: 76.57,
21+
functions: 94.93,
22+
lines: 91.78,
23+
statements: 91.36,
2424
},
2525
},
2626

packages/network-controller/src/NetworkController.ts

+1-20
Original file line numberDiff line numberDiff line change
@@ -965,26 +965,7 @@ export class NetworkController extends BaseController<
965965
`Unknown Infura provider type "${type}".`,
966966
);
967967

968-
this.#previousProviderConfig = this.state.providerConfig;
969-
970-
// If testnet the ticker symbol should use a testnet prefix
971-
const ticker =
972-
type in NetworksTicker && NetworksTicker[type].length > 0
973-
? NetworksTicker[type]
974-
: 'ETH';
975-
976-
this.#ensureAutoManagedNetworkClientRegistryPopulated();
977-
978-
this.update((state) => {
979-
state.providerConfig.type = type;
980-
state.providerConfig.ticker = ticker;
981-
state.providerConfig.chainId = ChainId[type];
982-
state.providerConfig.rpcPrefs = BUILT_IN_NETWORKS[type].rpcPrefs;
983-
state.providerConfig.rpcUrl = undefined;
984-
state.providerConfig.nickname = undefined;
985-
state.providerConfig.id = undefined;
986-
});
987-
await this.#refreshNetwork();
968+
await this.setActiveNetwork(type);
988969
}
989970

990971
/**

0 commit comments

Comments
 (0)