From 8e786ec164cfd20eba5d89834579fbe07ac96480 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 11 Dec 2023 22:58:38 -0500 Subject: [PATCH] feat: add fromSignedRegistryEntry --- src/cid.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cid.ts b/src/cid.ts index 2f9b31c..1426260 100644 --- a/src/cid.ts +++ b/src/cid.ts @@ -4,6 +4,7 @@ import { CID_HASH_TYPES, CID_TYPES, REGISTRY_TYPES } from "#constants.js"; import { decodeEndian, encodeEndian } from "#util.js"; import { concatBytes, equalBytes } from "@noble/curves/abstract/utils"; import { hexToBytes } from "@noble/hashes/utils"; +import { SignedRegistryEntry } from "#types.js"; export default class CID extends Multibase { type: number; @@ -42,6 +43,10 @@ export default class CID extends Multibase { return CID._init(bytes); } + static fromSignedRegistryEntry(sre: SignedRegistryEntry): CID { + return CID.fromRegistryPublicKey(sre.pk); + } + static fromRegistryPublicKey(pubkey: string | Uint8Array): CID { return CID.fromHash(pubkey, 0, CID_TYPES.RESOLVER); }