refactor: use CID class
This commit is contained in:
parent
75c6c30284
commit
b7bfbcc3cf
|
@ -326,20 +326,14 @@ 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]) {
|
|
||||||
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;
|
validCid = true;
|
||||||
|
if (cid.type === CID_TYPES.RESOLVER) {
|
||||||
isResolver = true;
|
isResolver = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!validCid) {
|
if (!validCid) {
|
||||||
logErr("moduleCall", "received moduleCall with malformed module");
|
logErr("moduleCall", "received moduleCall with malformed module");
|
||||||
|
|
Loading…
Reference in New Issue