Skip to content

Commit 4eab923

Browse files
MajorLifterwolff
andauthored
feat: Add KnownCaipNamespacedChainId type (#258)
This commit adds a type for CAIP chain IDs that are namespaced by a known CAIP namespace. This type enables the usage of safer literal string types for namespaced CAIP chain IDs, and is intended as a narrower alternative to `CaipChainId`. --------- Co-authored-by: Eric Wolff <erwolff@gmail.com>
1 parent a8b12f2 commit 4eab923

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/caip-types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ export enum KnownCaipNamespace {
142142
Wallet = 'wallet',
143143
}
144144

145+
/**
146+
* A CAIP-2 chain ID that is guaranteed to have a known CAIP namespace
147+
* (@see {@link KnownCaipNamespace}).
148+
*
149+
* This is a narrower, more type-safe alternative to {@link CaipChainId} for use cases
150+
* where the chain namespace must be one of the known standards.
151+
*/
152+
export type KnownCaipNamespacedChainId = `${KnownCaipNamespace}:${string}`;
153+
145154
/**
146155
* Check if the given value is a {@link CaipChainId}.
147156
*

0 commit comments

Comments
 (0)