From 202a0fdc2b657363263d714d1bd23457865d70f1 Mon Sep 17 00:00:00 2001 From: Felipe Forbeck Date: Wed, 18 Dec 2024 10:48:07 -0300 Subject: [PATCH 1/3] chore(capabilities): top level filecoin cap --- packages/capabilities/src/filecoin/index.js | 1 + packages/capabilities/src/filecoin/storefront.js | 12 ++++++++++++ packages/capabilities/src/types.ts | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/packages/capabilities/src/filecoin/index.js b/packages/capabilities/src/filecoin/index.js index aee774398..4449c58e4 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 53f0cc4b3..84d09e3ad 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 354665924..e3af88f0e 100644 --- a/packages/capabilities/src/types.ts +++ b/packages/capabilities/src/types.ts @@ -808,6 +808,9 @@ export interface AdminStoreInspectSuccess { } export type AdminStoreInspectFailure = Ucanto.Failure // Filecoin +export type Filecoin = InferInvokedCapability< + typeof StorefrontCaps.filecoin +> export type FilecoinOffer = InferInvokedCapability< typeof StorefrontCaps.filecoinOffer > @@ -921,6 +924,7 @@ export type ServiceAbilityArray = [ RateLimitAdd['can'], RateLimitRemove['can'], RateLimitList['can'], + Filecoin['can'], FilecoinOffer['can'], FilecoinSubmit['can'], FilecoinAccept['can'], From 9ea0f7e8cf5c21b4fb8dfcb54628d87a0c0ac4b4 Mon Sep 17 00:00:00 2001 From: Felipe Forbeck Date: Wed, 18 Dec 2024 10:51:27 -0300 Subject: [PATCH 2/3] chore(w3up-client): use filecoin top cap --- packages/w3up-client/src/client.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/w3up-client/src/client.js b/packages/w3up-client/src/client.js index 096dcdbce..b24c5ac2c 100644 --- a/packages/w3up-client/src/client.js +++ b/packages/w3up-client/src/client.js @@ -354,10 +354,7 @@ export class Client extends Base { 'upload/*', 'access/*', 'usage/*', - 'filecoin/offer', - 'filecoin/info', - 'filecoin/accept', - 'filecoin/submit', + 'filecoin/*', ], expiration: Infinity, } From bdd69a9f38c0c2749a5a1739f8ece657fd3b21fd Mon Sep 17 00:00:00 2001 From: Felipe Forbeck Date: Wed, 18 Dec 2024 11:07:48 -0300 Subject: [PATCH 3/3] fix lint --- packages/capabilities/package.json | 1 + packages/capabilities/src/types.ts | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/capabilities/package.json b/packages/capabilities/package.json index b616448dd..4babc0271 100644 --- a/packages/capabilities/package.json +++ b/packages/capabilities/package.json @@ -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", diff --git a/packages/capabilities/src/types.ts b/packages/capabilities/src/types.ts index e3af88f0e..810243338 100644 --- a/packages/capabilities/src/types.ts +++ b/packages/capabilities/src/types.ts @@ -808,9 +808,7 @@ export interface AdminStoreInspectSuccess { } export type AdminStoreInspectFailure = Ucanto.Failure // Filecoin -export type Filecoin = InferInvokedCapability< - typeof StorefrontCaps.filecoin -> +export type Filecoin = InferInvokedCapability export type FilecoinOffer = InferInvokedCapability< typeof StorefrontCaps.filecoinOffer >