Compare commits

...

3 Commits

3 changed files with 6 additions and 6 deletions

View File

@ -36,7 +36,7 @@ export function encodeCid(hash: any, size: bigint) {
export function decodeCid(cid: string): CID { export function decodeCid(cid: string): CID {
let bytes = base58btc.decode(cid); let bytes = base58btc.decode(cid);
if (!arrayBufferEqual(bytes.slice(0, 2).buffer, bytes.buffer)) { if (!arrayBufferEqual(bytes.slice(0, 2).buffer, MAGIC_BYTES.buffer)) {
throw new Error("Invalid cid"); throw new Error("Invalid cid");
} }

View File

@ -44,11 +44,11 @@ export async function getVerifiableStream(
}); });
}; };
await getNextBytes();
// @ts-ignore // @ts-ignore
const wasmId = callExports("start"); const wasmId = callExports("start");
getWasmProperty(wasmId, "set_root")(root); getWasmProperty(wasmId, "set_root")(root);
getWasmProperty(wasmId, "set_proof")(proof); getWasmProperty(wasmId, "set_proof")(proof);
await getNextBytes();
return new ReadableStream({ return new ReadableStream({
async pull(controller) { async pull(controller) {

View File

@ -5,12 +5,12 @@ export default async function (imports) {
// @ts-ignore // @ts-ignore
const wasmPath = new URL("wasm/bao.wasm", import.meta.url); const wasmPath = new URL("wasm/bao.wasm", import.meta.url);
const wasm = await fs.readFile(wasmPath); const wasm = await fs.readFile(wasmPath);
return (await WebAssembly.instantiate(wasm, imports)).instance;
return WebAssembly.instantiate(wasm, imports);
} }
// @ts-ignore // @ts-ignore
return await import("./wasm/bao.wasm"); let wasm = await import("./wasm/bao.wasm");
wasm = wasm.default || wasm;
return (await wasm(imports)).instance;
} }