Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/acp-base/cross-chain-transfer-service/buyer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down
1 change: 0 additions & 1 deletion examples/acp-base/external-evaluation/buyer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ async function buyer() {
"<your-schema-key-2>": "<your-schema-value-2>",
},
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`);
Expand Down
1 change: 0 additions & 1 deletion examples/acp-base/polling-mode/buyer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ async function buyer() {
"<your-schema-key-2>": "<your-schema-value-2>",
},
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`);
Expand Down
1 change: 0 additions & 1 deletion examples/acp-base/skip-evaluation/buyer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ async function buyer() {
"<your-schema-key-2>": "<your-schema-value-2>",
},
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`);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/acpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ class AcpClient {
price,
priceType,
offering.requiredFunds,
offering.slaMinutes,
offering.requirement,
offering.deliverable,
);
Expand Down
5 changes: 3 additions & 2 deletions src/acpJobOffering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export interface IAcpAgent {
value: number;
};
requiredFunds: boolean;
slaMinutes: number;
requirement?: Object | string;
deliverable?: Object | string;
}[];
Expand Down
2 changes: 2 additions & 0 deletions test/unit/acpClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ describe("AcpClient Unit Testing", () => {
value: 100,
type: "NATIVE",
},
requiredFunds: true,
slaMinutes: 1440,
requirement: "Test requirement",
status: "active",
},
Expand Down
14 changes: 14 additions & 0 deletions test/unit/acpJobOffering.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe("AcpJobOffering Unit Testing", () => {
100,
PriceType.FIXED,
true,
1440,
);

expect(offering).toBeInstanceOf(AcpJobOffering);
Expand All @@ -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);
});
Expand All @@ -87,6 +89,7 @@ describe("AcpJobOffering Unit Testing", () => {
100,
PriceType.FIXED,
false,
1440,
);

expect(offering).toBeInstanceOf(AcpJobOffering);
Expand All @@ -103,6 +106,7 @@ describe("AcpJobOffering Unit Testing", () => {
100,
PriceType.PERCENTAGE,
true,
1440,
);

expect(offering.priceType).toBe(PriceType.PERCENTAGE);
Expand All @@ -117,6 +121,7 @@ describe("AcpJobOffering Unit Testing", () => {
100,
PriceType.FIXED,
true,
1440,
"custom requirement",
);

Expand All @@ -138,6 +143,7 @@ describe("AcpJobOffering Unit Testing", () => {
100,
PriceType.FIXED,
true,
1440,
requirementObject,
);

Expand All @@ -154,6 +160,7 @@ describe("AcpJobOffering Unit Testing", () => {
100,
PriceType.FIXED,
true,
1440,
undefined,
"custom deliverable",
);
Expand All @@ -173,6 +180,7 @@ describe("AcpJobOffering Unit Testing", () => {
100,
PriceType.FIXED,
false,
1440,
undefined,
deliverableObject,
);
Expand Down Expand Up @@ -208,6 +216,7 @@ describe("AcpJobOffering Unit Testing", () => {
100,
PriceType.FIXED,
true,
1440,
);

const result = await offering.initiateJob(
Expand Down Expand Up @@ -265,6 +274,7 @@ describe("AcpJobOffering Unit Testing", () => {
100,
PriceType.FIXED,
true,
1440,
requirementSchema,
);

Expand Down Expand Up @@ -297,6 +307,7 @@ describe("AcpJobOffering Unit Testing", () => {
100,
PriceType.FIXED,
true,
1440,
requirementSchema,
);

Expand Down Expand Up @@ -335,6 +346,7 @@ describe("AcpJobOffering Unit Testing", () => {
100,
PriceType.PERCENTAGE,
true,
1440,
);

const result = await offering.initiateJob(
Expand Down Expand Up @@ -375,6 +387,7 @@ describe("AcpJobOffering Unit Testing", () => {
100,
PriceType.FIXED,
true,
1440,
);

const result = await offering.initiateJob(
Expand Down Expand Up @@ -427,6 +440,7 @@ describe("AcpJobOffering Unit Testing", () => {
100,
PriceType.FIXED,
true,
1440,
);

const result = await offering.initiateJob(
Expand Down