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,20 +326,14 @@ 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) {
const cid = CID.decode(event.data.data.module);
validCid = true;
if (cid.type === CID_TYPES.RESOLVER) {
isResolver = true;
}
}
}
if (!validCid) {
logErr("moduleCall", "received moduleCall with malformed module");