Skip to content

Commit

Permalink
fix: upload-client api misalignment
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed May 14, 2024
1 parent c8e0088 commit a3382e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/upload-client/src/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ function parseBlobAddReceiptNext(receipt) {
const putTask = forkInvocations.find(
(fork) => fork.capabilities[0].can === HTTPCapabilities.put.can
)
const acceptTask = receipt.fx.join
const acceptTask = forkInvocations.find(
(fork) => fork.capabilities[0].can === W3sBlobCapabilities.accept.can
)

/* c8 ignore next 3 */
if (!allocateTask || !concludefxs.length || !putTask || !acceptTask) {
throw new Error('mandatory effects not received')
Expand All @@ -80,10 +83,11 @@ function parseBlobAddReceiptNext(receipt) {
const putReceipt = nextReceipts.find((receipt) =>
receipt.ran.link().equals(putTask.cid)
)

/** @type {import('@ucanto/interface').Receipt<import('./types.js').BlobAcceptSuccess, import('./types.js').BlobAcceptFailure> | undefined} */
// @ts-expect-error types unknown for next
const acceptReceipt = nextReceipts.find((receipt) =>
receipt.ran.link().equals(acceptTask.link())
receipt.ran.link().equals(acceptTask.cid)
)

/* c8 ignore next 3 */
Expand Down
2 changes: 1 addition & 1 deletion packages/upload-client/test/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,6 @@ const setupBlobAddResponse = async function (
.fork(blobAllocateTask)
.fork(blobConcludeAllocate)
.fork(blobPutTask)
.join(blobAcceptTask)
.fork(blobAcceptTask)
.fork(blobConcludeAccept)
}

0 comments on commit a3382e4

Please sign in to comment.