Skip to content

Commit

Permalink
chore(capabilities): top level filecoin cap (#1606)
Browse files Browse the repository at this point in the history
### Changes
- Added the Filecoin top-level capability.
- Updated w3up-client to use it instead of defining all of the filecoin
capabilities.

### Related Issues
Resolves: #1554
  • Loading branch information
fforbeck authored Dec 19, 2024
1 parent a0b48f8 commit 22d0bf9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/capabilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"scripts": {
"attw": "attw --pack .",
"lint": "tsc && eslint '**/*.{js,ts}' && prettier --check '**/*.{js,ts,yml,json}' --ignore-path ../../.gitignore",
"lint:fix": "tsc && eslint '**/*.{js,ts}' --fix && prettier --write '**/*.{js,ts,yml,json}' --ignore-path ../../.gitignore",
"build": "tsc --build",
"dev": "tsc --build --watch",
"check": "tsc --build",
Expand Down
1 change: 1 addition & 0 deletions packages/capabilities/src/filecoin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export {
filecoinSubmit as submit,
filecoinAccept as accept,
filecoinInfo as info,
filecoin as filecoin,
} from './storefront.js'
12 changes: 12 additions & 0 deletions packages/capabilities/src/filecoin/storefront.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ import { capability, Schema, ok } from '@ucanto/validator'
import { PieceLink } from './lib.js'
import { equalWith, checkLink, and } from '../utils.js'

/**
* Top-level capability for Filecoin operations.
*/
export const filecoin = capability({
can: 'filecoin/*',
/**
* DID of the space the content is stored in.
*/
with: Schema.did(),
derives: equalWith,
})

/**
* Capability allowing an agent to _request_ storing a content piece in
* Filecoin.
Expand Down
2 changes: 2 additions & 0 deletions packages/capabilities/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ export interface AdminStoreInspectSuccess {
}
export type AdminStoreInspectFailure = Ucanto.Failure
// Filecoin
export type Filecoin = InferInvokedCapability<typeof StorefrontCaps.filecoin>
export type FilecoinOffer = InferInvokedCapability<
typeof StorefrontCaps.filecoinOffer
>
Expand Down Expand Up @@ -921,6 +922,7 @@ export type ServiceAbilityArray = [
RateLimitAdd['can'],
RateLimitRemove['can'],
RateLimitList['can'],
Filecoin['can'],
FilecoinOffer['can'],
FilecoinSubmit['can'],
FilecoinAccept['can'],
Expand Down
5 changes: 1 addition & 4 deletions packages/w3up-client/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,7 @@ export class Client extends Base {
'upload/*',
'access/*',
'usage/*',
'filecoin/offer',
'filecoin/info',
'filecoin/accept',
'filecoin/submit',
'filecoin/*',
],
expiration: Infinity,
}
Expand Down

0 comments on commit 22d0bf9

Please sign in to comment.