@@ -289,7 +289,7 @@ class AcpClient {
289289 callback ( true ) ;
290290
291291 if ( this . onEvaluate ) {
292- const job = this . _hydrateJob ( data ) ;
292+ const job = await this . _hydrateJob ( data ) ;
293293
294294 this . onEvaluate ( job ) ;
295295 }
@@ -299,7 +299,7 @@ class AcpClient {
299299 callback ( true ) ;
300300
301301 if ( this . onNewTask ) {
302- const job = this . _hydrateJob ( data ) ;
302+ const job = await this . _hydrateJob ( data ) ;
303303
304304 this . onNewTask (
305305 job ,
@@ -353,13 +353,10 @@ class AcpClient {
353353 }
354354 }
355355
356- private _hydrateMemo (
357- memo : IAcpMemoData ,
358- contractClient : BaseAcpContractClient
359- ) : AcpMemo {
356+ private async _hydrateMemo ( memo : IAcpMemoData ) : Promise < AcpMemo > {
360357 try {
361- return new AcpMemo (
362- contractClient ,
358+ return await AcpMemo . build (
359+ this ,
363360 memo . id ,
364361 memo . memoType ,
365362 memo . content ,
@@ -378,7 +375,7 @@ class AcpClient {
378375 }
379376 }
380377
381- private _hydrateJob ( job : IAcpJob ) : AcpJob {
378+ private async _hydrateJob ( job : IAcpJob ) : Promise < AcpJob > {
382379 try {
383380 return new AcpJob (
384381 this ,
@@ -388,37 +385,33 @@ class AcpClient {
388385 job . evaluatorAddress ,
389386 job . price ,
390387 job . priceTokenAddress ,
391- job . memos . map ( ( memo ) =>
392- this . _hydrateMemo (
393- memo ,
394- this . contractClientByAddress ( job . contractAddress )
395- )
396- ) ,
388+ await Promise . all ( job . memos . map ( ( memo ) => this . _hydrateMemo ( memo ) ) ) ,
397389 job . phase ,
398390 job . context ,
399391 job . contractAddress ,
400- job . deliverable ,
401392 job . netPayableAmount
402393 ) ;
403394 } catch ( err ) {
404395 throw new AcpError ( `Failed to hydrate job ${ job . id } ` , err ) ;
405396 }
406397 }
407398
408- private _hydrateJobs (
399+ private async _hydrateJobs (
409400 rawJobs : IAcpJob [ ] ,
410401 options ?: {
411402 logPrefix ?: string ;
412403 }
413- ) : AcpJob [ ] {
414- const jobs = rawJobs . map ( ( job ) => {
415- try {
416- return this . _hydrateJob ( job ) ;
417- } catch ( err ) {
418- console . warn ( `${ options ?. logPrefix ?? "Skipped" } ` , err ) ;
419- return null ;
420- }
421- } ) ;
404+ ) : Promise < AcpJob [ ] > {
405+ const jobs = await Promise . all (
406+ rawJobs . map ( ( job ) => {
407+ try {
408+ return this . _hydrateJob ( job ) ;
409+ } catch ( err ) {
410+ console . warn ( `${ options ?. logPrefix ?? "Skipped" } ` , err ) ;
411+ return null ;
412+ }
413+ } )
414+ ) ;
422415
423416 return jobs . filter ( ( job ) => ! ! job ) as AcpJob [ ] ;
424417 }
@@ -458,7 +451,8 @@ class AcpClient {
458451 offering . requiredFunds ,
459452 offering . slaMinutes ,
460453 offering . requirement ,
461- offering . deliverable
454+ offering . deliverable ,
455+ offering . isPrivate
462456 ) ;
463457 } ) ,
464458 contractAddress : agent . contractAddress ,
@@ -617,11 +611,23 @@ class AcpClient {
617611 payloads . push ( setBudgetWithPaymentTokenPayload ) ;
618612 }
619613
614+ const isPrivate =
615+ typeof serviceRequirement === "object" &&
616+ "isPrivate" in serviceRequirement &&
617+ serviceRequirement . isPrivate ;
618+
619+ let content = preparePayload ( serviceRequirement ) ;
620+
621+ if ( isPrivate ) {
622+ const memoContent = await this . createMemoContent ( jobId , content ) ;
623+ content = memoContent . url ;
624+ }
625+
620626 payloads . push (
621627 this . acpContractClient . createMemo (
622628 jobId ,
623- preparePayload ( serviceRequirement ) ,
624- MemoType . MESSAGE ,
629+ content ,
630+ isPrivate ? MemoType . OBJECT_URL : MemoType . MESSAGE ,
625631 true ,
626632 AcpJobPhases . NEGOTIATION
627633 )
@@ -703,10 +709,7 @@ class AcpClient {
703709 return null ;
704710 }
705711
706- return this . _hydrateMemo (
707- memo ,
708- this . contractClientByAddress ( memo . contractAddress )
709- ) ;
712+ return this . _hydrateMemo ( memo ) ;
710713 }
711714
712715 async getAgent ( walletAddress : Address , options : IAcpGetAgentOptions = { } ) {
0 commit comments