@virtuals-protocol/acp-node 0.1.0-beta.9 → 0.2.0-beta-usdc.1

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.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
8
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
9
  var __getProtoOf = Object.getPrototypeOf;
@@ -19,6 +21,10 @@ var __spreadValues = (a, b) => {
19
21
  }
20
22
  return a;
21
23
  };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __commonJS = (cb, mod) => function __require() {
26
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
27
+ };
22
28
  var __export = (target, all) => {
23
29
  for (var name in all)
24
30
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -61,16 +67,55 @@ var __async = (__this, __arguments, generator) => {
61
67
  });
62
68
  };
63
69
 
70
+ // package.json
71
+ var require_package = __commonJS({
72
+ "package.json"(exports2, module2) {
73
+ module2.exports = {
74
+ name: "@virtuals-protocol/acp-node",
75
+ version: "0.1.0-beta-usdc.1",
76
+ main: "./dist/index.js",
77
+ module: "./dist/index.mjs",
78
+ types: "./dist/index.d.ts",
79
+ scripts: {
80
+ test: 'echo "Error: no test specified" && exit 1',
81
+ tsup: "tsup src/index.ts --dts --format cjs,esm --out-dir dist"
82
+ },
83
+ author: "",
84
+ license: "ISC",
85
+ description: "",
86
+ devDependencies: {
87
+ typescript: "^5.8.3"
88
+ },
89
+ dependencies: {
90
+ "@aa-sdk/core": "^4.30.0",
91
+ "@account-kit/infra": "^4.30.0",
92
+ "@account-kit/smart-contracts": "^4.30.0",
93
+ ajv: "^8.17.1",
94
+ "socket.io-client": "^4.8.1",
95
+ tsup: "^8.5.0",
96
+ viem: "^2.28.2"
97
+ },
98
+ files: [
99
+ "dist"
100
+ ]
101
+ };
102
+ }
103
+ });
104
+
64
105
  // src/index.ts
65
106
  var index_exports = {};
