Skip to content

Commit f50fbfc

Browse files
feat: add bulkOnly filter on dataset orderbook
1 parent 1e5dd97 commit f50fbfc

File tree

9 files changed

+80
-3
lines changed

9 files changed

+80
-3
lines changed

CLI.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,6 +1978,7 @@ Options:
19781978
| --app-strict | fetch orders created strictly for the specified app |
19791979
| --requester-strict | fetch orders created strictly for the specified requester |
19801980
| --workerpool-strict | fetch orders created strictly for the specified workerpool |
1981+
| --bulk-only | only include bulk orders |
19811982

19821983
#### iexec orderbook workerpool
19831984

docs/classes/IExecOrderbookModule.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ console.log('total orders:', count);
155155
| `datasetAddressOrOptions` | `string` \| { `app?`: `string` ; `dataset?`: `string` ; `datasetOwner?`: `string` ; `isAppStrict?`: `boolean` ; `isRequesterStrict?`: `boolean` ; `isWorkerpoolStrict?`: `boolean` ; `maxTag?`: [`Tag`](../modules.md#tag) \| `string`[] ; `minTag?`: [`Tag`](../modules.md#tag) \| `string`[] ; `minVolume?`: [`BNish`](../modules.md#bnish) ; `page?`: `number` ; `pageSize?`: `number` ; `requester?`: `string` ; `workerpool?`: `string` } | - |
156156
| `options?` | `Object` | **`Deprecated`** use first parameter instead migration: replace `fetchDatasetOrderbook(datasetAddress, options)` by `fetchDatasetOrderbook({ dataset: datasetAddress, ...options })` |
157157
| `options.app?` | `string` | include orders restricted to specified app (use `'any'` to include any app) |
158+
| `options.bulkOnly?` | `boolean` | filters out orders that don't allow bulk processing (default: `false`) |
158159
| `options.isAppStrict?` | `boolean` | filters out orders allowing “any” app (default: `false`) |
159160
| `options.isRequesterStrict?` | `boolean` | filters out orders allowing “any” requester (default: `false`) |
160161
| `options.isWorkerpoolStrict?` | `boolean` | filters out orders allowing “any” workerpool (default: `false`) |

docs/interfaces/internal_.PublishedDatasetorder.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ published sell order for a dataset
1010

1111
### Properties
1212

13+
- [bulk](internal_.PublishedDatasetorder.md#bulk)
1314
- [chainId](internal_.PublishedDatasetorder.md#chainid)
1415
- [order](internal_.PublishedDatasetorder.md#order)
1516
- [orderHash](internal_.PublishedDatasetorder.md#orderhash)
@@ -20,6 +21,14 @@ published sell order for a dataset
2021

2122
## Properties
2223

24+
### bulk
25+
26+
`Optional` **bulk**: `boolean`
27+
28+
true if the order allows bulk processing
29+
30+
___
31+
2332
### chainId
2433

2534
**chainId**: `number`

src/cli/cmd/iexec-orderbook.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ orderbookDataset
155155
.option(...option.isAppStrict())
156156
.option(...option.isRequesterStrict())
157157
.option(...option.isWorkerpoolStrict())
158+
.option(...option.bulkOnly())
158159
.description(desc.showObj('dataset orderbook', 'marketplace'))
159160
.action(async (dataset, opts) => {
160161
await checkUpdate(opts);
@@ -175,8 +176,8 @@ orderbookDataset
175176
isAppStrict,
176177
isRequesterStrict,
177178
isWorkerpoolStrict,
179+
bulkOnly,
178180
} = opts;
179-
180181
const request = fetchDatasetOrderbook(
181182
chain.contracts,
182183
getPropertyFormChain(chain, 'iexecGateway'),
@@ -191,6 +192,7 @@ orderbookDataset
191192
isAppStrict,
192193
isRequesterStrict,
193194
isWorkerpoolStrict,
195+
bulkOnly,
194196
},
195197
);
196198
const fetchMessage = info.showing(objName);
@@ -205,6 +207,7 @@ orderbookDataset
205207
apprestrict: e.order.apprestrict,
206208
workerpoolrestrict: e.order.workerpoolrestrict,
207209
requesterrestrict: e.order.requesterrestrict,
210+
bulk: e.bulk,
208211
}))
209212
: [];
210213
const createResultsMessage = (
@@ -219,6 +222,7 @@ orderbookDataset
219222
orderHash: e.orderHash,
220223
price: e.price,
221224
remaining: e.remaining,
225+
...(e.bulk && { bulk: e.bulk }),
222226
...(e.tag !== NULL_BYTES32 && { tag: e.tag }),
223227
...(e.apprestrict !== NULL_ADDRESS && {
224228
apprestrict: e.apprestrict,

src/cli/utils/cli-helper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ export const option = {
312312
minVolume: () => ['--min-volume <integer>', 'specify minimum volume'],
313313
minTrust: () => ['--min-trust <integer>', 'specify minimum trust'],
314314
maxTrust: () => ['--max-trust <integer>', 'specify maximum trust'],
315+
bulkOnly: () => ['--bulk-only', 'only include bulk orders'],
315316
password: () => [
316317
'--password <password>',
317318
'password used to encrypt the wallet (unsafe)',

src/common/market/orderbook.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export const fetchDatasetOrderbook = async (
181181
let isAppStrict;
182182
let isWorkerpoolStrict;
183183
let isRequesterStrict;
184+
let bulkOnly;
184185
if (typeof datasetOrOptions === 'object' && datasetOrOptions !== null) {
185186
({
186187
dataset,
@@ -196,6 +197,7 @@ export const fetchDatasetOrderbook = async (
196197
isAppStrict = false,
197198
isWorkerpoolStrict = false,
198199
isRequesterStrict = false,
200+
bulkOnly = false,
199201
} = datasetOrOptions);
200202
} else {
201203
// deprecated
@@ -216,6 +218,7 @@ export const fetchDatasetOrderbook = async (
216218
isAppStrict = false,
217219
isWorkerpoolStrict = false,
218220
isRequesterStrict = false,
221+
bulkOnly = false,
219222
} = options || {});
220223
}
221224
if (!dataset && !datasetOwner) {
@@ -279,6 +282,7 @@ export const fetchDatasetOrderbook = async (
279282
...(maxTag !== undefined && {
280283
maxTag: await tagSchema().label('maxTag').validate(maxTag),
281284
}),
285+
bulkOnly: await booleanSchema().label('bulkOnly').validate(bulkOnly),
282286
...(page !== undefined && {
283287
pageIndex: await positiveIntSchema().label('page').validate(page),
284288
}),

src/lib/IExecOrderbookModule.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export interface PublishedDatasetorder {
4747
status: string;
4848
signer: Address;
4949
publicationTimestamp: string;
50+
/**
51+
* true if the order allows bulk processing
52+
*/
53+
bulk?: boolean;
5054
order: {
5155
dataset: Address;
5256
datasetprice: number;
@@ -379,6 +383,10 @@ export default class IExecOrderbookModule extends IExecModule {
379383
* filters out orders allowing “any” workerpool (default: `false`)
380384
*/
381385
isWorkerpoolStrict?: boolean;
386+
/**
387+
* filters out orders that don't allow bulk processing (default: `false`)
388+
*/
389+
bulkOnly?: boolean;
382390
},
383391
): Promise<PaginableOrders<PublishedDatasetorder>>;
384392
/**

test/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ services:
244244
condition: service_started
245245

246246
market-api:
247-
image: iexechub/iexec-market-api:7.0.0
247+
image: iexechub/iexec-market-api:7.0.0-feat-bulk-order-filter-cae060a
248248
restart: unless-stopped
249249
ports:
250250
- 3000:3000

test/lib/e2e/IExecOrderbookModule.test.js

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import {
1717
SERVICE_HTTP_500_URL,
1818
getRandomBytes32,
1919
} from '../../test-utils.js';
20-
import '../../jest-setup.js';
20+
import { DATASET_INFINITE_VOLUME } from '../../../src/common/utils/constant.js';
2121
import { errors } from '../../../src/lib/index.js';
22+
import '../../jest-setup.js';
2223

2324
const { MarketCallError } = errors;
2425

@@ -598,6 +599,7 @@ describe('orderbook', () => {
598599
);
599600
expect(res1.orders).toLooseEqual(res1deprecated.orders);
600601
});
602+
601603
test('datasetOwner returns orders from dataset owner', async () => {
602604
const { iexec: iexecUser, wallet } = getTestConfig(iexecTestChain)();
603605
const { iexec: iexecOtherUser } = getTestConfig(iexecTestChain)();
@@ -815,6 +817,53 @@ describe('orderbook', () => {
815817
expect(strictAppOrders.count).toBe(0);
816818
expect(strictAppOrders.orders.length).toBe(0);
817819
});
820+
821+
test('bulkOnly option allow filtering only orders allowing dataset bulk processing', async () => {
822+
const { iexec } = getTestConfig(iexecTestChain)();
823+
const { iexec: iexecReadOnly } = getTestConfig(iexecTestChain)({
824+
readOnly: true,
825+
});
826+
// 1 and 2: orders without any restrictions
827+
const datasetOrderTemplate = await deployAndGetDatasetorder(iexec);
828+
const datasetAddress = datasetOrderTemplate.dataset;
829+
830+
await iexec.order
831+
.signDatasetorder(datasetOrderTemplate, { preflightCheck: false })
832+
.then((o) =>
833+
iexec.order.publishDatasetorder(o, { preflightCheck: false }),
834+
);
835+
await iexec.order
836+
.signDatasetorder(
837+
{
838+
...datasetOrderTemplate,
839+
datasetprice: 0,
840+
volume: DATASET_INFINITE_VOLUME,
841+
},
842+
{ preflightCheck: false },
843+
)
844+
.then((o) =>
845+
iexec.order.publishDatasetorder(o, { preflightCheck: false }),
846+
);
847+
848+
const allOrders = await iexecReadOnly.orderbook.fetchDatasetOrderbook({
849+
dataset: datasetAddress,
850+
});
851+
expect(allOrders.count).toBe(2);
852+
expect(allOrders.orders.length).toBe(2);
853+
854+
const bulkOnlyOrders =
855+
await iexecReadOnly.orderbook.fetchDatasetOrderbook({
856+
dataset: datasetAddress,
857+
bulkOnly: true,
858+
});
859+
expect(bulkOnlyOrders.count).toBe(1);
860+
expect(bulkOnlyOrders.orders.length).toBe(1);
861+
expect(bulkOnlyOrders.orders[0].order.datasetprice).toBe(0);
862+
expect(bulkOnlyOrders.orders[0].order.volume).toBe(
863+
DATASET_INFINITE_VOLUME,
864+
);
865+
expect(bulkOnlyOrders.orders[0].bulk).toBe(true);
866+
});
818867
});
819868

820869
describe('fetchWorkerpoolOrderbook()', () => {

0 commit comments

Comments
 (0)