Skip to content

Commit

Permalink
feat: add KnownCaipNamespace.Bip122 for Bitcoin family (#213)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ccharly authored Oct 9, 2024
1 parent aac1497 commit f4e3820
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/caip-types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
);

Expand Down
2 changes: 2 additions & 0 deletions src/caip-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export type CaipAccountAddress = Infer<typeof CaipAccountAddressStruct>;

/** Known CAIP namespaces. */
export enum KnownCaipNamespace {
/** BIP-122 (Bitcoin) compatible chains. */
Bip122 = 'bip122',
/** EIP-155 compatible chains. */
Eip155 = 'eip155',
Wallet = 'wallet',
Expand Down

0 comments on commit f4e3820

Please sign in to comment.