Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6fd2e6f
feat: add bulk order support to grantAccess
SeddikBellamine Oct 16, 2025
22bb425
feat: add processBulkRequest for bulk data processing
SeddikBellamine Oct 16, 2025
e7b3ce8
feat: add ProcessBulkRequest types and update GrantAccess types
SeddikBellamine Oct 16, 2025
042f4ca
test: add unit tests for processBulkRequest
SeddikBellamine Oct 16, 2025
92317e6
chore: update dependencies and test configurations
SeddikBellamine Oct 16, 2025
07c2644
fix: remove pricePerAccess parameter from createBulkOrder call
SeddikBellamine Oct 16, 2025
fb9f2b2
fix: correct pushRequesterSecret mock return type in tests
SeddikBellamine Oct 16, 2025
7a3e762
style: format processBulkRequest test file
SeddikBellamine Oct 16, 2025
7d371f0
refactor: use bulkOnly filter on fetchDatasetOrderbook
PierreJeanjacquot Oct 20, 2025
1915e31
refactor: remove debug log
PierreJeanjacquot Oct 20, 2025
ca41a56
refactor: merge grantAccess standard and bulk workflows
PierreJeanjacquot Oct 20, 2025
018a45a
fix: use effective deal volume instead of estimated
PierreJeanjacquot Oct 20, 2025
9b081c9
refactor: use SCONE_TAG const
PierreJeanjacquot Oct 22, 2025
a57e48d
refactor: split processBulkRequest in 2 methods
PierreJeanjacquot Oct 23, 2025
6906514
test: update tests
PierreJeanjacquot Oct 23, 2025
5ab1aad
fix: lint
PierreJeanjacquot Oct 23, 2025
1970325
test: update unit test
PierreJeanjacquot Oct 23, 2025
b460f90
refactor: change processBulkRequest response for consumer convenience
PierreJeanjacquot Oct 23, 2025
777065f
chore: use iexec fixed version
PierreJeanjacquot Oct 27, 2025
1938c77
fix: pass ipfsNodeURL to iexec instance
PierreJeanjacquot Oct 28, 2025
460396e
feat: add waitForResult option to processBulkRequest
PierreJeanjacquot Oct 28, 2025
9140a6b
fix: maxProtectedDataPerTask is optional
PierreJeanjacquot Oct 29, 2025
1bd0b75
chore: update ProcessBulkRequestStatuses
PierreJeanjacquot Oct 29, 2025
9e0c699
refactor: update processBulkRequest status titles
PierreJeanjacquot Oct 29, 2025
e4ca552
refactor: rename bulkOrders to bulkAccesses
PierreJeanjacquot Oct 29, 2025
7c71470
chore: update unit tests
PierreJeanjacquot Oct 29, 2025
1490ebe
chore: update iexec dep
PierreJeanjacquot Oct 29, 2025
142131b
chore: update iexec dep
PierreJeanjacquot Oct 30, 2025
285f95c
chore: update iexec
PierreJeanjacquot Nov 3, 2025
a4f6fc1
chore: update kubo-rpc-client to dedup deps
PierreJeanjacquot Nov 3, 2025
9673f36
chore: fix default syntax
PierreJeanjacquot Nov 3, 2025
27243d8
feat: enhance bulkRequest validation message
PierreJeanjacquot Nov 3, 2025
ed47ca9
refactor: merge imports
PierreJeanjacquot Nov 3, 2025
d870c2e
fix: use validation error
PierreJeanjacquot Nov 3, 2025
88812ff
fix: add missing defaultWorkerpool in test
PierreJeanjacquot Nov 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
444 changes: 296 additions & 148 deletions packages/sdk/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
"debug": "^4.3.4",
"ethers": "^6.13.2",
"graphql-request": "^6.0.0",
"iexec": "^8.20.0",
"iexec": "^8.22.0",
"jszip": "^3.7.1",
"kubo-rpc-client": "^4.1.1",
"kubo-rpc-client": "^5.4.1",
"magic-bytes.js": "^1.0.15",
"typechain": "^8.3.2",
"yup": "^1.0.2"
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/lib/IExecDataProtectorModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ abstract class IExecDataProtectorModule {
{ ethProvider: this.ethProvider },
{
ipfsGatewayURL: ipfsGateway,
ipfsNodeURL: ipfsNode,
...this.options?.iexecOptions,
allowExperimentalNetworks: this.options.allowExperimentalNetworks,
}
Expand Down
29 changes: 29 additions & 0 deletions packages/sdk/src/lib/dataProtectorCore/IExecDataProtectorCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
GrantedAccessResponse,
ProcessProtectedDataParams,
ProcessProtectedDataResponse,
ProcessBulkRequestParams,
ProcessBulkRequestResponse,
ProtectDataParams,
ProtectedData,
GetResultFromCompletedTaskParams,
Expand All @@ -19,11 +21,15 @@ import {
TransferResponse,
WaitForTaskCompletionResponse,
WaitForTaskCompletionParams,
PrepareBulkRequestParams,
PrepareBulkRequestResponse,
} from '../types/index.js';
import { getGrantedAccess } from './getGrantedAccess.js';
import { getProtectedData } from './getProtectedData.js';
import { getResultFromCompletedTask } from './getResultFromCompletedTask.js';
import { grantAccess } from './grantAccess.js';
import { prepareBulkRequest } from './prepareBulkRequest.js';
import { processBulkRequest } from './processBulkRequest.js';
import { processProtectedData } from './processProtectedData.js';
import { protectData } from './protectData.js';
import { revokeAllAccess } from './revokeAllAccess.js';
Expand Down Expand Up @@ -83,6 +89,29 @@ class IExecDataProtectorCore extends IExecDataProtectorModule {
});
}

