From f4e3820504664457cd03a90790b2876b244373b6 Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Wed, 9 Oct 2024 14:30:20 +0200 Subject: [PATCH] feat: add `KnownCaipNamespace.Bip122` for Bitcoin family (#213) Adding a new known CAIP namespace for Bitcoin. You can find a proper BIP-122 CAIP 2 identifier here: - https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md#test-cases We could also update the for `KnownCaipNamespaces` to match those test cases but the test as-is seems good enough AND future-proof too. --- src/caip-types.test.ts | 5 +---- src/caip-types.ts | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/caip-types.test.ts b/src/caip-types.test.ts index d610f0e88..16d4958ec 100644 --- a/src/caip-types.test.ts +++ b/src/caip-types.test.ts @@ -295,10 +295,7 @@ describe('toCaipChainId', () => { it.each(Object.values(KnownCaipNamespace))( 'treats %s as a valid namespace', (namespace) => { - const reference = '1'; - expect(toCaipChainId(namespace, reference)).toBe( - `${namespace}:${reference}`, - ); + expect(isCaipNamespace(namespace)).toBe(true); }, ); diff --git a/src/caip-types.ts b/src/caip-types.ts index 361aa60d6..037179ace 100644 --- a/src/caip-types.ts +++ b/src/caip-types.ts @@ -54,6 +54,8 @@ export type CaipAccountAddress = Infer; /** Known CAIP namespaces. */ export enum KnownCaipNamespace { + /** BIP-122 (Bitcoin) compatible chains. */ + Bip122 = 'bip122', /** EIP-155 compatible chains. */ Eip155 = 'eip155', Wallet = 'wallet',