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

Remove providerConfig from NetworkController #4254

Merged
merged 8 commits into from
Jun 12, 2024
12 changes: 0 additions & 12 deletions packages/assets-controllers/src/TokenRatesController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,11 +641,6 @@ describe('TokenRatesController', () => {
.mockResolvedValue();
triggerNetworkStateChange({
...defaultNetworkState,
providerConfig: {
...defaultNetworkState.providerConfig,
chainId: ChainId.mainnet,
ticker: 'NEW',
},
selectedNetworkClientId: defaultSelectedNetworkClientId,
});

Expand Down Expand Up @@ -1421,13 +1416,6 @@ describe('TokenRatesController', () => {
},
},
},
mockNetworkState: {
providerConfig: {
...defaultNetworkState.providerConfig,
chainId: toHex(2),
ticker: 'ticker',
},
},
},
async ({ controller }) => {
controller.startPollingByNetworkClientId('mainnet');
Expand Down
10 changes: 7 additions & 3 deletions packages/assets-controllers/src/TokenRatesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,16 @@ export class TokenRatesController extends StaticIntervalPollingController<
chainId: Hex;
ticker: string;
} {
const { providerConfig } = this.messagingSystem.call(
const { selectedNetworkClientId } = this.messagingSystem.call(
'NetworkController:getState',
);
const networkClient = this.messagingSystem.call(
'NetworkController:getNetworkClientById',
selectedNetworkClientId,
);
return {
chainId: providerConfig.chainId,
ticker: providerConfig.ticker,
chainId: networkClient.configuration.chainId,
ticker: networkClient.configuration.ticker,
};
}

Expand Down
10 changes: 10 additions & 0 deletions packages/network-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- **BREAKING:** Update `networksMetadata` state property so that the keys in the object will only ever be network client IDs and not RPC URLs ([#4254](https://github.com/MetaMask/core/pull/4254))
- Some keys could have been RPC URLs if the initial network controller state had a `providerConfig` with an empty `id`, but since `providerConfig` is being removed, that won't happen anymore.

### Removed

- **BREAKING:** Remove `providerConfig` property from state along with `ProviderConfig` type and `NetworkController:getProviderConfig` messenger action ([#4254](https://github.com/MetaMask/core/pull/4254))
- The best way to obtain the equivalent configuration object, e.g. to access the chain ID of the currently selected network, is to get `selectedNetworkClientId` from state, pass this to the `NetworkController:getNetworkClientId` messenger action, and then use the `configuration` property on the network client.

## [19.0.0]

### Changed
Expand Down
Loading
Loading