Skip to content

Commit

Permalink
fix: cid for filecoin offer must be raw (#1450)
Browse files Browse the repository at this point in the history
As we previously decided, `filecoin/offer` should receive raw CIDs
#1408 (comment)
so that everything works out of the box and Blobs can be read from
roundabout for validation + from SPs

Co-authored-by: Andrew Gillis <gammazero@users.noreply.github.com>
Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
  • Loading branch information
3 people authored May 14, 2024
1 parent 797f628 commit c3dd7b5
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit c3dd7b5

Please sign in to comment.