export type * from '../common/types.js'; export type * from './IExecConfig.js'; import IExecConfig from './IExecConfig.js'; import IExecModule from './IExecModule.js'; import { Address, BNish, Bytes, Bytes32, OrderHash, HumanSingleTag, Tag, } from '../common/types.js'; /** * published sell order for an app */ export interface PublishedApporder { orderHash: OrderHash; chainId: number; remaining: number; status: string; signer: Address; publicationTimestamp: string; order: { app: Address; appprice: number; volume: number; tag: Bytes32; datasetrestrict: Address; workerpoolrestrict: Address; requesterrestrict: Address; salt: Bytes32; sign: Bytes; }; } /** * published sell order for a dataset */ export interface PublishedDatasetorder { orderHash: OrderHash; chainId: number; remaining: number; status: string; signer: Address; publicationTimestamp: string; /** * true if the order allows bulk processing */ bulk?: boolean; order: { dataset: Address; datasetprice: number; volume: number; tag: Bytes32; apprestrict: Address; workerpoolrestrict: Address; requesterrestrict: Address; salt: Bytes32; sign: Bytes; }; } /** * published sell order for computing power */ export interface PublishedWorkerpoolorder { orderHash: OrderHash; chainId: number; remaining: number; status: string; signer: Address; publicationTimestamp: string; order: { workerpool: Address; workerpoolprice: number; volume: number; tag: Bytes32; category: number; trust: number; apprestrict: Address; datasetrestrict: Address; requesterrestrict: Address; salt: Bytes32; sign: Bytes; }; } /** * published buy order for computing tasks */ export interface PublishedRequestorder { orderHash: OrderHash; chainId: number; remaining: number; status: string; signer: Address; publicationTimestamp: string; order: { app: Address; appmaxprice: number; dataset: Address; datasetmaxprice: number; workerpool: Address; workerpoolmaxprice: number; volume: number; tag: Bytes32; category: number; trust: number; requester: Address; beneficiary: Address; callback: Address; params: string; salt: Bytes32; sign: Bytes; }; } export interface PaginableOrders { /** * order page (this may be a partial result) */ orders: OT[]; /** * total count */ count: number; /** * when a partial result is returned, `more()` can be called to get the next page. */ more?: () => Promise>; } /** * module exposing orderbook methods */ export default class IExecOrderbookModule extends IExecModule { /** * find the cheapest orders for the specified app. * * _NB_: use `options` to include restricted orders or filter results. * * example: * ```js * const { count, orders } = await fetchAppOrderbook(appAddress); * console.log('best order:', orders[0]?.order); * console.log('total orders:', count); * ``` */ fetchAppOrderbook(options: { /** * filter by app */ app?: Address | 'any'; /** * filter by app owner */ appOwner?: Address; /** * include orders restricted to specified dataset (use `'any'` to include any dataset) */ dataset?: Address | 'any'; /** * include orders restricted to specified workerpool (use `'any'` to include any workerpool) */ workerpool?: Address | 'any'; /** * include orders restricted to specified requester (use `'any'` to include any requester) */ requester?: Address | 'any'; /** * filter by minimum volume remaining */ minVolume?: BNish; /** * filter by minimum tag required */ minTag?: Tag | HumanSingleTag[]; /** * filter by maximum tag accepted */ maxTag?: Tag | HumanSingleTag[]; /** * index of the page to fetch */ page?: number; /** * size of the page to fetch */ pageSize?: number; /** * filters out orders allowing “any” dataset (default: `false`) */ isDatasetStrict?: boolean; /** * filters out orders allowing “any” requester (default: `false`) */ isRequesterStrict?: boolean; /** * filters out orders allowing “any” workerpool (default: `false`) */ isWorkerpoolStrict?: boolean; }): Promise>; /** * find the cheapest orders for the specified dataset. * * _NB_: use `options` to include restricted orders or filter results. * * example: * ```js * const { count, orders } = await fetchDatasetOrderbook(datasetAddress); * console.log('best order:', orders[0]?.order); * console.log('total orders:', count); * ``` */ fetchDatasetOrderbook(options: { /** * filter by dataset */ dataset?: Address | 'any'; /** * filter by dataset owner */ datasetOwner?: Address; /** * include orders restricted to specified app (use `'any'` to include any app) */ app?: Address | 'any'; /** * include orders restricted to specified workerpool (use `'any'` to include any workerpool) */ workerpool?: Address | 'any'; /** * include orders restricted to specified requester (use `'any'` to include any requester) */ requester?: Address | 'any'; /** * filter by minimum volume remaining */ minVolume?: BNish; /** * filter by minimum tag required */ minTag?: Tag | HumanSingleTag[]; /** * filter by maximum tag accepted */ maxTag?: Tag | HumanSingleTag[]; /** * index of the page to fetch */ page?: number; /** * size of the page to fetch */ pageSize?: number; /** * filters out orders allowing “any” app (default: `false`) */ isAppStrict?: boolean; /** * filters out orders allowing “any” requester (default: `false`) */ isRequesterStrict?: boolean; /** * filters out orders allowing “any” workerpool (default: `false`) */ isWorkerpoolStrict?: boolean; /** * filters out orders that don't allow bulk processing (default: `false`) */ bulkOnly?: boolean; }): Promise>; /** * find the cheapest orders for the specified computing resource. * * _NB_: use `options` to include restricted orders or filter results. * * example: * ```js * const { count, orders } = await fetchWorkerpoolOrderbook(); * console.log('best order:', orders[0]?.order); * console.log('total orders:', count); * ``` */ fetchWorkerpoolOrderbook(options?: { /** * filter by workerpool */ workerpool?: Address; /** * filter by workerpool owner */ workerpoolOwner?: Address; /** * filter by category */ category?: BNish; /** * include orders restricted to specified app (use `'any'` to include any app) */ app?: Address | 'any'; /** * include orders restricted to specified dataset (use `'any'` to include any dataset) */ dataset?: Address | 'any'; /** * include orders restricted to specified requester (use `'any'` to include any requester) */ requester?: Address | 'any'; /** * filter by minimum volume remaining */ minVolume?: BNish; /** * filter by minimum tag required */ minTag?: Tag | HumanSingleTag[]; /** * filter by maximum tag offered */ maxTag?: Tag | HumanSingleTag[]; /** * filter by minimum trust required */ minTrust?: BNish; /** * index of the page to fetch */ page?: number; /** * size of the page to fetch */ pageSize?: number; /** * filters out orders allowing “any” dataset (default: `false`) */ isDatasetStrict?: boolean; /** * filters out orders allowing “any” requester (default: `false`) */ isRequesterStrict?: boolean; /** * filters out orders allowing “any” app (default: `false`) */ isAppStrict?: boolean; }): Promise>; /** * find the best paying request orders for computing resource. * * _NB_: use `options` to include restricted orders or filter results. * * example: * ```js * const { count, orders } = await fetchRequestOrderbook(); * console.log('best order:', orders[0]?.order); * console.log('total orders:', count); * ``` */ fetchRequestOrderbook(options?: { /** * filter by requester */ requester?: Address; /** * filter by category */ category?: BNish; /** * filter by specified app */ app?: Address; /** * filter by specified dataset */ dataset?: Address; /** * include orders restricted to specified workerpool (use `'any'` to include any workerpool) */ workerpool?: Address | 'any'; /** * filter by minimum volume remaining */ minVolume?: BNish; /** * filter by minimum tag required */ minTag?: Tag | HumanSingleTag[]; /** * filter by maximum tag accepted */ maxTag?: Tag | HumanSingleTag[]; /** * filter by maximum trust required */ maxTrust?: BNish; /** * index of the page to fetch */ page?: number; /** * size of the page to fetch */ pageSize?: number; /** * filters out orders allowing “any” workerpool (default: `false`) */ isWorkerpoolStrict?: boolean; }): Promise>; /** * find a published apporder by orderHash. * * example: * ```js * const { order, remaining } = await fetchApporder(orderHash); * console.log('order:' order); * console.log('remaining volume:', remaining); * ``` */ fetchApporder(orderHash: OrderHash): Promise; /** * find a published datasetorder by orderHash. * * example: * ```js * const { order, remaining } = await fetchDatasetorder(orderHash); * console.log('order:' order); * console.log('remaining volume:', remaining); * ``` */ fetchDatasetorder(orderHash: OrderHash): Promise; /** * find a published workerpoolorder by orderHash. * * example: * ```js * const { order, remaining } = await fetchWorkerpoolorder(orderHash); * console.log('order:' order); * console.log('remaining volume:', remaining); * ``` */ fetchWorkerpoolorder(orderHash: OrderHash): Promise; /** * find a published requestorder by orderHash. * * example: * ```js * const { order, remaining } = await fetchRequestorder(orderHash); * console.log('order:' order); * console.log('remaining volume:', remaining); * ``` */ fetchRequestorder(orderHash: OrderHash): Promise; /** * Create an IExecOrderbookModule instance using an IExecConfig instance */ static fromConfig(config: IExecConfig): IExecOrderbookModule; }