-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: upload client should perform filecoin offer #1333
Merged
vasco-santos
merged 4 commits into
main
from
fix/upload-client-should-perform-filecoin-offer
Mar 21, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ import { | |
UsageReportSuccess, | ||
UsageReportFailure, | ||
} from '@web3-storage/capabilities/types' | ||
import { StorefrontService } from '@web3-storage/filecoin-client/storefront' | ||
import { code as pieceHashCode } from '@web3-storage/data-segment/multihash' | ||
|
||
type Override<T, R> = Omit<T, keyof R> & R | ||
|
@@ -93,7 +94,7 @@ export interface ProgressStatus extends XHRProgressStatus { | |
|
||
export type ProgressFn = (status: ProgressStatus) => void | ||
|
||
export interface Service { | ||
export interface Service extends StorefrontService { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. adds storefront capabilities as implemented by |
||
store: { | ||
add: ServiceMethod<StoreAdd, StoreAddSuccess, Failure> | ||
get: ServiceMethod<StoreGet, StoreGetSuccess, StoreGetFailure> | ||
|
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand why this is the issuer?
https://github.com/web3-storage/w3up/blob/f5bac9d27610d976d1144ea12a5c6f9448e7974a/packages/capabilities/src/filecoin/storefront.js#L22-L25
lolz looks like I wrote that comment...still why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my comment is actually also wrong, the did must be the same as the issuer in order to have a self issued invocation.. Otherwise you would need to either have been delegated such capability or inline proofs given resource is not did of issuer.