Skip to content

Commit

Permalink
refactor!: filecoin capabilities
Browse files Browse the repository at this point in the history
refactor: switch to rust piece CID calculator (storacha#930)

Currently blocked on top level await issue.

---------

Co-authored-by: Irakli Gozalishvili <contact@gozala.io>

feat: add piece CID to car metadata

chore(main): release upload-client 9.4.0 (storacha#935)

:robot: I have created a release *beep* *boop*
---

[9.4.0](storacha/w3up@upload-client-v9.3.0...upload-client-v9.4.0)
(2023-09-20)

* add piece CID to car metadata
([1e52687](storacha@1e52687))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

fix: only aggregate CID in aggregate offer success response

Update packages/capabilities/src/filecoin/aggregator.js

Co-authored-by: Vasco Santos <santos.vasco10@gmail.com>

Update packages/capabilities/src/filecoin/aggregator.js

Co-authored-by: Vasco Santos <santos.vasco10@gmail.com>

Update packages/capabilities/src/filecoin/dealer.js

Co-authored-by: Vasco Santos <santos.vasco10@gmail.com>

Update packages/capabilities/src/types.ts

Co-authored-by: Vasco Santos <santos.vasco10@gmail.com>

Update packages/capabilities/src/types.ts

Co-authored-by: Vasco Santos <santos.vasco10@gmail.com>

fix: add missing ContentNotFound definition for filecoin offer failure

refactor: storefront caps

fix: type errors

fix: add missing filecoin submit success and failure types
  • Loading branch information
Alan Shaw authored and vasco-santos committed Oct 24, 2023
1 parent 84ebb2d commit c0b97bf
Show file tree
Hide file tree
Showing 13 changed files with 1,310 additions and 342 deletions.
20 changes: 20 additions & 0 deletions packages/capabilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@
"types": "./dist/src/*.d.ts",
"import": "./src/*.js"
},
"./filecoin": {
"types": "./dist/src/filecoin/index.d.ts",
"import": "./src/filecoin/index.js"
},
"./filecoin/storefront": {
"types": "./dist/src/filecoin/storefront.d.ts",
"import": "./src/filecoin/storefront.js"
},
"./filecoin/aggregator": {
"types": "./dist/src/filecoin/aggregator.d.ts",
"import": "./src/filecoin/aggregator.js"
},
"./filecoin/deal-tracker": {
"types": "./dist/src/filecoin/deal-tracker.d.ts",
"import": "./src/filecoin/deal-tracker.js"
},
"./filecoin/dealer": {
"types": "./dist/src/filecoin/dealer.d.ts",
"import": "./src/filecoin/dealer.js"
},
"./types": "./dist/src/types.d.ts"
},
"typesVersions": {
Expand Down
4 changes: 4 additions & 0 deletions packages/capabilities/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ import * as Types from '@web3-storage/capabilities/types'
import * as Upload from '@web3-storage/capabilities/upload'
import * as Utils from '@web3-storage/capabilities/utils'
import * as Voucher from '@web3-storage/capabilities/voucher'
import * as Filecoin from '@web3-storage/capabilities/filecoin'
import * as Aggregator from '@web3-storage/capabilities/filecoin/aggregator'
import * as DealTracker from '@web3-storage/capabilities/filecoin/deal-tracker'
import * as Dealer from '@web3-storage/capabilities/filecoin/dealer'

// This package has a "main" entrypoint but we recommend the usage of the specific imports above
```
Expand Down
271 changes: 0 additions & 271 deletions packages/capabilities/src/filecoin.js

This file was deleted.

76 changes: 76 additions & 0 deletions packages/capabilities/src/filecoin/aggregator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* Filecoin Aggregator Capabilities
*
* These can be imported directly with:
* ```js
* import * as Aggregator from '@web3-storage/capabilities/filecoin/aggregator'
* ```
*
* @module
*/

import { capability, Schema, ok } from '@ucanto/validator'
import { PieceLink } from './lib.js'
import { equal, equalWith, checkLink, and } from '../utils.js'

/**
* Capability that allows a Storefront to request that a piece be aggregated
* for inclusion in an upcoming an Filecoin deal.
*/
export const pieceOffer = capability({
can: 'piece/offer',
/**
* DID of an authorized Storefront.
*/
with: Schema.did(),
nb: Schema.struct({
/**
* CID of the piece.
*/
piece: PieceLink,
/**
* Grouping of joining segments into an aggregate.
*/
group: Schema.text(),
}),
derives: (claim, from) => {
return (
and(equalWith(claim, from)) ||
and(checkLink(claim.nb.piece, from.nb.piece, 'nb.piece')) ||
and(equal(claim.nb.group, from.nb.group, 'nb.group')) ||
ok({})
)
},
})

/**
* Capability that allows an Aggregator to signal a piece has been accepted
* or rejected for inclusion in an aggregate.
*/
export const pieceAccept = capability({
can: 'piece/accept',
/**
* DID of the Aggregator.
*/
with: Schema.did(),
nb: Schema.struct({
/**
* CID of the piece.
*
* @see https://github.com/filecoin-project/FIPs/pull/758/files
*/
piece: PieceLink,
/**
* Grouping of joining segments into an aggregate.
*/
group: Schema.text(),
}),
derives: (claim, from) => {
return (
and(equalWith(claim, from)) ||
and(checkLink(claim.nb.piece, from.nb.piece, 'nb.piece')) ||
and(equal(claim.nb.group, from.nb.group, 'nb.group')) ||
ok({})
)
},
})
Loading

0 comments on commit c0b97bf

Please sign in to comment.