@virtuals-protocol/acp-node 0.3.0-beta.30 → 0.3.0-beta.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +18 -8
- package/dist/index.mjs +18 -8
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -281,16 +281,16 @@ declare class AcpJob {
|
|
|
281
281
|
phase: AcpJobPhases;
|
|
282
282
|
context: Record<string, any>;
|
|
283
283
|
contractAddress: Address;
|
|
284
|
+
deliverable: DeliverablePayload | null;
|
|
284
285
|
netPayableAmount?: number | undefined;
|
|
285
286
|
name: string | undefined;
|
|
286
287
|
requirement: Record<string, any> | string | undefined;
|
|
287
288
|
priceType: PriceType;
|
|
288
289
|
priceValue: number;
|
|
289
|
-
constructor(acpClient: AcpClient, id: number, clientAddress: Address, providerAddress: Address, evaluatorAddress: Address, price: number, priceTokenAddress: Address, memos: AcpMemo[], phase: AcpJobPhases, context: Record<string, any>, contractAddress: Address, netPayableAmount?: number | undefined);
|
|
290
|
+
constructor(acpClient: AcpClient, id: number, clientAddress: Address, providerAddress: Address, evaluatorAddress: Address, price: number, priceTokenAddress: Address, memos: AcpMemo[], phase: AcpJobPhases, context: Record<string, any>, contractAddress: Address, deliverable: DeliverablePayload | null, netPayableAmount?: number | undefined);
|
|
290
291
|
get acpContractClient(): BaseAcpContractClient;
|
|
291
292
|
get config(): AcpContractConfig;
|
|
292
293
|
get baseFare(): Fare;
|
|
293
|
-
get deliverable(): string | undefined;
|
|
294
294
|
get rejectionReason(): string | undefined;
|
|
295
295
|
get providerAgent(): Promise<AcpAgent | null>;
|
|
296
296
|
get clientAgent(): Promise<AcpAgent | null>;
|
|
@@ -488,6 +488,11 @@ type X402PaymentResponse = {
|
|
|
488
488
|
isPaymentRequired: boolean;
|
|
489
489
|
data: X402PayableRequirements;
|
|
490
490
|
};
|
|
491
|
+
type IAcpMemoContent = {
|
|
492
|
+
id: number;
|
|
493
|
+
content: string;
|
|
494
|
+
url: string;
|
|
495
|
+
};
|
|
491
496
|
|
|
492
497
|
type SupportedChain = typeof mainnet | typeof sepolia | typeof polygon | typeof polygonAmoy | typeof bsc | typeof bscTestnet | typeof arbitrum | typeof arbitrumSepolia;
|
|
493
498
|
declare class AcpContractConfig {
|
|
@@ -643,7 +648,7 @@ declare class AcpClient {
|
|
|
643
648
|
getAgent(walletAddress: Address, options?: IAcpGetAgentOptions): Promise<AcpAgent | null>;
|
|
644
649
|
getAccountByJobId(jobId: number, acpContractClient?: BaseAcpContractClient): Promise<AcpAccount | null>;
|
|
645
650
|
getByClientAndProvider(clientAddress: Address, providerAddress: Address, acpContractClient?: BaseAcpContractClient): Promise<AcpAccount | null>;
|
|
646
|
-
createMemoContent(jobId: number, content: string): Promise<
|
|
651
|
+
createMemoContent(jobId: number, content: string): Promise<IAcpMemoContent>;
|
|
647
652
|
getTokenBalances(): Promise<{
|
|
648
653
|
tokens: Record<string, any>;
|
|
649
654
|
} | undefined>;
|
package/dist/index.d.ts
CHANGED
|
@@ -281,16 +281,16 @@ declare class AcpJob {
|
|
|
281
281
|
phase: AcpJobPhases;
|
|
282
282
|
context: Record<string, any>;
|
|
283
283
|
contractAddress: Address;
|
|
284
|
+
deliverable: DeliverablePayload | null;
|
|
284
285
|
netPayableAmount?: number | undefined;
|
|
285
286
|
name: string | undefined;
|
|
286
287
|
requirement: Record<string, any> | string | undefined;
|
|
287
288
|
priceType: PriceType;
|
|
288
289
|
priceValue: number;
|
|
289
|
-
constructor(acpClient: AcpClient, id: number, clientAddress: Address, providerAddress: Address, evaluatorAddress: Address, price: number, priceTokenAddress: Address, memos: AcpMemo[], phase: AcpJobPhases, context: Record<string, any>, contractAddress: Address, netPayableAmount?: number | undefined);
|
|
290
|
+
constructor(acpClient: AcpClient, id: number, clientAddress: Address, providerAddress: Address, evaluatorAddress: Address, price: number, priceTokenAddress: Address, memos: AcpMemo[], phase: AcpJobPhases, context: Record<string, any>, contractAddress: Address, deliverable: DeliverablePayload | null, netPayableAmount?: number | undefined);
|
|
290
291
|
get acpContractClient(): BaseAcpContractClient;
|
|
291
292
|
get config(): AcpContractConfig;
|
|
292
293
|
get baseFare(): Fare;
|
|
293
|
-
get deliverable(): string | undefined;
|
|
294
294
|
get rejectionReason(): string | undefined;
|
|
295
295
|
get providerAgent(): Promise<AcpAgent | null>;
|
|
296
296
|
get clientAgent(): Promise<AcpAgent | null>;
|
|
@@ -488,6 +488,11 @@ type X402PaymentResponse = {
|
|
|
488
488
|
isPaymentRequired: boolean;
|
|
489
489
|
data: X402PayableRequirements;
|
|
490
490
|
};
|
|
491
|
+
type IAcpMemoContent = {
|
|
492
|
+
id: number;
|
|
493
|
+
content: string;
|
|
494
|
+
url: string;
|
|
495
|
+
};
|
|
491
496
|
|
|
492
497
|
type SupportedChain = typeof mainnet | typeof sepolia | typeof polygon | typeof polygonAmoy | typeof bsc | typeof bscTestnet | typeof arbitrum | typeof arbitrumSepolia;
|
|
493
498
|
declare class AcpContractConfig {
|
|
@@ -643,7 +648,7 @@ declare class AcpClient {
|
|
|
643
648
|
getAgent(walletAddress: Address, options?: IAcpGetAgentOptions): Promise<AcpAgent | null>;
|
|
644
649
|
getAccountByJobId(jobId: number, acpContractClient?: BaseAcpContractClient): Promise<AcpAccount | null>;
|
|
645
650
|
getByClientAndProvider(clientAddress: Address, providerAddress: Address, acpContractClient?: BaseAcpContractClient): Promise<AcpAccount | null>;
|
|
646
|
-
createMemoContent(jobId: number, content: string): Promise<
|
|
651
|
+
createMemoContent(jobId: number, content: string): Promise<IAcpMemoContent>;
|
|
647
652
|
getTokenBalances(): Promise<{
|
|
648
653
|
tokens: Record<string, any>;
|
|
649
654
|
} | undefined>;
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var require_package = __commonJS({
|
|
|
35
35
|
"package.json"(exports2, module2) {
|
|
36
36
|
module2.exports = {
|
|
37
37
|
name: "@virtuals-protocol/acp-node",
|
|
38
|
-
version: "0.3.0-beta.
|
|
38
|
+
version: "0.3.0-beta.31",
|
|
39
39
|
main: "./dist/index.js",
|
|
40
40
|
module: "./dist/index.mjs",
|
|
41
41
|
types: "./dist/index.d.ts",
|
|
@@ -4225,7 +4225,7 @@ var acpJobOffering_default = AcpJobOffering;
|
|
|
4225
4225
|
// src/acpJob.ts
|
|
4226
4226
|
var util = __toESM(require("util"));
|
|
4227
4227
|
var AcpJob = class {
|
|
4228
|
-
constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, priceTokenAddress, memos, phase, context, contractAddress, netPayableAmount) {
|
|
4228
|
+
constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, priceTokenAddress, memos, phase, context, contractAddress, deliverable, netPayableAmount) {
|
|
4229
4229
|
this.acpClient = acpClient;
|
|
4230
4230
|
this.id = id;
|
|
4231
4231
|
this.clientAddress = clientAddress;
|
|
@@ -4237,6 +4237,7 @@ var AcpJob = class {
|
|
|
4237
4237
|
this.phase = phase;
|
|
4238
4238
|
this.context = context;
|
|
4239
4239
|
this.contractAddress = contractAddress;
|
|
4240
|
+
this.deliverable = deliverable;
|
|
4240
4241
|
this.netPayableAmount = netPayableAmount;
|
|
4241
4242
|
this.priceType = "fixed" /* FIXED */;
|
|
4242
4243
|
this.priceValue = 0;
|
|
@@ -4272,9 +4273,6 @@ var AcpJob = class {
|
|
|
4272
4273
|
get baseFare() {
|
|
4273
4274
|
return this.acpContractClient.config.baseFare;
|
|
4274
4275
|
}
|
|
4275
|
-
get deliverable() {
|
|
4276
|
-
return this.memos.find((m) => m.nextPhase === 4 /* COMPLETED */)?.content;
|
|
4277
|
-
}
|
|
4278
4276
|
get rejectionReason() {
|
|
4279
4277
|
const requestMemo = this.memos.find(
|
|
4280
4278
|
(m) => m.nextPhase === 1 /* NEGOTIATION */ && m.status === "REJECTED" /* REJECTED */
|
|
@@ -4519,12 +4517,19 @@ var AcpJob = class {
|
|
|
4519
4517
|
return await this.acpContractClient.handleOperation(operations);
|
|
4520
4518
|
}
|
|
4521
4519
|
async deliver(deliverable) {
|
|
4520
|
+
if (this.phase !== 2 /* TRANSACTION */) {
|
|
4521
|
+
throw new acpError_default("Job is not in transaction phase");
|
|
4522
|
+
}
|
|
4522
4523
|
const operations = [];
|
|
4524
|
+
const memoContent = await this.acpClient.createMemoContent(
|
|
4525
|
+
this.id,
|
|
4526
|
+
preparePayload(deliverable)
|
|
4527
|
+
);
|
|
4523
4528
|
operations.push(
|
|
4524
4529
|
this.acpContractClient.createMemo(
|
|
4525
4530
|
this.id,
|
|
4526
|
-
|
|
4527
|
-
|
|
4531
|
+
memoContent?.url,
|
|
4532
|
+
1 /* CONTEXT_URL */,
|
|
4528
4533
|
true,
|
|
4529
4534
|
4 /* COMPLETED */
|
|
4530
4535
|
)
|
|
@@ -4549,10 +4554,14 @@ var AcpJob = class {
|
|
|
4549
4554
|
);
|
|
4550
4555
|
const feeAmount = new FareAmount(0, this.acpContractClient.config.baseFare);
|
|
4551
4556
|
const isPercentagePricing = this.priceType === "percentage" /* PERCENTAGE */ && !skipFee;
|
|
4557
|
+
const memoContent = await this.acpClient.createMemoContent(
|
|
4558
|
+
this.id,
|
|
4559
|
+
preparePayload(deliverable)
|
|
4560
|
+
);
|
|
4552
4561
|
operations.push(
|
|
4553
4562
|
this.acpContractClient.createPayableMemo(
|
|
4554
4563
|
this.id,
|
|
4555
|
-
|
|
4564
|
+
memoContent.url,
|
|
4556
4565
|
amount.amount,
|
|
4557
4566
|
this.clientAddress,
|
|
4558
4567
|
isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
|
|
@@ -5067,6 +5076,7 @@ var AcpClient = class {
|
|
|
5067
5076
|
job.phase,
|
|
5068
5077
|
job.context,
|
|
5069
5078
|
job.contractAddress,
|
|
5079
|
+
job.deliverable,
|
|
5070
5080
|
job.netPayableAmount
|
|
5071
5081
|
);
|
|
5072
5082
|
} catch (err) {
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ var require_package = __commonJS({
|
|
|
8
8
|
"package.json"(exports, module) {
|
|
9
9
|
module.exports = {
|
|
10
10
|
name: "@virtuals-protocol/acp-node",
|
|
11
|
-
version: "0.3.0-beta.
|
|
11
|
+
version: "0.3.0-beta.31",
|
|
12
12
|
main: "./dist/index.js",
|
|
13
13
|
module: "./dist/index.mjs",
|
|
14
14
|
types: "./dist/index.d.ts",
|
|
@@ -4202,7 +4202,7 @@ var acpJobOffering_default = AcpJobOffering;
|
|
|
4202
4202
|
// src/acpJob.ts
|
|
4203
4203
|
import * as util from "util";
|
|
4204
4204
|
var AcpJob = class {
|
|
4205
|
-
constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, priceTokenAddress, memos, phase, context, contractAddress, netPayableAmount) {
|
|
4205
|
+
constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, priceTokenAddress, memos, phase, context, contractAddress, deliverable, netPayableAmount) {
|
|
4206
4206
|
this.acpClient = acpClient;
|
|
4207
4207
|
this.id = id;
|
|
4208
4208
|
this.clientAddress = clientAddress;
|
|
@@ -4214,6 +4214,7 @@ var AcpJob = class {
|
|
|
4214
4214
|
this.phase = phase;
|
|
4215
4215
|
this.context = context;
|
|
4216
4216
|
this.contractAddress = contractAddress;
|
|
4217
|
+
this.deliverable = deliverable;
|
|
4217
4218
|
this.netPayableAmount = netPayableAmount;
|
|
4218
4219
|
this.priceType = "fixed" /* FIXED */;
|
|
4219
4220
|
this.priceValue = 0;
|
|
@@ -4249,9 +4250,6 @@ var AcpJob = class {
|
|
|
4249
4250
|
get baseFare() {
|
|
4250
4251
|
return this.acpContractClient.config.baseFare;
|
|
4251
4252
|
}
|
|
4252
|
-
get deliverable() {
|
|
4253
|
-
return this.memos.find((m) => m.nextPhase === 4 /* COMPLETED */)?.content;
|
|
4254
|
-
}
|
|
4255
4253
|
get rejectionReason() {
|
|
4256
4254
|
const requestMemo = this.memos.find(
|
|
4257
4255
|
(m) => m.nextPhase === 1 /* NEGOTIATION */ && m.status === "REJECTED" /* REJECTED */
|
|
@@ -4496,12 +4494,19 @@ var AcpJob = class {
|
|
|
4496
4494
|
return await this.acpContractClient.handleOperation(operations);
|
|
4497
4495
|
}
|
|
4498
4496
|
async deliver(deliverable) {
|
|
4497
|
+
if (this.phase !== 2 /* TRANSACTION */) {
|
|
4498
|
+
throw new acpError_default("Job is not in transaction phase");
|
|
4499
|
+
}
|
|
4499
4500
|
const operations = [];
|
|
4501
|
+
const memoContent = await this.acpClient.createMemoContent(
|
|
4502
|
+
this.id,
|
|
4503
|
+
preparePayload(deliverable)
|
|
4504
|
+
);
|
|
4500
4505
|
operations.push(
|
|
4501
4506
|
this.acpContractClient.createMemo(
|
|
4502
4507
|
this.id,
|
|
4503
|
-
|
|
4504
|
-
|
|
4508
|
+
memoContent?.url,
|
|
4509
|
+
1 /* CONTEXT_URL */,
|
|
4505
4510
|
true,
|
|
4506
4511
|
4 /* COMPLETED */
|
|
4507
4512
|
)
|
|
@@ -4526,10 +4531,14 @@ var AcpJob = class {
|
|
|
4526
4531
|
);
|
|
4527
4532
|
const feeAmount = new FareAmount(0, this.acpContractClient.config.baseFare);
|
|
4528
4533
|
const isPercentagePricing = this.priceType === "percentage" /* PERCENTAGE */ && !skipFee;
|
|
4534
|
+
const memoContent = await this.acpClient.createMemoContent(
|
|
4535
|
+
this.id,
|
|
4536
|
+
preparePayload(deliverable)
|
|
4537
|
+
);
|
|
4529
4538
|
operations.push(
|
|
4530
4539
|
this.acpContractClient.createPayableMemo(
|
|
4531
4540
|
this.id,
|
|
4532
|
-
|
|
4541
|
+
memoContent.url,
|
|
4533
4542
|
amount.amount,
|
|
4534
4543
|
this.clientAddress,
|
|
4535
4544
|
isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
|
|
@@ -5044,6 +5053,7 @@ var AcpClient = class {
|
|
|
5044
5053
|
job.phase,
|
|
5045
5054
|
job.context,
|
|
5046
5055
|
job.contractAddress,
|
|
5056
|
+
job.deliverable,
|
|
5047
5057
|
job.netPayableAmount
|
|
5048
5058
|
);
|
|
5049
5059
|
} catch (err) {
|