From b7bfbcc3cf1c7574e9e8377e87d74d28e85d7c5f Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 8 Sep 2023 13:15:33 -0400 Subject: [PATCH] refactor: use CID class --- src/queries.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/queries.ts b/src/queries.ts index e068788..ce0c39e 100644 --- a/src/queries.ts +++ b/src/queries.ts @@ -326,18 +326,12 @@ async function handleModuleCall( let isResolver = false; if ( typeof event.data.data.module === "string" && - verifyCid(event.data.data.module) + CID.verify(event.data.data.module) ) { - const decodedCid = decodeCid(event.data.data.module); - if (!decodedCid[1]) { - const { type, hashType } = decodedCid[0]; - if (type === CID_TYPES.RAW && hashType === CID_HASH_TYPES.BLAKE3) { - validCid = true; - } - if (type === CID_TYPES.RESOLVER && hashType === CID_HASH_TYPES.ED25519) { - validCid = true; - isResolver = true; - } + const cid = CID.decode(event.data.data.module); + validCid = true; + if (cid.type === CID_TYPES.RESOLVER) { + isResolver = true; } }