refactor: use CID class

This commit is contained in:
Derrick Hammer 2023-09-08 13:15:33 -04:00
parent 75c6c30284
commit b7bfbcc3cf
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 5 additions and 11 deletions

View File

@ -326,18 +326,12 @@ async function handleModuleCall(
let isResolver = false; let isResolver = false;
if ( if (
typeof event.data.data.module === "string" && typeof event.data.data.module === "string" &&
verifyCid(event.data.data.module) CID.verify(event.data.data.module)
) { ) {
const decodedCid = decodeCid(event.data.data.module); const cid = CID.decode(event.data.data.module);
if (!decodedCid[1]) { validCid = true;
const { type, hashType } = decodedCid[0]; if (cid.type === CID_TYPES.RESOLVER) {
if (type === CID_TYPES.RAW && hashType === CID_HASH_TYPES.BLAKE3) { isResolver = true;
validCid = true;
}
if (type === CID_TYPES.RESOLVER && hashType === CID_HASH_TYPES.ED25519) {
validCid = true;
isResolver = true;
}
} }
} }