Skip to content

Commit

Permalink
chore: address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Jul 6, 2023
1 parent 7344322 commit 21c06f3
Show file tree
Hide file tree
Showing 3 changed files with 853 additions and 846 deletions.
8 changes: 4 additions & 4 deletions packages/aggregate-api/src/aggregate/offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const claim = async (
// Get offer block
const offerCid = capability.nb.offer
const piece = capability.nb.piece
const offers = getOfferBlock(offerCid, invocation)
const offers = getOfferBlock(offerCid, invocation.iterateIPLDBlocks())

if (!offers) {
return {
Expand Down Expand Up @@ -84,10 +84,10 @@ export const claim = async (

/**
* @param {Server.API.Link<unknown, number, number, 0 | 1>} offerCid
* @param {Server.API.Invocation<Server.API.Capability<"aggregate/offer", `did:${string}:${string}` & `did:${string}` & Server.API.Phantom<{ protocol: "did:"; }> & `${string}:${string}` & Server.API.Phantom<{ protocol: `${string}:`; }>, Pick<{ offer: Server.API.Link<unknown, number, number, 0 | 1>; piece: Server.Schema.InferStruct<{ link: Server.Schema.Schema<Server.API.Link<unknown, number, number, 0 | 1>, any>; size: Server.Schema.NumberSchema<number & Server.API.Phantom<{ typeof: "integer"; }>, unknown>; }>; }, "offer" | "piece"> & Partial<Pick<{ offer: Server.API.Link<unknown, number, number, 0 | 1>; piece: Server.Schema.InferStruct<{ link: Server.Schema.Schema<Server.API.Link<unknown, number, number, 0 | 1>, any>; size: Server.Schema.NumberSchema<number & Server.API.Phantom<{ typeof: "integer"; }>, unknown>; }>; }, never>>>>} invocation
* @param {IterableIterator<Server.API.Transport.Block<unknown, number, number, 1>>} blockIterator
*/
function getOfferBlock(offerCid, invocation) {
for (const block of invocation.iterateIPLDBlocks()) {
function getOfferBlock(offerCid, blockIterator) {
for (const block of blockIterator) {
if (block.cid.equals(offerCid)) {
const decoded =
/** @type {import('@web3-storage/aggregate-client/types').Piece[]} */ (
Expand Down
2 changes: 1 addition & 1 deletion packages/aggregate-client/src/aggregate.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function aggregateOffer(
* Get details of an aggregate.
*
* @param {import('./types').InvocationConfig} conf - Configuration
* @param {import('@ucanto/interface').Link<unknown, number, number, 0 | 1>} subject
* @param {import('@ucanto/interface').UnknownLink} subject
* @param {import('./types').RequestOptions} [options]
*/
export async function aggregateGet(
Expand Down
Loading

0 comments on commit 21c06f3

Please sign in to comment.