Skip to content
Merged
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
3 changes: 2 additions & 1 deletion packages/config-registry-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Add `ConfigRegistryControllerStateChangedEvent` (`ConfigRegistryController:stateChanged`) to the controller's events ([#9595](https://github.com/MetaMask/core/pull/9595))
- Add `ConfigRegistryController.getNetworkConfigByCaip2ChainId` method to retrieve a network config by its CAIP-2 chain ID ([#9597](https://github.com/MetaMask/core/pull/9597))
- Add `ConfigRegistryController.getNetworkConfigByCaip2ChainId` method to retrieve a network config by its CAIP-2 chain ID ([#9597](https://github.com/MetaMask/core/pull/9597), [#9606](https://github.com/MetaMask/core/pull/9606))
- The method returns the network config if found, or `undefined` if not found.
- The method is also accessible via the controller's messenger as `ConfigRegistryController:getNetworkConfigByCaip2ChainId`.

### Changed

- **BREAKING:** `ConfigRegistryControllerState.configs.networks` is now a `Record<Caip2ChainId, RegistryNetworkConfig>` instead of a `Record<string, RegistryNetworkConfig>` ([#9606](https://github.com/MetaMask/core/pull/9606))
- Bump `@metamask/utils` from `^11.9.0` to `^11.11.0` ([#9074](https://github.com/MetaMask/core/pull/9074))
- Bump `@metamask/controller-utils` from `^12.1.1` to `^12.3.0` ([#9083](https://github.com/MetaMask/core/pull/9083), [#9218](https://github.com/MetaMask/core/pull/9218))
- Bump `@metamask/profile-sync-controller` from `^28.1.1` to `^28.3.0` ([#9119](https://github.com/MetaMask/core/pull/9119), [#9463](https://github.com/MetaMask/core/pull/9463))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { Messenger } from '@metamask/messenger';
import { StaticIntervalPollingController } from '@metamask/polling-controller';
import type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';
import type { RemoteFeatureFlagControllerStateChangeEvent } from '@metamask/remote-feature-flag-controller';
import { Duration, inMilliseconds, Json } from '@metamask/utils';
import { CaipChainId, Duration, inMilliseconds, Json } from '@metamask/utils';

import type { ConfigRegistryApiServiceFetchConfigAction } from './config-registry-api-service/config-registry-api-service-method-action-types.js';
import type { RegistryNetworkConfig } from './config-registry-api-service/types.js';
Expand All @@ -37,7 +37,7 @@ export type ConfigRegistryControllerState = {
* Use selectors (e.g. selectFeaturedNetworks) to filter when needed.
*/
configs: {
networks: Record<string, RegistryNetworkConfig>;
networks: Record<CaipChainId, RegistryNetworkConfig>;
};
/**
* Semantic version string of the configuration data from the API.
Expand Down Expand Up @@ -216,7 +216,7 @@ export class ConfigRegistryController extends StaticIntervalPollingController<nu
* @returns The network configuration if found, otherwise undefined.
*/
getNetworkConfigByCaip2ChainId(
caip2ChainId: string,
caip2ChainId: CaipChainId,
): RegistryNetworkConfig | undefined {
return this.state.configs.networks[caip2ChainId];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
string,
type,
} from '@metamask/superstruct';
import { CaipChainIdStruct } from '@metamask/utils';

const AssetSchema = type({
assetId: string(),
Expand Down Expand Up @@ -55,7 +56,7 @@ const ChainConfigSchema = type({
* chainId is in CAIP-2 format (e.g. "eip155:1", "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp").
*/
export const RegistryNetworkConfigSchema = type({
chainId: string(),
chainId: CaipChainIdStruct,
name: string(),
imageUrl: string(),
coingeckoPlatformId: string(),
Expand Down