Skip to content

Commit af607b6

Browse files
refactor: use bulkOnly filter on fetchDatasetOrderbook
1 parent 8943a3e commit af607b6

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

packages/sdk/src/lib/dataProtectorCore/getGrantedAccess.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { utils } from 'iexec';
21
import { WorkflowError, handleIfProtocolError } from '../../utils/errors.js';
32
import { formatGrantedAccess } from '../../utils/formatGrantedAccess.js';
43
import {
@@ -51,18 +50,11 @@ export const getGrantedAccess = async ({
5150
isAppStrict: true,
5251
page: vPage,
5352
pageSize: vPageSize,
53+
bulkOnly: vBulkOnly,
5454
});
55-
let grantedAccess = orders?.map((order) =>
55+
const grantedAccess = orders?.map((order) =>
5656
formatGrantedAccess(order.order, order.remaining)
5757
);
58-
59-
// Filter for bulk orders if bulkOnly is true
60-
if (vBulkOnly && grantedAccess) {
61-
grantedAccess = grantedAccess.filter(
62-
(access) => access.volume === utils.DATASET_INFINITE_VOLUME.toString()
63-
);
64-
}
65-
6658
return { count, grantedAccess };
6759
} catch (e) {
6860
handleIfProtocolError(e);

packages/sdk/tests/unit/dataProtectorCore/getGrantedAccess.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ describe('getGrantedAccess', () => {
125125
pageSize: 10,
126126
isRequesterStrict: true,
127127
isAppStrict: true,
128+
bulkOnly: false,
128129
});
129130
});
130131
});
@@ -242,6 +243,7 @@ describe('getGrantedAccess', () => {
242243
pageSize: undefined,
243244
isRequesterStrict: false,
244245
isAppStrict: true,
246+
bulkOnly: false,
245247
});
246248

247249
expect(grantedAccessResult.count).toBe(1);

0 commit comments

Comments
 (0)