@virtuals-protocol/acp-node 0.3.0-beta.5 → 0.3.0-beta.6
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +37 -18
- package/dist/index.mjs +37 -18
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -435,6 +435,7 @@ declare class AcpJob {
|
|
|
435
435
|
respond(accept: boolean, reason?: string): Promise<`0x${string}`>;
|
|
436
436
|
accept(reason?: string): Promise<`0x${string}`>;
|
|
437
437
|
reject(reason?: string): Promise<`0x${string}`>;
|
|
438
|
+
rejectPayable(reason: string | undefined, amount: FareAmountBase, expiredAt?: Date): Promise<`0x${string}`>;
|
|
438
439
|
deliver(deliverable: DeliverablePayload): Promise<`0x${string}`>;
|
|
439
440
|
deliverPayable(deliverable: DeliverablePayload, amount: FareAmountBase, expiredAt?: Date): Promise<`0x${string}`>;
|
|
440
441
|
evaluate(accept: boolean, reason?: string): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -435,6 +435,7 @@ declare class AcpJob {
|
|
|
435
435
|
respond(accept: boolean, reason?: string): Promise<`0x${string}`>;
|
|
436
436
|
accept(reason?: string): Promise<`0x${string}`>;
|
|
437
437
|
reject(reason?: string): Promise<`0x${string}`>;
|
|
438
|
+
rejectPayable(reason: string | undefined, amount: FareAmountBase, expiredAt?: Date): Promise<`0x${string}`>;
|
|
438
439
|
deliver(deliverable: DeliverablePayload): Promise<`0x${string}`>;
|
|
439
440
|
deliverPayable(deliverable: DeliverablePayload, amount: FareAmountBase, expiredAt?: Date): Promise<`0x${string}`>;
|
|
440
441
|
evaluate(accept: boolean, reason?: string): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -55,7 +55,7 @@ var require_package = __commonJS({
|
|
|
55
55
|
"package.json"(exports2, module2) {
|
|
56
56
|
module2.exports = {
|
|
57
57
|
name: "@virtuals-protocol/acp-node",
|
|
58
|
-
version: "0.3.0-beta.
|
|
58
|
+
version: "0.3.0-beta.6",
|
|
59
59
|
main: "./dist/index.js",
|
|
60
60
|
module: "./dist/index.mjs",
|
|
61
61
|
types: "./dist/index.d.ts",
|
|
@@ -3439,41 +3439,32 @@ var AcpJob = class {
|
|
|
3439
3439
|
const memoContent = `${reason || `Job ${this.id} ${accept ? "accepted" : "rejected"}.`}`;
|
|
3440
3440
|
if (accept) {
|
|
3441
3441
|
yield this.accept(memoContent);
|
|
3442
|
-
return
|
|
3442
|
+
return this.createRequirement(memoContent);
|
|
3443
3443
|
}
|
|
3444
3444
|
return yield this.reject(memoContent);
|
|
3445
3445
|
});
|
|
3446
3446
|
}
|
|
3447
3447
|
accept(reason) {
|
|
3448
3448
|
return __async(this, null, function* () {
|
|
3449
|
-
var _a;
|
|
3450
3449
|
const memoContent = `Job ${this.id} accepted. ${reason || ""}`;
|
|
3451
|
-
const
|
|
3452
|
-
if ((
|
|
3450
|
+
const latestMemo = this.latestMemo;
|
|
3451
|
+
if ((latestMemo == null ? void 0 : latestMemo.nextPhase) !== 1 /* NEGOTIATION */) {
|
|
3453
3452
|
throw new acpError_default("No request memo found");
|
|
3454
3453
|
}
|
|
3455
|
-
|
|
3456
|
-
operations.push(
|
|
3457
|
-
this.acpContractClient.signMemo(memo.id, true, memoContent)
|
|
3458
|
-
);
|
|
3459
|
-
return yield this.acpContractClient.handleOperation(operations);
|
|
3454
|
+
return yield latestMemo.sign(true, memoContent);
|
|
3460
3455
|
});
|
|
3461
3456
|
}
|
|
3462
3457
|
reject(reason) {
|
|
3463
3458
|
return __async(this, null, function* () {
|
|
3464
|
-
var _a;
|
|
3465
3459
|
const memoContent = `Job ${this.id} rejected. ${reason || ""}`;
|
|
3466
|
-
const operations = [];
|
|
3467
3460
|
if (this.phase === 0 /* REQUEST */) {
|
|
3468
|
-
|
|
3461
|
+
const latestMemo = this.latestMemo;
|
|
3462
|
+
if ((latestMemo == null ? void 0 : latestMemo.nextPhase) !== 1 /* NEGOTIATION */) {
|
|
3469
3463
|
throw new acpError_default("No request memo found");
|
|
3470
3464
|
}
|
|
3471
|
-
|
|
3472
|
-
operations.push(
|
|
3473
|
-
this.acpContractClient.signMemo(memo.id, false, memoContent)
|
|
3474
|
-
);
|
|
3475
|
-
return yield this.acpContractClient.handleOperation(operations);
|
|
3465
|
+
return yield latestMemo.sign(false, memoContent);
|
|
3476
3466
|
}
|
|
3467
|
+
const operations = [];
|
|
3477
3468
|
operations.push(
|
|
3478
3469
|
this.acpContractClient.createMemo(
|
|
3479
3470
|
this.id,
|
|
@@ -3486,6 +3477,34 @@ var AcpJob = class {
|
|
|
3486
3477
|
return yield this.acpContractClient.handleOperation(operations);
|
|
3487
3478
|
});
|
|
3488
3479
|
}
|
|
3480
|
+
rejectPayable() {
|
|
3481
|
+
return __async(this, arguments, function* (reason = "", amount, expiredAt = new Date(Date.now() + 1e3 * 60 * 5)) {
|
|
3482
|
+
const memoContent = `Job ${this.id} rejected. ${reason}`;
|
|
3483
|
+
const feeAmount = new FareAmount(0, this.acpContractClient.config.baseFare);
|
|
3484
|
+
const operations = [];
|
|
3485
|
+
operations.push(
|
|
3486
|
+
this.acpContractClient.approveAllowance(
|
|
3487
|
+
amount.amount,
|
|
3488
|
+
amount.fare.contractAddress
|
|
3489
|
+
)
|
|
3490
|
+
);
|
|
3491
|
+
operations.push(
|
|
3492
|
+
this.acpContractClient.createPayableMemo(
|
|
3493
|
+
this.id,
|
|
3494
|
+
memoContent,
|
|
3495
|
+
amount.amount,
|
|
3496
|
+
this.clientAddress,
|
|
3497
|
+
feeAmount.amount,
|
|
3498
|
+
0 /* NO_FEE */,
|
|
3499
|
+
5 /* REJECTED */,
|
|
3500
|
+
7 /* PAYABLE_TRANSFER */,
|
|
3501
|
+
expiredAt,
|
|
3502
|
+
amount.fare.contractAddress
|
|
3503
|
+
)
|
|
3504
|
+
);
|
|
3505
|
+
return yield this.acpContractClient.handleOperation(operations);
|
|
3506
|
+
});
|
|
3507
|
+
}
|
|
3489
3508
|
deliver(deliverable) {
|
|
3490
3509
|
return __async(this, null, function* () {
|
|
3491
3510
|
var _a;
|
package/dist/index.mjs
CHANGED
|
@@ -28,7 +28,7 @@ var require_package = __commonJS({
|
|
|
28
28
|
"package.json"(exports, module) {
|
|
29
29
|
module.exports = {
|
|
30
30
|
name: "@virtuals-protocol/acp-node",
|
|
31
|
-
version: "0.3.0-beta.
|
|
31
|
+
version: "0.3.0-beta.6",
|
|
32
32
|
main: "./dist/index.js",
|
|
33
33
|
module: "./dist/index.mjs",
|
|
34
34
|
types: "./dist/index.d.ts",
|
|
@@ -3391,41 +3391,32 @@ var AcpJob = class {
|
|
|
3391
3391
|
const memoContent = `${reason || `Job ${this.id} ${accept ? "accepted" : "rejected"}.`}`;
|
|
3392
3392
|
if (accept) {
|
|
3393
3393
|
yield this.accept(memoContent);
|
|
3394
|
-
return
|
|
3394
|
+
return this.createRequirement(memoContent);
|
|
3395
3395
|
}
|
|
3396
3396
|
return yield this.reject(memoContent);
|
|
3397
3397
|
});
|
|
3398
3398
|
}
|
|
3399
3399
|
accept(reason) {
|
|
3400
3400
|
return __async(this, null, function* () {
|
|
3401
|
-
var _a;
|
|
3402
3401
|
const memoContent = `Job ${this.id} accepted. ${reason || ""}`;
|
|
3403
|
-
const
|
|
3404
|
-
if ((
|
|
3402
|
+
const latestMemo = this.latestMemo;
|
|
3403
|
+
if ((latestMemo == null ? void 0 : latestMemo.nextPhase) !== 1 /* NEGOTIATION */) {
|
|
3405
3404
|
throw new acpError_default("No request memo found");
|
|
3406
3405
|
}
|
|
3407
|
-
|
|
3408
|
-
operations.push(
|
|
3409
|
-
this.acpContractClient.signMemo(memo.id, true, memoContent)
|
|
3410
|
-
);
|
|
3411
|
-
return yield this.acpContractClient.handleOperation(operations);
|
|
3406
|
+
return yield latestMemo.sign(true, memoContent);
|
|
3412
3407
|
});
|
|
3413
3408
|
}
|
|
3414
3409
|
reject(reason) {
|
|
3415
3410
|
return __async(this, null, function* () {
|
|
3416
|
-
var _a;
|
|
3417
3411
|
const memoContent = `Job ${this.id} rejected. ${reason || ""}`;
|
|
3418
|
-
const operations = [];
|
|
3419
3412
|
if (this.phase === 0 /* REQUEST */) {
|
|
3420
|
-
|
|
3413
|
+
const latestMemo = this.latestMemo;
|
|
3414
|
+
if ((latestMemo == null ? void 0 : latestMemo.nextPhase) !== 1 /* NEGOTIATION */) {
|
|
3421
3415
|
throw new acpError_default("No request memo found");
|
|
3422
3416
|
}
|
|
3423
|
-
|
|
3424
|
-
operations.push(
|
|
3425
|
-
this.acpContractClient.signMemo(memo.id, false, memoContent)
|
|
3426
|
-
);
|
|
3427
|
-
return yield this.acpContractClient.handleOperation(operations);
|
|
3417
|
+
return yield latestMemo.sign(false, memoContent);
|
|
3428
3418
|
}
|
|
3419
|
+
const operations = [];
|
|
3429
3420
|
operations.push(
|
|
3430
3421
|
this.acpContractClient.createMemo(
|
|
3431
3422
|
this.id,
|
|
@@ -3438,6 +3429,34 @@ var AcpJob = class {
|
|
|
3438
3429
|
return yield this.acpContractClient.handleOperation(operations);
|
|
3439
3430
|
});
|
|
3440
3431
|
}
|
|
3432
|
+
rejectPayable() {
|
|
3433
|
+
return __async(this, arguments, function* (reason = "", amount, expiredAt = new Date(Date.now() + 1e3 * 60 * 5)) {
|
|
3434
|
+
const memoContent = `Job ${this.id} rejected. ${reason}`;
|
|
3435
|
+
const feeAmount = new FareAmount(0, this.acpContractClient.config.baseFare);
|
|
3436
|
+
const operations = [];
|
|
3437
|
+
operations.push(
|
|
3438
|
+
this.acpContractClient.approveAllowance(
|
|
3439
|
+
amount.amount,
|
|
3440
|
+
amount.fare.contractAddress
|
|
3441
|
+
)
|
|
3442
|
+
);
|
|
3443
|
+
operations.push(
|
|
3444
|
+
this.acpContractClient.createPayableMemo(
|
|
3445
|
+
this.id,
|
|
3446
|
+
memoContent,
|
|
3447
|
+
amount.amount,
|
|
3448
|
+
this.clientAddress,
|
|
3449
|
+
feeAmount.amount,
|
|
3450
|
+
0 /* NO_FEE */,
|
|
3451
|
+
5 /* REJECTED */,
|
|
3452
|
+
7 /* PAYABLE_TRANSFER */,
|
|
3453
|
+
expiredAt,
|
|
3454
|
+
amount.fare.contractAddress
|
|
3455
|
+
)
|
|
3456
|
+
);
|
|
3457
|
+
return yield this.acpContractClient.handleOperation(operations);
|
|
3458
|
+
});
|
|
3459
|
+
}
|
|
3441
3460
|
deliver(deliverable) {
|
|
3442
3461
|
return __async(this, null, function* () {
|
|
3443
3462
|
var _a;
|