diff --git a/plugins/acpPlugin/src/acpPlugin.ts b/plugins/acpPlugin/src/acpPlugin.ts index 9c1622df..df0d0de3 100644 --- a/plugins/acpPlugin/src/acpPlugin.ts +++ b/plugins/acpPlugin/src/acpPlugin.ts @@ -534,6 +534,13 @@ class AcpPlugin { try { const state = await this.getAcpState(); + if (state.jobs.cancelled.find(c => c.jobId === +args.jobId!)) { + return new ExecutableGameFunctionResponse( + ExecutableGameFunctionStatus.Failed, + "Cannot respond - this job has been cancelled" + ); + } + const job = state.jobs.active.asASeller.find( (c) => c.jobId === +args.jobId! ); @@ -654,6 +661,13 @@ class AcpPlugin { try { const state = await this.getAcpState(); + if (state.jobs.cancelled.find(c => c.jobId === +args.jobId!)) { + return new ExecutableGameFunctionResponse( + ExecutableGameFunctionStatus.Failed, + "Cannot pay - this job has been cancelled" + ); + } + const job = state.jobs.active.asABuyer.find( (c) => c.jobId === +args.jobId! ); @@ -779,6 +793,13 @@ class AcpPlugin { try { const state = await this.getAcpState(); + if (state.jobs.cancelled.find(c => c.jobId === +args.jobId!)) { + return new ExecutableGameFunctionResponse( + ExecutableGameFunctionStatus.Failed, + "Cannot deliver - this job has been cancelled" + ); + } + const job = state.jobs.active.asASeller.find( (c) => c.jobId === +args.jobId! ); @@ -790,6 +811,14 @@ class AcpPlugin { ); } + if (job.expiredAt && new Date(job.expiredAt) < new Date()) { + const expiredDate = new Date(job.expiredAt); + return new ExecutableGameFunctionResponse( + ExecutableGameFunctionStatus.Failed, + `Cannot deliver - this job has expired on ${expiredDate.toISOString()} (UTC). The buyer may need to create a new job request.` + ); + } + if (job.phase !== AcpJobPhasesDesc.TRANSACTION) { return new ExecutableGameFunctionResponse( ExecutableGameFunctionStatus.Failed, diff --git a/plugins/acpPlugin/src/interface.ts b/plugins/acpPlugin/src/interface.ts index e5355dc2..dc0ecb8c 100644 --- a/plugins/acpPlugin/src/interface.ts +++ b/plugins/acpPlugin/src/interface.ts @@ -49,6 +49,7 @@ export interface AcpJob { memo: AcpRequestMemo[]; tweetHistory: ITweet[]; lastUpdated: number; + expiredAt?: string; } export interface IDeliverable {