async prepareBulkRequest(
args: PrepareBulkRequestParams
): Promise<PrepareBulkRequestResponse> {
await this.init();
await isValidProvider(this.iexec);
return prepareBulkRequest({
...args,
iexec: this.iexec,
});
}

async processBulkRequest<Params extends ProcessBulkRequestParams>(
args: Params
): Promise<ProcessBulkRequestResponse<Params>> {
await this.init();
await isValidProvider(this.iexec);
return processBulkRequest({
...args,
iexec: this.iexec,
defaultWorkerpool: this.defaultWorkerpool,
});
}

// ----- READ METHODS -----
async getProtectedData(
args?: GetProtectedDataParams
Expand Down
3 changes: 3 additions & 0 deletions packages/sdk/src/lib/dataProtectorCore/getGrantedAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const getGrantedAccess = async ({
isUserStrict = false,
page,
pageSize,
bulkOnly = false,
}: IExecConsumer & GetGrantedAccessParams): Promise<GrantedAccessResponse> => {
const vProtectedData = addressOrEnsSchema()
.label('protectedData')
Expand All @@ -38,6 +39,7 @@ export const getGrantedAccess = async ({
const vPageSize = numberBetweenSchema(10, 1000)
.label('pageSize')
.validateSync(pageSize);
const vBulkOnly = booleanSchema().label('bulkOnly').validateSync(bulkOnly);

try {
const { count, orders } = await iexec.orderbook.fetchDatasetOrderbook({
Expand All @@ -48,6 +50,7 @@ export const getGrantedAccess = async ({
isAppStrict: true,
page: vPage,
pageSize: vPageSize,
bulkOnly: vBulkOnly,
});
const grantedAccess = orders?.map((order) =>
formatGrantedAccess(order.order, order.remaining)
Expand Down
34 changes: 30 additions & 4 deletions packages/sdk/src/lib/dataProtectorCore/grantAccess.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ZeroAddress } from 'ethers';
import { NULL_ADDRESS } from 'iexec/utils';
import { DATASET_INFINITE_VOLUME, NULL_ADDRESS } from 'iexec/utils';
import {
ValidationError,
WorkflowError,
Expand All @@ -9,6 +9,7 @@ import {
import { formatGrantedAccess } from '../../utils/formatGrantedAccess.js';
import {
addressOrEnsSchema,
booleanSchema,
isEnsTest,
positiveIntegerStringSchema,
positiveStrictIntegerStringSchema,
Expand Down Expand Up @@ -47,8 +48,9 @@ export const grantAccess = async ({
protectedData,
authorizedApp,
authorizedUser,
pricePerAccess,
pricePerAccess = 0,
numberOfAccess,
allowBulk = false,
onStatusUpdate = () => {},
}: IExecConsumer & GrantAccessParams): Promise<GrantedAccess> => {
const vProtectedData = addressOrEnsSchema()
Expand All @@ -62,17 +64,37 @@ export const grantAccess = async ({
const vAuthorizedUser = addressOrEnsSchema()
.label('authorizedUser')
.validateSync(authorizedUser);
const vPricePerAccess = positiveIntegerStringSchema()
let vPricePerAccess = positiveIntegerStringSchema()
.label('pricePerAccess')
.validateSync(pricePerAccess);
const vNumberOfAccess = positiveStrictIntegerStringSchema()
let vNumberOfAccess = positiveStrictIntegerStringSchema()
.label('numberOfAccess')
.validateSync(numberOfAccess);
const vAllowBulk = booleanSchema().label('allowBulk').validateSync(allowBulk);
const vOnStatusUpdate =
validateOnStatusUpdateCallback<OnStatusUpdateFn<GrantAccessStatuses>>(
onStatusUpdate
);

// Validate consistency between allowBulk, pricePerAccess and numberOfAccess
if (vAllowBulk) {
if (vPricePerAccess && vPricePerAccess !== '0') {
throw new ValidationError(
'allowBulk requires pricePerAccess to be 0 or undefined'
);
}
vPricePerAccess = '0';
if (
vNumberOfAccess &&
vNumberOfAccess !== DATASET_INFINITE_VOLUME.toString()
) {
throw new ValidationError(
`allowBulk requires numberOfAccess to be ${DATASET_INFINITE_VOLUME.toString()} or undefined`
);
}
vNumberOfAccess = DATASET_INFINITE_VOLUME.toString();
}

if (vAuthorizedApp && isEnsTest(vAuthorizedApp)) {
const resolved = await iexec.ens.resolveName(vAuthorizedApp);
if (!resolved) {
Expand Down Expand Up @@ -127,6 +149,7 @@ export const grantAccess = async ({
title: 'CREATE_DATASET_ORDER',
isDone: false,
});

const datasetorder = await iexec.order
.createDatasetorder({
dataset: vProtectedData,
Expand All @@ -145,6 +168,7 @@ export const grantAccess = async ({
errorCause: e,
});
});

vOnStatusUpdate({
title: 'CREATE_DATASET_ORDER',
isDone: true,
Expand All @@ -154,13 +178,15 @@ export const grantAccess = async ({
title: 'PUBLISH_DATASET_ORDER',
isDone: false,
});

await iexec.order.publishDatasetorder(datasetorder).catch((e) => {
handleIfProtocolError(e);
throw new WorkflowError({
message: 'Failed to publish data access',
errorCause: e,
});
});

vOnStatusUpdate({
title: 'PUBLISH_DATASET_ORDER',
isDone: true,
Expand Down
Loading