@@ -443,78 +443,6 @@ export class Provider {
443443 throw new Error ( JSON . stringify ( resolvedResponse ) )
444444 }
445445
446- /** Initializes the provider for a compute request.
447- * @param {ComputeAsset[] } assets The datasets array to initialize compute request.
448- * @param {ComputeAlgorithmber } algorithm The algorithm to use.
449- * @param {string } computeEnv The compute environment.
450- * @param {string } providerUri The provider URI.
451- * @param {string } accountId caller address
452- * @param {string } chainId The chain Id to start compute on
453- * @param {string } token The token to use for the compute payment
454- * @param {number } maxJobDuration The maximum duration the job can take
455- * @param {AbortSignal } signal abort signal
456- * @return {Promise<ProviderComputeInitialize> } ProviderComputeInitialize data
457- */
458- public async initializeComputeV1 (
459- assets : ComputeAsset [ ] ,
460- algorithm : ComputeAlgorithm ,
461- computeEnv : string ,
462- providerUri : string ,
463- accountId : string ,
464- chainId : number ,
465- token : string ,
466- maxJobDuration : number ,
467- signal ?: AbortSignal
468- ) : Promise < ProviderComputeInitializeResults > {
469- const providerEndpoints = await this . getEndpoints ( providerUri )
470- const serviceEndpoints = await this . getServiceEndpoints (
471- providerUri ,
472- providerEndpoints
473- )
474- const payment : ComputePayment = {
475- chainId,
476- token,
477- maxJobDuration
478- }
479- const payload : Object = {
480- datasets : assets ,
481- algorithm,
482- payment,
483- consumerAddress : accountId ,
484- environment : computeEnv
485- }
486- const initializeUrl = this . getEndpointURL ( serviceEndpoints , 'initializeCompute' )
487- ? this . getEndpointURL ( serviceEndpoints , 'initializeCompute' ) . urlPath
488- : null
489- if ( ! initializeUrl ) return null
490- let response
491- try {
492- response = await fetch ( initializeUrl , {
493- method : 'POST' ,
494- body : JSON . stringify ( payload ) ,
495- headers : { 'Content-Type' : 'application/json' } ,
496- signal
497- } )
498- } catch ( e ) {
499- LoggerInstance . error ( 'Initialize compute failed: ' )
500- LoggerInstance . error ( e )
501- throw new Error ( 'ComputeJob cannot be initialized' )
502- }
503- if ( response ?. ok ) {
504- const params = await response . json ( )
505- return params
506- }
507- const resolvedResponse = await response . json ( )
508- LoggerInstance . error (
509- 'Initialize compute failed: ' ,
510- response . status ,
511- response . statusText ,
512- resolvedResponse
513- )
514- LoggerInstance . error ( 'Payload was:' , JSON . stringify ( payload ) )
515- throw new Error ( JSON . stringify ( resolvedResponse ) )
516- }
517-
518446 /** Initializes the provider for a compute request.
519447 * @param {ComputeAsset[] } assets The datasets array to initialize compute request.
520448 * @param {ComputeAlgorithmber } algorithm The algorithm to use.
@@ -527,6 +455,7 @@ export class Provider {
527455 * @param {number } chainId The chain used to do payments
528456 * @param {any } policyServer Policy server data.
529457 * @param {AbortSignal } signal abort signal
458+ * @param {ComputeOutput } output The compute job output settings.
530459 * @param {dockerRegistryAuth } dockerRegistryAuth Docker registry authentication data.
531460 * @return {Promise<ProviderComputeInitialize> } ProviderComputeInitialize data
532461 */
@@ -542,6 +471,7 @@ export class Provider {
542471 chainId : number ,
543472 policyServer ?: any ,
544473 signal ?: AbortSignal ,
474+ output ?: ComputeOutput ,
545475 dockerRegistryAuth ?: dockerRegistryAuth
546476 ) : Promise < ProviderComputeInitializeResults > {
547477 const providerEndpoints = await this . getEndpoints ( providerUri )
@@ -601,7 +531,12 @@ export class Provider {
601531 }
602532
603533 if ( policyServer ) providerData . policyServer = policyServer
604-
534+ if ( output ) {
535+ const nodeKey = await this . getNodePublicKey ( providerUri )
536+ if ( nodeKey ) {
537+ providerData . output = eciesencrypt ( nodeKey , JSON . stringify ( output ) )
538+ }
539+ }
605540 let response
606541 try {
607542 console . log ( 'Initialize compute url:' , initializeUrl )
0 commit comments