From b33a23288716c2d7a01426957834262f0ff7a4aa Mon Sep 17 00:00:00 2001 From: jxx016 Date: Tue, 29 Apr 2025 17:32:05 -0500 Subject: [PATCH 1/4] fix: better error handling for expired jobs --- plugins/acpPlugin/src/acpPlugin.ts | 7 +++++++ plugins/acpPlugin/src/interface.ts | 1 + 2 files changed, 8 insertions(+) diff --git a/plugins/acpPlugin/src/acpPlugin.ts b/plugins/acpPlugin/src/acpPlugin.ts index 9c1622df..ee1cf809 100644 --- a/plugins/acpPlugin/src/acpPlugin.ts +++ b/plugins/acpPlugin/src/acpPlugin.ts @@ -790,6 +790,13 @@ class AcpPlugin { ); } + if (job.expiredAt && new Date(job.expiredAt) < new Date()) { + return new ExecutableGameFunctionResponse( + ExecutableGameFunctionStatus.Failed, + `Cannot deliver - this job has expired on ${new Date(job.expiredAt).toLocaleString()}. 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 { From b2b42d48168b91a165d74adb4da22d594afe8889 Mon Sep 17 00:00:00 2001 From: jxx016 Date: Thu, 1 May 2025 16:40:09 -0500 Subject: [PATCH 2/4] changing to UTC --- plugins/acpPlugin/src/acpPlugin.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/acpPlugin/src/acpPlugin.ts b/plugins/acpPlugin/src/acpPlugin.ts index ee1cf809..a2a298fc 100644 --- a/plugins/acpPlugin/src/acpPlugin.ts +++ b/plugins/acpPlugin/src/acpPlugin.ts @@ -791,9 +791,10 @@ 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 ${new Date(job.expiredAt).toLocaleString()}. The buyer may need to create a new job request.` + `Cannot deliver - this job has expired on ${expiredDate.toISOString()} (UTC). The buyer may need to create a new job request.` ); } From 9d3eb5bd29414a30b12be5f209721082ed9f9018 Mon Sep 17 00:00:00 2001 From: jxx016 Date: Thu, 1 May 2025 17:50:51 -0500 Subject: [PATCH 3/4] changing it to check for cancelled job instead --- plugins/acpPlugin/src/acpPlugin.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/acpPlugin/src/acpPlugin.ts b/plugins/acpPlugin/src/acpPlugin.ts index a2a298fc..822abdfc 100644 --- a/plugins/acpPlugin/src/acpPlugin.ts +++ b/plugins/acpPlugin/src/acpPlugin.ts @@ -779,6 +779,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! ); From 7ec35064dd8a31423df1248a30141a07dd912e2e Mon Sep 17 00:00:00 2001 From: jxx016 Date: Fri, 2 May 2025 23:14:59 -0500 Subject: [PATCH 4/4] adding check for respondJob and payJob too --- plugins/acpPlugin/src/acpPlugin.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plugins/acpPlugin/src/acpPlugin.ts b/plugins/acpPlugin/src/acpPlugin.ts index 822abdfc..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! );