Skip to content

Commit 2d342af

Browse files
add VoucherAddress to processProtectedData
1 parent fd67b7a commit 2d342af

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
import { isERC734 } from '../../utils/whitelist.js';
2626
import { getResultFromCompletedTask } from './getResultFromCompletedTask.js';
2727
import {
28+
MatchOptions,
2829
OnStatusUpdateFn,
2930
ProcessProtectedDataParams,
3031
ProcessProtectedDataResponse,
@@ -49,6 +50,7 @@ export const processProtectedData = async ({
4950
secrets,
5051
workerpool,
5152
useVoucher = false,
53+
voucherAddress,
5254
onStatusUpdate = () => {},
5355
}: IExecConsumer &
5456
ProcessProtectedDataParams): Promise<ProcessProtectedDataResponse> => {
@@ -79,7 +81,9 @@ export const processProtectedData = async ({
7981
const vUseVoucher = booleanSchema()
8082
.label('useVoucher')
8183
.validateSync(useVoucher);
82-
84+
const vVoucherAddress = addressOrEnsSchema()
85+
.label('voucherAddress')
86+
.validateSync(voucherAddress);
8387
try {
8488
const vOnStatusUpdate =
8589
validateOnStatusUpdateCallback<
@@ -216,12 +220,16 @@ export const processProtectedData = async ({
216220
},
217221
});
218222
const requestorder = await iexec.order.signRequestorder(requestorderToSign);
223+
const matchOptions: MatchOptions = {
224+
useVoucher: vUseVoucher,
225+
...(vVoucherAddress ? { voucherAddress: vVoucherAddress } : {}),
226+
};
219227
const { dealid, txHash } = await iexec.order.matchOrders(
220228
{
221229
requestorder,
222230
...underMaxPriceOrders,
223231
},
224-
{ useVoucher: vUseVoucher }
232+
matchOptions
225233
);
226234
const taskId = await iexec.deal.computeTaskId(dealid, 0);
227235

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,8 @@ export interface SearchableDataSchema
117117
| SearchableSchemaEntryType
118118
| SearchableSchemaEntryType[]
119119
> {}
120+
121+
export type MatchOptions = {
122+
useVoucher: boolean;
123+
voucherAddress?: string;
124+
};

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ export type ProcessProtectedDataParams = {
339339
*/
340340
useVoucher?: boolean;
341341

342+
/**
343+
* 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.
344+
*/
345+
voucherAddress?: AddressOrENS;
346+
342347
/**
343348
* Callback function that will get called at each step of the process
344349
*/

0 commit comments

Comments
 (0)