@@ -33,7 +33,7 @@ import {
3333 ProcessProtectedDataResponse ,
3434 ProcessProtectedDataStatuses ,
3535} from '../types/index.js' ;
36- import { IExecConsumer } from '../types/internalTypes.js' ;
36+ import { IExecConsumer , VoucherInfo } from '../types/internalTypes.js' ;
3737import { getResultFromCompletedTask } from './getResultFromCompletedTask.js' ;
3838import { getWhitelistContract } from './smartContract/getWhitelistContract.js' ;
3939import { isAddressInWhitelist } from './smartContract/whitelistContract.read.js' ;
@@ -52,7 +52,7 @@ export const processProtectedData = async ({
5252 secrets,
5353 workerpool,
5454 useVoucher = false ,
55- voucherAddress ,
55+ voucherOwner ,
5656 onStatusUpdate = ( ) => { } ,
5757} : IExecConsumer &
5858 ProcessProtectedDataParams ) : Promise < ProcessProtectedDataResponse > => {
@@ -83,9 +83,9 @@ export const processProtectedData = async ({
8383 const vUseVoucher = booleanSchema ( )
8484 . label ( 'useVoucher' )
8585 . validateSync ( useVoucher ) ;
86- const vVoucherAddress = addressOrEnsSchema ( )
87- . label ( 'voucherAddress ' )
88- . validateSync ( voucherAddress ) ;
86+ const vVoucherOwner = addressOrEnsSchema ( )
87+ . label ( 'voucherOwner ' )
88+ . validateSync ( voucherOwner ) ;
8989 try {
9090 const vOnStatusUpdate =
9191 validateOnStatusUpdateCallback <
@@ -118,10 +118,12 @@ export const processProtectedData = async ({
118118 requester = vUserWhitelist ;
119119 }
120120 }
121- let userVoucher ;
121+ let userVoucher : VoucherInfo | undefined ;
122122 if ( vUseVoucher ) {
123123 try {
124- userVoucher = await iexec . voucher . showUserVoucher ( requester ) ;
124+ userVoucher = await iexec . voucher . showUserVoucher (
125+ vVoucherOwner || requester
126+ ) ;
125127 checkUserVoucher ( { userVoucher } ) ;
126128 } catch ( err ) {
127129 if ( err ?. message ?. startsWith ( 'No Voucher found for address' ) ) {
@@ -182,8 +184,11 @@ export const processProtectedData = async ({
182184 workerpool : vWorkerpool === ethers . ZeroAddress ? 'any' : vWorkerpool , // if address zero was chosen use any workerpool
183185 app : vApp ,
184186 dataset : vProtectedData ,
185- requester : requester , // public orders + user specific orders
186- isRequesterStrict : useVoucher , // If voucher, we only want user specific orders
187+ requester : requester ,
188+ isRequesterStrict :
189+ vVoucherOwner && vVoucherOwner . toLowerCase ( ) !== requester . toLowerCase ( )
190+ ? false
191+ : useVoucher ,
187192 minTag : SCONE_TAG ,
188193 maxTag : SCONE_TAG ,
189194 category : 0 ,
@@ -240,7 +245,7 @@ export const processProtectedData = async ({
240245 } ;
241246 const matchOptions : MatchOptions = {
242247 useVoucher : vUseVoucher ,
243- ...( vVoucherAddress ? { voucherAddress : vVoucherAddress } : { } ) ,
248+ ...( vVoucherOwner ? { voucherAddress : userVoucher ?. address } : { } ) ,
244249 } ;
245250
246251 const estimatedMatchOrderPrice = await iexec . order . estimateMatchOrders (
0 commit comments