66
107
  __export(index_exports, {
67
108
  ACP_ABI: () => acpAbi_default,
68
109
  AcpAgentSort: () => AcpAgentSort,
69
110
  AcpContractClient: () => acpContractClient_default,
111
+ AcpGraduationStatus: () => AcpGraduationStatus,
70
112
  AcpJob: () => acpJob_default,
71
113
  AcpJobPhases: () => AcpJobPhases,
72
114
  AcpMemo: () => acpMemo_default,
115
+ AcpMemoStatus: () => AcpMemoStatus,
116
+ AcpOnlineStatus: () => AcpOnlineStatus,
73
117
  MemoType: () => MemoType,
118
+ PayloadType: () => PayloadType,
74
119
  baseAcpConfig: () => baseAcpConfig,
75
120
  baseSepoliaAcpConfig: () => baseSepoliaAcpConfig,
76
121
  default: () => index_default
@@ -79,32 +124,82 @@ module.exports = __toCommonJS(index_exports);
79
124
 
80
125
  // src/acpAbi.ts
81
126
  var ACP_ABI = [
82
- { inputs: [], stateMutability: "nonpayable", type: "constructor" },
83
- { inputs: [], name: "AccessControlBadConfirmation", type: "error" },
127
+ {
128
+ inputs: [],
129
+ stateMutability: "nonpayable",
130
+ type: "constructor"
131
+ },
132
+ {
133
+ inputs: [],
134
+ name: "AccessControlBadConfirmation",
135
+ type: "error"
136
+ },
84
137
  {
85
138
  inputs: [
86
- { internalType: "address", name: "account", type: "address" },
87
- { internalType: "bytes32", name: "neededRole", type: "bytes32" }
139
+ {
140
+ internalType: "address",
141
+ name: "account",
142
+ type: "address"
143
+ },
144
+ {
145
+ internalType: "bytes32",
146
+ name: "neededRole",
147
+ type: "bytes32"
148
+ }
88
149
  ],
89
150
  name: "AccessControlUnauthorizedAccount",
90
151
  type: "error"
91
152
  },
92
153
  {
93
- inputs: [{ internalType: "address", name: "target", type: "address" }],
154
+ inputs: [
155
+ {
156
+ internalType: "address",
157
+ name: "target",
158
+ type: "address"
159
+ }
160
+ ],
94
161
  name: "AddressEmptyCode",
95
162
  type: "error"
96
163
  },
97
164
  {
98
- inputs: [{ internalType: "address", name: "account", type: "address" }],
165
+ inputs: [
166
+ {
167
+ internalType: "address",
168
+ name: "account",
169
+ type: "address"
170
+ }
171
+ ],
99
172
  name: "AddressInsufficientBalance",
100
173
  type: "error"
101
174
  },
102
- { inputs: [], name: "FailedInnerCall", type: "error" },
103
- { inputs: [], name: "InvalidInitialization", type: "error" },
104
- { inputs: [], name: "NotInitializing", type: "error" },
105
- { inputs: [], name: "ReentrancyGuardReentrantCall", type: "error" },
106
175
  {
107
- inputs: [{ internalType: "address", name: "token", type: "address" }],
176
+ inputs: [],
177
+ name: "FailedInnerCall",
178
+ type: "error"
179
+ },
180
+ {
181
+ inputs: [],
182
+ name: "InvalidInitialization",
183
+ type: "error"
184
+ },
185
+ {
186
+ inputs: [],
187
+ name: "NotInitializing",
188
+ type: "error"
189
+ },
190
+ {
191
+ inputs: [],
192
+ name: "ReentrancyGuardReentrantCall",
193
+ type: "error"
194
+ },
195
+ {
196
+ inputs: [
197
+ {
198
+ internalType: "address",
199
+ name: "token",
200
+ type: "address"
201
+ }
202
+ ],
108
203
  name: "SafeERC20FailedOperation",
109
204
  type: "error"
110
205
  },
@@ -221,6 +316,25 @@ var ACP_ABI = [
221
316
  name: "JobCreated",
222
317
  type: "event"
223
318
  },
319
+ {
320
+ anonymous: false,
321
+ inputs: [
322
+ {
323
+ indexed: true,
324
+ internalType: "uint256",
325
+ name: "jobId",
326
+ type: "uint256"
327
+ },
328
+ {
329
+ indexed: true,
330
+ internalType: "address",
331
+ name: "paymentToken",
332
+ type: "address"
333
+ }
334
+ ],
335
+ name: "JobPaymentTokenSet",
336
+ type: "event"
337
+ },
224
338
  {
225
339
  anonymous: false,
226
340
  inputs: [
@@ -236,7 +350,12 @@ var ACP_ABI = [
236
350
  name: "oldPhase",
237
351
  type: "uint8"
238
352
  },
239
- { indexed: false, internalType: "uint8", name: "phase", type: "uint8" }
353
+ {
354
+ indexed: false,
355
+ internalType: "uint8",
356
+ name: "phase",
357
+ type: "uint8"
358
+ }
240
359
  ],
241
360
  name: "JobPhaseUpdated",
242
361
  type: "event"
@@ -286,6 +405,12 @@ var ACP_ABI = [
286
405
  internalType: "uint256",
287
406
  name: "memoId",
288
407
  type: "uint256"
408
+ },
409
+ {
410
+ indexed: false,
411
+ internalType: "string",
412
+ name: "content",
413
+ type: "string"
289
414
  }
290
415
  ],
291
416
  name: "NewMemo",
@@ -295,15 +420,21 @@ var ACP_ABI = [
295
420
  anonymous: false,
296
421
  inputs: [
297
422
  {
298
- indexed: false,
423
+ indexed: true,
299
424
  internalType: "uint256",
300
425
  name: "jobId",
301
426
  type: "uint256"
302
427
  },
428
+ {
429
+ indexed: true,
430
+ internalType: "uint256",
431
+ name: "memoId",
432
+ type: "uint256"
433
+ },
303
434
  {
304
435
  indexed: true,
305
436
  internalType: "address",
306
- name: "client",
437
+ name: "payer",
307
438
  type: "address"
308
439
  },
309
440
  {
@@ -313,375 +444,1279 @@ var ACP_ABI = [
313
444
  type: "uint256"
314
445
  }
315
446
  ],
316
- name: "RefundedBudget",
447
+ name: "PayableFeeCollected",
317
448
  type: "event"
318
449
  },
319
450
  {
320
451
  anonymous: false,
321
452
  inputs: [
322
- { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
323
453
  {
324
454
  indexed: true,
325
- internalType: "bytes32",
326
- name: "previousAdminRole",
327
- type: "bytes32"
455
+ internalType: "uint256",
456
+ name: "jobId",
457
+ type: "uint256"
328
458
  },
329
459
  {
330
460
  indexed: true,
331
- internalType: "bytes32",
332
- name: "newAdminRole",
333
- type: "bytes32"
461
+ internalType: "uint256",
462
+ name: "memoId",
463
+ type: "uint256"
464
+ },
465
+ {
466
+ indexed: true,
467
+ internalType: "address",
468
+ name: "payer",
469
+ type: "address"
470
+ },
471
+ {
472
+ indexed: false,
473
+ internalType: "address",
474
+ name: "recipient",
475
+ type: "address"
476
+ },
477
+ {
478
+ indexed: false,
479
+ internalType: "uint256",
480
+ name: "netAmount",
481
+ type: "uint256"
334
482
  }
335
483
  ],
336
- name: "RoleAdminChanged",
484
+ name: "PayableFeeRequestExecuted",
337
485
  type: "event"
338
486
  },
339
487
  {
340
488
  anonymous: false,
341
489
  inputs: [
342
- { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
343
490
  {
344
491
  indexed: true,
345
- internalType: "address",
346
- name: "account",
347
- type: "address"
492
+ internalType: "uint256",
493
+ name: "jobId",
494
+ type: "uint256"
495
+ },
496
+ {
497
+ indexed: true,
498
+ internalType: "uint256",
499
+ name: "memoId",
500
+ type: "uint256"
348
501
  },
349
502
  {
350
503
  indexed: true,
351
504
  internalType: "address",
352
505
  name: "sender",
353
506
  type: "address"
507
+ },
508
+ {
509
+ indexed: false,
510
+ internalType: "address",
511
+ name: "token",
512
+ type: "address"
513
+ },
514
+ {
515
+ indexed: false,
516
+ internalType: "uint256",
517
+ name: "amount",
518
+ type: "uint256"
519
+ },
520
+ {
521
+ indexed: false,
522
+ internalType: "uint256",
523
+ name: "feeAmount",
524
+ type: "uint256"
354
525
  }
355
526
  ],
356
- name: "RoleGranted",
527
+ name: "PayableFundsEscrowed",
357
528
  type: "event"
358
529
  },
359
530
  {
360
531
  anonymous: false,
361
532
  inputs: [
362
- { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
533
+ {
534
+ indexed: true,
535
+ internalType: "uint256",
536
+ name: "jobId",
537
+ type: "uint256"
538
+ },
539
+ {
540
+ indexed: true,
541
+ internalType: "uint256",
542
+ name: "memoId",
543
+ type: "uint256"
544
+ },
363
545
  {
364
546
  indexed: true,
365
547
  internalType: "address",
366
- name: "account",
548
+ name: "from",
367
549
  type: "address"
368
550
  },
369
551
  {
370
- indexed: true,
552
+ indexed: false,
371
553
  internalType: "address",
372
- name: "sender",
554
+ name: "to",
555
+ type: "address"
556
+ },
557
+ {
558
+ indexed: false,
559
+ internalType: "address",
560
+ name: "token",
373
561
  type: "address"
562
+ },
563
+ {
564
+ indexed: false,
565
+ internalType: "uint256",
566
+ name: "amount",
567
+ type: "uint256"
374
568
  }
375
569
  ],
376
- name: "RoleRevoked",
570
+ name: "PayableRequestExecuted",
377
571
  type: "event"
378
572
  },
379
573
  {
380
- inputs: [],
381
- name: "ADMIN_ROLE",
382
- outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
383
- stateMutability: "view",
384
- type: "function"
385
- },
386
- {
387
- inputs: [],
388
- name: "DEFAULT_ADMIN_ROLE",
389
- outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
390
- stateMutability: "view",
391
- type: "function"
574
+ anonymous: false,
575
+ inputs: [
576
+ {
577
+ indexed: true,
578
+ internalType: "uint256",
579
+ name: "jobId",
580
+ type: "uint256"
581
+ },
582
+ {
583
+ indexed: true,
584
+ internalType: "uint256",
585
+ name: "memoId",
586
+ type: "uint256"
587
+ },
588
+ {
589
+ indexed: true,
590
+ internalType: "address",
591
+ name: "from",
592
+ type: "address"
593
+ },
594
+ {
595
+ indexed: false,
596
+ internalType: "address",
597
+ name: "to",
598
+ type: "address"
599
+ },
600
+ {
601
+ indexed: false,
602
+ internalType: "address",
603
+ name: "token",
604
+ type: "address"
605
+ },
606
+ {
607
+ indexed: false,
608
+ internalType: "uint256",
609
+ name: "amount",
610
+ type: "uint256"
611
+ }
612
+ ],
613
+ name: "PayableTransferExecuted",
614
+ type: "event"
392
615
  },
393
616
  {
394
- inputs: [],
395
- name: "PHASE_COMPLETED",
396
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
397
- stateMutability: "view",
398
- type: "function"
617
+ anonymous: false,
618
+ inputs: [
619
+ {
620
+ indexed: true,
621
+ internalType: "uint256",
622
+ name: "jobId",
623
+ type: "uint256"
624
+ },
625
+ {
626
+ indexed: true,
627
+ internalType: "address",
628
+ name: "client",
629
+ type: "address"
630
+ },
631
+ {
632
+ indexed: false,
633
+ internalType: "uint256",
634
+ name: "amount",
635
+ type: "uint256"
636
+ }
637
+ ],
638
+ name: "RefundedAdditionalFees",
639
+ type: "event"
399
640
  },
400
641
  {
401
- inputs: [],
642
+ anonymous: false,
643
+ inputs: [
644
+ {
645
+ indexed: false,
646
+ internalType: "uint256",
647
+ name: "jobId",
648
+ type: "uint256"
649
+ },
650
+ {
651
+ indexed: true,
652
+ internalType: "address",
653
+ name: "client",
654
+ type: "address"
655
+ },
656
+ {
657
+ indexed: false,
658
+ internalType: "uint256",
659
+ name: "amount",
660
+ type: "uint256"
661
+ }
662
+ ],
663
+ name: "RefundedBudget",
664
+ type: "event"
665
+ },
666
+ {
667
+ anonymous: false,
668
+ inputs: [
669
+ {
670
+ indexed: true,
671
+ internalType: "bytes32",
672
+ name: "role",
673
+ type: "bytes32"
674
+ },
675
+ {
676
+ indexed: true,
677
+ internalType: "bytes32",
678
+ name: "previousAdminRole",
679
+ type: "bytes32"
680
+ },
681
+ {
682
+ indexed: true,
683
+ internalType: "bytes32",
684
+ name: "newAdminRole",
685
+ type: "bytes32"
686
+ }
687
+ ],
688
+ name: "RoleAdminChanged",
689
+ type: "event"
690
+ },
691
+ {
692
+ anonymous: false,
693
+ inputs: [
694
+ {
695
+ indexed: true,
696
+ internalType: "bytes32",
697
+ name: "role",
698
+ type: "bytes32"
699
+ },
700
+ {
701
+ indexed: true,
702
+ internalType: "address",
703
+ name: "account",
704
+ type: "address"
705
+ },
706
+ {
707
+ indexed: true,
708
+ internalType: "address",
709
+ name: "sender",
710
+ type: "address"
711
+ }
712
+ ],
713
+ name: "RoleGranted",
714
+ type: "event"
715
+ },
716
+ {
717
+ anonymous: false,
718
+ inputs: [
719
+ {
720
+ indexed: true,
721
+ internalType: "bytes32",
722
+ name: "role",
723
+ type: "bytes32"
724
+ },
725
+ {
726
+ indexed: true,
727
+ internalType: "address",
728
+ name: "account",
729
+ type: "address"
730
+ },
731
+ {
732
+ indexed: true,
733
+ internalType: "address",
734
+ name: "sender",
735
+ type: "address"
736
+ }
737
+ ],
738
+ name: "RoleRevoked",
739
+ type: "event"
740
+ },
741
+ {
742
+ inputs: [],
743
+ name: "ADMIN_ROLE",
744
+ outputs: [
745
+ {
746
+ internalType: "bytes32",
747
+ name: "",
748
+ type: "bytes32"
749
+ }
750
+ ],
751
+ stateMutability: "view",
752
+ type: "function"
753
+ },
754
+ {
755
+ inputs: [],
756
+ name: "DEFAULT_ADMIN_ROLE",
757
+ outputs: [
758
+ {
759
+ internalType: "bytes32",
760
+ name: "",
761
+ type: "bytes32"
762
+ }
763
+ ],
764
+ stateMutability: "view",
765
+ type: "function"
766
+ },
767
+ {
768
+ inputs: [],
769
+ name: "PHASE_COMPLETED",
770
+ outputs: [
771
+ {
772
+ internalType: "uint8",
773
+ name: "",
774
+ type: "uint8"
775
+ }
776
+ ],
777
+ stateMutability: "view",
778
+ type: "function"
779
+ },
780
+ {
781
+ inputs: [],
402
782
  name: "PHASE_EVALUATION",
403
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
783
+ outputs: [
784
+ {
785
+ internalType: "uint8",
786
+ name: "",
787
+ type: "uint8"
788
+ }
789
+ ],
790
+ stateMutability: "view",
791
+ type: "function"
792
+ },
793
+ {
794
+ inputs: [],
795
+ name: "PHASE_EXPIRED",
796
+ outputs: [
797
+ {
798
+ internalType: "uint8",
799
+ name: "",
800
+ type: "uint8"
801
+ }
802
+ ],
404
803
  stateMutability: "view",
405
804
  type: "function"
406
805
  },
407
806
  {
408
807
  inputs: [],
409
808
  name: "PHASE_NEGOTIATION",
410
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
809
+ outputs: [
810
+ {
811
+ internalType: "uint8",
812
+ name: "",
813
+ type: "uint8"
814
+ }
815
+ ],
411
816
  stateMutability: "view",
412
817
  type: "function"
413
818
  },
414
819
  {
415
820
  inputs: [],
416
821
  name: "PHASE_REJECTED",
417
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
822
+ outputs: [
823
+ {
824
+ internalType: "uint8",
825
+ name: "",
826
+ type: "uint8"
827
+ }
828
+ ],
418
829
  stateMutability: "view",
419
830
  type: "function"
420
831
  },
421
832
  {
422
833
  inputs: [],
423
834
  name: "PHASE_REQUEST",
424
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
835
+ outputs: [
836
+ {
837
+ internalType: "uint8",
838
+ name: "",
839
+ type: "uint8"
840
+ }
841
+ ],
425
842
  stateMutability: "view",
426
843
  type: "function"
427
844
  },
428
845
  {
429
846
  inputs: [],
430
847
  name: "PHASE_TRANSACTION",
431
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
848
+ outputs: [
849
+ {
850
+ internalType: "uint8",
851
+ name: "",
852
+ type: "uint8"
853
+ }
854
+ ],
855
+ stateMutability: "view",
856
+ type: "function"
857
+ },
858
+ {
859
+ inputs: [],
860
+ name: "TOTAL_PHASES",
861
+ outputs: [
862
+ {
863
+ internalType: "uint8",
864
+ name: "",
865
+ type: "uint8"
866
+ }
867
+ ],
868
+ stateMutability: "view",
869
+ type: "function"
870
+ },
871
+ {
872
+ inputs: [
873
+ {
874
+ internalType: "address",
875
+ name: "account",
876
+ type: "address"
877
+ },
878
+ {
879
+ components: [
880
+ {
881
+ internalType: "uint256",
882
+ name: "id",
883
+ type: "uint256"
884
+ },
885
+ {
886
+ internalType: "address",
887
+ name: "client",
888
+ type: "address"
889
+ },
890
+ {
891
+ internalType: "address",
892
+ name: "provider",
893
+ type: "address"
894
+ },
895
+ {
896
+ internalType: "uint256",
897
+ name: "budget",
898
+ type: "uint256"
899
+ },
900
+ {
901
+ internalType: "uint256",
902
+ name: "amountClaimed",
903
+ type: "uint256"
904
+ },
905
+ {
906
+ internalType: "uint8",
907
+ name: "phase",
908
+ type: "uint8"
909
+ },
910
+ {
911
+ internalType: "uint256",
912
+ name: "memoCount",
913
+ type: "uint256"
914
+ },
915
+ {
916
+ internalType: "uint256",
917
+ name: "expiredAt",
918
+ type: "uint256"
919
+ },
920
+ {
921
+ internalType: "address",
922
+ name: "evaluator",
923
+ type: "address"
924
+ },
925
+ {
926
+ internalType: "contract IERC20",
927
+ name: "jobPaymentToken",
928
+ type: "address"
929
+ }
930
+ ],
931
+ internalType: "struct ACPSimple.Job",
932
+ name: "job",
933
+ type: "tuple"
934
+ }
935
+ ],
936
+ name: "canSign",
937
+ outputs: [
938
+ {
939
+ internalType: "bool",
940
+ name: "",
941
+ type: "bool"
942
+ }
943
+ ],
944
+ stateMutability: "pure",
945
+ type: "function"
946
+ },
947
+ {
948
+ inputs: [
949
+ {
950
+ internalType: "uint256",
951
+ name: "id",
952
+ type: "uint256"
953
+ }
954
+ ],
955
+ name: "claimBudget",
956
+ outputs: [],
957
+ stateMutability: "nonpayable",
958
+ type: "function"
959
+ },
960
+ {
961
+ inputs: [
962
+ {
963
+ internalType: "address",
964
+ name: "provider",
965
+ type: "address"
966
+ },
967
+ {
968
+ internalType: "address",
969
+ name: "evaluator",
970
+ type: "address"
971
+ },
972
+ {
973
+ internalType: "uint256",
974
+ name: "expiredAt",
975
+ type: "uint256"
976
+ }
977
+ ],
978
+ name: "createJob",
979
+ outputs: [
980
+ {
981
+ internalType: "uint256",
982
+ name: "",
983
+ type: "uint256"
984
+ }
985
+ ],
986
+ stateMutability: "nonpayable",
987
+ type: "function"
988
+ },
989
+ {
990
+ inputs: [
991
+ {
992
+ internalType: "uint256",
993
+ name: "jobId",
994
+ type: "uint256"
995
+ },
996
+ {
997
+ internalType: "string",
998
+ name: "content",
999
+ type: "string"
1000
+ },
1001
+ {
1002
+ internalType: "enum InteractionLedger.MemoType",
1003
+ name: "memoType",
1004
+ type: "uint8"
1005
+ },
1006
+ {
1007
+ internalType: "bool",
1008
+ name: "isSecured",
1009
+ type: "bool"
1010
+ },
1011
+ {
1012
+ internalType: "uint8",
1013
+ name: "nextPhase",
1014
+ type: "uint8"
1015
+ }
1016
+ ],
1017
+ name: "createMemo",
1018
+ outputs: [
1019
+ {
1020
+ internalType: "uint256",
1021
+ name: "",
1022
+ type: "uint256"
1023
+ }
1024
+ ],
1025
+ stateMutability: "nonpayable",
1026
+ type: "function"
1027
+ },
1028
+ {
1029
+ inputs: [
1030
+ {
1031
+ internalType: "uint256",
1032
+ name: "jobId",
1033
+ type: "uint256"
1034
+ },
1035
+ {
1036
+ internalType: "string",
1037
+ name: "content",
1038
+ type: "string"
1039
+ },
1040
+ {
1041
+ internalType: "address",
1042
+ name: "token",
1043
+ type: "address"
1044
+ },
1045
+ {
1046
+ internalType: "uint256",
1047
+ name: "amount",
1048
+ type: "uint256"
1049
+ },
1050
+ {
1051
+ internalType: "address",
1052
+ name: "recipient",
1053
+ type: "address"
1054
+ },
1055
+ {
1056
+ internalType: "uint256",
1057
+ name: "feeAmount",
1058
+ type: "uint256"
1059
+ },
1060
+ {
1061
+ internalType: "enum ACPSimple.FeeType",
1062
+ name: "feeType",
1063
+ type: "uint8"
1064
+ },
1065
+ {
1066
+ internalType: "enum InteractionLedger.MemoType",
1067
+ name: "memoType",
1068
+ type: "uint8"
1069
+ },
1070
+ {
1071
+ internalType: "uint8",
1072
+ name: "nextPhase",
1073
+ type: "uint8"
1074
+ },
1075
+ {
1076
+ internalType: "uint256",
1077
+ name: "expiredAt",
1078
+ type: "uint256"
1079
+ }
1080
+ ],
1081
+ name: "createPayableMemo",
1082
+ outputs: [
1083
+ {
1084
+ internalType: "uint256",
1085
+ name: "",
1086
+ type: "uint256"
1087
+ }
1088
+ ],
1089
+ stateMutability: "nonpayable",
1090
+ type: "function"
1091
+ },
1092
+ {
1093
+ inputs: [],
1094
+ name: "evaluatorFeeBP",
1095
+ outputs: [
1096
+ {
1097
+ internalType: "uint256",
1098
+ name: "",
1099
+ type: "uint256"
1100
+ }
1101
+ ],
1102
+ stateMutability: "view",
1103
+ type: "function"
1104
+ },
1105
+ {
1106
+ inputs: [
1107
+ {
1108
+ internalType: "uint256",
1109
+ name: "jobId",
1110
+ type: "uint256"
1111
+ },
1112
+ {
1113
+ internalType: "uint256",
1114
+ name: "offset",
1115
+ type: "uint256"
1116
+ },
1117
+ {
1118
+ internalType: "uint256",
1119
+ name: "limit",
1120
+ type: "uint256"
1121
+ }
1122
+ ],
1123
+ name: "getAllMemos",
1124
+ outputs: [
1125
+ {
1126
+ components: [
1127
+ {
1128
+ internalType: "string",
1129
+ name: "content",
1130
+ type: "string"
1131
+ },
1132
+ {
1133
+ internalType: "enum InteractionLedger.MemoType",
1134
+ name: "memoType",
1135
+ type: "uint8"
1136
+ },
1137
+ {
1138
+ internalType: "bool",
1139
+ name: "isSecured",
1140
+ type: "bool"
1141
+ },
1142
+ {
1143
+ internalType: "uint8",
1144
+ name: "nextPhase",
1145
+ type: "uint8"
1146
+ },
1147
+ {
1148
+ internalType: "uint256",
1149
+ name: "jobId",
1150
+ type: "uint256"
1151
+ },
1152
+ {
1153
+ internalType: "address",
1154
+ name: "sender",
1155
+ type: "address"
1156
+ }
1157
+ ],
1158
+ internalType: "struct InteractionLedger.Memo[]",
1159
+ name: "",
1160
+ type: "tuple[]"
1161
+ },
1162
+ {
1163
+ internalType: "uint256",
1164
+ name: "total",
1165
+ type: "uint256"
1166
+ }
1167
+ ],
1168
+ stateMutability: "view",
1169
+ type: "function"
1170
+ },
1171
+ {
1172
+ inputs: [
1173
+ {
1174
+ internalType: "uint256",
1175
+ name: "jobId",
1176
+ type: "uint256"
1177
+ },
1178
+ {
1179
+ internalType: "uint8",
1180
+ name: "phase",
1181
+ type: "uint8"
1182
+ }
1183
+ ],
1184
+ name: "getJobPhaseMemoIds",
1185
+ outputs: [
1186
+ {
1187
+ internalType: "uint256[]",
1188
+ name: "",
1189
+ type: "uint256[]"
1190
+ }
1191
+ ],
1192
+ stateMutability: "view",
1193
+ type: "function"
1194
+ },
1195
+ {
1196
+ inputs: [
1197
+ {
1198
+ internalType: "uint256",
1199
+ name: "jobId",
1200
+ type: "uint256"
1201
+ },
1202
+ {
1203
+ internalType: "uint8",
1204
+ name: "phase",
1205
+ type: "uint8"
1206
+ },
1207
+ {
1208
+ internalType: "uint256",
1209
+ name: "offset",
1210
+ type: "uint256"
1211
+ },
1212
+ {
1213
+ internalType: "uint256",
1214
+ name: "limit",
1215
+ type: "uint256"
1216
+ }
1217
+ ],
1218
+ name: "getMemosForPhase",
1219
+ outputs: [
1220
+ {
1221
+ components: [
1222
+ {
1223
+ internalType: "string",
1224
+ name: "content",
1225
+ type: "string"
1226
+ },
1227
+ {
1228
+ internalType: "enum InteractionLedger.MemoType",
1229
+ name: "memoType",
1230
+ type: "uint8"
1231
+ },
1232
+ {
1233
+ internalType: "bool",
1234
+ name: "isSecured",
1235
+ type: "bool"
1236
+ },
1237
+ {
1238
+ internalType: "uint8",
1239
+ name: "nextPhase",
1240
+ type: "uint8"
1241
+ },
1242
+ {
1243
+ internalType: "uint256",
1244
+ name: "jobId",
1245
+ type: "uint256"
1246
+ },
1247
+ {
1248
+ internalType: "address",
1249
+ name: "sender",
1250
+ type: "address"
1251
+ }
1252
+ ],
1253
+ internalType: "struct InteractionLedger.Memo[]",
1254
+ name: "",
1255
+ type: "tuple[]"
1256
+ },
1257
+ {
1258
+ internalType: "uint256",
1259
+ name: "total",
1260
+ type: "uint256"
1261
+ }
1262
+ ],
432
1263
  stateMutability: "view",
433
1264
  type: "function"
434
1265
  },
435
1266
  {
436
1267
  inputs: [],
437
- name: "TOTAL_PHASES",
438
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
439
- stateMutability: "view",
1268
+ name: "getPhases",
1269
+ outputs: [
1270
+ {
1271
+ internalType: "string[7]",
1272
+ name: "",
1273
+ type: "string[7]"
1274
+ }
1275
+ ],
1276
+ stateMutability: "pure",
440
1277
  type: "function"
441
1278
  },
442
1279
  {
443
1280
  inputs: [
444
- { internalType: "address", name: "account", type: "address" },
445
- { internalType: "uint256", name: "jobId", type: "uint256" }
1281
+ {
1282
+ internalType: "bytes32",
1283
+ name: "role",
1284
+ type: "bytes32"
1285
+ }
1286
+ ],
1287
+ name: "getRoleAdmin",
1288
+ outputs: [
1289
+ {
1290
+ internalType: "bytes32",
1291
+ name: "",
1292
+ type: "bytes32"
1293
+ }
446
1294
  ],
447
- name: "canSign",
448
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
449
1295
  stateMutability: "view",
450
1296
  type: "function"
451
1297
  },
452
1298
  {
453
- inputs: [{ internalType: "uint256", name: "id", type: "uint256" }],
454
- name: "claimBudget",
1299
+ inputs: [
1300
+ {
1301
+ internalType: "bytes32",
1302
+ name: "role",
1303
+ type: "bytes32"
1304
+ },
1305
+ {
1306
+ internalType: "address",
1307
+ name: "account",
1308
+ type: "address"
1309
+ }
1310
+ ],
1311
+ name: "grantRole",
455
1312
  outputs: [],
456
1313
  stateMutability: "nonpayable",
457
1314
  type: "function"
458
1315
  },
459
1316
  {
460
1317
  inputs: [
461
- { internalType: "address", name: "provider", type: "address" },
462
- { internalType: "address", name: "evaluator", type: "address" },
463
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
1318
+ {
1319
+ internalType: "bytes32",
1320
+ name: "role",
1321
+ type: "bytes32"
1322
+ },
1323
+ {
1324
+ internalType: "address",
1325
+ name: "account",
1326
+ type: "address"
1327
+ }
464
1328
  ],
465
- name: "createJob",
466
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
467
- stateMutability: "nonpayable",
1329
+ name: "hasRole",
1330
+ outputs: [
1331
+ {
1332
+ internalType: "bool",
1333
+ name: "",
1334
+ type: "bool"
1335
+ }
1336
+ ],
1337
+ stateMutability: "view",
468
1338
  type: "function"
469
1339
  },
470
1340
  {
471
1341
  inputs: [
472
- { internalType: "uint256", name: "jobId", type: "uint256" },
473
- { internalType: "string", name: "content", type: "string" },
474
1342
  {
475
- internalType: "enum InteractionLedger.MemoType",
476
- name: "memoType",
477
- type: "uint8"
1343
+ internalType: "address",
1344
+ name: "paymentTokenAddress",
1345
+ type: "address"
1346
+ },
1347
+ {
1348
+ internalType: "uint256",
1349
+ name: "evaluatorFeeBP_",
1350
+ type: "uint256"
1351
+ },
1352
+ {
1353
+ internalType: "uint256",
1354
+ name: "platformFeeBP_",
1355
+ type: "uint256"
478
1356
  },
479
- { internalType: "bool", name: "isSecured", type: "bool" },
480
- { internalType: "uint8", name: "nextPhase", type: "uint8" }
1357
+ {
1358
+ internalType: "address",
1359
+ name: "platformTreasury_",
1360
+ type: "address"
1361
+ }
481
1362
  ],
482
- name: "createMemo",
483
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1363
+ name: "initialize",
1364
+ outputs: [],
484
1365
  stateMutability: "nonpayable",
485
1366
  type: "function"
486
1367
  },
487
1368
  {
488
- inputs: [],
489
- name: "evaluatorFeeBP",
490
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1369
+ inputs: [
1370
+ {
1371
+ internalType: "uint256",
1372
+ name: "jobId",
1373
+ type: "uint256"
1374
+ },
1375
+ {
1376
+ internalType: "address",
1377
+ name: "account",
1378
+ type: "address"
1379
+ }
1380
+ ],
1381
+ name: "isJobEvaluator",
1382
+ outputs: [
1383
+ {
1384
+ internalType: "bool",
1385
+ name: "",
1386
+ type: "bool"
1387
+ }
1388
+ ],
491
1389
  stateMutability: "view",
492
1390
  type: "function"
493
1391
  },
494
1392
  {
495
1393
  inputs: [
496
- { internalType: "uint256", name: "jobId", type: "uint256" },
497
- { internalType: "uint256", name: "offset", type: "uint256" },
498
- { internalType: "uint256", name: "limit", type: "uint256" }
1394
+ {
1395
+ internalType: "uint256",
1396
+ name: "memoId",
1397
+ type: "uint256"
1398
+ }
499
1399
  ],
500
- name: "getAllMemos",
1400
+ name: "isPayableMemo",
501
1401
  outputs: [
502
1402
  {
503
- components: [
504
- { internalType: "string", name: "content", type: "string" },
505
- {
506
- internalType: "enum InteractionLedger.MemoType",
507
- name: "memoType",
508
- type: "uint8"
509
- },
510
- { internalType: "bool", name: "isSecured", type: "bool" },
511
- { internalType: "uint8", name: "nextPhase", type: "uint8" },
512
- { internalType: "uint256", name: "jobId", type: "uint256" },
513
- { internalType: "address", name: "sender", type: "address" }
514
- ],
515
- internalType: "struct InteractionLedger.Memo[]",
1403
+ internalType: "bool",
516
1404
  name: "",
517
- type: "tuple[]"
518
- },
519
- { internalType: "uint256", name: "total", type: "uint256" }
1405
+ type: "bool"
1406
+ }
520
1407
  ],
521
1408
  stateMutability: "view",
522
1409
  type: "function"
523
1410
  },
524
1411
  {
525
1412
  inputs: [
526
- { internalType: "uint256", name: "jobId", type: "uint256" },
527
- { internalType: "uint8", name: "phase", type: "uint8" },
528
- { internalType: "uint256", name: "offset", type: "uint256" },
529
- { internalType: "uint256", name: "limit", type: "uint256" }
1413
+ {
1414
+ internalType: "uint256",
1415
+ name: "jobId",
1416
+ type: "uint256"
1417
+ }
530
1418
  ],
531
- name: "getMemosForPhase",
1419
+ name: "jobAdditionalFees",
532
1420
  outputs: [
533
1421
  {
534
- components: [
535
- { internalType: "string", name: "content", type: "string" },
536
- {
537
- internalType: "enum InteractionLedger.MemoType",
538
- name: "memoType",
539
- type: "uint8"
540
- },
541
- { internalType: "bool", name: "isSecured", type: "bool" },
542
- { internalType: "uint8", name: "nextPhase", type: "uint8" },
543
- { internalType: "uint256", name: "jobId", type: "uint256" },
544
- { internalType: "address", name: "sender", type: "address" }
545
- ],
546
- internalType: "struct InteractionLedger.Memo[]",
1422
+ internalType: "uint256",
547
1423
  name: "",
548
- type: "tuple[]"
549
- },
550
- { internalType: "uint256", name: "total", type: "uint256" }
1424
+ type: "uint256"
1425
+ }
551
1426
  ],
552
1427
  stateMutability: "view",
553
1428
  type: "function"
554
1429
  },
555
1430
  {
556
1431
  inputs: [],
557
- name: "getPhases",
558
- outputs: [{ internalType: "string[6]", name: "", type: "string[6]" }],
559
- stateMutability: "pure",
560
- type: "function"
561
- },
562
- {
563
- inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
564
- name: "getRoleAdmin",
565
- outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
1432
+ name: "jobCounter",
1433
+ outputs: [
1434
+ {
1435
+ internalType: "uint256",
1436
+ name: "",
1437
+ type: "uint256"
1438
+ }
1439
+ ],
566
1440
  stateMutability: "view",
567
1441
  type: "function"
568
1442
  },
569
1443
  {
570
1444
  inputs: [
571
- { internalType: "bytes32", name: "role", type: "bytes32" },
572
- { internalType: "address", name: "account", type: "address" }
1445
+ {
1446
+ internalType: "uint256",
1447
+ name: "jobId",
1448
+ type: "uint256"
1449
+ },
1450
+ {
1451
+ internalType: "uint8",
1452
+ name: "phase",
1453
+ type: "uint8"
1454
+ },
1455
+ {
1456
+ internalType: "uint256",
1457
+ name: "",
1458
+ type: "uint256"
1459
+ }
573
1460
  ],
574
- name: "grantRole",
575
- outputs: [],
576
- stateMutability: "nonpayable",
577
- type: "function"
578
- },
579
- {
580
- inputs: [
581
- { internalType: "bytes32", name: "role", type: "bytes32" },
582
- { internalType: "address", name: "account", type: "address" }
1461
+ name: "jobMemoIds",
1462
+ outputs: [
1463
+ {
1464
+ internalType: "uint256",
1465
+ name: "memoIds",
1466
+ type: "uint256"
1467
+ }
583
1468
  ],
584
- name: "hasRole",
585
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
586
1469
  stateMutability: "view",
587
1470
  type: "function"
588
1471
  },
589
1472
  {
590
1473
  inputs: [
591
- { internalType: "address", name: "paymentTokenAddress", type: "address" },
592
- { internalType: "uint256", name: "evaluatorFeeBP_", type: "uint256" },
593
- { internalType: "uint256", name: "platformFeeBP_", type: "uint256" },
594
- { internalType: "address", name: "platformTreasury_", type: "address" }
1474
+ {
1475
+ internalType: "uint256",
1476
+ name: "",
1477
+ type: "uint256"
1478
+ }
595
1479
  ],
596
- name: "initialize",
597
- outputs: [],
598
- stateMutability: "nonpayable",
599
- type: "function"
600
- },
601
- {
602
- inputs: [
603
- { internalType: "uint256", name: "jobId", type: "uint256" },
604
- { internalType: "address", name: "account", type: "address" }
1480
+ name: "jobs",
1481
+ outputs: [
1482
+ {
1483
+ internalType: "uint256",
1484
+ name: "id",
1485
+ type: "uint256"
1486
+ },
1487
+ {
1488
+ internalType: "address",
1489
+ name: "client",
1490
+ type: "address"
1491
+ },
1492
+ {
1493
+ internalType: "address",
1494
+ name: "provider",
1495
+ type: "address"
1496
+ },
1497
+ {
1498
+ internalType: "uint256",
1499
+ name: "budget",
1500
+ type: "uint256"
1501
+ },
1502
+ {
1503
+ internalType: "uint256",
1504
+ name: "amountClaimed",
1505
+ type: "uint256"
1506
+ },
1507
+ {
1508
+ internalType: "uint8",
1509
+ name: "phase",
1510
+ type: "uint8"
1511
+ },
1512
+ {
1513
+ internalType: "uint256",
1514
+ name: "memoCount",
1515
+ type: "uint256"
1516
+ },
1517
+ {
1518
+ internalType: "uint256",
1519
+ name: "expiredAt",
1520
+ type: "uint256"
1521
+ },
1522
+ {
1523
+ internalType: "address",
1524
+ name: "evaluator",
1525
+ type: "address"
1526
+ },
1527
+ {
1528
+ internalType: "contract IERC20",
1529
+ name: "jobPaymentToken",
1530
+ type: "address"
1531
+ }
605
1532
  ],
606
- name: "isJobEvaluator",
607
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
608
1533
  stateMutability: "view",
609
1534
  type: "function"
610
1535
  },
611
1536
  {
612
1537
  inputs: [],
613
- name: "jobCounter",
614
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1538
+ name: "memoCounter",
1539
+ outputs: [
1540
+ {
1541
+ internalType: "uint256",
1542
+ name: "",
1543
+ type: "uint256"
1544
+ }
1545
+ ],
615
1546
  stateMutability: "view",
616
1547
  type: "function"
617
1548
  },
618
1549
  {
619
1550
  inputs: [
620
- { internalType: "uint256", name: "jobId", type: "uint256" },
621
- { internalType: "uint8", name: "phase", type: "uint8" },
622
- { internalType: "uint256", name: "", type: "uint256" }
1551
+ {
1552
+ internalType: "uint256",
1553
+ name: "memoId",
1554
+ type: "uint256"
1555
+ }
1556
+ ],
1557
+ name: "memoExpiredAt",
1558
+ outputs: [
1559
+ {
1560
+ internalType: "uint256",
1561
+ name: "expiredAt",
1562
+ type: "uint256"
1563
+ }
623
1564
  ],
624
- name: "jobMemoIds",
625
- outputs: [{ internalType: "uint256", name: "memoIds", type: "uint256" }],
626
1565
  stateMutability: "view",
627
1566
  type: "function"
628
1567
  },
629
1568
  {
630
- inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
631
- name: "jobs",
1569
+ inputs: [
1570
+ {
1571
+ internalType: "uint256",
1572
+ name: "",
1573
+ type: "uint256"
1574
+ }
1575
+ ],
1576
+ name: "memos",
632
1577
  outputs: [
633
- { internalType: "uint256", name: "id", type: "uint256" },
634
- { internalType: "address", name: "client", type: "address" },
635
- { internalType: "address", name: "provider", type: "address" },
636
- { internalType: "uint256", name: "budget", type: "uint256" },
637
- { internalType: "uint256", name: "amountClaimed", type: "uint256" },
638
- { internalType: "uint8", name: "phase", type: "uint8" },
639
- { internalType: "uint256", name: "memoCount", type: "uint256" },
640
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
641
- { internalType: "address", name: "evaluator", type: "address" }
1578
+ {
1579
+ internalType: "string",
1580
+ name: "content",
1581
+ type: "string"
1582
+ },
1583
+ {
1584
+ internalType: "enum InteractionLedger.MemoType",
1585
+ name: "memoType",
1586
+ type: "uint8"
1587
+ },
1588
+ {
1589
+ internalType: "bool",
1590
+ name: "isSecured",
1591
+ type: "bool"
1592
+ },
1593
+ {
1594
+ internalType: "uint8",
1595
+ name: "nextPhase",
1596
+ type: "uint8"
1597
+ },
1598
+ {
1599
+ internalType: "uint256",
1600
+ name: "jobId",
1601
+ type: "uint256"
1602
+ },
1603
+ {
1604
+ internalType: "address",
1605
+ name: "sender",
1606
+ type: "address"
1607
+ }
642
1608
  ],
643
1609
  stateMutability: "view",
644
1610
  type: "function"
645
1611
  },
646
1612
  {
647
1613
  inputs: [],
648
- name: "memoCounter",
649
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1614
+ name: "numEvaluatorsPerJob",
1615
+ outputs: [
1616
+ {
1617
+ internalType: "uint8",
1618
+ name: "",
1619
+ type: "uint8"
1620
+ }
1621
+ ],
650
1622
  stateMutability: "view",
651
1623
  type: "function"
652
1624
  },
653
1625
  {
654
- inputs: [],
655
- name: "numEvaluatorsPerJob",
656
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
1626
+ inputs: [
1627
+ {
1628
+ internalType: "uint256",
1629
+ name: "memoId",
1630
+ type: "uint256"
1631
+ }
1632
+ ],
1633
+ name: "payableDetails",
1634
+ outputs: [
1635
+ {
1636
+ internalType: "address",
1637
+ name: "token",
1638
+ type: "address"
1639
+ },
1640
+ {
1641
+ internalType: "uint256",
1642
+ name: "amount",
1643
+ type: "uint256"
1644
+ },
1645
+ {
1646
+ internalType: "address",
1647
+ name: "recipient",
1648
+ type: "address"
1649
+ },
1650
+ {
1651
+ internalType: "uint256",
1652
+ name: "feeAmount",
1653
+ type: "uint256"
1654
+ },
1655
+ {
1656
+ internalType: "enum ACPSimple.FeeType",
1657
+ name: "feeType",
1658
+ type: "uint8"
1659
+ },
1660
+ {
1661
+ internalType: "bool",
1662
+ name: "isExecuted",
1663
+ type: "bool"
1664
+ }
1665
+ ],
657
1666
  stateMutability: "view",
658
1667
  type: "function"
659
1668
  },
660
1669
  {
661
1670
  inputs: [],
662
1671
  name: "paymentToken",
663
- outputs: [{ internalType: "contract IERC20", name: "", type: "address" }],
1672
+ outputs: [
1673
+ {
1674
+ internalType: "contract IERC20",
1675
+ name: "",
1676
+ type: "address"
1677
+ }
1678
+ ],
664
1679
  stateMutability: "view",
665
1680
  type: "function"
666
1681
  },
667
1682
  {
668
1683
  inputs: [],
669
1684
  name: "platformFeeBP",
670
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1685
+ outputs: [
1686
+ {
1687
+ internalType: "uint256",
1688
+ name: "",
1689
+ type: "uint256"
1690
+ }
1691
+ ],
671
1692
  stateMutability: "view",
672
1693
  type: "function"
673
1694
  },
674
1695
  {
675
1696
  inputs: [],
676
1697
  name: "platformTreasury",
677
- outputs: [{ internalType: "address", name: "", type: "address" }],
1698
+ outputs: [
1699
+ {
1700
+ internalType: "address",
1701
+ name: "",
1702
+ type: "address"
1703
+ }
1704
+ ],
678
1705
  stateMutability: "view",
679
1706
  type: "function"
680
1707
  },
681
1708
  {
682
1709
  inputs: [
683
- { internalType: "bytes32", name: "role", type: "bytes32" },
684
- { internalType: "address", name: "callerConfirmation", type: "address" }
1710
+ {
1711
+ internalType: "bytes32",
1712
+ name: "role",
1713
+ type: "bytes32"
1714
+ },
1715
+ {
1716
+ internalType: "address",
1717
+ name: "callerConfirmation",
1718
+ type: "address"
1719
+ }
685
1720
  ],
686
1721
  name: "renounceRole",
687
1722
  outputs: [],
@@ -690,8 +1725,16 @@ var ACP_ABI = [
690
1725
  },
691
1726
  {
692
1727
  inputs: [
693
- { internalType: "bytes32", name: "role", type: "bytes32" },
694
- { internalType: "address", name: "account", type: "address" }
1728
+ {
1729
+ internalType: "bytes32",
1730
+ name: "role",
1731
+ type: "bytes32"
1732
+ },
1733
+ {
1734
+ internalType: "address",
1735
+ name: "account",
1736
+ type: "address"
1737
+ }
695
1738
  ],
696
1739
  name: "revokeRole",
697
1740
  outputs: [],
@@ -700,8 +1743,16 @@ var ACP_ABI = [
700
1743
  },
701
1744
  {
702
1745
  inputs: [
703
- { internalType: "uint256", name: "jobId", type: "uint256" },
704
- { internalType: "uint256", name: "amount", type: "uint256" }
1746
+ {
1747
+ internalType: "uint256",
1748
+ name: "jobId",
1749
+ type: "uint256"
1750
+ },
1751
+ {
1752
+ internalType: "uint256",
1753
+ name: "amount",
1754
+ type: "uint256"
1755
+ }
705
1756
  ],
706
1757
  name: "setBudget",
707
1758
  outputs: [],
@@ -710,9 +1761,44 @@ var ACP_ABI = [
710
1761
  },
711
1762
  {
712
1763
  inputs: [
713
- { internalType: "uint256", name: "memoId", type: "uint256" },
714
- { internalType: "bool", name: "isApproved", type: "bool" },
715
- { internalType: "string", name: "reason", type: "string" }
1764
+ {
1765
+ internalType: "uint256",
1766
+ name: "jobId",
1767
+ type: "uint256"
1768
+ },
1769
+ {
1770
+ internalType: "uint256",
1771
+ name: "amount",
1772
+ type: "uint256"
1773
+ },
1774
+ {
1775
+ internalType: "contract IERC20",
1776
+ name: "jobPaymentToken_",
1777
+ type: "address"
1778
+ }
1779
+ ],
1780
+ name: "setBudgetWithPaymentToken",
1781
+ outputs: [],
1782
+ stateMutability: "nonpayable",
1783
+ type: "function"
1784
+ },
1785
+ {
1786
+ inputs: [
1787
+ {
1788
+ internalType: "uint256",
1789
+ name: "memoId",
1790
+ type: "uint256"
1791
+ },
1792
+ {
1793
+ internalType: "bool",
1794
+ name: "isApproved",
1795
+ type: "bool"
1796
+ },
1797
+ {
1798
+ internalType: "string",
1799
+ name: "reason",
1800
+ type: "string"
1801
+ }
716
1802
  ],
717
1803
  name: "signMemo",
718
1804
  outputs: [],
@@ -721,24 +1807,54 @@ var ACP_ABI = [
721
1807
  },
722
1808
  {
723
1809
  inputs: [
724
- { internalType: "uint256", name: "memoId", type: "uint256" },
725
- { internalType: "address", name: "signer", type: "address" }
1810
+ {
1811
+ internalType: "uint256",
1812
+ name: "memoId",
1813
+ type: "uint256"
1814
+ },
1815
+ {
1816
+ internalType: "address",
1817
+ name: "signer",
1818
+ type: "address"
1819
+ }
726
1820
  ],
727
1821
  name: "signatories",
728
- outputs: [{ internalType: "uint8", name: "res", type: "uint8" }],
1822
+ outputs: [
1823
+ {
1824
+ internalType: "uint8",
1825
+ name: "res",
1826
+ type: "uint8"
1827
+ }
1828
+ ],
729
1829
  stateMutability: "view",
730
1830
  type: "function"
731
1831
  },
732
1832
  {
733
- inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
1833
+ inputs: [
1834
+ {
1835
+ internalType: "bytes4",
1836
+ name: "interfaceId",
1837
+ type: "bytes4"
1838
+ }
1839
+ ],
734
1840
  name: "supportsInterface",
735
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
1841
+ outputs: [
1842
+ {
1843
+ internalType: "bool",
1844
+ name: "",
1845
+ type: "bool"
1846
+ }
1847
+ ],
736
1848
  stateMutability: "view",
737
1849
  type: "function"
738
1850
  },
739
1851
  {
740
1852
  inputs: [
741
- { internalType: "uint256", name: "evaluatorFeeBP_", type: "uint256" }
1853
+ {
1854
+ internalType: "uint256",
1855
+ name: "evaluatorFeeBP_",
1856
+ type: "uint256"
1857
+ }
742
1858
  ],
743
1859
  name: "updateEvaluatorFee",
744
1860
  outputs: [],
@@ -747,19 +1863,39 @@ var ACP_ABI = [
747
1863
  },
748
1864
  {
749
1865
  inputs: [
750
- { internalType: "uint256", name: "platformFeeBP_", type: "uint256" },
751
- { internalType: "address", name: "platformTreasury_", type: "address" }
1866
+ {
1867
+ internalType: "uint256",
1868
+ name: "platformFeeBP_",
1869
+ type: "uint256"
1870
+ },
1871
+ {
1872
+ internalType: "address",
1873
+ name: "platformTreasury_",
1874
+ type: "address"
1875
+ }
752
1876
  ],
753
1877
  name: "updatePlatformFee",
754
1878
  outputs: [],
755
1879
  stateMutability: "nonpayable",
756
1880
  type: "function"
1881
+ },
1882
+ {
1883
+ inputs: [
1884
+ {
1885
+ internalType: "uint256",
1886
+ name: "memoId",
1887
+ type: "uint256"
1888
+ }
1889
+ ],
1890
+ name: "withdrawEscrowedFunds",
1891
+ outputs: [],
1892
+ stateMutability: "nonpayable",
1893
+ type: "function"
757
1894
  }
758
1895
  ];
759
1896
  var acpAbi_default = ACP_ABI;
760
1897
 
761
1898
  // src/acpClient.ts
762
- var import_viem2 = require("viem");
763
1899
  var import_socket = require("socket.io-client");
764
1900
 
765
1901
  // src/acpContractClient.ts
@@ -771,21 +1907,30 @@ var import_smart_contracts = require("@account-kit/smart-contracts");
771
1907
  var import_infra = require("@account-kit/infra");
772
1908
  var baseSepoliaAcpConfig = {
773
1909
  chain: import_infra.baseSepolia,
774
- contractAddress: "0x2422c1c43451Eb69Ff49dfD39c4Dc8C5230fA1e6",
775
- virtualsTokenAddress: "0xbfAB80ccc15DF6fb7185f9498d6039317331846a",
1910
+ contractAddress: "0x8Db6B1c839Fc8f6bd35777E194677B67b4D51928",
1911
+ paymentTokenAddress: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
1912
+ paymentTokenDecimals: 6,
776
1913
  alchemyRpcUrl: "https://alchemy-proxy.virtuals.io/api/proxy/rpc",
777
- acpUrl: "https://acpx-staging.virtuals.io"
1914
+ acpUrl: "https://acpx.virtuals.gg",
1915
+ priorityFeeMultiplier: 2,
1916
+ maxFeePerGas: 2e7,
1917
+ maxPriorityFeePerGas: 21e6
778
1918
  };
779
1919
  var baseAcpConfig = {
780
1920
  chain: import_infra.base,
781
1921
  contractAddress: "0x6a1FE26D54ab0d3E1e3168f2e0c0cDa5cC0A0A4A",
782
- virtualsTokenAddress: "0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b",
1922
+ paymentTokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
1923
+ paymentTokenDecimals: 6,
783
1924
  alchemyRpcUrl: "https://alchemy-proxy-prod.virtuals.io/api/proxy/rpc",
784
- acpUrl: "https://acpx.virtuals.io"
1925
+ acpUrl: "https://acpx.virtuals.io",
1926
+ priorityFeeMultiplier: 2,
1927
+ maxFeePerGas: 2e7,
1928
+ maxPriorityFeePerGas: 21e6
785
1929
  };
786
1930
 
787
1931
  // src/acpContractClient.ts
788
1932
  var import_viem = require("viem");
1933
+ var import_op_stack = require("viem/op-stack");
789
1934
  var MemoType = /* @__PURE__ */ ((MemoType2) => {
790
1935
  MemoType2[MemoType2["MESSAGE"] = 0] = "MESSAGE";
791
1936
  MemoType2[MemoType2["CONTEXT_URL"] = 1] = "CONTEXT_URL";
@@ -793,6 +1938,9 @@ var MemoType = /* @__PURE__ */ ((MemoType2) => {
793
1938
  MemoType2[MemoType2["VOICE_URL"] = 3] = "VOICE_URL";
794
1939
  MemoType2[MemoType2["OBJECT_URL"] = 4] = "OBJECT_URL";
795
1940
  MemoType2[MemoType2["TXHASH"] = 5] = "TXHASH";
1941
+ MemoType2[MemoType2["PAYABLE_REQUEST"] = 6] = "PAYABLE_REQUEST";
1942
+ MemoType2[MemoType2["PAYABLE_TRANSFER"] = 7] = "PAYABLE_TRANSFER";
1943
+ MemoType2[MemoType2["PAYABLE_TRANSFER_ESCROW"] = 8] = "PAYABLE_TRANSFER_ESCROW";
796
1944
  return MemoType2;
797
1945
  })(MemoType || {});
798
1946
  var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
@@ -802,25 +1950,34 @@ var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
802
1950
  AcpJobPhases2[AcpJobPhases2["EVALUATION"] = 3] = "EVALUATION";
803
1951
  AcpJobPhases2[AcpJobPhases2["COMPLETED"] = 4] = "COMPLETED";
804
1952
  AcpJobPhases2[AcpJobPhases2["REJECTED"] = 5] = "REJECTED";
1953
+ AcpJobPhases2[AcpJobPhases2["EXPIRED"] = 6] = "EXPIRED";
805
1954
  return AcpJobPhases2;
806
1955
  })(AcpJobPhases || {});
807
1956
  var AcpContractClient = class _AcpContractClient {
808
- constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
1957
+ constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig, customRpcUrl) {
809
1958
  this.walletPrivateKey = walletPrivateKey;
810
1959
  this.sessionEntityKeyId = sessionEntityKeyId;
811
1960
  this.agentWalletAddress = agentWalletAddress;
812
1961
  this.config = config;
1962
+ this.customRpcUrl = customRpcUrl;
1963
+ this.MAX_RETRIES = 3;
813
1964
  this.chain = config.chain;
814
1965
  this.contractAddress = config.contractAddress;
815
- this.virtualsTokenAddress = config.virtualsTokenAddress;
1966
+ this.paymentTokenAddress = config.paymentTokenAddress;
1967
+ this.customRpcUrl = customRpcUrl;
1968
+ this.customRpcClient = (0, import_viem.createPublicClient)({
1969
+ chain: this.chain,
1970
+ transport: this.customRpcUrl ? (0, import_viem.http)(this.customRpcUrl) : (0, import_viem.http)()
1971
+ }).extend((0, import_op_stack.publicActionsL2)());
816
1972
  }
817
- static build(_0, _1, _2) {
818
- return __async(this, arguments, function* (walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
1973
+ static build(_0, _1, _2, _3) {
1974
+ return __async(this, arguments, function* (walletPrivateKey, sessionEntityKeyId, agentWalletAddress, customRpcUrl, config = baseAcpConfig) {
819
1975
  const acpContractClient = new _AcpContractClient(
820
1976
  walletPrivateKey,
821
1977
  sessionEntityKeyId,
822
1978
  agentWalletAddress,
823
- config
1979
+ config,
1980
+ customRpcUrl
824
1981
  );
825
1982
  yield acpContractClient.init();
826
1983
  return acpContractClient;
@@ -853,6 +2010,54 @@ var AcpContractClient = class _AcpContractClient {
853
2010
  get walletAddress() {
854
2011
  return this.sessionKeyClient.account.address;
855
2012
  }
2013
+ calculateGasFees() {
2014
+ return __async(this, null, function* () {
2015
+ const { maxFeePerGas, maxPriorityFeePerGas } = yield this.customRpcClient.estimateFeesPerGas();
2016
+ let finalMaxFeePerGas = maxFeePerGas;
2017
+ let priorityFeeMultiplier = Number(this.config.priorityFeeMultiplier) || 2;
2018
+ const overrideMaxFeePerGas = this.config.maxFeePerGas || maxFeePerGas;
2019
+ const overrideMaxPriorityFeePerGas = this.config.maxPriorityFeePerGas || maxPriorityFeePerGas;
2020
+ finalMaxFeePerGas = BigInt(overrideMaxFeePerGas) + BigInt(overrideMaxPriorityFeePerGas) * BigInt(Math.max(0, priorityFeeMultiplier - 1));
2021
+ return finalMaxFeePerGas;
2022
+ });
2023
+ }
2024
+ handleSendUserOperation(_0) {
2025
+ return __async(this, arguments, function* (data, contractAddress = this.contractAddress) {
2026
+ const payload = {
2027
+ uo: {
2028
+ target: contractAddress,
2029
+ data
2030
+ },
2031
+ overrides: {}
2032
+ };
2033
+ let retries = this.MAX_RETRIES;
2034
+ let finalError;
2035
+ while (retries > 0) {
2036
+ try {
2037
+ if (this.MAX_RETRIES > retries) {
2038
+ const gasFees = yield this.calculateGasFees();
2039
+ payload["overrides"] = {
2040
+ maxFeePerGas: `0x${gasFees.toString(16)}`
2041
+ };
2042
+ }
2043
+ const { hash } = yield this.sessionKeyClient.sendUserOperation(payload);
2044
+ yield this.sessionKeyClient.waitForUserOperationTransaction({
2045
+ hash
2046
+ });
2047
+ return hash;
2048
+ } catch (error) {
2049
+ console.debug("Failed to send user operation", error);
2050
+ retries -= 1;
2051
+ if (retries === 0) {
2052
+ finalError = error;
2053
+ break;
2054
+ }
2055
+ yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
2056
+ }
2057
+ }
2058
+ throw new Error(`Failed to send user operation ${finalError}`);
2059
+ });
2060
+ }
856
2061
  getJobId(hash) {
857
2062
  return __async(this, null, function* () {
858
2063
  const result = yield this.sessionKeyClient.getUserOperationReceipt(hash);
@@ -868,6 +2073,9 @@ var AcpContractClient = class _AcpContractClient {
868
2073
  return (0, import_viem.fromHex)(contractLogs.data, "number");
869
2074
  });
870
2075
  }
2076
+ formatAmount(amount) {
2077
+ return (0, import_viem.parseUnits)(amount.toString(), this.config.paymentTokenDecimals);
2078
+ }
871
2079
  createJob(providerAddress, evaluatorAddress, expireAt) {
872
2080
  return __async(this, null, function* () {
873
2081
  try {
@@ -880,51 +2088,50 @@ var AcpContractClient = class _AcpContractClient {
880
2088
  Math.floor(expireAt.getTime() / 1e3)
881
2089
  ]
882
2090
  });
883
- const { hash } = yield this.sessionKeyClient.sendUserOperation({
884
- uo: {
885
- target: this.contractAddress,
886
- data
887
- }
888
- });
889
- yield this.sessionKeyClient.waitForUserOperationTransaction({
890
- hash
891
- });
2091
+ const hash = yield this.handleSendUserOperation(data);
892
2092
  const jobId = yield this.getJobId(hash);
893
2093
  return { txHash: hash, jobId };
894
2094
  } catch (error) {
895
- console.error(error);
2095
+ console.error(`Failed to create job ${error}`);
896
2096
  throw new Error("Failed to create job");
897
2097
  }
898
2098
  });
899
2099
  }
900
- approveAllowance(priceInWei) {
901
- return __async(this, null, function* () {
902
- const data = (0, import_viem.encodeFunctionData)({
903
- abi: import_viem.erc20Abi,
904
- functionName: "approve",
905
- args: [this.contractAddress, priceInWei]
906
- });
907
- const { hash } = yield this.sessionKeyClient.sendUserOperation({
908
- uo: {
909
- target: this.virtualsTokenAddress,
910
- data
911
- }
912
- });
913
- yield this.sessionKeyClient.waitForUserOperationTransaction({
914
- hash
915
- });
916
- return hash;
2100
+ approveAllowance(_0) {
2101
+ return __async(this, arguments, function* (amount, paymentTokenAddress = this.paymentTokenAddress) {
2102
+ try {
2103
+ const data = (0, import_viem.encodeFunctionData)({
2104
+ abi: import_viem.erc20Abi,
2105
+ functionName: "approve",
2106
+ args: [this.contractAddress, this.formatAmount(amount)]
2107
+ });
2108
+ return yield this.handleSendUserOperation(data, paymentTokenAddress);
2109
+ } catch (error) {
2110
+ console.error(`Failed to approve allowance ${error}`);
2111
+ throw new Error("Failed to approve allowance");
2112
+ }
917
2113
  });
918
2114
  }
919
- createMemo(jobId, content, type, isSecured, nextPhase) {
920
- return __async(this, null, function* () {
2115
+ createPayableMemo(_0, _1, _2, _3, _4, _5, _6, _7, _8) {
2116
+ return __async(this, arguments, function* (jobId, content, amount, recipient, feeAmount, feeType, nextPhase, type, expiredAt, token = this.paymentTokenAddress) {
921
2117
  let retries = 3;
922
2118
  while (retries > 0) {
923
2119
  try {
924
2120
  const data = (0, import_viem.encodeFunctionData)({
925
2121
  abi: acpAbi_default,
926
- functionName: "createMemo",
927
- args: [jobId, content, type, isSecured, nextPhase]
2122
+ functionName: "createPayableMemo",
2123
+ args: [
2124
+ jobId,
2125
+ content,
2126
+ token,
2127
+ this.formatAmount(amount),
2128
+ recipient,
2129
+ this.formatAmount(feeAmount),
2130
+ feeType,
2131
+ type,
2132
+ nextPhase,
2133
+ Math.floor(expiredAt.getTime() / 1e3)
2134
+ ]
928
2135
  });
929
2136
  const { hash } = yield this.sessionKeyClient.sendUserOperation({
930
2137
  uo: {
@@ -937,41 +2144,67 @@ var AcpContractClient = class _AcpContractClient {
937
2144
  });
938
2145
  return hash;
939
2146
  } catch (error) {
940
- console.error(`failed to create memo ${jobId} ${content} ${error}`);
2147
+ console.error(
2148
+ `failed to create payable memo ${jobId} ${content} ${error}`
2149
+ );
941
2150
  retries -= 1;
942
2151
  yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
943
2152
  }
944
2153
  }
945
- throw new Error("Failed to create memo");
2154
+ throw new Error("Failed to create payable memo");
2155
+ });
2156
+ }
2157
+ createMemo(jobId, content, type, isSecured, nextPhase) {
2158
+ return __async(this, null, function* () {
2159
+ try {
2160
+ const data = (0, import_viem.encodeFunctionData)({
2161
+ abi: acpAbi_default,
2162
+ functionName: "createMemo",
2163
+ args: [jobId, content, type, isSecured, nextPhase]
2164
+ });
2165
+ return yield this.handleSendUserOperation(data);
2166
+ } catch (error) {
2167
+ console.error(`Failed to create memo ${jobId} ${content} ${error}`);
2168
+ throw new Error("Failed to create memo");
2169
+ }
2170
+ });
2171
+ }
2172
+ getMemoId(hash) {
2173
+ return __async(this, null, function* () {
2174
+ const result = yield this.sessionKeyClient.getUserOperationReceipt(hash);
2175
+ if (!result) {
2176
+ throw new Error("Failed to get user operation receipt");
2177
+ }
2178
+ const contractLogs = result.logs.find(
2179
+ (log) => log.address.toLowerCase() === this.contractAddress.toLowerCase()
2180
+ );
2181
+ if (!contractLogs) {
2182
+ throw new Error("Failed to get contract logs");
2183
+ }
2184
+ const decoded = (0, import_viem.decodeEventLog)({
2185
+ abi: acpAbi_default,
2186
+ data: contractLogs.data,
2187
+ topics: contractLogs.topics
2188
+ });
2189
+ if (!decoded.args) {
2190
+ throw new Error("Failed to decode event logs");
2191
+ }
2192
+ return parseInt(decoded.args.memoId);
946
2193
  });
947
2194
  }
948
2195
  signMemo(memoId, isApproved, reason) {
949
2196
  return __async(this, null, function* () {
950
- let retries = 3;
951
- while (retries > 0) {
952
- try {
953
- const data = (0, import_viem.encodeFunctionData)({
954
- abi: acpAbi_default,
955
- functionName: "signMemo",
956
- args: [memoId, isApproved, reason]
957
- });
958
- const { hash } = yield this.sessionKeyClient.sendUserOperation({
959
- uo: {
960
- target: this.contractAddress,
961
- data
962
- }
963
- });
964
- yield this.sessionKeyClient.waitForUserOperationTransaction({
965
- hash
966
- });
967
- return hash;
968
- } catch (error) {
969
- console.error(`failed to sign memo ${error}`);
970
- retries -= 1;
971
- yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
972
- }
2197
+ try {
2198
+ const data = (0, import_viem.encodeFunctionData)({
2199
+ abi: acpAbi_default,
2200
+ functionName: "signMemo",
2201
+ args: [memoId, isApproved, reason]
2202
+ });
2203
+ return yield this.handleSendUserOperation(data);
2204
+ } catch (error) {
2205
+ console.error(`Failed to sign memo ${error}`);
2206
+ throw new Error("Failed to sign memo");
973
2207
  }
974
- throw new Error("Failed to sign memo");
975
2208
  });
976
2209
  }
977
2210
  setBudget(jobId, budget) {
@@ -980,20 +2213,26 @@ var AcpContractClient = class _AcpContractClient {
980
2213
  const data = (0, import_viem.encodeFunctionData)({
981
2214
  abi: acpAbi_default,
982
2215
  functionName: "setBudget",
983
- args: [jobId, budget]
984
- });
985
- const { hash } = yield this.sessionKeyClient.sendUserOperation({
986
- uo: {
987
- target: this.contractAddress,
988
- data
989
- }
2216
+ args: [jobId, this.formatAmount(budget)]
990
2217
  });
991
- yield this.sessionKeyClient.waitForUserOperationTransaction({
992
- hash
2218
+ return yield this.handleSendUserOperation(data);
2219
+ } catch (error) {
2220
+ console.error(`Failed to set budget ${error}`);
2221
+ throw new Error("Failed to set budget");
2222
+ }
2223
+ });
2224
+ }
2225
+ setBudgetWithPaymentToken(_0, _1) {
2226
+ return __async(this, arguments, function* (jobId, budget, paymentTokenAddress = this.paymentTokenAddress) {
2227
+ try {
2228
+ const data = (0, import_viem.encodeFunctionData)({
2229
+ abi: acpAbi_default,
2230
+ functionName: "setBudgetWithPaymentToken",
2231
+ args: [jobId, this.formatAmount(budget), paymentTokenAddress]
993
2232
  });
994
- return hash;
2233
+ return yield this.handleSendUserOperation(data);
995
2234
  } catch (error) {
996
- console.error(error);
2235
+ console.error(`Failed to set budget ${error}`);
997
2236
  throw new Error("Failed to set budget");
998
2237
  }
999
2238
  });
@@ -1001,22 +2240,93 @@ var AcpContractClient = class _AcpContractClient {
1001
2240
  };
1002
2241
  var acpContractClient_default = AcpContractClient;
1003
2242
 
2243
+ // src/interfaces.ts
2244
+ var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
2245
+ AcpMemoStatus2["PENDING"] = "PENDING";
2246
+ AcpMemoStatus2["APPROVED"] = "APPROVED";
2247
+ AcpMemoStatus2["REJECTED"] = "REJECTED";
2248
+ return AcpMemoStatus2;
2249
+ })(AcpMemoStatus || {});
2250
+ var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
2251
+ AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
2252
+ AcpAgentSort2["SUCCESS_RATE"] = "successRate";
2253
+ AcpAgentSort2["UNIQUE_BUYER_COUNT"] = "uniqueBuyerCount";
2254
+ AcpAgentSort2["MINS_FROM_LAST_ONLINE"] = "minsFromLastOnlineTime";
2255
+ return AcpAgentSort2;
2256
+ })(AcpAgentSort || {});
2257
+ var AcpGraduationStatus = /* @__PURE__ */ ((AcpGraduationStatus2) => {
2258
+ AcpGraduationStatus2["ALL"] = "all";
2259
+ AcpGraduationStatus2["GRADUATED"] = "graduated";
2260
+ AcpGraduationStatus2["NOT_GRADUATED"] = "not_graduated";
2261
+ return AcpGraduationStatus2;
2262
+ })(AcpGraduationStatus || {});
2263
+ var AcpOnlineStatus = /* @__PURE__ */ ((AcpOnlineStatus2) => {
2264
+ AcpOnlineStatus2["ALL"] = "all";
2265
+ AcpOnlineStatus2["ONLINE"] = "online";
2266
+ AcpOnlineStatus2["OFFLINE"] = "offline";
2267
+ return AcpOnlineStatus2;
2268
+ })(AcpOnlineStatus || {});
2269
+ var PayloadType = /* @__PURE__ */ ((PayloadType2) => {
2270
+ PayloadType2["FUND_RESPONSE"] = "fund_response";
2271
+ PayloadType2["OPEN_POSITION"] = "open_position";
2272
+ PayloadType2["CLOSE_PARTIAL_POSITION"] = "close_partial_position";
2273
+ PayloadType2["CLOSE_POSITION"] = "close_position";
2274
+ PayloadType2["POSITION_FULFILLED"] = "position_fulfilled";
2275
+ PayloadType2["CLOSE_JOB_AND_WITHDRAW"] = "close_job_and_withdraw";
2276
+ PayloadType2["UNFULFILLED_POSITION"] = "unfulfilled_position";
2277
+ return PayloadType2;
2278
+ })(PayloadType || {});
2279
+
2280
+ // src/utils.ts
2281
+ function tryParseJson(content) {
2282
+ try {
2283
+ return JSON.parse(content);
2284
+ } catch (error) {
2285
+ return null;
2286
+ }
2287
+ }
2288
+
1004
2289
  // src/acpJob.ts
1005
2290
  var AcpJob = class {
1006
- constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, memos, phase, context) {
2291
+ constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, priceTokenAddress, memos, phase, context) {
1007
2292
  this.acpClient = acpClient;
1008
2293
  this.id = id;
1009
2294
  this.clientAddress = clientAddress;
1010
2295
  this.providerAddress = providerAddress;
1011
2296
  this.evaluatorAddress = evaluatorAddress;
1012
2297
  this.price = price;
2298
+ this.priceTokenAddress = priceTokenAddress;
1013
2299
  this.memos = memos;
1014
2300
  this.phase = phase;
1015
2301
  this.context = context;
1016
2302
  }
1017
2303
  get serviceRequirement() {
1018
2304
  var _a;
1019
- return (_a = this.memos.find((m) => m.nextPhase === 1 /* NEGOTIATION */)) == null ? void 0 : _a.content;
2305
+ const content = (_a = this.memos.find(
2306
+ (m) => m.nextPhase === 1 /* NEGOTIATION */
2307
+ )) == null ? void 0 : _a.content;
2308
+ if (!content) {
2309
+ return void 0;
2310
+ }
2311
+ const contentObj = tryParseJson(content);
2312
+ if (!contentObj) {
2313
+ return content;
2314
+ }
2315
+ if (contentObj.serviceRequirement) {
2316
+ return contentObj.serviceRequirement;
2317
+ }
2318
+ return contentObj;
2319
+ }
2320
+ get serviceName() {
2321
+ var _a;
2322
+ const content = (_a = this.memos.find(
2323
+ (m) => m.nextPhase === 1 /* NEGOTIATION */
2324
+ )) == null ? void 0 : _a.content;
2325
+ if (!content) {
2326
+ return void 0;
2327
+ }
2328
+ const contentObj = tryParseJson(content);
2329
+ return contentObj == null ? void 0 : contentObj.serviceName;
1020
2330
  }
1021
2331
  get deliverable() {
1022
2332
  var _a;
@@ -1031,6 +2341,9 @@ var AcpJob = class {
1031
2341
  get evaluatorAgent() {
1032
2342
  return this.acpClient.getAgent(this.evaluatorAddress);
1033
2343
  }
2344
+ get latestMemo() {
2345
+ return this.memos[this.memos.length - 1];
2346
+ }
1034
2347
  pay(amount, reason) {
1035
2348
  return __async(this, null, function* () {
1036
2349
  const memo = this.memos.find(
@@ -1042,23 +2355,25 @@ var AcpJob = class {
1042
2355
  return yield this.acpClient.payJob(this.id, amount, memo.id, reason);
1043
2356
  });
1044
2357
  }
1045
- respond(accept, reason) {
2358
+ respond(accept, payload, reason) {
1046
2359
  return __async(this, null, function* () {
1047
- const memo = this.memos.find(
1048
- (m) => m.nextPhase === 1 /* NEGOTIATION */
1049
- );
1050
- if (!memo) {
2360
+ var _a;
2361
+ if (((_a = this.latestMemo) == null ? void 0 : _a.nextPhase) !== 1 /* NEGOTIATION */) {
1051
2362
  throw new Error("No negotiation memo found");
1052
2363
  }
1053
- return yield this.acpClient.respondJob(this.id, memo.id, accept, reason);
2364
+ return yield this.acpClient.respondJob(
2365
+ this.id,
2366
+ this.latestMemo.id,
2367
+ accept,
2368
+ payload ? JSON.stringify(payload) : void 0,
2369
+ reason
2370
+ );
1054
2371
  });
1055
2372
  }
1056
2373
  deliver(deliverable) {
1057
2374
  return __async(this, null, function* () {
1058
- const memo = this.memos.find(
1059
- (m) => m.nextPhase === 3 /* EVALUATION */
1060
- );
1061
- if (!memo) {
2375
+ var _a;
2376
+ if (((_a = this.latestMemo) == null ? void 0 : _a.nextPhase) !== 3 /* EVALUATION */) {
1062
2377
  throw new Error("No transaction memo found");
1063
2378
  }
1064
2379
  return yield this.acpClient.deliverJob(this.id, deliverable);
@@ -1066,28 +2381,304 @@ var AcpJob = class {
1066
2381
  }
1067
2382
  evaluate(accept, reason) {
1068
2383
  return __async(this, null, function* () {
1069
- const memo = this.memos.find((m) => m.nextPhase === 4 /* COMPLETED */);
1070
- if (!memo) {
2384
+ var _a;
2385
+ if (((_a = this.latestMemo) == null ? void 0 : _a.nextPhase) !== 4 /* COMPLETED */) {
1071
2386
  throw new Error("No evaluation memo found");
1072
2387
  }
1073
2388
  return yield this.acpClient.acpContractClient.signMemo(
2389
+ this.latestMemo.id,
2390
+ accept,
2391
+ reason
2392
+ );
2393
+ });
2394
+ }
2395
+ openPosition(_0, _1) {
2396
+ return __async(this, arguments, function* (payload, feeAmount, expiredAt = new Date(Date.now() + 1e3 * 60 * 3), walletAddress) {
2397
+ if (payload.length === 0) {
2398
+ throw new Error("No positions to open");
2399
+ }
2400
+ return yield this.acpClient.transferFunds(
2401
+ this.id,
2402
+ payload.reduce((acc, curr) => acc + curr.amount, 0),
2403
+ walletAddress || this.providerAddress,
2404
+ feeAmount,
2405
+ 1 /* IMMEDIATE_FEE */,
2406
+ {
2407
+ type: "open_position" /* OPEN_POSITION */,
2408
+ data: payload
2409
+ },
2410
+ 2 /* TRANSACTION */,
2411
+ expiredAt
2412
+ );
2413
+ });
2414
+ }
2415
+ responseOpenPosition(memoId, accept, reason) {
2416
+ return __async(this, null, function* () {
2417
+ const memo = this.memos.find((m) => m.id === memoId);
2418
+ if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
2419
+ throw new Error("No open position memo found");
2420
+ }
2421
+ const payload = tryParseJson(
2422
+ memo.content
2423
+ );
2424
+ if ((payload == null ? void 0 : payload.type) !== "open_position" /* OPEN_POSITION */) {
2425
+ throw new Error("Invalid open position memo");
2426
+ }
2427
+ return yield this.acpClient.responseFundsTransfer(memo.id, accept, reason);
2428
+ });
2429
+ }
2430
+ closePartialPosition(_0) {
2431
+ return __async(this, arguments, function* (payload, expireAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
2432
+ return yield this.acpClient.requestFunds(
2433
+ this.id,
2434
+ payload.amount,
2435
+ this.clientAddress,
2436
+ 0,
2437
+ 0 /* NO_FEE */,
2438
+ {
2439
+ type: "close_partial_position" /* CLOSE_PARTIAL_POSITION */,
2440
+ data: payload
2441
+ },
2442
+ 2 /* TRANSACTION */,
2443
+ expireAt
2444
+ );
2445
+ });
2446
+ }
2447
+ responseClosePartialPosition(memoId, accept, reason) {
2448
+ return __async(this, null, function* () {
2449
+ const memo = this.memos.find((m) => m.id === memoId);
2450
+ if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 6 /* PAYABLE_REQUEST */) {
2451
+ throw new Error("No close position memo found");
2452
+ }
2453
+ const payload = tryParseJson(
2454
+ memo.content
2455
+ );
2456
+ if ((payload == null ? void 0 : payload.type) !== "close_partial_position" /* CLOSE_PARTIAL_POSITION */) {
2457
+ throw new Error("Invalid close position memo");
2458
+ }
2459
+ return yield this.acpClient.responseFundsRequest(
1074
2460
  memo.id,
1075
2461
  accept,
2462
+ payload.data.amount,
1076
2463
  reason
1077
2464
  );
1078
2465
  });
1079
2466
  }
2467
+ requestClosePosition(payload) {
2468
+ return __async(this, null, function* () {
2469
+ return yield this.acpClient.sendMessage(
2470
+ this.id,
2471
+ {
2472
+ type: "close_position" /* CLOSE_POSITION */,
2473
+ data: payload
2474
+ },
2475
+ 2 /* TRANSACTION */
2476
+ );
2477
+ });
2478
+ }
2479
+ responseRequestClosePosition(_0, _1, _2, _3) {
2480
+ return __async(this, arguments, function* (memoId, accept, payload, reason, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
2481
+ const memo = this.memos.find((m) => m.id === memoId);
2482
+ if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 0 /* MESSAGE */) {
2483
+ throw new Error("No message memo found");
2484
+ }
2485
+ const messagePayload = tryParseJson(memo.content);
2486
+ if ((messagePayload == null ? void 0 : messagePayload.type) !== "close_position" /* CLOSE_POSITION */) {
2487
+ throw new Error("Invalid close position memo");
2488
+ }
2489
+ yield memo.sign(accept, reason);
2490
+ if (accept) {
2491
+ return yield this.acpClient.transferFunds(
2492
+ this.id,
2493
+ payload.amount,
2494
+ this.clientAddress,
2495
+ 0,
2496
+ 0 /* NO_FEE */,
2497
+ {
2498
+ type: "close_position" /* CLOSE_POSITION */,
2499
+ data: payload
2500
+ },
2501
+ 2 /* TRANSACTION */,
2502
+ expiredAt
2503
+ );
2504
+ }
2505
+ });
2506
+ }
2507
+ confirmClosePosition(memoId, accept, reason) {
2508
+ return __async(this, null, function* () {
2509
+ const memo = this.memos.find((m) => m.id === memoId);
2510
+ if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
2511
+ throw new Error("No payable transfer memo found");
2512
+ }
2513
+ const payload = tryParseJson(
2514
+ memo.content
2515
+ );
2516
+ if ((payload == null ? void 0 : payload.type) !== "close_position" /* CLOSE_POSITION */) {
2517
+ throw new Error("Invalid close position memo");
2518
+ }
2519
+ yield memo.sign(accept, reason);
2520
+ });
2521
+ }
2522
+ positionFulfilled(_0) {
2523
+ return __async(this, arguments, function* (payload, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
2524
+ return yield this.acpClient.transferFunds(
2525
+ this.id,
2526
+ payload.amount,
2527
+ this.clientAddress,
2528
+ 0,
2529
+ 0 /* NO_FEE */,
2530
+ {
2531
+ type: "position_fulfilled" /* POSITION_FULFILLED */,
2532
+ data: payload
2533
+ },
2534
+ 2 /* TRANSACTION */,
2535
+ expiredAt
2536
+ );
2537
+ });
2538
+ }
2539
+ unfulfilledPosition(_0) {
2540
+ return __async(this, arguments, function* (payload, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
2541
+ return yield this.acpClient.transferFunds(
2542
+ this.id,
2543
+ payload.amount,
2544
+ this.clientAddress,
2545
+ 0,
2546
+ 0 /* NO_FEE */,
2547
+ {
2548
+ type: "unfulfilled_position" /* UNFULFILLED_POSITION */,
2549
+ data: payload
2550
+ },
2551
+ 2 /* TRANSACTION */,
2552
+ expiredAt
2553
+ );
2554
+ });
2555
+ }
2556
+ responseUnfulfilledPosition(memoId, accept, reason) {
2557
+ return __async(this, null, function* () {
2558
+ const memo = this.memos.find((m) => m.id === memoId);
2559
+ if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
2560
+ throw new Error("No unfulfilled position memo found");
2561
+ }
2562
+ const payload = tryParseJson(
2563
+ memo.content
2564
+ );
2565
+ if ((payload == null ? void 0 : payload.type) !== "unfulfilled_position" /* UNFULFILLED_POSITION */) {
2566
+ throw new Error("Invalid unfulfilled position memo");
2567
+ }
2568
+ return yield this.acpClient.responseFundsTransfer(memo.id, accept, reason);
2569
+ });
2570
+ }
2571
+ responsePositionFulfilled(memoId, accept, reason) {
2572
+ return __async(this, null, function* () {
2573
+ const memo = this.memos.find((m) => m.id === memoId);
2574
+ if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
2575
+ throw new Error("No position fulfilled memo found");
2576
+ }
2577
+ const payload = tryParseJson(
2578
+ memo.content
2579
+ );
2580
+ if ((payload == null ? void 0 : payload.type) !== "position_fulfilled" /* POSITION_FULFILLED */) {
2581
+ throw new Error("Invalid position fulfilled memo");
2582
+ }
2583
+ return yield this.acpClient.responseFundsTransfer(memo.id, accept, reason);
2584
+ });
2585
+ }
2586
+ closeJob(message = "Close job and withdraw all") {
2587
+ return __async(this, null, function* () {
2588
+ return yield this.acpClient.sendMessage(
2589
+ this.id,
2590
+ {
2591
+ type: "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */,
2592
+ data: {
2593
+ message
2594
+ }
2595
+ },
2596
+ 2 /* TRANSACTION */
2597
+ );
2598
+ });
2599
+ }
2600
+ responseCloseJob(_0, _1, _2, _3) {
2601
+ return __async(this, arguments, function* (memoId, accept, fulfilledPositions, reason, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
2602
+ const memo = this.memos.find((m) => m.id === memoId);
2603
+ if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 0 /* MESSAGE */) {
2604
+ throw new Error("No message memo found");
2605
+ }
2606
+ const payload = tryParseJson(
2607
+ memo.content
2608
+ );
2609
+ if ((payload == null ? void 0 : payload.type) !== "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */) {
2610
+ throw new Error("Invalid close job and withdraw memo");
2611
+ }
2612
+ yield memo.sign(accept, reason);
2613
+ if (!accept) {
2614
+ return;
2615
+ }
2616
+ const totalAmount = fulfilledPositions.reduce(
2617
+ (acc, curr) => acc + curr.amount,
2618
+ 0
2619
+ );
2620
+ if (totalAmount === 0) {
2621
+ return yield this.acpClient.sendMessage(
2622
+ this.id,
2623
+ {
2624
+ type: "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */,
2625
+ data: fulfilledPositions
2626
+ },
2627
+ 4 /* COMPLETED */
2628
+ );
2629
+ }
2630
+ return yield this.acpClient.transferFunds(
2631
+ this.id,
2632
+ fulfilledPositions.reduce((acc, curr) => acc + curr.amount, 0),
2633
+ this.clientAddress,
2634
+ 0,
2635
+ 0 /* NO_FEE */,
2636
+ {
2637
+ type: "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */,
2638
+ data: fulfilledPositions
2639
+ },
2640
+ 4 /* COMPLETED */,
2641
+ expiredAt
2642
+ );
2643
+ });
2644
+ }
2645
+ confirmJobClosure(memoId, accept, reason) {
2646
+ return __async(this, null, function* () {
2647
+ const memo = this.memos.find((m) => m.id === memoId);
2648
+ if (!memo) {
2649
+ throw new Error("Memo not found");
2650
+ }
2651
+ const payload = tryParseJson(
2652
+ memo.content
2653
+ );
2654
+ if ((payload == null ? void 0 : payload.type) !== "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */) {
2655
+ throw new Error("Invalid close job and withdraw memo");
2656
+ }
2657
+ yield memo.sign(accept, reason);
2658
+ });
2659
+ }
1080
2660
  };
1081
2661
  var acpJob_default = AcpJob;
1082
2662
 
1083
2663
  // src/acpMemo.ts
1084
2664
  var AcpMemo = class {
1085
- constructor(acpClient, id, type, content, nextPhase) {
2665
+ constructor(acpClient, id, type, content, nextPhase, status, signedReason, expiry) {
1086
2666
  this.acpClient = acpClient;
1087
2667
  this.id = id;
1088
2668
  this.type = type;
1089
2669
  this.content = content;
1090
2670
  this.nextPhase = nextPhase;
2671
+ this.status = status;
2672
+ this.signedReason = signedReason;
2673
+ this.expiry = expiry;
2674
+ this.structuredContent = tryParseJson(this.content) || void 0;
2675
+ }
2676
+ get payloadType() {
2677
+ var _a;
2678
+ return (_a = this.structuredContent) == null ? void 0 : _a.type;
2679
+ }
2680
+ getStructuredContent() {
2681
+ return this.structuredContent;
1091
2682
  }
1092
2683
  create(jobId, isSecured = true) {
1093
2684
  return __async(this, null, function* () {
@@ -1115,10 +2706,10 @@ var acpMemo_default = AcpMemo;
1115
2706
  // src/acpJobOffering.ts
1116
2707
  var import_ajv = __toESM(require("ajv"));
1117
2708
  var AcpJobOffering = class {
1118
- constructor(acpClient, providerAddress, type, price, requirementSchema) {
2709
+ constructor(acpClient, providerAddress, name, price, requirementSchema) {
1119
2710
  this.acpClient = acpClient;
1120
2711
  this.providerAddress = providerAddress;
1121
- this.type = type;
2712
+ this.name = name;
1122
2713
  this.price = price;
1123
2714
  this.requirementSchema = requirementSchema;
1124
2715
  this.ajv = new import_ajv.default({ allErrors: true });
@@ -1132,9 +2723,21 @@ var AcpJobOffering = class {
1132
2723
  throw new Error(this.ajv.errorsText(validator.errors));
1133
2724
  }
1134
2725
  }
2726
+ let finalServiceRequirement = {
2727
+ serviceName: this.name
2728
+ };
2729
+ if (typeof serviceRequirement === "string") {
2730
+ finalServiceRequirement = __spreadProps(__spreadValues({}, finalServiceRequirement), {
2731
+ message: serviceRequirement
2732
+ });
2733
+ } else {
2734
+ finalServiceRequirement = __spreadProps(__spreadValues({}, finalServiceRequirement), {
2735
+ serviceRequirement
2736
+ });
2737
+ }
1135
2738
  return yield this.acpClient.initiateJob(
1136
2739
  this.providerAddress,
1137
- serviceRequirement,
2740
+ finalServiceRequirement,
1138
2741
  this.price,
1139
2742
  evaluatorAddress,
1140
2743
  expiredAt
@@ -1145,6 +2748,7 @@ var AcpJobOffering = class {
1145
2748
  var acpJobOffering_default = AcpJobOffering;
1146
2749
 
1147
2750
  // src/acpClient.ts
2751
+ var { version } = require_package();
1148
2752
  var AcpClient = class {
1149
2753
  constructor(options) {
1150
2754
  this.acpContractClient = options.acpContractClient;
@@ -1161,11 +2765,16 @@ var AcpClient = class {
1161
2765
  init() {
1162
2766
  return __async(this, null, function* () {
1163
2767
  const socket = (0, import_socket.io)(this.acpUrl, {
1164
- auth: __spreadValues(__spreadValues({}, this.onNewTask && {
2768
+ auth: __spreadValues({
1165
2769
  walletAddress: this.acpContractClient.walletAddress
1166
- }), this.onEvaluate !== this.defaultOnEvaluate && {
2770
+ }, this.onEvaluate !== this.defaultOnEvaluate && {
1167
2771
  evaluatorAddress: this.acpContractClient.walletAddress
1168
- })
2772
+ }),
2773
+ extraHeaders: {
2774
+ "x-sdk-version": version,
2775
+ "x-sdk-language": "node"
2776
+ },
2777
+ transports: ["websocket"]
1169
2778
  });
1170
2779
  socket.on("roomJoined" /* ROOM_JOINED */, (_, callback) => {
1171
2780
  console.log("Joined ACP Room");
@@ -1183,13 +2792,17 @@ var AcpClient = class {
1183
2792
  data.providerAddress,
1184
2793
  data.evaluatorAddress,
1185
2794
  data.price,
2795
+ data.priceTokenAddress,
1186
2796
  data.memos.map((memo) => {
1187
2797
  return new acpMemo_default(
1188
2798
  this,
1189
2799
  memo.id,
1190
2800
  memo.memoType,
1191
2801
  memo.content,
1192
- memo.nextPhase
2802
+ memo.nextPhase,
2803
+ memo.status,
2804
+ memo.signedReason,
2805
+ memo.expiry ? new Date(parseInt(memo.expiry)) : void 0
1193
2806
  );
1194
2807
  }),
1195
2808
  data.phase,
@@ -1211,19 +2824,26 @@ var AcpClient = class {
1211
2824
  data.providerAddress,
1212
2825
  data.evaluatorAddress,
1213
2826
  data.price,
2827
+ data.priceTokenAddress,
1214
2828
  data.memos.map((memo) => {
1215
2829
  return new acpMemo_default(
1216
2830
  this,
1217
2831
  memo.id,
1218
2832
  memo.memoType,
1219
2833
  memo.content,
1220
- memo.nextPhase
2834
+ memo.nextPhase,
2835
+ memo.status,
2836
+ memo.signedReason,
2837
+ memo.expiry ? new Date(parseInt(memo.expiry)) : void 0
1221
2838
  );
1222
2839
  }),
1223
2840
  data.phase,
1224
2841
  data.context
1225
2842
  );
1226
- this.onNewTask(job);
2843
+ this.onNewTask(
2844
+ job,
2845
+ job.memos.find((m) => m.id == data.memoToSign)
2846
+ );
1227
2847
  }
1228
2848
  })
1229
2849
  );
@@ -1239,28 +2859,26 @@ var AcpClient = class {
1239
2859
  }
1240
2860
  browseAgents(keyword, options) {
1241
2861
  return __async(this, null, function* () {
1242
- let { cluster, sort_by, rerank, top_k, graduated } = options;
1243
- rerank = rerank != null ? rerank : true;
2862
+ let { cluster, sort_by, top_k, graduationStatus, onlineStatus } = options;
1244
2863
  top_k = top_k != null ? top_k : 5;
1245
- graduated = graduated != null ? graduated : true;
1246
- let url = `${this.acpUrl}/api/agents?search=${keyword}`;
2864
+ let url = `${this.acpUrl}/api/agents/v2/search?search=${keyword}`;
1247
2865
  if (sort_by && sort_by.length > 0) {
1248
- url += `&sort=${sort_by.map((s) => s).join(",")}`;
2866
+ url += `&sortBy=${sort_by.map((s) => s).join(",")}`;
1249
2867
  }
1250
2868
  if (top_k) {
1251
2869
  url += `&top_k=${top_k}`;
1252
2870
  }
1253
- if (rerank) {
1254
- url += `&rerank=true`;
1255
- }
1256
2871
  if (this.acpContractClient.walletAddress) {
1257
- url += `&filters[walletAddress][$notIn]=${this.acpContractClient.walletAddress}`;
2872
+ url += `&walletAddressesToExclude=${this.acpContractClient.walletAddress}`;
1258
2873
  }
1259
2874
  if (cluster) {
1260
- url += `&filters[cluster]=${cluster}`;
2875
+ url += `&cluster=${cluster}`;
1261
2876
  }
1262
- if (graduated === false) {
1263
- url += `&filters[hasGraduated]=false`;
2877
+ if (graduationStatus) {
2878
+ url += `&graduationStatus=${graduationStatus}`;
2879
+ }
2880
+ if (onlineStatus) {
2881
+ url += `&onlineStatus=${onlineStatus}`;
1264
2882
  }
1265
2883
  const response = yield fetch(url);
1266
2884
  const data = yield response.json();
@@ -1274,7 +2892,7 @@ var AcpClient = class {
1274
2892
  this,
1275
2893
  agent.walletAddress,
1276
2894
  offering.name,
1277
- offering.price,
2895
+ offering.priceUsd,
1278
2896
  offering.requirementSchema
1279
2897
  );
1280
2898
  }),
@@ -1292,10 +2910,7 @@ var AcpClient = class {
1292
2910
  evaluatorAddress || this.acpContractClient.walletAddress,
1293
2911
  expiredAt
1294
2912
  );
1295
- yield this.acpContractClient.setBudget(
1296
- jobId,
1297
- (0, import_viem2.parseEther)(amount.toString())
1298
- );
2913
+ yield this.acpContractClient.setBudgetWithPaymentToken(jobId, amount);
1299
2914
  yield this.acpContractClient.createMemo(
1300
2915
  jobId,
1301
2916
  typeof serviceRequirement === "string" ? serviceRequirement : JSON.stringify(serviceRequirement),
@@ -1306,7 +2921,7 @@ var AcpClient = class {
1306
2921
  return jobId;
1307
2922
  });
1308
2923
  }
1309
- respondJob(jobId, memoId, accept, reason) {
2924
+ respondJob(jobId, memoId, accept, content, reason) {
1310
2925
  return __async(this, null, function* () {
1311
2926
  yield this.acpContractClient.signMemo(memoId, accept, reason);
1312
2927
  if (!accept) {
@@ -1314,7 +2929,7 @@ var AcpClient = class {
1314
2929
  }
1315
2930
  return yield this.acpContractClient.createMemo(
1316
2931
  jobId,
1317
- `Job ${jobId} accepted. ${reason != null ? reason : ""}`,
2932
+ content != null ? content : `Job ${jobId} accepted. ${reason != null ? reason : ""}`,
1318
2933
  0 /* MESSAGE */,
1319
2934
  false,
1320
2935
  2 /* TRANSACTION */
@@ -1323,9 +2938,9 @@ var AcpClient = class {
1323
2938
  }
1324
2939
  payJob(jobId, amount, memoId, reason) {
1325
2940
  return __async(this, null, function* () {
1326
- yield this.acpContractClient.approveAllowance(
1327
- (0, import_viem2.parseEther)(amount.toString())
1328
- );
2941
+ if (amount > 0) {
2942
+ yield this.acpContractClient.approveAllowance(amount);
2943
+ }
1329
2944
  yield this.acpContractClient.signMemo(memoId, true, reason);
1330
2945
  return yield this.acpContractClient.createMemo(
1331
2946
  jobId,
@@ -1336,11 +2951,72 @@ var AcpClient = class {
1336
2951
  );
1337
2952
  });
1338
2953
  }
2954
+ requestFunds(jobId, amount, recipient, feeAmount, feeType, reason, nextPhase, expiredAt) {
2955
+ return __async(this, null, function* () {
2956
+ return yield this.acpContractClient.createPayableMemo(
2957
+ jobId,
2958
+ JSON.stringify(reason),
2959
+ amount,
2960
+ recipient,
2961
+ feeAmount,
2962
+ feeType,
2963
+ nextPhase,
2964
+ 6 /* PAYABLE_REQUEST */,
2965
+ expiredAt
2966
+ );
2967
+ });
2968
+ }
2969
+ responseFundsRequest(memoId, accept, amount, reason) {
2970
+ return __async(this, null, function* () {
2971
+ if (!accept) {
2972
+ return yield this.acpContractClient.signMemo(memoId, accept, reason);
2973
+ }
2974
+ if (amount > 0) {
2975
+ yield this.acpContractClient.approveAllowance(amount);
2976
+ }
2977
+ return yield this.acpContractClient.signMemo(memoId, true, reason);
2978
+ });
2979
+ }
2980
+ transferFunds(jobId, amount, recipient, feeAmount, feeType, reason, nextPhase, expiredAt) {
2981
+ return __async(this, null, function* () {
2982
+ const totalAmount = amount + feeAmount;
2983
+ if (totalAmount > 0) {
2984
+ yield this.acpContractClient.approveAllowance(totalAmount);
2985
+ }
2986
+ return yield this.acpContractClient.createPayableMemo(
2987
+ jobId,
2988
+ JSON.stringify(reason),
2989
+ amount,
2990
+ recipient,
2991
+ feeAmount,
2992
+ feeType,
2993
+ nextPhase,
2994
+ 8 /* PAYABLE_TRANSFER_ESCROW */,
2995
+ expiredAt
2996
+ );
2997
+ });
2998
+ }
2999
+ sendMessage(jobId, message, nextPhase) {
3000
+ return __async(this, null, function* () {
3001
+ return yield this.acpContractClient.createMemo(
3002
+ jobId,
3003
+ JSON.stringify(message),
3004
+ 0 /* MESSAGE */,
3005
+ false,
3006
+ nextPhase
3007
+ );
3008
+ });
3009
+ }
3010
+ responseFundsTransfer(memoId, accept, reason) {
3011
+ return __async(this, null, function* () {
3012
+ return yield this.acpContractClient.signMemo(memoId, accept, reason);
3013
+ });
3014
+ }
1339
3015
  deliverJob(jobId, deliverable) {
1340
3016
  return __async(this, null, function* () {
1341
3017
  return yield this.acpContractClient.createMemo(
1342
3018
  jobId,
1343
- deliverable,
3019
+ JSON.stringify(deliverable),
1344
3020
  4 /* OBJECT_URL */,
1345
3021
  true,
1346
3022
  4 /* COMPLETED */
@@ -1368,13 +3044,17 @@ var AcpClient = class {
1368
3044
  job.providerAddress,
1369
3045
  job.evaluatorAddress,
1370
3046
  job.price,
3047
+ job.priceTokenAddress,
1371
3048
  job.memos.map((memo) => {
1372
3049
  return new acpMemo_default(
1373
3050
  this,
1374
3051
  memo.id,
1375
3052
  memo.memoType,
1376
3053
  memo.content,
1377
- memo.nextPhase
3054
+ memo.nextPhase,
3055
+ memo.status,
3056
+ memo.signedReason,
3057
+ memo.expiry ? new Date(parseInt(memo.expiry)) : void 0
1378
3058
  );
1379
3059
  }),
1380
3060
  job.phase,
@@ -1407,13 +3087,17 @@ var AcpClient = class {
1407
3087
  job.providerAddress,
1408
3088
  job.evaluatorAddress,
1409
3089
  job.price,
3090
+ job.priceTokenAddress,
1410
3091
  job.memos.map((memo) => {
1411
3092
  return new acpMemo_default(
1412
3093
  this,
1413
3094
  memo.id,
1414
3095
  memo.memoType,
1415
3096
  memo.content,
1416
- memo.nextPhase
3097
+ memo.nextPhase,
3098
+ memo.status,
3099
+ memo.signedReason,
3100
+ memo.expiry ? new Date(parseInt(memo.expiry)) : void 0
1417
3101
  );
1418
3102
  }),
1419
3103
  job.phase,
@@ -1446,13 +3130,17 @@ var AcpClient = class {
1446
3130
  job.providerAddress,
1447
3131
  job.evaluatorAddress,
1448
3132
  job.price,
3133
+ job.priceTokenAddress,
1449
3134
  job.memos.map((memo) => {
1450
3135
  return new acpMemo_default(
1451
3136
  this,
1452
3137
  memo.id,
1453
3138
  memo.memoType,
1454
3139
  memo.content,
1455
- memo.nextPhase
3140
+ memo.nextPhase,
3141
+ memo.status,
3142
+ memo.signedReason,
3143
+ memo.expiry ? new Date(parseInt(memo.expiry)) : void 0
1456
3144
  );
1457
3145
  }),
1458
3146
  job.phase,
@@ -1488,13 +3176,17 @@ var AcpClient = class {
1488
3176
  job.providerAddress,
1489
3177
  job.evaluatorAddress,
1490
3178
  job.price,
3179
+ job.priceTokenAddress,
1491
3180
  job.memos.map((memo) => {
1492
3181
  return new acpMemo_default(
1493
3182
  this,
1494
3183
  memo.id,
1495
3184
  memo.memoType,
1496
3185
  memo.content,
1497
- memo.nextPhase
3186
+ memo.nextPhase,
3187
+ memo.status,
3188
+ memo.signedReason,
3189
+ memo.expiry ? new Date(parseInt(memo.expiry)) : void 0
1498
3190
  );
1499
3191
  }),
1500
3192
  job.phase,
@@ -1527,7 +3219,10 @@ var AcpClient = class {
1527
3219
  memo.id,
1528
3220
  memo.memoType,
1529
3221
  memo.content,
1530
- memo.nextPhase
3222
+ memo.nextPhase,
3223
+ memo.status,
3224
+ memo.signedReason,
3225
+ memo.expiry ? new Date(parseInt(memo.expiry)) : void 0
1531
3226
  );
1532
3227
  } catch (error) {
1533
3228
  throw error;
@@ -1549,16 +3244,6 @@ var AcpClient = class {
1549
3244
  };
1550
3245
  var acpClient_default = AcpClient;
1551
3246
 
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
3247
  // src/index.ts
1563
3248
  var index_default = acpClient_default;
1564
3249
  // Annotate the CommonJS export names for ESM import in node:
@@ -1566,10 +3251,14 @@ var index_default = acpClient_default;
1566
3251
  ACP_ABI,
1567
3252
  AcpAgentSort,
1568
3253
  AcpContractClient,
3254
+ AcpGraduationStatus,
1569
3255
  AcpJob,
1570
3256
  AcpJobPhases,
1571
3257
  AcpMemo,
3258
+ AcpMemoStatus,
3259
+ AcpOnlineStatus,
1572
3260
  MemoType,
3261
+ PayloadType,
1573
3262
  baseAcpConfig,
1574
3263
  baseSepoliaAcpConfig
1575
3264
  });