Skip to content

Commit a0ce781

Browse files
feat(core): support allowDeposit option for protected and bulk data processing
1 parent cf49464 commit a0ce781

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { sumTags } from 'iexec/utils';
22
import { SCONE_TAG } from '../../config/config.js';
33
import {
4-
WorkflowError,
5-
processProtectedDataErrorMessage,
64
handleIfProtocolError,
5+
processProtectedDataErrorMessage,
76
ValidationError,
7+
WorkflowError,
88
} from '../../utils/errors.js';
99
import {
1010
checkUserVoucher,
@@ -50,6 +50,7 @@ export const processBulkRequest = async <
5050
bulkRequest,
5151
workerpool,
5252
useVoucher = false,
53+
allowDeposit = false,
5354
voucherOwner,
5455
path,
5556
pemPrivateKey,
@@ -66,6 +67,9 @@ export const processBulkRequest = async <
6667
.default(defaultWorkerpool) // Default workerpool if none is specified
6768
.label('workerpool')
6869
.validateSync(workerpool);
70+
const vAllowDeposit = booleanSchema()
71+
.label('allowDeposit')
72+
.validateSync(allowDeposit);
6973
const vUseVoucher = booleanSchema()
7074
.label('useVoucher')
7175
.validateSync(useVoucher);
@@ -215,6 +219,7 @@ export const processBulkRequest = async <
215219
const matchOptions: MatchOptions = {
216220
useVoucher: vUseVoucher,
217221
...(vVoucherOwner ? { voucherAddress: userVoucher?.address } : {}),
222+
allowDeposit: vAllowDeposit,
218223
};
219224

220225
const {

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ import {
66
SCONE_TAG,
77
} from '../../config/config.js';
88
import {
9-
WorkflowError,
10-
processProtectedDataErrorMessage,
119
handleIfProtocolError,
10+
processProtectedDataErrorMessage,
1211
ValidationError,
12+
WorkflowError,
1313
} from '../../utils/errors.js';
1414
import {
1515
checkUserVoucher,
1616
filterWorkerpoolOrders,
1717
} from '../../utils/processProtectedData.models.js';
1818
import { pushRequesterSecret } from '../../utils/pushRequesterSecret.js';
1919
import {
20-
getPemFormattedKeyPair,
2120
formatPemPublicKeyForSMS,
21+
getPemFormattedKeyPair,
2222
} from '../../utils/rsa.js';
2323
import {
2424
addressOrEnsSchema,
@@ -64,6 +64,7 @@ export const processProtectedData = async <
6464
inputFiles,
6565
secrets,
6666
workerpool,
67+
allowDeposit = false,
6768
useVoucher = false,
6869
voucherOwner,
6970
encryptResult = false,
@@ -103,6 +104,9 @@ export const processProtectedData = async <
103104
.default(defaultWorkerpool) // Default workerpool if none is specified
104105
.label('workerpool')
105106
.validateSync(workerpool);
107+
const vAllowDeposit = booleanSchema()
108+
.label('allowDeposit')
109+
.validateSync(allowDeposit);
106110
const vUseVoucher = booleanSchema()
107111
.label('useVoucher')
108112
.validateSync(useVoucher);
@@ -369,9 +373,9 @@ export const processProtectedData = async <
369373
};
370374
const matchOptions: MatchOptions = {
371375
useVoucher: vUseVoucher,
376+
allowDeposit: vAllowDeposit,
372377
...(vVoucherOwner ? { voucherAddress: userVoucher?.address } : {}),
373378
};
374-
375379
const { dealid: dealId, txHash } = await iexec.order.matchOrders(
376380
orders,
377381
matchOptions

packages/sdk/src/lib/types/coreTypes.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,12 @@ export type ProcessProtectedDataParams = {
380380
*/
381381
workerpool?: AddressOrENS;
382382

383+
/**
384+
* A boolean that indicates whether to allow automatic deposit from wallet when account balance is insufficient to cover the cost of the task.
385+
* @default false
386+
*/
387+
allowDeposit?: boolean;
388+
383389
/**
384390
* A boolean that indicates whether to use a voucher or no.
385391
*/
@@ -567,6 +573,12 @@ export type ProcessBulkRequestParams = {
567573
*/
568574
useVoucher?: boolean;
569575

576+
/**
577+
* A boolean that indicates whether to allow automatic deposit from wallet when account balance is insufficient to cover the cost of the bulk request.
578+
* @default false
579+
*/
580+
allowDeposit?: boolean;
581+
570582
/**
571583
* Override the voucher contract to use, must be combined with useVoucher: true the user must be authorized by the voucher's owner to use it.
572584
*/

0 commit comments

Comments
 (0)