From dff1e6254440de6f8fd55efead3c363a856d0b68 Mon Sep 17 00:00:00 2001 From: Felipe Forbeck Date: Wed, 18 Dec 2024 11:11:46 -0300 Subject: [PATCH] chore(capabilities): filecoin top level cap --- packages/capabilities/src/filecoin/index.js | 1 + packages/capabilities/src/filecoin/storefront.js | 12 ++++++++++++ packages/capabilities/src/types.ts | 2 ++ packages/w3up-client/src/client.js | 5 +---- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/capabilities/src/filecoin/index.js b/packages/capabilities/src/filecoin/index.js index 42d09f78c..00716be48 100644 --- a/packages/capabilities/src/filecoin/index.js +++ b/packages/capabilities/src/filecoin/index.js @@ -17,4 +17,5 @@ export { filecoinSubmit as submit, filecoinAccept as accept, filecoinInfo as info, + filecoin as filecoin, } from './storefront.js' diff --git a/packages/capabilities/src/filecoin/storefront.js b/packages/capabilities/src/filecoin/storefront.js index 01dfa4074..d8f1a9611 100644 --- a/packages/capabilities/src/filecoin/storefront.js +++ b/packages/capabilities/src/filecoin/storefront.js @@ -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. diff --git a/packages/capabilities/src/types.ts b/packages/capabilities/src/types.ts index 9e475c18d..673102420 100644 --- a/packages/capabilities/src/types.ts +++ b/packages/capabilities/src/types.ts @@ -812,6 +812,7 @@ export interface AdminStoreInspectSuccess { } export type AdminStoreInspectFailure = Ucanto.Failure // Filecoin +export type Filecoin = InferInvokedCapability export type FilecoinOffer = InferInvokedCapability< typeof StorefrontCaps.filecoinOffer > @@ -923,6 +924,7 @@ export type ServiceAbilityArray = [ RateLimitAdd['can'], RateLimitRemove['can'], RateLimitList['can'], + Filecoin['can'], FilecoinOffer['can'], FilecoinSubmit['can'], FilecoinAccept['can'], diff --git a/packages/w3up-client/src/client.js b/packages/w3up-client/src/client.js index 07909e3a4..d26ba9b91 100644 --- a/packages/w3up-client/src/client.js +++ b/packages/w3up-client/src/client.js @@ -324,10 +324,7 @@ export class Client extends Base { 'upload/*', 'access/*', 'usage/*', - 'filecoin/offer', - 'filecoin/info', - 'filecoin/accept', - 'filecoin/submit', + 'filecoin/*', ], expiration: Infinity, }