feat: add fromSignedRegistryEntry
This commit is contained in:
parent
067dd9cd22
commit
8e786ec164
|
@ -4,6 +4,7 @@ import { CID_HASH_TYPES, CID_TYPES, REGISTRY_TYPES } from "#constants.js";
|
||||||
import { decodeEndian, encodeEndian } from "#util.js";
|
import { decodeEndian, encodeEndian } from "#util.js";
|
||||||
import { concatBytes, equalBytes } from "@noble/curves/abstract/utils";
|
import { concatBytes, equalBytes } from "@noble/curves/abstract/utils";
|
||||||
import { hexToBytes } from "@noble/hashes/utils";
|
import { hexToBytes } from "@noble/hashes/utils";
|
||||||
|
import { SignedRegistryEntry } from "#types.js";
|
||||||
|
|
||||||
export default class CID extends Multibase {
|
export default class CID extends Multibase {
|
||||||
type: number;
|
type: number;
|
||||||
|
@ -42,6 +43,10 @@ export default class CID extends Multibase {
|
||||||
return CID._init(bytes);
|
return CID._init(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static fromSignedRegistryEntry(sre: SignedRegistryEntry): CID {
|
||||||
|
return CID.fromRegistryPublicKey(sre.pk);
|
||||||
|
}
|
||||||
|
|
||||||
static fromRegistryPublicKey(pubkey: string | Uint8Array): CID {
|
static fromRegistryPublicKey(pubkey: string | Uint8Array): CID {
|
||||||
return CID.fromHash(pubkey, 0, CID_TYPES.RESOLVER);
|
return CID.fromHash(pubkey, 0, CID_TYPES.RESOLVER);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue