diff --git a/src/pack/blob.ts b/src/pack/blob.ts index e703c2b..5b90f5c 100644 --- a/src/pack/blob.ts +++ b/src/pack/blob.ts @@ -8,11 +8,12 @@ import { MemoryBlockStore } from '../blockstore/memory' import { pack } from './index' import type { PackProperties } from './index' -export async function packToBlob ({ input, blockstore: userBlockstore, hasher, maxChunkSize, maxChildrenPerNode, wrapWithDirectory, rawLeaves }: PackProperties) { +export async function packToBlob ({ input, blockstore: userBlockstore, cidVersion, hasher, maxChunkSize, maxChildrenPerNode, wrapWithDirectory, rawLeaves }: PackProperties) { const blockstore = userBlockstore ? userBlockstore : new MemoryBlockStore() const { root, out } = await pack({ input, blockstore, + cidVersion, hasher, maxChunkSize, maxChildrenPerNode, diff --git a/src/pack/index.ts b/src/pack/index.ts index 00c3499..ef23f93 100644 --- a/src/pack/index.ts +++ b/src/pack/index.ts @@ -11,10 +11,12 @@ export type { ImportCandidateStream } import { Blockstore } from '../blockstore' import { MemoryBlockStore } from '../blockstore/memory' import { unixfsImporterOptionsDefault } from './constants' +import { CIDVersion } from 'multiformats/cid' export interface PackProperties { input: ImportCandidateStream | ImportCandidate, blockstore?: Blockstore, + cidVersion?: CIDVersion; maxChunkSize?: number, maxChildrenPerNode?: number, wrapWithDirectory?: boolean, @@ -26,7 +28,7 @@ export interface PackProperties { rawLeaves?: boolean } -export async function pack ({ input, blockstore: userBlockstore, hasher, maxChunkSize, maxChildrenPerNode, wrapWithDirectory, rawLeaves }: PackProperties) { +export async function pack ({ input, blockstore: userBlockstore, cidVersion, hasher, maxChunkSize, maxChildrenPerNode, wrapWithDirectory, rawLeaves }: PackProperties) { if (!input || (Array.isArray(input) && !input.length)) { throw new Error('missing input file(s)') } @@ -38,6 +40,7 @@ export async function pack ({ input, blockstore: userBlockstore, hasher, maxChun getNormaliser(input), (source: any) => importer(source, blockstore, { ...unixfsImporterOptionsDefault, + cidVersion: cidVersion !== undefined ? cidVersion : unixfsImporterOptionsDefault.cidVersion, hasher: hasher || unixfsImporterOptionsDefault.hasher, maxChunkSize: maxChunkSize || unixfsImporterOptionsDefault.maxChunkSize, maxChildrenPerNode: maxChildrenPerNode || unixfsImporterOptionsDefault.maxChildrenPerNode,