fix: update encodeCid overloads and return types
This commit is contained in:
parent
c1913e7ba5
commit
7dc8067e95
23
src/cid.ts
23
src/cid.ts
|
@ -6,18 +6,31 @@ import {
|
||||||
import { addContextToErr } from "#err.js";
|
import { addContextToErr } from "#err.js";
|
||||||
import type { CID } from "@lumeweb/libportal";
|
import type { CID } from "@lumeweb/libportal";
|
||||||
|
|
||||||
export function encodeCid(hash: Uint8Array, size: bigint): ErrTuple<string>;
|
export function encodeCid(
|
||||||
export function encodeCid(hash: string, size: bigint): ErrTuple<string>;
|
hash: Uint8Array,
|
||||||
|
size: bigint,
|
||||||
|
type?: number,
|
||||||
|
hashType?: number,
|
||||||
|
raw?: boolean,
|
||||||
|
): ErrTuple<string>;
|
||||||
|
export function encodeCid(
|
||||||
|
hash: string,
|
||||||
|
size: bigint,
|
||||||
|
type?: number,
|
||||||
|
hashType?: number,
|
||||||
|
raw?: boolean,
|
||||||
|
): ErrTuple<string>;
|
||||||
export function encodeCid(
|
export function encodeCid(
|
||||||
hash: any,
|
hash: any,
|
||||||
size: bigint,
|
size: bigint,
|
||||||
type?: number,
|
type?: number,
|
||||||
hashType?: number,
|
hashType?: number,
|
||||||
): ErrTuple<CID> {
|
raw: boolean = false,
|
||||||
|
): ErrTuple<string> {
|
||||||
try {
|
try {
|
||||||
return [encodeCidPortal(hash, size, type, hashType), null];
|
return [encodeCidPortal(hash, size, type, hashType, raw), null];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return [null, addContextToErr(e as Error, "failed to encode cid")];
|
return ["", addContextToErr(e as Error, "failed to encode cid")];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue