diff --git a/examples/acp-base/cross-chain-transfer-service/buyer.ts b/examples/acp-base/cross-chain-transfer-service/buyer.ts index 96e7d3dc..38e72706 100644 --- a/examples/acp-base/cross-chain-transfer-service/buyer.ts +++ b/examples/acp-base/cross-chain-transfer-service/buyer.ts @@ -75,7 +75,6 @@ async function buyer() { // Reference: (./images/specify_requirement_toggle_switch.png) {}, undefined, // evaluator address, undefined fallback to empty address - skip-evaluation - new Date(Date.now() + 1000 * 60 * 15) // job expiry duration, minimum 5 minutes ); console.log(`Job ${jobId} initiated`); diff --git a/examples/acp-base/external-evaluation/buyer.ts b/examples/acp-base/external-evaluation/buyer.ts index e77c704a..c1e42a15 100644 --- a/examples/acp-base/external-evaluation/buyer.ts +++ b/examples/acp-base/external-evaluation/buyer.ts @@ -71,7 +71,6 @@ async function buyer() { "": "", }, EVALUATOR_AGENT_WALLET_ADDRESS, // evaluator address - new Date(Date.now() + 1000 * 60 * 3.1) // job expiry duration, minimum 3 minutes ); console.log(`Job ${jobId} initiated`); diff --git a/examples/acp-base/polling-mode/buyer.ts b/examples/acp-base/polling-mode/buyer.ts index 54bf8fc5..27055796 100644 --- a/examples/acp-base/polling-mode/buyer.ts +++ b/examples/acp-base/polling-mode/buyer.ts @@ -63,7 +63,6 @@ async function buyer() { "": "", }, EVALUATOR_AGENT_WALLET_ADDRESS, // evaluator address - new Date(Date.now() + 1000 * 60 * 3.1) // job expiry duration, minimum 3 minutes ); console.log(`Job ${jobId} initiated`); diff --git a/examples/acp-base/skip-evaluation/buyer.ts b/examples/acp-base/skip-evaluation/buyer.ts index e2124637..8c26605f 100644 --- a/examples/acp-base/skip-evaluation/buyer.ts +++ b/examples/acp-base/skip-evaluation/buyer.ts @@ -72,7 +72,6 @@ async function buyer() { "": "", }, undefined, // evaluator address, undefined fallback to empty address - skip-evaluation - new Date(Date.now() + 1000 * 60 * 5) // job expiry duration, minimum 5 minutes ); console.log(`Job ${jobId} initiated`); diff --git a/package-lock.json b/package-lock.json index ad97bc56..91b5a10e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@virtuals-protocol/acp-node", - "version": "0.3.0-beta.24", + "version": "0.3.0-beta.30", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@virtuals-protocol/acp-node", - "version": "0.3.0-beta.24", + "version": "0.3.0-beta.30", "license": "ISC", "dependencies": { "@aa-sdk/core": "^4.73.0", diff --git a/package.json b/package.json index 945e711f..c1cedfc1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@virtuals-protocol/acp-node", - "version": "0.3.0-beta.24", + "version": "0.3.0-beta.30", "main": "./dist/index.js", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", diff --git a/src/acpClient.ts b/src/acpClient.ts index bce7dfce..90f58024 100644 --- a/src/acpClient.ts +++ b/src/acpClient.ts @@ -436,6 +436,7 @@ class AcpClient { price, priceType, offering.requiredFunds, + offering.slaMinutes, offering.requirement, offering.deliverable, ); diff --git a/src/acpJobOffering.ts b/src/acpJobOffering.ts index d7ac515d..c4c5bc59 100644 --- a/src/acpJobOffering.ts +++ b/src/acpJobOffering.ts @@ -31,6 +31,7 @@ class AcpJobOffering { public price: number, public priceType: PriceType, public requiredFunds: boolean, + public slaMinutes: number, public requirement?: Object | string, public deliverable?: Object | string ) { @@ -39,9 +40,9 @@ class AcpJobOffering { async initiateJob( serviceRequirement: Object | string, - evaluatorAddress?: Address, - expiredAt: Date = new Date(Date.now() + 1000 * 60 * 60 * 24) // default: 1 day + evaluatorAddress?: Address ) { + const expiredAt = new Date(Date.now() + this.slaMinutes * 60 * 1000); if (this.providerAddress === this.acpClient.walletAddress) { throw new AcpError( "Provider address cannot be the same as the client address" diff --git a/src/interfaces.ts b/src/interfaces.ts index d4ac6ba9..97022750 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -132,6 +132,7 @@ export interface IAcpAgent { value: number; }; requiredFunds: boolean; + slaMinutes: number; requirement?: Object | string; deliverable?: Object | string; }[]; diff --git a/test/unit/acpClient.test.ts b/test/unit/acpClient.test.ts index 7b6fa86c..ccd3c66a 100644 --- a/test/unit/acpClient.test.ts +++ b/test/unit/acpClient.test.ts @@ -185,6 +185,8 @@ describe("AcpClient Unit Testing", () => { value: 100, type: "NATIVE", }, + requiredFunds: true, + slaMinutes: 1440, requirement: "Test requirement", status: "active", }, diff --git a/test/unit/acpJobOffering.test.ts b/test/unit/acpJobOffering.test.ts index 8aad3df9..ad23f8d2 100644 --- a/test/unit/acpJobOffering.test.ts +++ b/test/unit/acpJobOffering.test.ts @@ -66,6 +66,7 @@ describe("AcpJobOffering Unit Testing", () => { 100, PriceType.FIXED, true, + 1440, ); expect(offering).toBeInstanceOf(AcpJobOffering); @@ -74,6 +75,7 @@ describe("AcpJobOffering Unit Testing", () => { expect(offering.price).toBe(100); expect(offering.priceType).toBe(PriceType.FIXED); expect(offering.requiredFunds).toBe(true); + expect(offering.slaMinutes).toBe(1440); expect(offering.requirement).toBe(undefined); expect(offering.deliverable).toBe(undefined); }); @@ -87,6 +89,7 @@ describe("AcpJobOffering Unit Testing", () => { 100, PriceType.FIXED, false, + 1440, ); expect(offering).toBeInstanceOf(AcpJobOffering); @@ -103,6 +106,7 @@ describe("AcpJobOffering Unit Testing", () => { 100, PriceType.PERCENTAGE, true, + 1440, ); expect(offering.priceType).toBe(PriceType.PERCENTAGE); @@ -117,6 +121,7 @@ describe("AcpJobOffering Unit Testing", () => { 100, PriceType.FIXED, true, + 1440, "custom requirement", ); @@ -138,6 +143,7 @@ describe("AcpJobOffering Unit Testing", () => { 100, PriceType.FIXED, true, + 1440, requirementObject, ); @@ -154,6 +160,7 @@ describe("AcpJobOffering Unit Testing", () => { 100, PriceType.FIXED, true, + 1440, undefined, "custom deliverable", ); @@ -173,6 +180,7 @@ describe("AcpJobOffering Unit Testing", () => { 100, PriceType.FIXED, false, + 1440, undefined, deliverableObject, ); @@ -208,6 +216,7 @@ describe("AcpJobOffering Unit Testing", () => { 100, PriceType.FIXED, true, + 1440, ); const result = await offering.initiateJob( @@ -265,6 +274,7 @@ describe("AcpJobOffering Unit Testing", () => { 100, PriceType.FIXED, true, + 1440, requirementSchema, ); @@ -297,6 +307,7 @@ describe("AcpJobOffering Unit Testing", () => { 100, PriceType.FIXED, true, + 1440, requirementSchema, ); @@ -335,6 +346,7 @@ describe("AcpJobOffering Unit Testing", () => { 100, PriceType.PERCENTAGE, true, + 1440, ); const result = await offering.initiateJob( @@ -375,6 +387,7 @@ describe("AcpJobOffering Unit Testing", () => { 100, PriceType.FIXED, true, + 1440, ); const result = await offering.initiateJob( @@ -427,6 +440,7 @@ describe("AcpJobOffering Unit Testing", () => { 100, PriceType.FIXED, true, + 1440, ); const result = await offering.initiateJob(