refactor: update encodeCid to match the portal encodeCid

This commit is contained in:
Derrick Hammer 2023-09-02 06:38:47 -04:00
parent dd296e9e50
commit bb0c8de24e
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 7 additions and 2 deletions

View File

@ -7,9 +7,14 @@ import { addContextToErr } from "#err.js";
export function encodeCid(hash: Uint8Array, size: bigint): any;
export function encodeCid(hash: string, size: bigint): any;
export function encodeCid(hash: any, size: bigint): ErrTuple {
export function encodeCid(
hash: any,
size: bigint,
type?: number,
hashType?: number,
): ErrTuple {
try {
return [encodeCidPortal(hash, size), null];
return [encodeCidPortal(hash, size, type, hashType), null];
} catch (e) {
return [null, addContextToErr(e as Error, "failed to encode cid")];
}