@@ -33,10 +33,12 @@ import { IExecConsumer } from '../types/internalTypes.js';
3333import { getWhitelistContract } from './smartContract/getWhitelistContract.js' ;
3434import { isAddressInWhitelist } from './smartContract/whitelistContract.read.js' ;
3535
36+ export type ProcessProtectedData = typeof processProtectedData ;
37+
3638export const processProtectedData = async ( {
3739 iexec = throwIfMissing ( ) ,
38- protectedData = throwIfMissing ( ) ,
39- app = throwIfMissing ( ) ,
40+ protectedData,
41+ app,
4042 userWhitelist,
4143 maxPrice = DEFAULT_MAX_PRICE ,
4244 args,
@@ -46,30 +48,31 @@ export const processProtectedData = async ({
4648 onStatusUpdate = ( ) => { } ,
4749} : IExecConsumer &
4850 ProcessProtectedDataParams ) : Promise < ProcessProtectedDataResponse > => {
51+ const vProtectedData = addressOrEnsSchema ( )
52+ . required ( )
53+ . label ( 'protectedData' )
54+ . validateSync ( protectedData ) ;
55+ const vApp = addressOrEnsSchema ( )
56+ . required ( )
57+ . label ( 'authorizedApp' )
58+ . validateSync ( app ) ;
59+ const vUserWhitelist = addressSchema ( )
60+ . label ( 'userWhitelist' )
61+ . validateSync ( userWhitelist ) ;
62+ const vMaxPrice = positiveNumberSchema ( )
63+ . label ( 'maxPrice' )
64+ . validateSync ( maxPrice ) ;
65+ const vInputFiles = urlArraySchema ( )
66+ . label ( 'inputFiles' )
67+ . validateSync ( inputFiles ) ;
68+ const vArgs = stringSchema ( ) . label ( 'args' ) . validateSync ( args ) ;
69+ const vSecrets = secretsSchema ( ) . label ( 'secrets' ) . validateSync ( secrets ) ;
70+ const vWorkerpool = addressOrEnsSchema ( )
71+ . default ( WORKERPOOL_ADDRESS ) // Default workerpool if none is specified
72+ . label ( 'workerpool' )
73+ . validateSync ( workerpool ) ;
74+
4975 try {
50- const vApp = addressOrEnsSchema ( )
51- . required ( )
52- . label ( 'authorizedApp' )
53- . validateSync ( app ) ;
54- const vProtectedData = addressOrEnsSchema ( )
55- . required ( )
56- . label ( 'protectedData' )
57- . validateSync ( protectedData ) ;
58- const vUserWhitelist = addressSchema ( )
59- . label ( 'userWhitelist' )
60- . validateSync ( userWhitelist ) ;
61- const vMaxPrice = positiveNumberSchema ( )
62- . label ( 'maxPrice' )
63- . validateSync ( maxPrice ) ;
64- const vInputFiles = urlArraySchema ( )
65- . label ( 'inputFiles' )
66- . validateSync ( inputFiles ) ;
67- const vArgs = stringSchema ( ) . label ( 'args' ) . validateSync ( args ) ;
68- const vSecrets = secretsSchema ( ) . label ( 'secrets' ) . validateSync ( secrets ) ;
69- const vWorkerpool = addressOrEnsSchema ( )
70- . default ( WORKERPOOL_ADDRESS ) // Default workerpool if none is specified
71- . label ( 'workerpool' )
72- . validateSync ( workerpool ) ;
7376 const vOnStatusUpdate =
7477 validateOnStatusUpdateCallback <
7578 OnStatusUpdateFn < ProcessProtectedDataStatuses >
@@ -95,7 +98,7 @@ export const processProtectedData = async ({
9598
9699 if ( ! isRequesterInWhitelist ) {
97100 throw new Error (
98- ` As a user, you are not in the whitelist. So you can't access to the protectedData in order process it`
101+ " As a user, you are not in the whitelist. You can't access the protectedData so you can't process it."
99102 ) ;
100103 }
101104 requester = vUserWhitelist ;
@@ -243,6 +246,7 @@ export const processProtectedData = async ({
243246 result,
244247 } ;
245248 } catch ( error ) {
249+ console . error ( '[processProtectedData] ERROR' , error ) ;
246250 handleIfProtocolError ( error ) ;
247251 throw new WorkflowError ( {
248252 message : processProtectedDataErrorMessage ,
0 commit comments