Skip to content

Commit

Permalink
fix: cid for filecoin offer must be raw
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed May 14, 2024
1 parent 797f628 commit 78acf4d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/upload-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,15 @@ async function uploadBlockStream(
const bytes = new Uint8Array(await car.arrayBuffer())
// Invoke blob/add and write bytes to write target
const multihash = await Blob.add(conf, bytes, options)
// Should this be raw instead?
const cid = Link.create(carCodec.code, multihash)
let piece
if (pieceHasher) {
const multihashDigest = await pieceHasher.digest(bytes)
/** @type {import('@web3-storage/capabilities/types').PieceLink} */
piece = Link.create(raw.code, multihashDigest)
const content = Link.create(raw.code, multihash)

// Invoke filecoin/offer for data
const result = await Storefront.filecoinOffer(
{
Expand All @@ -149,7 +152,7 @@ async function uploadBlockStream(
with: conf.issuer.did(),
proofs: conf.proofs,
},
cid,
content,
piece,
options
)
Expand Down
1 change: 0 additions & 1 deletion packages/upload-client/test/helpers/car.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { toBlock } from './block.js'
*/
export async function toCAR(bytes) {
const block = await toBlock(bytes)
// @ts-expect-error old multiformats in @ipld/car
const { writer, out } = CarWriter.create(block.cid)
writer.put(block)
writer.close()
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 78acf4d

Please sign in to comment.