diff --git a/src/cid.ts b/src/cid.ts index e711f43..2fd80c7 100644 --- a/src/cid.ts +++ b/src/cid.ts @@ -6,18 +6,31 @@ import { import { addContextToErr } from "#err.js"; import type { CID } from "@lumeweb/libportal"; -export function encodeCid(hash: Uint8Array, size: bigint): ErrTuple; -export function encodeCid(hash: string, size: bigint): ErrTuple; +export function encodeCid( + hash: Uint8Array, + size: bigint, + type?: number, + hashType?: number, + raw?: boolean, +): ErrTuple; +export function encodeCid( + hash: string, + size: bigint, + type?: number, + hashType?: number, + raw?: boolean, +): ErrTuple; export function encodeCid( hash: any, size: bigint, type?: number, hashType?: number, -): ErrTuple { + raw: boolean = false, +): ErrTuple { try { - return [encodeCidPortal(hash, size, type, hashType), null]; + return [encodeCidPortal(hash, size, type, hashType, raw), null]; } catch (e) { - return [null, addContextToErr(e as Error, "failed to encode cid")]; + return ["", addContextToErr(e as Error, "failed to encode cid")]; } }