From b9cfb7b6167047e62aa26620ddf4f257768c4891 Mon Sep 17 00:00:00 2001 From: Jongsun Suh Date: Mon, 25 Aug 2025 09:16:26 -0400 Subject: [PATCH 1/2] Add `KnownCaipNamespacedChainId` type --- src/caip-types.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/caip-types.ts b/src/caip-types.ts index b20076134..79f6a626c 100644 --- a/src/caip-types.ts +++ b/src/caip-types.ts @@ -142,6 +142,15 @@ export enum KnownCaipNamespace { Wallet = 'wallet', } +/** + * A CAIP chain ID namespaced by a known CAIP namespace (@see {@link KnownCaipNamespace}). + * This is a narrower alternative to {@link CaipChainId}. + * + * This type is necessary because `const` strings are not assignable to the `string` type. + * Because of this, e.g. `eip155:${string}` is not assignable to (is not a subtype of) `${string}:${string}`. + */ +export type KnownCaipNamespacedChainId = `${KnownCaipNamespace}:${string}`; + /** * Check if the given value is a {@link CaipChainId}. * From 23c99b9464ff356a0a41ec1a8ec80399f0e165f8 Mon Sep 17 00:00:00 2001 From: Jongsun Suh Date: Mon, 25 Aug 2025 10:28:08 -0400 Subject: [PATCH 2/2] Apply suggested correction to jsdoc Co-authored-by: Eric Wolff --- src/caip-types.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/caip-types.ts b/src/caip-types.ts index 79f6a626c..443f99c29 100644 --- a/src/caip-types.ts +++ b/src/caip-types.ts @@ -143,11 +143,11 @@ export enum KnownCaipNamespace { } /** - * A CAIP chain ID namespaced by a known CAIP namespace (@see {@link KnownCaipNamespace}). - * This is a narrower alternative to {@link CaipChainId}. + * A CAIP-2 chain ID that is guaranteed to have a known CAIP namespace + * (@see {@link KnownCaipNamespace}). * - * This type is necessary because `const` strings are not assignable to the `string` type. - * Because of this, e.g. `eip155:${string}` is not assignable to (is not a subtype of) `${string}:${string}`. + * 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. */ export type KnownCaipNamespacedChainId = `${KnownCaipNamespace}:${string}`;