diff --git a/packages/capabilities/src/types.ts b/packages/capabilities/src/types.ts index d6c58dab6..2c17f5d11 100644 --- a/packages/capabilities/src/types.ts +++ b/packages/capabilities/src/types.ts @@ -320,10 +320,23 @@ export interface ProofNotFound extends Ucanto.Failure { export interface FilecoinInfoSuccess { piece: PieceLink + aggregates: FilecoinInfoAcceptedAggregate[] deals: FilecoinInfoAcceptedDeal[] } + +export interface FilecoinInfoAcceptedAggregate { + /** + * Aggregate piece CID. + */ + aggregate: PieceLink + /** + * Proof the piece is included in the aggregate. + */ + inclusion: InclusionProof +} + export interface FilecoinInfoAcceptedDeal - extends DataAggregationProof, + extends Omit, DealDetails { aggregate: PieceLink } diff --git a/packages/filecoin-api/src/storefront/events.js b/packages/filecoin-api/src/storefront/events.js index 1a3f65bc1..488320d18 100644 --- a/packages/filecoin-api/src/storefront/events.js +++ b/packages/filecoin-api/src/storefront/events.js @@ -148,10 +148,9 @@ export const handleCronTick = async (context) => { pieceStore: context.pieceStore, taskStore: context.taskStore, receiptStore: context.receiptStore, - }) - , + }), { - concurrency: 20 + concurrency: 20, } ) diff --git a/packages/filecoin-api/src/storefront/service.js b/packages/filecoin-api/src/storefront/service.js index 5f93a6177..b4b5c3036 100644 --- a/packages/filecoin-api/src/storefront/service.js +++ b/packages/filecoin-api/src/storefront/service.js @@ -270,6 +270,7 @@ export const filecoinInfo = async ({ capability }, context) => { /** @type {API.UcantoInterface.OkBuilder} */ const processingResult = Server.ok({ piece, + aggregates: [], deals: [], }) return processingResult @@ -287,27 +288,21 @@ export const filecoinInfo = async ({ capability }, context) => { ) if (info.out.error) { - return { - error: info.out.error, - } + return info.out } const deals = Object.entries(info.out.ok.deals || {}) - if (!deals.length) { - // Should not happen if there is `piece/accept` receipt - return { - error: new Server.Failure( - `no deals were obtained for aggregate ${pieceAcceptOut.aggregate} where piece ${piece} is included` - ), - } - } - /** @type {API.UcantoInterface.OkBuilder} */ const result = Server.ok({ piece, + aggregates: [ + { + aggregate: pieceAcceptOut.aggregate, + inclusion: pieceAcceptOut.inclusion, + }, + ], deals: deals.map(([dealId, dealDetails]) => ({ aggregate: pieceAcceptOut.aggregate, provider: dealDetails.provider, - inclusion: pieceAcceptOut.inclusion, aux: { dataType: 0n, dataSource: { diff --git a/packages/filecoin-api/test/events/aggregator.js b/packages/filecoin-api/test/events/aggregator.js index 4e092cb03..c15844c59 100644 --- a/packages/filecoin-api/test/events/aggregator.js +++ b/packages/filecoin-api/test/events/aggregator.js @@ -738,7 +738,7 @@ export const test = { minPieceInsertedAt: new Date().toISOString(), } const putAggregateRes = await context.aggregateStore.put( - aggregateRecord, + aggregateRecord ) assert.ok(putAggregateRes.ok) diff --git a/packages/filecoin-api/test/services/storefront.js b/packages/filecoin-api/test/services/storefront.js index fdc9c7c24..6f7b938ac 100644 --- a/packages/filecoin-api/test/services/storefront.js +++ b/packages/filecoin-api/test/services/storefront.js @@ -552,8 +552,11 @@ export const test = { BigInt(response.out.ok.deals[0].aux.dataSource.dealID), dealMetadata.dataSource.dealID ) - assert.ok(response.out.ok.deals[0].inclusion.index) - assert.ok(response.out.ok.deals[0].inclusion.subtree) + const respAggregate = response.out.ok.aggregates.find((a) => + a.aggregate.equals(aggregate.link) + ) + assert.ok(respAggregate?.inclusion.index) + assert.ok(respAggregate?.inclusion.subtree) }, async (context) => { /** diff --git a/packages/filecoin-client/test/storefront.test.js b/packages/filecoin-client/test/storefront.test.js index 557ed0507..927bdc02f 100644 --- a/packages/filecoin-client/test/storefront.test.js +++ b/packages/filecoin-client/test/storefront.test.js @@ -290,6 +290,7 @@ describe('storefront', () => { return Server.ok({ piece, + aggregates: [], deals: [], }) }, diff --git a/packages/w3up-client/test/capability/filecoin.test.js b/packages/w3up-client/test/capability/filecoin.test.js index 53427c4fc..8fe283aba 100644 --- a/packages/w3up-client/test/capability/filecoin.test.js +++ b/packages/w3up-client/test/capability/filecoin.test.js @@ -99,14 +99,19 @@ describe('FilecoinClient', () => { /** @type {import('@web3-storage/capabilities/types').FilecoinInfoSuccess} */ const filecoinAcceptResponse = { piece: cargo.link, - deals: [ + aggregates: [ { aggregate: aggregate.link, - provider: 'f1111', inclusion: { subtree: proof.ok[0], index: proof.ok[1], }, + }, + ], + deals: [ + { + aggregate: aggregate.link, + provider: 'f1111', aux: { dataType: 0n, dataSource: { @@ -153,7 +158,7 @@ describe('FilecoinClient', () => { assert(res.out.ok.deals[0].aggregate.equals(aggregate.link)) assert(res.out.ok.deals[0].aux.dataSource.dealID) assert(res.out.ok.deals[0].provider) - assert.deepEqual(res.out.ok.deals[0].inclusion, { + assert.deepEqual(res.out.ok.aggregates[0].inclusion, { subtree: proof.ok[0], index: proof.ok[1], })