-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: upload client should perform filecoin offer (#1333)
In context of storacha/project-tracking#25 and storacha/w3infra#344 we set the client to perform filecoin/offer already so that new users, as well as users that upgrade in the meantime can already perform this, in order to better prepare us to get rid of bucket event --------- Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
- Loading branch information
1 parent
f5bac9d
commit 466e3f7
Showing
11 changed files
with
352 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as StorefrontCapabilities from '@web3-storage/capabilities/filecoin/storefront' | ||
import * as Server from '@ucanto/server' | ||
|
||
/** | ||
* @param {Server.Signer<`did:${string}:${string}`, Server.API.SigAlg>} id | ||
* @param {import('@web3-storage/data-segment').PieceLink} piece | ||
* @param {Pick<{ content: Server.API.Link<unknown, number, number, 0 | 1>; piece: import('@web3-storage/data-segment').PieceLink; }, 'content' | 'piece'>} args | ||
*/ | ||
export async function getFilecoinOfferResponse(id, piece, args) { | ||
// Create effect for receipt with self signed queued operation | ||
const submitfx = await StorefrontCapabilities.filecoinSubmit | ||
.invoke({ | ||
issuer: id, | ||
audience: id, | ||
with: id.did(), | ||
nb: args, | ||
expiration: Infinity, | ||
}) | ||
.delegate() | ||
|
||
const acceptfx = await StorefrontCapabilities.filecoinAccept | ||
.invoke({ | ||
issuer: id, | ||
audience: id, | ||
with: id.did(), | ||
nb: args, | ||
expiration: Infinity, | ||
}) | ||
.delegate() | ||
|
||
return Server.ok({ piece }).fork(submitfx.link()).join(acceptfx.link()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.