diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a2fa282c..af214104e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Make `KnownCaipNamespacedChainId` type generic over `Namespace` type parameter ([#262](https://github.com/MetaMask/utils/pull/262)) + ## [11.5.0] ### Added diff --git a/src/caip-types.ts b/src/caip-types.ts index 443f99c29..a48c7f2f1 100644 --- a/src/caip-types.ts +++ b/src/caip-types.ts @@ -148,8 +148,12 @@ export enum KnownCaipNamespace { * * This is a narrower, more type-safe alternative to {@link CaipChainId} for use cases * where the chain namespace must be one of the known standards. + * + * @template Namespace - The namespace of the CAIP-2 chain ID. Must be a known namespace specified in {@link KnownCaipNamespace}. */ -export type KnownCaipNamespacedChainId = `${KnownCaipNamespace}:${string}`; +export type KnownCaipNamespacedChainId< + Namespace extends `${KnownCaipNamespace}` = `${KnownCaipNamespace}`, +> = `${Namespace}:${string}`; /** * Check if the given value is a {@link CaipChainId}.