@virtuals-protocol/acp-node 0.1.0-beta.9 → 0.2.0-beta.2
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/README.md +54 -13
- package/dist/index.d.mts +280 -142
- package/dist/index.d.ts +280 -142
- package/dist/index.js +941 -113
- package/dist/index.mjs +947 -114
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19,6 +19,9 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
}
|
|
20
20
|
return a;
|
|
21
21
|
};
|
|
22
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
23
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
24
|
+
};
|
|
22
25
|
var __export = (target, all) => {
|
|
23
26
|
for (var name in all)
|
|
24
27
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -61,16 +64,54 @@ var __async = (__this, __arguments, generator) => {
|
|
|
61
64
|
});
|
|
62
65
|
};
|
|
63
66
|
|
|
67
|
+
// package.json
|
|
68
|
+
var require_package = __commonJS({
|
|
69
|
+
"package.json"(exports2, module2) {
|
|
70
|
+
module2.exports = {
|
|
71
|
+
name: "@virtuals-protocol/acp-node",
|
|
72
|
+
version: "0.2.0-beta.2",
|
|
73
|
+
main: "./dist/index.js",
|
|
74
|
+
module: "./dist/index.mjs",
|
|
75
|
+
types: "./dist/index.d.ts",
|
|
76
|
+
scripts: {
|
|
77
|
+
test: 'echo "Error: no test specified" && exit 1',
|
|
78
|
+
tsup: "tsup src/index.ts --dts --format cjs,esm --out-dir dist"
|
|
79
|
+
},
|
|
80
|
+
author: "",
|
|
81
|
+
license: "ISC",
|
|
82
|
+
description: "",
|
|
83
|
+
devDependencies: {
|
|
84
|
+
typescript: "^5.8.3"
|
|
85
|
+
},
|
|
86
|
+
dependencies: {
|
|
87
|
+
"@aa-sdk/core": "^4.30.0",
|
|
88
|
+
"@account-kit/infra": "^4.30.0",
|
|
89
|
+
"@account-kit/smart-contracts": "^4.30.0",
|
|
90
|
+
ajv: "^8.17.1",
|
|
91
|
+
"socket.io-client": "^4.8.1",
|
|
92
|
+
tsup: "^8.5.0",
|
|
93
|
+
viem: "^2.28.2"
|
|
94
|
+
},
|
|
95
|
+
files: [
|
|
96
|
+
"dist"
|
|
97
|
+
]
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
64
102
|
// src/index.ts
|
|
65
103
|
var index_exports = {};
|
|
66
104
|
__export(index_exports, {
|
|
67
105
|
ACP_ABI: () => acpAbi_default,
|
|
68
106
|
AcpAgentSort: () => AcpAgentSort,
|
|
69
107
|
AcpContractClient: () => acpContractClient_default,
|
|
108
|
+
AcpGraduationStatus: () => AcpGraduationStatus,
|
|
70
109
|
AcpJob: () => acpJob_default,
|
|
71
110
|
AcpJobPhases: () => AcpJobPhases,
|
|
72
111
|
AcpMemo: () => acpMemo_default,
|
|
112
|
+
AcpOnlineStatus: () => AcpOnlineStatus,
|
|
73
113
|
MemoType: () => MemoType,
|
|
114
|
+
PayloadType: () => PayloadType,
|
|
74
115
|
baseAcpConfig: () => baseAcpConfig,
|
|
75
116
|
baseSepoliaAcpConfig: () => baseSepoliaAcpConfig,
|
|
76
117
|
default: () => index_default
|
|
@@ -286,11 +327,176 @@ var ACP_ABI = [
|
|
|
286
327
|
internalType: "uint256",
|
|
287
328
|
name: "memoId",
|
|
288
329
|
type: "uint256"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
indexed: false,
|
|
333
|
+
internalType: "string",
|
|
334
|
+
name: "content",
|
|
335
|
+
type: "string"
|
|
289
336
|
}
|
|
290
337
|
],
|
|
291
338
|
name: "NewMemo",
|
|
292
339
|
type: "event"
|
|
293
340
|
},
|
|
341
|
+
{
|
|
342
|
+
anonymous: false,
|
|
343
|
+
inputs: [
|
|
344
|
+
{
|
|
345
|
+
indexed: true,
|
|
346
|
+
internalType: "uint256",
|
|
347
|
+
name: "jobId",
|
|
348
|
+
type: "uint256"
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
indexed: true,
|
|
352
|
+
internalType: "uint256",
|
|
353
|
+
name: "memoId",
|
|
354
|
+
type: "uint256"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
indexed: true,
|
|
358
|
+
internalType: "address",
|
|
359
|
+
name: "payer",
|
|
360
|
+
type: "address"
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
indexed: false,
|
|
364
|
+
internalType: "uint256",
|
|
365
|
+
name: "amount",
|
|
366
|
+
type: "uint256"
|
|
367
|
+
}
|
|
368
|
+
],
|
|
369
|
+
name: "PayableFeeCollected",
|
|
370
|
+
type: "event"
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
anonymous: false,
|
|
374
|
+
inputs: [
|
|
375
|
+
{
|
|
376
|
+
indexed: true,
|
|
377
|
+
internalType: "uint256",
|
|
378
|
+
name: "jobId",
|
|
379
|
+
type: "uint256"
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
indexed: true,
|
|
383
|
+
internalType: "uint256",
|
|
384
|
+
name: "memoId",
|
|
385
|
+
type: "uint256"
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
indexed: true,
|
|
389
|
+
internalType: "address",
|
|
390
|
+
name: "payer",
|
|
391
|
+
type: "address"
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
indexed: false,
|
|
395
|
+
internalType: "address",
|
|
396
|
+
name: "recipient",
|
|
397
|
+
type: "address"
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
indexed: false,
|
|
401
|
+
internalType: "uint256",
|
|
402
|
+
name: "netAmount",
|
|
403
|
+
type: "uint256"
|
|
404
|
+
}
|
|
405
|
+
],
|
|
406
|
+
name: "PayableFeeRequestExecuted",
|
|
407
|
+
type: "event"
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
anonymous: false,
|
|
411
|
+
inputs: [
|
|
412
|
+
{
|
|
413
|
+
indexed: true,
|
|
414
|
+
internalType: "uint256",
|
|
415
|
+
name: "jobId",
|
|
416
|
+
type: "uint256"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
indexed: true,
|
|
420
|
+
internalType: "uint256",
|
|
421
|
+
name: "memoId",
|
|
422
|
+
type: "uint256"
|
|
423
|
+
},
|
|
424
|
+
{ indexed: true, internalType: "address", name: "from", type: "address" },
|
|
425
|
+
{ indexed: false, internalType: "address", name: "to", type: "address" },
|
|
426
|
+
{
|
|
427
|
+
indexed: false,
|
|
428
|
+
internalType: "address",
|
|
429
|
+
name: "token",
|
|
430
|
+
type: "address"
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
indexed: false,
|
|
434
|
+
internalType: "uint256",
|
|
435
|
+
name: "amount",
|
|
436
|
+
type: "uint256"
|
|
437
|
+
}
|
|
438
|
+
],
|
|
439
|
+
name: "PayableRequestExecuted",
|
|
440
|
+
type: "event"
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
anonymous: false,
|
|
444
|
+
inputs: [
|
|
445
|
+
{
|
|
446
|
+
indexed: true,
|
|
447
|
+
internalType: "uint256",
|
|
448
|
+
name: "jobId",
|
|
449
|
+
type: "uint256"
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
indexed: true,
|
|
453
|
+
internalType: "uint256",
|
|
454
|
+
name: "memoId",
|
|
455
|
+
type: "uint256"
|
|
456
|
+
},
|
|
457
|
+
{ indexed: true, internalType: "address", name: "from", type: "address" },
|
|
458
|
+
{ indexed: false, internalType: "address", name: "to", type: "address" },
|
|
459
|
+
{
|
|
460
|
+
indexed: false,
|
|
461
|
+
internalType: "address",
|
|
462
|
+
name: "token",
|
|
463
|
+
type: "address"
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
indexed: false,
|
|
467
|
+
internalType: "uint256",
|
|
468
|
+
name: "amount",
|
|
469
|
+
type: "uint256"
|
|
470
|
+
}
|
|
471
|
+
],
|
|
472
|
+
name: "PayableTransferExecuted",
|
|
473
|
+
type: "event"
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
anonymous: false,
|
|
477
|
+
inputs: [
|
|
478
|
+
{
|
|
479
|
+
indexed: true,
|
|
480
|
+
internalType: "uint256",
|
|
481
|
+
name: "jobId",
|
|
482
|
+
type: "uint256"
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
indexed: true,
|
|
486
|
+
internalType: "address",
|
|
487
|
+
name: "client",
|
|
488
|
+
type: "address"
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
indexed: false,
|
|
492
|
+
internalType: "uint256",
|
|
493
|
+
name: "amount",
|
|
494
|
+
type: "uint256"
|
|
495
|
+
}
|
|
496
|
+
],
|
|
497
|
+
name: "RefundedAdditionalFees",
|
|
498
|
+
type: "event"
|
|
499
|
+
},
|
|
294
500
|
{
|
|
295
501
|
anonymous: false,
|
|
296
502
|
inputs: [
|
|
@@ -404,6 +610,13 @@ var ACP_ABI = [
|
|
|
404
610
|
stateMutability: "view",
|
|
405
611
|
type: "function"
|
|
406
612
|
},
|
|
613
|
+
{
|
|
614
|
+
inputs: [],
|
|
615
|
+
name: "PHASE_EXPIRED",
|
|
616
|
+
outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
|
|
617
|
+
stateMutability: "view",
|
|
618
|
+
type: "function"
|
|
619
|
+
},
|
|
407
620
|
{
|
|
408
621
|
inputs: [],
|
|
409
622
|
name: "PHASE_NEGOTIATION",
|
|
@@ -442,11 +655,26 @@ var ACP_ABI = [
|
|
|
442
655
|
{
|
|
443
656
|
inputs: [
|
|
444
657
|
{ internalType: "address", name: "account", type: "address" },
|
|
445
|
-
{
|
|
658
|
+
{
|
|
659
|
+
components: [
|
|
660
|
+
{ internalType: "uint256", name: "id", type: "uint256" },
|
|
661
|
+
{ internalType: "address", name: "client", type: "address" },
|
|
662
|
+
{ internalType: "address", name: "provider", type: "address" },
|
|
663
|
+
{ internalType: "uint256", name: "budget", type: "uint256" },
|
|
664
|
+
{ internalType: "uint256", name: "amountClaimed", type: "uint256" },
|
|
665
|
+
{ internalType: "uint8", name: "phase", type: "uint8" },
|
|
666
|
+
{ internalType: "uint256", name: "memoCount", type: "uint256" },
|
|
667
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
668
|
+
{ internalType: "address", name: "evaluator", type: "address" }
|
|
669
|
+
],
|
|
670
|
+
internalType: "struct ACPSimple.Job",
|
|
671
|
+
name: "job",
|
|
672
|
+
type: "tuple"
|
|
673
|
+
}
|
|
446
674
|
],
|
|
447
675
|
name: "canSign",
|
|
448
676
|
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
449
|
-
stateMutability: "
|
|
677
|
+
stateMutability: "pure",
|
|
450
678
|
type: "function"
|
|
451
679
|
},
|
|
452
680
|
{
|
|
@@ -484,6 +712,32 @@ var ACP_ABI = [
|
|
|
484
712
|
stateMutability: "nonpayable",
|
|
485
713
|
type: "function"
|
|
486
714
|
},
|
|
715
|
+
{
|
|
716
|
+
inputs: [
|
|
717
|
+
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
718
|
+
{ internalType: "string", name: "content", type: "string" },
|
|
719
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
720
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
721
|
+
{ internalType: "address", name: "recipient", type: "address" },
|
|
722
|
+
{ internalType: "uint256", name: "feeAmount", type: "uint256" },
|
|
723
|
+
{
|
|
724
|
+
internalType: "enum ACPSimple.FeeType",
|
|
725
|
+
name: "feeType",
|
|
726
|
+
type: "uint8"
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
internalType: "enum InteractionLedger.MemoType",
|
|
730
|
+
name: "memoType",
|
|
731
|
+
type: "uint8"
|
|
732
|
+
},
|
|
733
|
+
{ internalType: "uint8", name: "nextPhase", type: "uint8" },
|
|
734
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" }
|
|
735
|
+
],
|
|
736
|
+
name: "createPayableMemo",
|
|
737
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
738
|
+
stateMutability: "nonpayable",
|
|
739
|
+
type: "function"
|
|
740
|
+
},
|
|
487
741
|
{
|
|
488
742
|
inputs: [],
|
|
489
743
|
name: "evaluatorFeeBP",
|
|
@@ -521,6 +775,16 @@ var ACP_ABI = [
|
|
|
521
775
|
stateMutability: "view",
|
|
522
776
|
type: "function"
|
|
523
777
|
},
|
|
778
|
+
{
|
|
779
|
+
inputs: [
|
|
780
|
+
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
781
|
+
{ internalType: "uint8", name: "phase", type: "uint8" }
|
|
782
|
+
],
|
|
783
|
+
name: "getJobPhaseMemoIds",
|
|
784
|
+
outputs: [{ internalType: "uint256[]", name: "", type: "uint256[]" }],
|
|
785
|
+
stateMutability: "view",
|
|
786
|
+
type: "function"
|
|
787
|
+
},
|
|
524
788
|
{
|
|
525
789
|
inputs: [
|
|
526
790
|
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
@@ -555,7 +819,7 @@ var ACP_ABI = [
|
|
|
555
819
|
{
|
|
556
820
|
inputs: [],
|
|
557
821
|
name: "getPhases",
|
|
558
|
-
outputs: [{ internalType: "string[
|
|
822
|
+
outputs: [{ internalType: "string[7]", name: "", type: "string[7]" }],
|
|
559
823
|
stateMutability: "pure",
|
|
560
824
|
type: "function"
|
|
561
825
|
},
|
|
@@ -608,6 +872,20 @@ var ACP_ABI = [
|
|
|
608
872
|
stateMutability: "view",
|
|
609
873
|
type: "function"
|
|
610
874
|
},
|
|
875
|
+
{
|
|
876
|
+
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
877
|
+
name: "isPayableMemo",
|
|
878
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
879
|
+
stateMutability: "view",
|
|
880
|
+
type: "function"
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
inputs: [{ internalType: "uint256", name: "jobId", type: "uint256" }],
|
|
884
|
+
name: "jobAdditionalFees",
|
|
885
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
886
|
+
stateMutability: "view",
|
|
887
|
+
type: "function"
|
|
888
|
+
},
|
|
611
889
|
{
|
|
612
890
|
inputs: [],
|
|
613
891
|
name: "jobCounter",
|
|
@@ -650,6 +928,31 @@ var ACP_ABI = [
|
|
|
650
928
|
stateMutability: "view",
|
|
651
929
|
type: "function"
|
|
652
930
|
},
|
|
931
|
+
{
|
|
932
|
+
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
933
|
+
name: "memoExpiredAt",
|
|
934
|
+
outputs: [{ internalType: "uint256", name: "expiredAt", type: "uint256" }],
|
|
935
|
+
stateMutability: "view",
|
|
936
|
+
type: "function"
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
940
|
+
name: "memos",
|
|
941
|
+
outputs: [
|
|
942
|
+
{ internalType: "string", name: "content", type: "string" },
|
|
943
|
+
{
|
|
944
|
+
internalType: "enum InteractionLedger.MemoType",
|
|
945
|
+
name: "memoType",
|
|
946
|
+
type: "uint8"
|
|
947
|
+
},
|
|
948
|
+
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
949
|
+
{ internalType: "uint8", name: "nextPhase", type: "uint8" },
|
|
950
|
+
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
951
|
+
{ internalType: "address", name: "sender", type: "address" }
|
|
952
|
+
],
|
|
953
|
+
stateMutability: "view",
|
|
954
|
+
type: "function"
|
|
955
|
+
},
|
|
653
956
|
{
|
|
654
957
|
inputs: [],
|
|
655
958
|
name: "numEvaluatorsPerJob",
|
|
@@ -657,6 +960,24 @@ var ACP_ABI = [
|
|
|
657
960
|
stateMutability: "view",
|
|
658
961
|
type: "function"
|
|
659
962
|
},
|
|
963
|
+
{
|
|
964
|
+
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
965
|
+
name: "payableDetails",
|
|
966
|
+
outputs: [
|
|
967
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
968
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
969
|
+
{ internalType: "address", name: "recipient", type: "address" },
|
|
970
|
+
{ internalType: "uint256", name: "feeAmount", type: "uint256" },
|
|
971
|
+
{
|
|
972
|
+
internalType: "enum ACPSimple.FeeType",
|
|
973
|
+
name: "feeType",
|
|
974
|
+
type: "uint8"
|
|
975
|
+
},
|
|
976
|
+
{ internalType: "bool", name: "isExecuted", type: "bool" }
|
|
977
|
+
],
|
|
978
|
+
stateMutability: "view",
|
|
979
|
+
type: "function"
|
|
980
|
+
},
|
|
660
981
|
{
|
|
661
982
|
inputs: [],
|
|
662
983
|
name: "paymentToken",
|
|
@@ -771,21 +1092,28 @@ var import_smart_contracts = require("@account-kit/smart-contracts");
|
|
|
771
1092
|
var import_infra = require("@account-kit/infra");
|
|
772
1093
|
var baseSepoliaAcpConfig = {
|
|
773
1094
|
chain: import_infra.baseSepolia,
|
|
774
|
-
contractAddress: "
|
|
1095
|
+
contractAddress: "0x8Db6B1c839Fc8f6bd35777E194677B67b4D51928",
|
|
775
1096
|
virtualsTokenAddress: "0xbfAB80ccc15DF6fb7185f9498d6039317331846a",
|
|
776
1097
|
alchemyRpcUrl: "https://alchemy-proxy.virtuals.io/api/proxy/rpc",
|
|
777
|
-
acpUrl: "https://acpx
|
|
1098
|
+
acpUrl: "https://acpx.virtuals.gg",
|
|
1099
|
+
priorityFeeMultiplier: 2,
|
|
1100
|
+
maxFeePerGas: 2e7,
|
|
1101
|
+
maxPriorityFeePerGas: 21e6
|
|
778
1102
|
};
|
|
779
1103
|
var baseAcpConfig = {
|
|
780
1104
|
chain: import_infra.base,
|
|
781
1105
|
contractAddress: "0x6a1FE26D54ab0d3E1e3168f2e0c0cDa5cC0A0A4A",
|
|
782
1106
|
virtualsTokenAddress: "0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b",
|
|
783
1107
|
alchemyRpcUrl: "https://alchemy-proxy-prod.virtuals.io/api/proxy/rpc",
|
|
784
|
-
acpUrl: "https://acpx.virtuals.io"
|
|
1108
|
+
acpUrl: "https://acpx.virtuals.io",
|
|
1109
|
+
priorityFeeMultiplier: 2,
|
|
1110
|
+
maxFeePerGas: 2e7,
|
|
1111
|
+
maxPriorityFeePerGas: 21e6
|
|
785
1112
|
};
|
|
786
1113
|
|
|
787
1114
|
// src/acpContractClient.ts
|
|
788
1115
|
var import_viem = require("viem");
|
|
1116
|
+
var import_op_stack = require("viem/op-stack");
|
|
789
1117
|
var MemoType = /* @__PURE__ */ ((MemoType2) => {
|
|
790
1118
|
MemoType2[MemoType2["MESSAGE"] = 0] = "MESSAGE";
|
|
791
1119
|
MemoType2[MemoType2["CONTEXT_URL"] = 1] = "CONTEXT_URL";
|
|
@@ -793,6 +1121,10 @@ var MemoType = /* @__PURE__ */ ((MemoType2) => {
|
|
|
793
1121
|
MemoType2[MemoType2["VOICE_URL"] = 3] = "VOICE_URL";
|
|
794
1122
|
MemoType2[MemoType2["OBJECT_URL"] = 4] = "OBJECT_URL";
|
|
795
1123
|
MemoType2[MemoType2["TXHASH"] = 5] = "TXHASH";
|
|
1124
|
+
MemoType2[MemoType2["PAYABLE_REQUEST"] = 6] = "PAYABLE_REQUEST";
|
|
1125
|
+
MemoType2[MemoType2["PAYABLE_TRANSFER"] = 7] = "PAYABLE_TRANSFER";
|
|
1126
|
+
MemoType2[MemoType2["PAYABLE_FEE"] = 8] = "PAYABLE_FEE";
|
|
1127
|
+
MemoType2[MemoType2["PAYABLE_FEE_REQUEST"] = 9] = "PAYABLE_FEE_REQUEST";
|
|
796
1128
|
return MemoType2;
|
|
797
1129
|
})(MemoType || {});
|
|
798
1130
|
var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
|
|
@@ -802,25 +1134,34 @@ var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
|
|
|
802
1134
|
AcpJobPhases2[AcpJobPhases2["EVALUATION"] = 3] = "EVALUATION";
|
|
803
1135
|
AcpJobPhases2[AcpJobPhases2["COMPLETED"] = 4] = "COMPLETED";
|
|
804
1136
|
AcpJobPhases2[AcpJobPhases2["REJECTED"] = 5] = "REJECTED";
|
|
1137
|
+
AcpJobPhases2[AcpJobPhases2["EXPIRED"] = 6] = "EXPIRED";
|
|
805
1138
|
return AcpJobPhases2;
|
|
806
1139
|
})(AcpJobPhases || {});
|
|
807
1140
|
var AcpContractClient = class _AcpContractClient {
|
|
808
|
-
constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
|
|
1141
|
+
constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig, customRpcUrl) {
|
|
809
1142
|
this.walletPrivateKey = walletPrivateKey;
|
|
810
1143
|
this.sessionEntityKeyId = sessionEntityKeyId;
|
|
811
1144
|
this.agentWalletAddress = agentWalletAddress;
|
|
812
1145
|
this.config = config;
|
|
1146
|
+
this.customRpcUrl = customRpcUrl;
|
|
1147
|
+
this.MAX_RETRIES = 3;
|
|
813
1148
|
this.chain = config.chain;
|
|
814
1149
|
this.contractAddress = config.contractAddress;
|
|
815
1150
|
this.virtualsTokenAddress = config.virtualsTokenAddress;
|
|
1151
|
+
this.customRpcUrl = customRpcUrl;
|
|
1152
|
+
this.customRpcClient = (0, import_viem.createPublicClient)({
|
|
1153
|
+
chain: this.chain,
|
|
1154
|
+
transport: this.customRpcUrl ? (0, import_viem.http)(this.customRpcUrl) : (0, import_viem.http)()
|
|
1155
|
+
}).extend((0, import_op_stack.publicActionsL2)());
|
|
816
1156
|
}
|
|
817
|
-
static build(_0, _1, _2) {
|
|
818
|
-
return __async(this, arguments, function* (walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
|
|
1157
|
+
static build(_0, _1, _2, _3) {
|
|
1158
|
+
return __async(this, arguments, function* (walletPrivateKey, sessionEntityKeyId, agentWalletAddress, customRpcUrl, config = baseAcpConfig) {
|
|
819
1159
|
const acpContractClient = new _AcpContractClient(
|
|
820
1160
|
walletPrivateKey,
|
|
821
1161
|
sessionEntityKeyId,
|
|
822
1162
|
agentWalletAddress,
|
|
823
|
-
config
|
|
1163
|
+
config,
|
|
1164
|
+
customRpcUrl
|
|
824
1165
|
);
|
|
825
1166
|
yield acpContractClient.init();
|
|
826
1167
|
return acpContractClient;
|
|
@@ -853,6 +1194,54 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
853
1194
|
get walletAddress() {
|
|
854
1195
|
return this.sessionKeyClient.account.address;
|
|
855
1196
|
}
|
|
1197
|
+
calculateGasFees() {
|
|
1198
|
+
return __async(this, null, function* () {
|
|
1199
|
+
const { maxFeePerGas, maxPriorityFeePerGas } = yield this.customRpcClient.estimateFeesPerGas();
|
|
1200
|
+
let finalMaxFeePerGas = maxFeePerGas;
|
|
1201
|
+
let priorityFeeMultiplier = Number(this.config.priorityFeeMultiplier) || 2;
|
|
1202
|
+
const overrideMaxFeePerGas = this.config.maxFeePerGas || maxFeePerGas;
|
|
1203
|
+
const overrideMaxPriorityFeePerGas = this.config.maxPriorityFeePerGas || maxPriorityFeePerGas;
|
|
1204
|
+
finalMaxFeePerGas = BigInt(overrideMaxFeePerGas) + BigInt(overrideMaxPriorityFeePerGas) * BigInt(Math.max(0, priorityFeeMultiplier - 1));
|
|
1205
|
+
return finalMaxFeePerGas;
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
handleSendUserOperation(_0) {
|
|
1209
|
+
return __async(this, arguments, function* (data, contractAddress = this.contractAddress) {
|
|
1210
|
+
const payload = {
|
|
1211
|
+
uo: {
|
|
1212
|
+
target: contractAddress,
|
|
1213
|
+
data
|
|
1214
|
+
},
|
|
1215
|
+
overrides: {}
|
|
1216
|
+
};
|
|
1217
|
+
let retries = this.MAX_RETRIES;
|
|
1218
|
+
let finalError;
|
|
1219
|
+
while (retries > 0) {
|
|
1220
|
+
try {
|
|
1221
|
+
if (this.MAX_RETRIES > retries) {
|
|
1222
|
+
const gasFees = yield this.calculateGasFees();
|
|
1223
|
+
payload["overrides"] = {
|
|
1224
|
+
maxFeePerGas: `0x${gasFees.toString(16)}`
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1227
|
+
const { hash } = yield this.sessionKeyClient.sendUserOperation(payload);
|
|
1228
|
+
yield this.sessionKeyClient.waitForUserOperationTransaction({
|
|
1229
|
+
hash
|
|
1230
|
+
});
|
|
1231
|
+
return hash;
|
|
1232
|
+
} catch (error) {
|
|
1233
|
+
console.debug("Failed to send user operation", error);
|
|
1234
|
+
retries -= 1;
|
|
1235
|
+
if (retries === 0) {
|
|
1236
|
+
finalError = error;
|
|
1237
|
+
break;
|
|
1238
|
+
}
|
|
1239
|
+
yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
throw new Error(`Failed to send user operation ${finalError}`);
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
856
1245
|
getJobId(hash) {
|
|
857
1246
|
return __async(this, null, function* () {
|
|
858
1247
|
const result = yield this.sessionKeyClient.getUserOperationReceipt(hash);
|
|
@@ -880,51 +1269,42 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
880
1269
|
Math.floor(expireAt.getTime() / 1e3)
|
|
881
1270
|
]
|
|
882
1271
|
});
|
|
883
|
-
const
|
|
884
|
-
uo: {
|
|
885
|
-
target: this.contractAddress,
|
|
886
|
-
data
|
|
887
|
-
}
|
|
888
|
-
});
|
|
889
|
-
yield this.sessionKeyClient.waitForUserOperationTransaction({
|
|
890
|
-
hash
|
|
891
|
-
});
|
|
1272
|
+
const hash = yield this.handleSendUserOperation(data);
|
|
892
1273
|
const jobId = yield this.getJobId(hash);
|
|
893
1274
|
return { txHash: hash, jobId };
|
|
894
1275
|
} catch (error) {
|
|
895
|
-
console.error(error);
|
|
1276
|
+
console.error(`Failed to create job ${error}`);
|
|
896
1277
|
throw new Error("Failed to create job");
|
|
897
1278
|
}
|
|
898
1279
|
});
|
|
899
1280
|
}
|
|
900
1281
|
approveAllowance(priceInWei) {
|
|
901
1282
|
return __async(this, null, function* () {
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
})
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
}
|
|
916
|
-
return hash;
|
|
1283
|
+
try {
|
|
1284
|
+
const data = (0, import_viem.encodeFunctionData)({
|
|
1285
|
+
abi: import_viem.erc20Abi,
|
|
1286
|
+
functionName: "approve",
|
|
1287
|
+
args: [this.contractAddress, priceInWei]
|
|
1288
|
+
});
|
|
1289
|
+
return yield this.handleSendUserOperation(
|
|
1290
|
+
data,
|
|
1291
|
+
this.virtualsTokenAddress
|
|
1292
|
+
);
|
|
1293
|
+
} catch (error) {
|
|
1294
|
+
console.error(`Failed to approve allowance ${error}`);
|
|
1295
|
+
throw new Error("Failed to approve allowance");
|
|
1296
|
+
}
|
|
917
1297
|
});
|
|
918
1298
|
}
|
|
919
|
-
|
|
1299
|
+
createPayableFeeMemo(jobId, content, amount, memoType, nextPhase) {
|
|
920
1300
|
return __async(this, null, function* () {
|
|
921
1301
|
let retries = 3;
|
|
922
1302
|
while (retries > 0) {
|
|
923
1303
|
try {
|
|
924
1304
|
const data = (0, import_viem.encodeFunctionData)({
|
|
925
1305
|
abi: acpAbi_default,
|
|
926
|
-
functionName: "
|
|
927
|
-
args: [jobId, content,
|
|
1306
|
+
functionName: "createPayableFeeMemo",
|
|
1307
|
+
args: [jobId, content, amount, memoType, nextPhase]
|
|
928
1308
|
});
|
|
929
1309
|
const { hash } = yield this.sessionKeyClient.sendUserOperation({
|
|
930
1310
|
uo: {
|
|
@@ -937,23 +1317,36 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
937
1317
|
});
|
|
938
1318
|
return hash;
|
|
939
1319
|
} catch (error) {
|
|
940
|
-
console.error(
|
|
1320
|
+
console.error(
|
|
1321
|
+
`failed to create payable fee memo ${jobId} ${content} ${error}`
|
|
1322
|
+
);
|
|
941
1323
|
retries -= 1;
|
|
942
1324
|
yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
|
|
943
1325
|
}
|
|
944
1326
|
}
|
|
945
|
-
throw new Error("Failed to create memo");
|
|
1327
|
+
throw new Error("Failed to create payable fee memo");
|
|
946
1328
|
});
|
|
947
1329
|
}
|
|
948
|
-
|
|
949
|
-
return __async(this,
|
|
1330
|
+
createPayableMemo(_0, _1, _2, _3, _4, _5, _6, _7, _8) {
|
|
1331
|
+
return __async(this, arguments, function* (jobId, content, amount, recipient, feeAmount, feeType, nextPhase, type, expiredAt, token = this.config.virtualsTokenAddress) {
|
|
950
1332
|
let retries = 3;
|
|
951
1333
|
while (retries > 0) {
|
|
952
1334
|
try {
|
|
953
1335
|
const data = (0, import_viem.encodeFunctionData)({
|
|
954
1336
|
abi: acpAbi_default,
|
|
955
|
-
functionName: "
|
|
956
|
-
args: [
|
|
1337
|
+
functionName: "createPayableMemo",
|
|
1338
|
+
args: [
|
|
1339
|
+
jobId,
|
|
1340
|
+
content,
|
|
1341
|
+
token,
|
|
1342
|
+
amount,
|
|
1343
|
+
recipient,
|
|
1344
|
+
feeAmount,
|
|
1345
|
+
feeType,
|
|
1346
|
+
type,
|
|
1347
|
+
nextPhase,
|
|
1348
|
+
expiredAt ? Math.floor(expiredAt.getTime() / 1e3) : 0
|
|
1349
|
+
]
|
|
957
1350
|
});
|
|
958
1351
|
const { hash } = yield this.sessionKeyClient.sendUserOperation({
|
|
959
1352
|
uo: {
|
|
@@ -966,12 +1359,67 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
966
1359
|
});
|
|
967
1360
|
return hash;
|
|
968
1361
|
} catch (error) {
|
|
969
|
-
console.error(
|
|
1362
|
+
console.error(
|
|
1363
|
+
`failed to create payable memo ${jobId} ${content} ${error}`
|
|
1364
|
+
);
|
|
970
1365
|
retries -= 1;
|
|
971
1366
|
yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
|
|
972
1367
|
}
|
|
973
1368
|
}
|
|
974
|
-
throw new Error("Failed to
|
|
1369
|
+
throw new Error("Failed to create payable memo");
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
createMemo(jobId, content, type, isSecured, nextPhase) {
|
|
1373
|
+
return __async(this, null, function* () {
|
|
1374
|
+
try {
|
|
1375
|
+
const data = (0, import_viem.encodeFunctionData)({
|
|
1376
|
+
abi: acpAbi_default,
|
|
1377
|
+
functionName: "createMemo",
|
|
1378
|
+
args: [jobId, content, type, isSecured, nextPhase]
|
|
1379
|
+
});
|
|
1380
|
+
return yield this.handleSendUserOperation(data);
|
|
1381
|
+
} catch (error) {
|
|
1382
|
+
console.error(`Failed to create memo ${jobId} ${content} ${error}`);
|
|
1383
|
+
throw new Error("Failed to create memo");
|
|
1384
|
+
}
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
getMemoId(hash) {
|
|
1388
|
+
return __async(this, null, function* () {
|
|
1389
|
+
const result = yield this.sessionKeyClient.getUserOperationReceipt(hash);
|
|
1390
|
+
if (!result) {
|
|
1391
|
+
throw new Error("Failed to get user operation receipt");
|
|
1392
|
+
}
|
|
1393
|
+
const contractLogs = result.logs.find(
|
|
1394
|
+
(log) => log.address.toLowerCase() === this.contractAddress.toLowerCase()
|
|
1395
|
+
);
|
|
1396
|
+
if (!contractLogs) {
|
|
1397
|
+
throw new Error("Failed to get contract logs");
|
|
1398
|
+
}
|
|
1399
|
+
const decoded = (0, import_viem.decodeEventLog)({
|
|
1400
|
+
abi: acpAbi_default,
|
|
1401
|
+
data: contractLogs.data,
|
|
1402
|
+
topics: contractLogs.topics
|
|
1403
|
+
});
|
|
1404
|
+
if (!decoded.args) {
|
|
1405
|
+
throw new Error("Failed to decode event logs");
|
|
1406
|
+
}
|
|
1407
|
+
return parseInt(decoded.args.memoId);
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
signMemo(memoId, isApproved, reason) {
|
|
1411
|
+
return __async(this, null, function* () {
|
|
1412
|
+
try {
|
|
1413
|
+
const data = (0, import_viem.encodeFunctionData)({
|
|
1414
|
+
abi: acpAbi_default,
|
|
1415
|
+
functionName: "signMemo",
|
|
1416
|
+
args: [memoId, isApproved, reason]
|
|
1417
|
+
});
|
|
1418
|
+
return yield this.handleSendUserOperation(data);
|
|
1419
|
+
} catch (error) {
|
|
1420
|
+
console.error(`Failed to sign memo ${error}`);
|
|
1421
|
+
throw new Error("Failed to sign memo");
|
|
1422
|
+
}
|
|
975
1423
|
});
|
|
976
1424
|
}
|
|
977
1425
|
setBudget(jobId, budget) {
|
|
@@ -982,18 +1430,9 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
982
1430
|
functionName: "setBudget",
|
|
983
1431
|
args: [jobId, budget]
|
|
984
1432
|
});
|
|
985
|
-
|
|
986
|
-
uo: {
|
|
987
|
-
target: this.contractAddress,
|
|
988
|
-
data
|
|
989
|
-
}
|
|
990
|
-
});
|
|
991
|
-
yield this.sessionKeyClient.waitForUserOperationTransaction({
|
|
992
|
-
hash
|
|
993
|
-
});
|
|
994
|
-
return hash;
|
|
1433
|
+
return yield this.handleSendUserOperation(data);
|
|
995
1434
|
} catch (error) {
|
|
996
|
-
console.error(error);
|
|
1435
|
+
console.error(`Failed to set budget ${error}`);
|
|
997
1436
|
throw new Error("Failed to set budget");
|
|
998
1437
|
}
|
|
999
1438
|
});
|
|
@@ -1001,6 +1440,46 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1001
1440
|
};
|
|
1002
1441
|
var acpContractClient_default = AcpContractClient;
|
|
1003
1442
|
|
|
1443
|
+
// src/interfaces.ts
|
|
1444
|
+
var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
|
|
1445
|
+
AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
|
|
1446
|
+
AcpAgentSort2["SUCCESS_RATE"] = "successRate";
|
|
1447
|
+
AcpAgentSort2["UNIQUE_BUYER_COUNT"] = "uniqueBuyerCount";
|
|
1448
|
+
AcpAgentSort2["MINS_FROM_LAST_ONLINE"] = "minsFromLastOnlineTime";
|
|
1449
|
+
return AcpAgentSort2;
|
|
1450
|
+
})(AcpAgentSort || {});
|
|
1451
|
+
var AcpGraduationStatus = /* @__PURE__ */ ((AcpGraduationStatus2) => {
|
|
1452
|
+
AcpGraduationStatus2["ALL"] = "all";
|
|
1453
|
+
AcpGraduationStatus2["GRADUATED"] = "graduated";
|
|
1454
|
+
AcpGraduationStatus2["NOT_GRADUATED"] = "not_graduated";
|
|
1455
|
+
return AcpGraduationStatus2;
|
|
1456
|
+
})(AcpGraduationStatus || {});
|
|
1457
|
+
var AcpOnlineStatus = /* @__PURE__ */ ((AcpOnlineStatus2) => {
|
|
1458
|
+
AcpOnlineStatus2["ALL"] = "all";
|
|
1459
|
+
AcpOnlineStatus2["ONLINE"] = "online";
|
|
1460
|
+
AcpOnlineStatus2["OFFLINE"] = "offline";
|
|
1461
|
+
return AcpOnlineStatus2;
|
|
1462
|
+
})(AcpOnlineStatus || {});
|
|
1463
|
+
var PayloadType = /* @__PURE__ */ ((PayloadType2) => {
|
|
1464
|
+
PayloadType2["FUND_RESPONSE"] = "fund_response";
|
|
1465
|
+
PayloadType2["OPEN_POSITION"] = "open_position";
|
|
1466
|
+
PayloadType2["CLOSE_PARTIAL_POSITION"] = "close_partial_position";
|
|
1467
|
+
PayloadType2["CLOSE_POSITION"] = "close_position";
|
|
1468
|
+
PayloadType2["POSITION_FULFILLED"] = "position_fulfilled";
|
|
1469
|
+
PayloadType2["CLOSE_JOB_AND_WITHDRAW"] = "close_job_and_withdraw";
|
|
1470
|
+
PayloadType2["UNFULFILLED_POSITION"] = "unfulfilled_position";
|
|
1471
|
+
return PayloadType2;
|
|
1472
|
+
})(PayloadType || {});
|
|
1473
|
+
|
|
1474
|
+
// src/utils.ts
|
|
1475
|
+
function tryParseJson(content) {
|
|
1476
|
+
try {
|
|
1477
|
+
return JSON.parse(content);
|
|
1478
|
+
} catch (error) {
|
|
1479
|
+
return null;
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1004
1483
|
// src/acpJob.ts
|
|
1005
1484
|
var AcpJob = class {
|
|
1006
1485
|
constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, memos, phase, context) {
|
|
@@ -1031,6 +1510,9 @@ var AcpJob = class {
|
|
|
1031
1510
|
get evaluatorAgent() {
|
|
1032
1511
|
return this.acpClient.getAgent(this.evaluatorAddress);
|
|
1033
1512
|
}
|
|
1513
|
+
get latestMemo() {
|
|
1514
|
+
return this.memos[this.memos.length - 1];
|
|
1515
|
+
}
|
|
1034
1516
|
pay(amount, reason) {
|
|
1035
1517
|
return __async(this, null, function* () {
|
|
1036
1518
|
const memo = this.memos.find(
|
|
@@ -1042,23 +1524,25 @@ var AcpJob = class {
|
|
|
1042
1524
|
return yield this.acpClient.payJob(this.id, amount, memo.id, reason);
|
|
1043
1525
|
});
|
|
1044
1526
|
}
|
|
1045
|
-
respond(accept, reason) {
|
|
1527
|
+
respond(accept, payload, reason) {
|
|
1046
1528
|
return __async(this, null, function* () {
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
);
|
|
1050
|
-
if (!memo) {
|
|
1529
|
+
var _a;
|
|
1530
|
+
if (((_a = this.latestMemo) == null ? void 0 : _a.nextPhase) !== 1 /* NEGOTIATION */) {
|
|
1051
1531
|
throw new Error("No negotiation memo found");
|
|
1052
1532
|
}
|
|
1053
|
-
return yield this.acpClient.respondJob(
|
|
1533
|
+
return yield this.acpClient.respondJob(
|
|
1534
|
+
this.id,
|
|
1535
|
+
this.latestMemo.id,
|
|
1536
|
+
accept,
|
|
1537
|
+
payload ? JSON.stringify(payload) : void 0,
|
|
1538
|
+
reason
|
|
1539
|
+
);
|
|
1054
1540
|
});
|
|
1055
1541
|
}
|
|
1056
1542
|
deliver(deliverable) {
|
|
1057
1543
|
return __async(this, null, function* () {
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
);
|
|
1061
|
-
if (!memo) {
|
|
1544
|
+
var _a;
|
|
1545
|
+
if (((_a = this.latestMemo) == null ? void 0 : _a.nextPhase) !== 3 /* EVALUATION */) {
|
|
1062
1546
|
throw new Error("No transaction memo found");
|
|
1063
1547
|
}
|
|
1064
1548
|
return yield this.acpClient.deliverJob(this.id, deliverable);
|
|
@@ -1066,28 +1550,297 @@ var AcpJob = class {
|
|
|
1066
1550
|
}
|
|
1067
1551
|
evaluate(accept, reason) {
|
|
1068
1552
|
return __async(this, null, function* () {
|
|
1069
|
-
|
|
1070
|
-
if (
|
|
1553
|
+
var _a;
|
|
1554
|
+
if (((_a = this.latestMemo) == null ? void 0 : _a.nextPhase) !== 4 /* COMPLETED */) {
|
|
1071
1555
|
throw new Error("No evaluation memo found");
|
|
1072
1556
|
}
|
|
1073
1557
|
return yield this.acpClient.acpContractClient.signMemo(
|
|
1558
|
+
this.latestMemo.id,
|
|
1559
|
+
accept,
|
|
1560
|
+
reason
|
|
1561
|
+
);
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
openPosition(payload, feeAmount, expiredAt, walletAddress) {
|
|
1565
|
+
return __async(this, null, function* () {
|
|
1566
|
+
if (payload.length === 0) {
|
|
1567
|
+
throw new Error("No positions to open");
|
|
1568
|
+
}
|
|
1569
|
+
return yield this.acpClient.transferFunds(
|
|
1570
|
+
this.id,
|
|
1571
|
+
payload.reduce((acc, curr) => acc + curr.amount, 0),
|
|
1572
|
+
walletAddress || this.providerAddress,
|
|
1573
|
+
feeAmount,
|
|
1574
|
+
1 /* IMMEDIATE_FEE */,
|
|
1575
|
+
{
|
|
1576
|
+
type: "open_position" /* OPEN_POSITION */,
|
|
1577
|
+
data: payload
|
|
1578
|
+
},
|
|
1579
|
+
2 /* TRANSACTION */,
|
|
1580
|
+
expiredAt
|
|
1581
|
+
);
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
responseOpenPosition(memoId, accept, reason) {
|
|
1585
|
+
return __async(this, null, function* () {
|
|
1586
|
+
const memo = this.memos.find((m) => m.id === memoId);
|
|
1587
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 7 /* PAYABLE_TRANSFER */) {
|
|
1588
|
+
throw new Error("No open position memo found");
|
|
1589
|
+
}
|
|
1590
|
+
const payload = tryParseJson(
|
|
1591
|
+
memo.content
|
|
1592
|
+
);
|
|
1593
|
+
if ((payload == null ? void 0 : payload.type) !== "open_position" /* OPEN_POSITION */) {
|
|
1594
|
+
throw new Error("Invalid open position memo");
|
|
1595
|
+
}
|
|
1596
|
+
return yield this.acpClient.responseFundsTransfer(memo.id, accept, reason);
|
|
1597
|
+
});
|
|
1598
|
+
}
|
|
1599
|
+
closePartialPosition(payload) {
|
|
1600
|
+
return __async(this, null, function* () {
|
|
1601
|
+
return yield this.acpClient.requestFunds(
|
|
1602
|
+
this.id,
|
|
1603
|
+
payload.amount,
|
|
1604
|
+
this.clientAddress,
|
|
1605
|
+
0,
|
|
1606
|
+
0 /* NO_FEE */,
|
|
1607
|
+
{
|
|
1608
|
+
type: "close_partial_position" /* CLOSE_PARTIAL_POSITION */,
|
|
1609
|
+
data: payload
|
|
1610
|
+
},
|
|
1611
|
+
2 /* TRANSACTION */
|
|
1612
|
+
);
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
responseClosePartialPosition(memoId, accept, reason) {
|
|
1616
|
+
return __async(this, null, function* () {
|
|
1617
|
+
const memo = this.memos.find((m) => m.id === memoId);
|
|
1618
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 6 /* PAYABLE_REQUEST */) {
|
|
1619
|
+
throw new Error("No close position memo found");
|
|
1620
|
+
}
|
|
1621
|
+
const payload = tryParseJson(
|
|
1622
|
+
memo.content
|
|
1623
|
+
);
|
|
1624
|
+
if ((payload == null ? void 0 : payload.type) !== "close_partial_position" /* CLOSE_PARTIAL_POSITION */) {
|
|
1625
|
+
throw new Error("Invalid close position memo");
|
|
1626
|
+
}
|
|
1627
|
+
return yield this.acpClient.responseFundsRequest(
|
|
1074
1628
|
memo.id,
|
|
1075
1629
|
accept,
|
|
1630
|
+
payload.data.amount,
|
|
1076
1631
|
reason
|
|
1077
1632
|
);
|
|
1078
1633
|
});
|
|
1079
1634
|
}
|
|
1635
|
+
requestClosePosition(payload) {
|
|
1636
|
+
return __async(this, null, function* () {
|
|
1637
|
+
return yield this.acpClient.sendMessage(
|
|
1638
|
+
this.id,
|
|
1639
|
+
{
|
|
1640
|
+
type: "close_position" /* CLOSE_POSITION */,
|
|
1641
|
+
data: payload
|
|
1642
|
+
},
|
|
1643
|
+
2 /* TRANSACTION */
|
|
1644
|
+
);
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1647
|
+
responseRequestClosePosition(memoId, accept, payload, reason) {
|
|
1648
|
+
return __async(this, null, function* () {
|
|
1649
|
+
const memo = this.memos.find((m) => m.id === memoId);
|
|
1650
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 0 /* MESSAGE */) {
|
|
1651
|
+
throw new Error("No message memo found");
|
|
1652
|
+
}
|
|
1653
|
+
const messagePayload = tryParseJson(memo.content);
|
|
1654
|
+
if ((messagePayload == null ? void 0 : messagePayload.type) !== "close_position" /* CLOSE_POSITION */) {
|
|
1655
|
+
throw new Error("Invalid close position memo");
|
|
1656
|
+
}
|
|
1657
|
+
yield memo.sign(accept, reason);
|
|
1658
|
+
if (accept) {
|
|
1659
|
+
return yield this.acpClient.transferFunds(
|
|
1660
|
+
this.id,
|
|
1661
|
+
payload.amount,
|
|
1662
|
+
this.clientAddress,
|
|
1663
|
+
0,
|
|
1664
|
+
0 /* NO_FEE */,
|
|
1665
|
+
{
|
|
1666
|
+
type: "close_position" /* CLOSE_POSITION */,
|
|
1667
|
+
data: payload
|
|
1668
|
+
},
|
|
1669
|
+
2 /* TRANSACTION */
|
|
1670
|
+
);
|
|
1671
|
+
}
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
confirmClosePosition(memoId, accept, reason) {
|
|
1675
|
+
return __async(this, null, function* () {
|
|
1676
|
+
const memo = this.memos.find((m) => m.id === memoId);
|
|
1677
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 7 /* PAYABLE_TRANSFER */) {
|
|
1678
|
+
throw new Error("No payable transfer memo found");
|
|
1679
|
+
}
|
|
1680
|
+
const payload = tryParseJson(
|
|
1681
|
+
memo.content
|
|
1682
|
+
);
|
|
1683
|
+
if ((payload == null ? void 0 : payload.type) !== "close_position" /* CLOSE_POSITION */) {
|
|
1684
|
+
throw new Error("Invalid close position memo");
|
|
1685
|
+
}
|
|
1686
|
+
yield memo.sign(accept, reason);
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
positionFulfilled(payload) {
|
|
1690
|
+
return __async(this, null, function* () {
|
|
1691
|
+
return yield this.acpClient.transferFunds(
|
|
1692
|
+
this.id,
|
|
1693
|
+
payload.amount,
|
|
1694
|
+
this.clientAddress,
|
|
1695
|
+
0,
|
|
1696
|
+
0 /* NO_FEE */,
|
|
1697
|
+
{
|
|
1698
|
+
type: "position_fulfilled" /* POSITION_FULFILLED */,
|
|
1699
|
+
data: payload
|
|
1700
|
+
},
|
|
1701
|
+
2 /* TRANSACTION */
|
|
1702
|
+
);
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
unfulfilledPosition(payload) {
|
|
1706
|
+
return __async(this, null, function* () {
|
|
1707
|
+
return yield this.acpClient.transferFunds(
|
|
1708
|
+
this.id,
|
|
1709
|
+
payload.amount,
|
|
1710
|
+
this.clientAddress,
|
|
1711
|
+
0,
|
|
1712
|
+
0 /* NO_FEE */,
|
|
1713
|
+
{
|
|
1714
|
+
type: "unfulfilled_position" /* UNFULFILLED_POSITION */,
|
|
1715
|
+
data: payload
|
|
1716
|
+
},
|
|
1717
|
+
2 /* TRANSACTION */
|
|
1718
|
+
);
|
|
1719
|
+
});
|
|
1720
|
+
}
|
|
1721
|
+
responseUnfulfilledPosition(memoId, accept, reason) {
|
|
1722
|
+
return __async(this, null, function* () {
|
|
1723
|
+
const memo = this.memos.find((m) => m.id === memoId);
|
|
1724
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 7 /* PAYABLE_TRANSFER */) {
|
|
1725
|
+
throw new Error("No unfulfilled position memo found");
|
|
1726
|
+
}
|
|
1727
|
+
const payload = tryParseJson(
|
|
1728
|
+
memo.content
|
|
1729
|
+
);
|
|
1730
|
+
if ((payload == null ? void 0 : payload.type) !== "unfulfilled_position" /* UNFULFILLED_POSITION */) {
|
|
1731
|
+
throw new Error("Invalid unfulfilled position memo");
|
|
1732
|
+
}
|
|
1733
|
+
return yield this.acpClient.responseFundsTransfer(memo.id, accept, reason);
|
|
1734
|
+
});
|
|
1735
|
+
}
|
|
1736
|
+
responsePositionFulfilled(memoId, accept, reason) {
|
|
1737
|
+
return __async(this, null, function* () {
|
|
1738
|
+
const memo = this.memos.find((m) => m.id === memoId);
|
|
1739
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 7 /* PAYABLE_TRANSFER */) {
|
|
1740
|
+
throw new Error("No position fulfilled memo found");
|
|
1741
|
+
}
|
|
1742
|
+
const payload = tryParseJson(
|
|
1743
|
+
memo.content
|
|
1744
|
+
);
|
|
1745
|
+
if ((payload == null ? void 0 : payload.type) !== "position_fulfilled" /* POSITION_FULFILLED */) {
|
|
1746
|
+
throw new Error("Invalid position fulfilled memo");
|
|
1747
|
+
}
|
|
1748
|
+
return yield this.acpClient.responseFundsTransfer(memo.id, accept, reason);
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
closeJob(message = "Close job and withdraw all") {
|
|
1752
|
+
return __async(this, null, function* () {
|
|
1753
|
+
return yield this.acpClient.sendMessage(
|
|
1754
|
+
this.id,
|
|
1755
|
+
{
|
|
1756
|
+
type: "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */,
|
|
1757
|
+
data: {
|
|
1758
|
+
message
|
|
1759
|
+
}
|
|
1760
|
+
},
|
|
1761
|
+
2 /* TRANSACTION */
|
|
1762
|
+
);
|
|
1763
|
+
});
|
|
1764
|
+
}
|
|
1765
|
+
responseCloseJob(memoId, accept, fulfilledPositions, reason) {
|
|
1766
|
+
return __async(this, null, function* () {
|
|
1767
|
+
const memo = this.memos.find((m) => m.id === memoId);
|
|
1768
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 0 /* MESSAGE */) {
|
|
1769
|
+
throw new Error("No message memo found");
|
|
1770
|
+
}
|
|
1771
|
+
const payload = tryParseJson(
|
|
1772
|
+
memo.content
|
|
1773
|
+
);
|
|
1774
|
+
if ((payload == null ? void 0 : payload.type) !== "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */) {
|
|
1775
|
+
throw new Error("Invalid close job and withdraw memo");
|
|
1776
|
+
}
|
|
1777
|
+
yield memo.sign(accept, reason);
|
|
1778
|
+
if (!accept) {
|
|
1779
|
+
return;
|
|
1780
|
+
}
|
|
1781
|
+
const totalAmount = fulfilledPositions.reduce(
|
|
1782
|
+
(acc, curr) => acc + curr.amount,
|
|
1783
|
+
0
|
|
1784
|
+
);
|
|
1785
|
+
if (totalAmount === 0) {
|
|
1786
|
+
return yield this.acpClient.sendMessage(
|
|
1787
|
+
this.id,
|
|
1788
|
+
{
|
|
1789
|
+
type: "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */,
|
|
1790
|
+
data: fulfilledPositions
|
|
1791
|
+
},
|
|
1792
|
+
4 /* COMPLETED */
|
|
1793
|
+
);
|
|
1794
|
+
}
|
|
1795
|
+
return yield this.acpClient.transferFunds(
|
|
1796
|
+
this.id,
|
|
1797
|
+
fulfilledPositions.reduce((acc, curr) => acc + curr.amount, 0),
|
|
1798
|
+
this.clientAddress,
|
|
1799
|
+
0,
|
|
1800
|
+
0 /* NO_FEE */,
|
|
1801
|
+
{
|
|
1802
|
+
type: "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */,
|
|
1803
|
+
data: fulfilledPositions
|
|
1804
|
+
},
|
|
1805
|
+
4 /* COMPLETED */
|
|
1806
|
+
);
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
confirmJobClosure(memoId, accept, reason) {
|
|
1810
|
+
return __async(this, null, function* () {
|
|
1811
|
+
const memo = this.memos.find((m) => m.id === memoId);
|
|
1812
|
+
if (!memo) {
|
|
1813
|
+
throw new Error("Memo not found");
|
|
1814
|
+
}
|
|
1815
|
+
const payload = tryParseJson(
|
|
1816
|
+
memo.content
|
|
1817
|
+
);
|
|
1818
|
+
if ((payload == null ? void 0 : payload.type) !== "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */) {
|
|
1819
|
+
throw new Error("Invalid close job and withdraw memo");
|
|
1820
|
+
}
|
|
1821
|
+
yield memo.sign(accept, reason);
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1080
1824
|
};
|
|
1081
1825
|
var acpJob_default = AcpJob;
|
|
1082
1826
|
|
|
1083
1827
|
// src/acpMemo.ts
|
|
1084
1828
|
var AcpMemo = class {
|
|
1085
|
-
constructor(acpClient, id, type, content, nextPhase) {
|
|
1829
|
+
constructor(acpClient, id, type, content, nextPhase, expiry) {
|
|
1086
1830
|
this.acpClient = acpClient;
|
|
1087
1831
|
this.id = id;
|
|
1088
1832
|
this.type = type;
|
|
1089
1833
|
this.content = content;
|
|
1090
1834
|
this.nextPhase = nextPhase;
|
|
1835
|
+
this.expiry = expiry;
|
|
1836
|
+
this.structuredContent = tryParseJson(this.content) || void 0;
|
|
1837
|
+
}
|
|
1838
|
+
get payloadType() {
|
|
1839
|
+
var _a;
|
|
1840
|
+
return (_a = this.structuredContent) == null ? void 0 : _a.type;
|
|
1841
|
+
}
|
|
1842
|
+
getStructuredContent() {
|
|
1843
|
+
return this.structuredContent;
|
|
1091
1844
|
}
|
|
1092
1845
|
create(jobId, isSecured = true) {
|
|
1093
1846
|
return __async(this, null, function* () {
|
|
@@ -1145,6 +1898,7 @@ var AcpJobOffering = class {
|
|
|
1145
1898
|
var acpJobOffering_default = AcpJobOffering;
|
|
1146
1899
|
|
|
1147
1900
|
// src/acpClient.ts
|
|
1901
|
+
var { version } = require_package();
|
|
1148
1902
|
var AcpClient = class {
|
|
1149
1903
|
constructor(options) {
|
|
1150
1904
|
this.acpContractClient = options.acpContractClient;
|
|
@@ -1161,11 +1915,16 @@ var AcpClient = class {
|
|
|
1161
1915
|
init() {
|
|
1162
1916
|
return __async(this, null, function* () {
|
|
1163
1917
|
const socket = (0, import_socket.io)(this.acpUrl, {
|
|
1164
|
-
auth: __spreadValues(
|
|
1918
|
+
auth: __spreadValues({
|
|
1165
1919
|
walletAddress: this.acpContractClient.walletAddress
|
|
1166
|
-
}
|
|
1920
|
+
}, this.onEvaluate !== this.defaultOnEvaluate && {
|
|
1167
1921
|
evaluatorAddress: this.acpContractClient.walletAddress
|
|
1168
|
-
})
|
|
1922
|
+
}),
|
|
1923
|
+
extraHeaders: {
|
|
1924
|
+
"x-sdk-version": version,
|
|
1925
|
+
"x-sdk-language": "node"
|
|
1926
|
+
},
|
|
1927
|
+
transports: ["websocket"]
|
|
1169
1928
|
});
|
|
1170
1929
|
socket.on("roomJoined" /* ROOM_JOINED */, (_, callback) => {
|
|
1171
1930
|
console.log("Joined ACP Room");
|
|
@@ -1189,7 +1948,8 @@ var AcpClient = class {
|
|
|
1189
1948
|
memo.id,
|
|
1190
1949
|
memo.memoType,
|
|
1191
1950
|
memo.content,
|
|
1192
|
-
memo.nextPhase
|
|
1951
|
+
memo.nextPhase,
|
|
1952
|
+
memo.expiry ? new Date(parseInt(memo.expiry)) : null
|
|
1193
1953
|
);
|
|
1194
1954
|
}),
|
|
1195
1955
|
data.phase,
|
|
@@ -1217,13 +1977,17 @@ var AcpClient = class {
|
|
|
1217
1977
|
memo.id,
|
|
1218
1978
|
memo.memoType,
|
|
1219
1979
|
memo.content,
|
|
1220
|
-
memo.nextPhase
|
|
1980
|
+
memo.nextPhase,
|
|
1981
|
+
memo.expiry ? new Date(parseInt(memo.expiry)) : null
|
|
1221
1982
|
);
|
|
1222
1983
|
}),
|
|
1223
1984
|
data.phase,
|
|
1224
1985
|
data.context
|
|
1225
1986
|
);
|
|
1226
|
-
this.onNewTask(
|
|
1987
|
+
this.onNewTask(
|
|
1988
|
+
job,
|
|
1989
|
+
job.memos.find((m) => m.id == data.memoToSign)
|
|
1990
|
+
);
|
|
1227
1991
|
}
|
|
1228
1992
|
})
|
|
1229
1993
|
);
|
|
@@ -1239,28 +2003,26 @@ var AcpClient = class {
|
|
|
1239
2003
|
}
|
|
1240
2004
|
browseAgents(keyword, options) {
|
|
1241
2005
|
return __async(this, null, function* () {
|
|
1242
|
-
let { cluster, sort_by,
|
|
1243
|
-
rerank = rerank != null ? rerank : true;
|
|
2006
|
+
let { cluster, sort_by, top_k, graduationStatus, onlineStatus } = options;
|
|
1244
2007
|
top_k = top_k != null ? top_k : 5;
|
|
1245
|
-
|
|
1246
|
-
let url = `${this.acpUrl}/api/agents?search=${keyword}`;
|
|
2008
|
+
let url = `${this.acpUrl}/api/agents/v2/search?search=${keyword}`;
|
|
1247
2009
|
if (sort_by && sort_by.length > 0) {
|
|
1248
|
-
url += `&
|
|
2010
|
+
url += `&sortBy=${sort_by.map((s) => s).join(",")}`;
|
|
1249
2011
|
}
|
|
1250
2012
|
if (top_k) {
|
|
1251
2013
|
url += `&top_k=${top_k}`;
|
|
1252
2014
|
}
|
|
1253
|
-
if (rerank) {
|
|
1254
|
-
url += `&rerank=true`;
|
|
1255
|
-
}
|
|
1256
2015
|
if (this.acpContractClient.walletAddress) {
|
|
1257
|
-
url += `&
|
|
2016
|
+
url += `&walletAddressesToExclude=${this.acpContractClient.walletAddress}`;
|
|
1258
2017
|
}
|
|
1259
2018
|
if (cluster) {
|
|
1260
|
-
url += `&
|
|
2019
|
+
url += `&cluster=${cluster}`;
|
|
2020
|
+
}
|
|
2021
|
+
if (graduationStatus) {
|
|
2022
|
+
url += `&graduationStatus=${graduationStatus}`;
|
|
1261
2023
|
}
|
|
1262
|
-
if (
|
|
1263
|
-
url += `&
|
|
2024
|
+
if (onlineStatus) {
|
|
2025
|
+
url += `&onlineStatus=${onlineStatus}`;
|
|
1264
2026
|
}
|
|
1265
2027
|
const response = yield fetch(url);
|
|
1266
2028
|
const data = yield response.json();
|
|
@@ -1292,10 +2054,12 @@ var AcpClient = class {
|
|
|
1292
2054
|
evaluatorAddress || this.acpContractClient.walletAddress,
|
|
1293
2055
|
expiredAt
|
|
1294
2056
|
);
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
2057
|
+
if (amount > 0) {
|
|
2058
|
+
yield this.acpContractClient.setBudget(
|
|
2059
|
+
jobId,
|
|
2060
|
+
(0, import_viem2.parseEther)(amount.toString())
|
|
2061
|
+
);
|
|
2062
|
+
}
|
|
1299
2063
|
yield this.acpContractClient.createMemo(
|
|
1300
2064
|
jobId,
|
|
1301
2065
|
typeof serviceRequirement === "string" ? serviceRequirement : JSON.stringify(serviceRequirement),
|
|
@@ -1306,7 +2070,7 @@ var AcpClient = class {
|
|
|
1306
2070
|
return jobId;
|
|
1307
2071
|
});
|
|
1308
2072
|
}
|
|
1309
|
-
respondJob(jobId, memoId, accept, reason) {
|
|
2073
|
+
respondJob(jobId, memoId, accept, content, reason) {
|
|
1310
2074
|
return __async(this, null, function* () {
|
|
1311
2075
|
yield this.acpContractClient.signMemo(memoId, accept, reason);
|
|
1312
2076
|
if (!accept) {
|
|
@@ -1314,7 +2078,7 @@ var AcpClient = class {
|
|
|
1314
2078
|
}
|
|
1315
2079
|
return yield this.acpContractClient.createMemo(
|
|
1316
2080
|
jobId,
|
|
1317
|
-
`Job ${jobId} accepted. ${reason != null ? reason : ""}`,
|
|
2081
|
+
content != null ? content : `Job ${jobId} accepted. ${reason != null ? reason : ""}`,
|
|
1318
2082
|
0 /* MESSAGE */,
|
|
1319
2083
|
false,
|
|
1320
2084
|
2 /* TRANSACTION */
|
|
@@ -1323,9 +2087,11 @@ var AcpClient = class {
|
|
|
1323
2087
|
}
|
|
1324
2088
|
payJob(jobId, amount, memoId, reason) {
|
|
1325
2089
|
return __async(this, null, function* () {
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
2090
|
+
if (amount > 0) {
|
|
2091
|
+
yield this.acpContractClient.approveAllowance(
|
|
2092
|
+
(0, import_viem2.parseEther)(amount.toString())
|
|
2093
|
+
);
|
|
2094
|
+
}
|
|
1329
2095
|
yield this.acpContractClient.signMemo(memoId, true, reason);
|
|
1330
2096
|
return yield this.acpContractClient.createMemo(
|
|
1331
2097
|
jobId,
|
|
@@ -1336,11 +2102,75 @@ var AcpClient = class {
|
|
|
1336
2102
|
);
|
|
1337
2103
|
});
|
|
1338
2104
|
}
|
|
2105
|
+
requestFunds(jobId, amount, recipient, feeAmount, feeType, reason, nextPhase) {
|
|
2106
|
+
return __async(this, null, function* () {
|
|
2107
|
+
return yield this.acpContractClient.createPayableMemo(
|
|
2108
|
+
jobId,
|
|
2109
|
+
JSON.stringify(reason),
|
|
2110
|
+
(0, import_viem2.parseEther)(amount.toString()),
|
|
2111
|
+
recipient,
|
|
2112
|
+
(0, import_viem2.parseEther)(feeAmount.toString()),
|
|
2113
|
+
feeType,
|
|
2114
|
+
nextPhase,
|
|
2115
|
+
6 /* PAYABLE_REQUEST */
|
|
2116
|
+
);
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2119
|
+
responseFundsRequest(memoId, accept, amount, reason) {
|
|
2120
|
+
return __async(this, null, function* () {
|
|
2121
|
+
if (!accept) {
|
|
2122
|
+
return yield this.acpContractClient.signMemo(memoId, accept, reason);
|
|
2123
|
+
}
|
|
2124
|
+
if (amount > 0) {
|
|
2125
|
+
yield this.acpContractClient.approveAllowance(
|
|
2126
|
+
(0, import_viem2.parseEther)(amount.toString())
|
|
2127
|
+
);
|
|
2128
|
+
}
|
|
2129
|
+
return yield this.acpContractClient.signMemo(memoId, true, reason);
|
|
2130
|
+
});
|
|
2131
|
+
}
|
|
2132
|
+
transferFunds(jobId, amount, recipient, feeAmount, feeType, reason, nextPhase, expiredAt) {
|
|
2133
|
+
return __async(this, null, function* () {
|
|
2134
|
+
const totalAmount = amount + feeAmount;
|
|
2135
|
+
if (totalAmount > 0) {
|
|
2136
|
+
yield this.acpContractClient.approveAllowance(
|
|
2137
|
+
(0, import_viem2.parseEther)(totalAmount.toString())
|
|
2138
|
+
);
|
|
2139
|
+
}
|
|
2140
|
+
return yield this.acpContractClient.createPayableMemo(
|
|
2141
|
+
jobId,
|
|
2142
|
+
JSON.stringify(reason),
|
|
2143
|
+
(0, import_viem2.parseEther)(amount.toString()),
|
|
2144
|
+
recipient,
|
|
2145
|
+
(0, import_viem2.parseEther)(feeAmount.toString()),
|
|
2146
|
+
feeType,
|
|
2147
|
+
nextPhase,
|
|
2148
|
+
7 /* PAYABLE_TRANSFER */,
|
|
2149
|
+
expiredAt
|
|
2150
|
+
);
|
|
2151
|
+
});
|
|
2152
|
+
}
|
|
2153
|
+
sendMessage(jobId, message, nextPhase) {
|
|
2154
|
+
return __async(this, null, function* () {
|
|
2155
|
+
return yield this.acpContractClient.createMemo(
|
|
2156
|
+
jobId,
|
|
2157
|
+
JSON.stringify(message),
|
|
2158
|
+
0 /* MESSAGE */,
|
|
2159
|
+
false,
|
|
2160
|
+
nextPhase
|
|
2161
|
+
);
|
|
2162
|
+
});
|
|
2163
|
+
}
|
|
2164
|
+
responseFundsTransfer(memoId, accept, reason) {
|
|
2165
|
+
return __async(this, null, function* () {
|
|
2166
|
+
return yield this.acpContractClient.signMemo(memoId, accept, reason);
|
|
2167
|
+
});
|
|
2168
|
+
}
|
|
1339
2169
|
deliverJob(jobId, deliverable) {
|
|
1340
2170
|
return __async(this, null, function* () {
|
|
1341
2171
|
return yield this.acpContractClient.createMemo(
|
|
1342
2172
|
jobId,
|
|
1343
|
-
deliverable,
|
|
2173
|
+
JSON.stringify(deliverable),
|
|
1344
2174
|
4 /* OBJECT_URL */,
|
|
1345
2175
|
true,
|
|
1346
2176
|
4 /* COMPLETED */
|
|
@@ -1374,7 +2204,8 @@ var AcpClient = class {
|
|
|
1374
2204
|
memo.id,
|
|
1375
2205
|
memo.memoType,
|
|
1376
2206
|
memo.content,
|
|
1377
|
-
memo.nextPhase
|
|
2207
|
+
memo.nextPhase,
|
|
2208
|
+
memo.expiry ? new Date(parseInt(memo.expiry)) : null
|
|
1378
2209
|
);
|
|
1379
2210
|
}),
|
|
1380
2211
|
job.phase,
|
|
@@ -1413,7 +2244,8 @@ var AcpClient = class {
|
|
|
1413
2244
|
memo.id,
|
|
1414
2245
|
memo.memoType,
|
|
1415
2246
|
memo.content,
|
|
1416
|
-
memo.nextPhase
|
|
2247
|
+
memo.nextPhase,
|
|
2248
|
+
memo.expiry ? new Date(parseInt(memo.expiry)) : null
|
|
1417
2249
|
);
|
|
1418
2250
|
}),
|
|
1419
2251
|
job.phase,
|
|
@@ -1452,7 +2284,8 @@ var AcpClient = class {
|
|
|
1452
2284
|
memo.id,
|
|
1453
2285
|
memo.memoType,
|
|
1454
2286
|
memo.content,
|
|
1455
|
-
memo.nextPhase
|
|
2287
|
+
memo.nextPhase,
|
|
2288
|
+
memo.expiry ? new Date(parseInt(memo.expiry)) : null
|
|
1456
2289
|
);
|
|
1457
2290
|
}),
|
|
1458
2291
|
job.phase,
|
|
@@ -1494,7 +2327,8 @@ var AcpClient = class {
|
|
|
1494
2327
|
memo.id,
|
|
1495
2328
|
memo.memoType,
|
|
1496
2329
|
memo.content,
|
|
1497
|
-
memo.nextPhase
|
|
2330
|
+
memo.nextPhase,
|
|
2331
|
+
memo.expiry ? new Date(parseInt(memo.expiry)) : null
|
|
1498
2332
|
);
|
|
1499
2333
|
}),
|
|
1500
2334
|
job.phase,
|
|
@@ -1527,7 +2361,8 @@ var AcpClient = class {
|
|
|
1527
2361
|
memo.id,
|
|
1528
2362
|
memo.memoType,
|
|
1529
2363
|
memo.content,
|
|
1530
|
-
memo.nextPhase
|
|
2364
|
+
memo.nextPhase,
|
|
2365
|
+
memo.expiry ? new Date(parseInt(memo.expiry)) : null
|
|
1531
2366
|
);
|
|
1532
2367
|
} catch (error) {
|
|
1533
2368
|
throw error;
|
|
@@ -1549,16 +2384,6 @@ var AcpClient = class {
|
|
|
1549
2384
|
};
|
|
1550
2385
|
var acpClient_default = AcpClient;
|
|
1551
2386
|
|
|
1552
|
-
// src/interfaces.ts
|
|
1553
|
-
var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
|
|
1554
|
-
AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
|
|
1555
|
-
AcpAgentSort2["SUCCESS_RATE"] = "successRate";
|
|
1556
|
-
AcpAgentSort2["UNIQUE_BUYER_COUNT"] = "uniqueBuyerCount";
|
|
1557
|
-
AcpAgentSort2["MINS_FROM_LAST_ONLINE"] = "minsFromLastOnlineTime";
|
|
1558
|
-
AcpAgentSort2["IS_ONLINE"] = "isOnline";
|
|
1559
|
-
return AcpAgentSort2;
|
|
1560
|
-
})(AcpAgentSort || {});
|
|
1561
|
-
|
|
1562
2387
|
// src/index.ts
|
|
1563
2388
|
var index_default = acpClient_default;
|
|
1564
2389
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1566,10 +2391,13 @@ var index_default = acpClient_default;
|
|
|
1566
2391
|
ACP_ABI,
|
|
1567
2392
|
AcpAgentSort,
|
|
1568
2393
|
AcpContractClient,
|
|
2394
|
+
AcpGraduationStatus,
|
|
1569
2395
|
AcpJob,
|
|
1570
2396
|
AcpJobPhases,
|
|
1571
2397
|
AcpMemo,
|
|
2398
|
+
AcpOnlineStatus,
|
|
1572
2399
|
MemoType,
|
|
2400
|
+
PayloadType,
|
|
1573
2401
|
baseAcpConfig,
|
|
1574
2402
|
baseSepoliaAcpConfig
|
|
1575
2403
|
});
|