refactor: use CID class
This commit is contained in:
parent
75c6c30284
commit
b7bfbcc3cf
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue