From a73561d36955a85073f59dcaf0d51e36e2eae609 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 8 Sep 2023 13:13:18 -0400 Subject: [PATCH] refactor: use CID class --- src/coreModules.ts | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/coreModules.ts b/src/coreModules.ts index f3cd586..fc8f3d7 100644 --- a/src/coreModules.ts +++ b/src/coreModules.ts @@ -1,10 +1,5 @@ import { internalModuleCall, modules } from "./queries.js"; -import { SignedRegistryEntry } from "@lumeweb/libs5"; -import { - decodeRegistryValue, - encodeCid, - decodeRegistryCid, -} from "@lumeweb/libweb"; +import { SignedRegistryEntry, CID } from "@lumeweb/libs5"; const CORE_MODULES = { swarm: "zdiLmwHCC15afFNLYzzT2DVV7m27SrBde7oXHdSzAe95GpFZXzdpatUN6b", @@ -35,7 +30,7 @@ function moduleLoaded(module: string) { } export async function resolveModuleRegistryEntry(module: string) { - const [cid] = decodeRegistryCid(module); + const cid = CID.decode(module); const pubkey = cid.hash; @@ -45,18 +40,5 @@ export async function resolveModuleRegistryEntry(module: string) { { pubkey }, )) as SignedRegistryEntry; - let [decodedRegistry, err] = decodeRegistryValue(signedEntry.data); - - if (err) { - throw new Error(err); - } - - let rawEncCid; - [rawEncCid, err] = encodeCid(decodedRegistry); - - if (err) { - throw new Error(err); - } - - return rawEncCid; + const entry = CID.fromRegistry(signedEntry.data); }