@virtuals-protocol/acp-node 0.2.0-beta.6 → 0.2.0-beta.8

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.mjs CHANGED
@@ -47,7 +47,7 @@ var require_package = __commonJS({
47
47
  "package.json"(exports, module) {
48
48
  module.exports = {
49
49
  name: "@virtuals-protocol/acp-node",
50
- version: "0.2.0-beta.6",
50
+ version: "0.2.0-beta.8",
51
51
  main: "./dist/index.js",
52
52
  module: "./dist/index.mjs",
53
53
  types: "./dist/index.d.ts",
@@ -79,32 +79,82 @@ var require_package = __commonJS({
79
79
 
80
80
  // src/acpAbi.ts
81
81
  var ACP_ABI = [
82
- { inputs: [], stateMutability: "nonpayable", type: "constructor" },
83
- { inputs: [], name: "AccessControlBadConfirmation", type: "error" },
82
+ {
83
+ inputs: [],
84
+ stateMutability: "nonpayable",
85
+ type: "constructor"
86
+ },
87
+ {
88
+ inputs: [],
89
+ name: "AccessControlBadConfirmation",
90
+ type: "error"
91
+ },
84
92
  {
85
93
  inputs: [
86
- { internalType: "address", name: "account", type: "address" },
87
- { internalType: "bytes32", name: "neededRole", type: "bytes32" }
94
+ {
95
+ internalType: "address",
96
+ name: "account",
97
+ type: "address"
98
+ },
99
+ {
100
+ internalType: "bytes32",
101
+ name: "neededRole",
102
+ type: "bytes32"
103
+ }
88
104
  ],
89
105
  name: "AccessControlUnauthorizedAccount",
90
106
  type: "error"
91
107
  },
92
108
  {
93
- inputs: [{ internalType: "address", name: "target", type: "address" }],
109
+ inputs: [
110
+ {
111
+ internalType: "address",
112
+ name: "target",
113
+ type: "address"
114
+ }
115
+ ],
94
116
  name: "AddressEmptyCode",
95
117
  type: "error"
96
118
  },
97
119
  {
98
- inputs: [{ internalType: "address", name: "account", type: "address" }],
120
+ inputs: [
121
+ {
122
+ internalType: "address",
123
+ name: "account",
124
+ type: "address"
125
+ }
126
+ ],
99
127
  name: "AddressInsufficientBalance",
100
128
  type: "error"
101
129
  },
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
130
  {
107
- inputs: [{ internalType: "address", name: "token", type: "address" }],
131
+ inputs: [],
132
+ name: "FailedInnerCall",
133
+ type: "error"
134
+ },
135
+ {
136
+ inputs: [],
137
+ name: "InvalidInitialization",
138
+ type: "error"
139
+ },
140
+ {
141
+ inputs: [],
142
+ name: "NotInitializing",
143
+ type: "error"
144
+ },
145
+ {
146
+ inputs: [],
147
+ name: "ReentrancyGuardReentrantCall",
148
+ type: "error"
149
+ },
150
+ {
151
+ inputs: [
152
+ {
153
+ internalType: "address",
154
+ name: "token",
155
+ type: "address"
156
+ }
157
+ ],
108
158
  name: "SafeERC20FailedOperation",
109
159
  type: "error"
110
160
  },
@@ -221,6 +271,25 @@ var ACP_ABI = [
221
271
  name: "JobCreated",
222
272
  type: "event"
223
273
  },
274
+ {
275
+ anonymous: false,
276
+ inputs: [
277
+ {
278
+ indexed: true,
279
+ internalType: "uint256",
280
+ name: "jobId",
281
+ type: "uint256"
282
+ },
283
+ {
284
+ indexed: true,
285
+ internalType: "address",
286
+ name: "paymentToken",
287
+ type: "address"
288
+ }
289
+ ],
290
+ name: "JobPaymentTokenSet",
291
+ type: "event"
292
+ },
224
293
  {
225
294
  anonymous: false,
226
295
  inputs: [
@@ -236,7 +305,12 @@ var ACP_ABI = [
236
305
  name: "oldPhase",
237
306
  type: "uint8"
238
307
  },
239
- { indexed: false, internalType: "uint8", name: "phase", type: "uint8" }
308
+ {
309
+ indexed: false,
310
+ internalType: "uint8",
311
+ name: "phase",
312
+ type: "uint8"
313
+ }
240
314
  ],
241
315
  name: "JobPhaseUpdated",
242
316
  type: "event"
@@ -423,8 +497,18 @@ var ACP_ABI = [
423
497
  name: "memoId",
424
498
  type: "uint256"
425
499
  },
426
- { indexed: true, internalType: "address", name: "from", type: "address" },
427
- { indexed: false, internalType: "address", name: "to", type: "address" },
500
+ {
501
+ indexed: true,
502
+ internalType: "address",
503
+ name: "from",
504
+ type: "address"
505
+ },
506
+ {
507
+ indexed: false,
508
+ internalType: "address",
509
+ name: "to",
510
+ type: "address"
511
+ },
428
512
  {
429
513
  indexed: false,
430
514
  internalType: "address",
@@ -456,8 +540,18 @@ var ACP_ABI = [
456
540
  name: "memoId",
457
541
  type: "uint256"
458
542
  },
459
- { indexed: true, internalType: "address", name: "from", type: "address" },
460
- { indexed: false, internalType: "address", name: "to", type: "address" },
543
+ {
544
+ indexed: true,
545
+ internalType: "address",
546
+ name: "from",
547
+ type: "address"
548
+ },
549
+ {
550
+ indexed: false,
551
+ internalType: "address",
552
+ name: "to",
553
+ type: "address"
554
+ },
461
555
  {
462
556
  indexed: false,
463
557
  internalType: "address",
@@ -527,7 +621,12 @@ var ACP_ABI = [
527
621
  {
528
622
  anonymous: false,
529
623
  inputs: [
530
- { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
624
+ {
625
+ indexed: true,
626
+ internalType: "bytes32",
627
+ name: "role",
628
+ type: "bytes32"
629
+ },
531
630
  {
532
631
  indexed: true,
533
632
  internalType: "bytes32",
@@ -547,7 +646,12 @@ var ACP_ABI = [
547
646
  {
548
647
  anonymous: false,
549
648
  inputs: [
550
- { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
649
+ {
650
+ indexed: true,
651
+ internalType: "bytes32",
652
+ name: "role",
653
+ type: "bytes32"
654
+ },
551
655
  {
552
656
  indexed: true,
553
657
  internalType: "address",
@@ -567,7 +671,12 @@ var ACP_ABI = [
567
671
  {
568
672
  anonymous: false,
569
673
  inputs: [
570
- { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
674
+ {
675
+ indexed: true,
676
+ internalType: "bytes32",
677
+ name: "role",
678
+ type: "bytes32"
679
+ },
571
680
  {
572
681
  indexed: true,
573
682
  internalType: "address",
@@ -587,87 +696,192 @@ var ACP_ABI = [
587
696
  {
588
697
  inputs: [],
589
698
  name: "ADMIN_ROLE",
590
- outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
699
+ outputs: [
700
+ {
701
+ internalType: "bytes32",
702
+ name: "",
703
+ type: "bytes32"
704
+ }
705
+ ],
591
706
  stateMutability: "view",
592
707
  type: "function"
593
708
  },
594
709
  {
595
710
  inputs: [],
596
711
  name: "DEFAULT_ADMIN_ROLE",
597
- outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
712
+ outputs: [
713
+ {
714
+ internalType: "bytes32",
715
+ name: "",
716
+ type: "bytes32"
717
+ }
718
+ ],
598
719
  stateMutability: "view",
599
720
  type: "function"
600
721
  },
601
722
  {
602
723
  inputs: [],
603
724
  name: "PHASE_COMPLETED",
604
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
725
+ outputs: [
726
+ {
727
+ internalType: "uint8",
728
+ name: "",
729
+ type: "uint8"
730
+ }
731
+ ],
605
732
  stateMutability: "view",
606
733
  type: "function"
607
734
  },
608
735
  {
609
736
  inputs: [],
610
737
  name: "PHASE_EVALUATION",
611
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
738
+ outputs: [
739
+ {
740
+ internalType: "uint8",
741
+ name: "",
742
+ type: "uint8"
743
+ }
744
+ ],
612
745
  stateMutability: "view",
613
746
  type: "function"
614
747
  },
615
748
  {
616
749
  inputs: [],
617
750
  name: "PHASE_EXPIRED",
618
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
751
+ outputs: [
752
+ {
753
+ internalType: "uint8",
754
+ name: "",
755
+ type: "uint8"
756
+ }
757
+ ],
619
758
  stateMutability: "view",
620
759
  type: "function"
621
760
  },
622
761
  {
623
762
  inputs: [],
624
763
  name: "PHASE_NEGOTIATION",
625
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
764
+ outputs: [
765
+ {
766
+ internalType: "uint8",
767
+ name: "",
768
+ type: "uint8"
769
+ }
770
+ ],
626
771
  stateMutability: "view",
627
772
  type: "function"
628
773
  },
629
774
  {
630
775
  inputs: [],
631
776
  name: "PHASE_REJECTED",
632
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
777
+ outputs: [
778
+ {
779
+ internalType: "uint8",
780
+ name: "",
781
+ type: "uint8"
782
+ }
783
+ ],
633
784
  stateMutability: "view",
634
785
  type: "function"
635
786
  },
636
787
  {
637
788
  inputs: [],
638
789
  name: "PHASE_REQUEST",
639
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
790
+ outputs: [
791
+ {
792
+ internalType: "uint8",
793
+ name: "",
794
+ type: "uint8"
795
+ }
796
+ ],
640
797
  stateMutability: "view",
641
798
  type: "function"
642
799
  },
643
800
  {
644
801
  inputs: [],
645
802
  name: "PHASE_TRANSACTION",
646
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
803
+ outputs: [
804
+ {
805
+ internalType: "uint8",
806
+ name: "",
807
+ type: "uint8"
808
+ }
809
+ ],
647
810
  stateMutability: "view",
648
811
  type: "function"
649
812
  },
650
813
  {
651
814
  inputs: [],
652
815
  name: "TOTAL_PHASES",
653
- outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
816
+ outputs: [
817
+ {
818
+ internalType: "uint8",
819
+ name: "",
820
+ type: "uint8"
821
+ }
822
+ ],
654
823
  stateMutability: "view",
655
824
  type: "function"
656
825
  },
657
826
  {
658
827
  inputs: [
659
- { internalType: "address", name: "account", type: "address" },
828
+ {
829
+ internalType: "address",
830
+ name: "account",
831
+ type: "address"
832
+ },
660
833
  {
661
834
  components: [
662
- { internalType: "uint256", name: "id", type: "uint256" },
663
- { internalType: "address", name: "client", type: "address" },
664
- { internalType: "address", name: "provider", type: "address" },
665
- { internalType: "uint256", name: "budget", type: "uint256" },
666
- { internalType: "uint256", name: "amountClaimed", type: "uint256" },
667
- { internalType: "uint8", name: "phase", type: "uint8" },
668
- { internalType: "uint256", name: "memoCount", type: "uint256" },
669
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
670
- { internalType: "address", name: "evaluator", type: "address" }
835
+ {
836
+ internalType: "uint256",
837
+ name: "id",
838
+ type: "uint256"
839
+ },
840
+ {
841
+ internalType: "address",
842
+ name: "client",
843
+ type: "address"
844
+ },
845
+ {
846
+ internalType: "address",
847
+ name: "provider",
848
+ type: "address"
849
+ },
850
+ {
851
+ internalType: "uint256",
852
+ name: "budget",
853
+ type: "uint256"
854
+ },
855
+ {
856
+ internalType: "uint256",
857
+ name: "amountClaimed",
858
+ type: "uint256"
859
+ },
860
+ {
861
+ internalType: "uint8",
862
+ name: "phase",
863
+ type: "uint8"
864
+ },
865
+ {
866
+ internalType: "uint256",
867
+ name: "memoCount",
868
+ type: "uint256"
869
+ },
870
+ {
871
+ internalType: "uint256",
872
+ name: "expiredAt",
873
+ type: "uint256"
874
+ },
875
+ {
876
+ internalType: "address",
877
+ name: "evaluator",
878
+ type: "address"
879
+ },
880
+ {
881
+ internalType: "contract IERC20",
882
+ name: "jobPaymentToken",
883
+ type: "address"
884
+ }
671
885
  ],
672
886
  internalType: "struct ACPSimple.Job",
673
887
  name: "job",
@@ -675,12 +889,24 @@ var ACP_ABI = [
675
889
  }
676
890
  ],
677
891
  name: "canSign",
678
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
892
+ outputs: [
893
+ {
894
+ internalType: "bool",
895
+ name: "",
896
+ type: "bool"
897
+ }
898
+ ],
679
899
  stateMutability: "pure",
680
900
  type: "function"
681
901
  },
682
902
  {
683
- inputs: [{ internalType: "uint256", name: "id", type: "uint256" }],
903
+ inputs: [
904
+ {
905
+ internalType: "uint256",
906
+ name: "id",
907
+ type: "uint256"
908
+ }
909
+ ],
684
910
  name: "claimBudget",
685
911
  outputs: [],
686
912
  stateMutability: "nonpayable",
@@ -688,40 +914,104 @@ var ACP_ABI = [
688
914
  },
689
915
  {
690
916
  inputs: [
691
- { internalType: "address", name: "provider", type: "address" },
692
- { internalType: "address", name: "evaluator", type: "address" },
693
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
917
+ {
918
+ internalType: "address",
919
+ name: "provider",
920
+ type: "address"
921
+ },
922
+ {
923
+ internalType: "address",
924
+ name: "evaluator",
925
+ type: "address"
926
+ },
927
+ {
928
+ internalType: "uint256",
929
+ name: "expiredAt",
930
+ type: "uint256"
931
+ }
694
932
  ],
695
933
  name: "createJob",
696
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
934
+ outputs: [
935
+ {
936
+ internalType: "uint256",
937
+ name: "",
938
+ type: "uint256"
939
+ }
940
+ ],
697
941
  stateMutability: "nonpayable",
698
942
  type: "function"
699
943
  },
700
944
  {
701
945
  inputs: [
702
- { internalType: "uint256", name: "jobId", type: "uint256" },
703
- { internalType: "string", name: "content", type: "string" },
704
946
  {
705
- internalType: "enum InteractionLedger.MemoType",
706
- name: "memoType",
707
- type: "uint8"
947
+ internalType: "uint256",
948
+ name: "jobId",
949
+ type: "uint256"
708
950
  },
709
- { internalType: "bool", name: "isSecured", type: "bool" },
710
- { internalType: "uint8", name: "nextPhase", type: "uint8" }
951
+ {
952
+ internalType: "string",
953
+ name: "content",
954
+ type: "string"
955
+ },
956
+ {
957
+ internalType: "enum InteractionLedger.MemoType",
958
+ name: "memoType",
959
+ type: "uint8"
960
+ },
961
+ {
962
+ internalType: "bool",
963
+ name: "isSecured",
964
+ type: "bool"
965
+ },
966
+ {
967
+ internalType: "uint8",
968
+ name: "nextPhase",
969
+ type: "uint8"
970
+ }
711
971
  ],
712
972
  name: "createMemo",
713
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
973
+ outputs: [
974
+ {
975
+ internalType: "uint256",
976
+ name: "",
977
+ type: "uint256"
978
+ }
979
+ ],
714
980
  stateMutability: "nonpayable",
715
981
  type: "function"
716
982
  },
717
983
  {
718
984
  inputs: [
719
- { internalType: "uint256", name: "jobId", type: "uint256" },
720
- { internalType: "string", name: "content", type: "string" },
721
- { internalType: "address", name: "token", type: "address" },
722
- { internalType: "uint256", name: "amount", type: "uint256" },
723
- { internalType: "address", name: "recipient", type: "address" },
724
- { internalType: "uint256", name: "feeAmount", type: "uint256" },
985
+ {
986
+ internalType: "uint256",
987
+ name: "jobId",
988
+ type: "uint256"
989
+ },
990
+ {
991
+ internalType: "string",
992
+ name: "content",
993
+ type: "string"
994
+ },
995
+ {
996
+ internalType: "address",
997
+ name: "token",
998
+ type: "address"
999
+ },
1000
+ {
1001
+ internalType: "uint256",
1002
+ name: "amount",
1003
+ type: "uint256"
1004
+ },
1005
+ {
1006
+ internalType: "address",
1007
+ name: "recipient",
1008
+ type: "address"
1009
+ },
1010
+ {
1011
+ internalType: "uint256",
1012
+ name: "feeAmount",
1013
+ type: "uint256"
1014
+ },
725
1015
  {
726
1016
  internalType: "enum ACPSimple.FeeType",
727
1017
  name: "feeType",
@@ -732,88 +1022,198 @@ var ACP_ABI = [
732
1022
  name: "memoType",
733
1023
  type: "uint8"
734
1024
  },
735
- { internalType: "uint8", name: "nextPhase", type: "uint8" },
736
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
1025
+ {
1026
+ internalType: "uint8",
1027
+ name: "nextPhase",
1028
+ type: "uint8"
1029
+ },
1030
+ {
1031
+ internalType: "uint256",
1032
+ name: "expiredAt",
1033
+ type: "uint256"
1034
+ }
737
1035
  ],
738
1036
  name: "createPayableMemo",
739
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1037
+ outputs: [
1038
+ {
1039
+ internalType: "uint256",
1040
+ name: "",
1041
+ type: "uint256"
1042
+ }
1043
+ ],
740
1044
  stateMutability: "nonpayable",
741
1045
  type: "function"
742
1046
  },
743
1047
  {
744
1048
  inputs: [],
745
1049
  name: "evaluatorFeeBP",
746
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1050
+ outputs: [
1051
+ {
1052
+ internalType: "uint256",
1053
+ name: "",
1054
+ type: "uint256"
1055
+ }
1056
+ ],
747
1057
  stateMutability: "view",
748
1058
  type: "function"
749
1059
  },
750
1060
  {
751
1061
  inputs: [
752
- { internalType: "uint256", name: "jobId", type: "uint256" },
753
- { internalType: "uint256", name: "offset", type: "uint256" },
754
- { internalType: "uint256", name: "limit", type: "uint256" }
1062
+ {
1063
+ internalType: "uint256",
1064
+ name: "jobId",
1065
+ type: "uint256"
1066
+ },
1067
+ {
1068
+ internalType: "uint256",
1069
+ name: "offset",
1070
+ type: "uint256"
1071
+ },
1072
+ {
1073
+ internalType: "uint256",
1074
+ name: "limit",
1075
+ type: "uint256"
1076
+ }
755
1077
  ],
756
1078
  name: "getAllMemos",
757
1079
  outputs: [
758
1080
  {
759
1081
  components: [
760
- { internalType: "string", name: "content", type: "string" },
1082
+ {
1083
+ internalType: "string",
1084
+ name: "content",
1085
+ type: "string"
1086
+ },
761
1087
  {
762
1088
  internalType: "enum InteractionLedger.MemoType",
763
1089
  name: "memoType",
764
1090
  type: "uint8"
765
1091
  },
766
- { internalType: "bool", name: "isSecured", type: "bool" },
767
- { internalType: "uint8", name: "nextPhase", type: "uint8" },
768
- { internalType: "uint256", name: "jobId", type: "uint256" },
769
- { internalType: "address", name: "sender", type: "address" }
1092
+ {
1093
+ internalType: "bool",
1094
+ name: "isSecured",
1095
+ type: "bool"
1096
+ },
1097
+ {
1098
+ internalType: "uint8",
1099
+ name: "nextPhase",
1100
+ type: "uint8"
1101
+ },
1102
+ {
1103
+ internalType: "uint256",
1104
+ name: "jobId",
1105
+ type: "uint256"
1106
+ },
1107
+ {
1108
+ internalType: "address",
1109
+ name: "sender",
1110
+ type: "address"
1111
+ }
770
1112
  ],
771
1113
  internalType: "struct InteractionLedger.Memo[]",
772
1114
  name: "",
773
1115
  type: "tuple[]"
774
1116
  },
775
- { internalType: "uint256", name: "total", type: "uint256" }
1117
+ {
1118
+ internalType: "uint256",
1119
+ name: "total",
1120
+ type: "uint256"
1121
+ }
776
1122
  ],
777
1123
  stateMutability: "view",
778
1124
  type: "function"
779
1125
  },
780
1126
  {
781
1127
  inputs: [
782
- { internalType: "uint256", name: "jobId", type: "uint256" },
783
- { internalType: "uint8", name: "phase", type: "uint8" }
1128
+ {
1129
+ internalType: "uint256",
1130
+ name: "jobId",
1131
+ type: "uint256"
1132
+ },
1133
+ {
1134
+ internalType: "uint8",
1135
+ name: "phase",
1136
+ type: "uint8"
1137
+ }
784
1138
  ],
785
1139
  name: "getJobPhaseMemoIds",
786
- outputs: [{ internalType: "uint256[]", name: "", type: "uint256[]" }],
1140
+ outputs: [
1141
+ {
1142
+ internalType: "uint256[]",
1143
+ name: "",
1144
+ type: "uint256[]"
1145
+ }
1146
+ ],
787
1147
  stateMutability: "view",
788
1148
  type: "function"
789
1149
  },
790
1150
  {
791
1151
  inputs: [
792
- { internalType: "uint256", name: "jobId", type: "uint256" },
793
- { internalType: "uint8", name: "phase", type: "uint8" },
794
- { internalType: "uint256", name: "offset", type: "uint256" },
795
- { internalType: "uint256", name: "limit", type: "uint256" }
1152
+ {
1153
+ internalType: "uint256",
1154
+ name: "jobId",
1155
+ type: "uint256"
1156
+ },
1157
+ {
1158
+ internalType: "uint8",
1159
+ name: "phase",
1160
+ type: "uint8"
1161
+ },
1162
+ {
1163
+ internalType: "uint256",
1164
+ name: "offset",
1165
+ type: "uint256"
1166
+ },
1167
+ {
1168
+ internalType: "uint256",
1169
+ name: "limit",
1170
+ type: "uint256"
1171
+ }
796
1172
  ],
797
1173
  name: "getMemosForPhase",
798
1174
  outputs: [
799
1175
  {
800
1176
  components: [
801
- { internalType: "string", name: "content", type: "string" },
1177
+ {
1178
+ internalType: "string",
1179
+ name: "content",
1180
+ type: "string"
1181
+ },
802
1182
  {
803
1183
  internalType: "enum InteractionLedger.MemoType",
804
1184
  name: "memoType",
805
1185
  type: "uint8"
806
1186
  },
807
- { internalType: "bool", name: "isSecured", type: "bool" },
808
- { internalType: "uint8", name: "nextPhase", type: "uint8" },
809
- { internalType: "uint256", name: "jobId", type: "uint256" },
810
- { internalType: "address", name: "sender", type: "address" }
1187
+ {
1188
+ internalType: "bool",
1189
+ name: "isSecured",
1190
+ type: "bool"
1191
+ },
1192
+ {
1193
+ internalType: "uint8",
1194
+ name: "nextPhase",
1195
+ type: "uint8"
1196
+ },
1197
+ {
1198
+ internalType: "uint256",
1199
+ name: "jobId",
1200
+ type: "uint256"
1201
+ },
1202
+ {
1203
+ internalType: "address",
1204
+ name: "sender",
1205
+ type: "address"
1206
+ }
811
1207
  ],
812
1208
  internalType: "struct InteractionLedger.Memo[]",
813
1209
  name: "",
814
1210
  type: "tuple[]"
815
1211
  },
816
- { internalType: "uint256", name: "total", type: "uint256" }
1212
+ {
1213
+ internalType: "uint256",
1214
+ name: "total",
1215
+ type: "uint256"
1216
+ }
817
1217
  ],
818
1218
  stateMutability: "view",
819
1219
  type: "function"
@@ -821,326 +1221,880 @@ var ACP_ABI = [
821
1221
  {
822
1222
  inputs: [],
823
1223
  name: "getPhases",
824
- outputs: [{ internalType: "string[7]", name: "", type: "string[7]" }],
1224
+ outputs: [
1225
+ {
1226
+ internalType: "string[7]",
1227
+ name: "",
1228
+ type: "string[7]"
1229
+ }
1230
+ ],
825
1231
  stateMutability: "pure",
826
1232
  type: "function"
827
1233
  },
828
1234
  {
829
- inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
1235
+ inputs: [
1236
+ {
1237
+ internalType: "bytes32",
1238
+ name: "role",
1239
+ type: "bytes32"
1240
+ }
1241
+ ],
830
1242
  name: "getRoleAdmin",
831
- outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
1243
+ outputs: [
1244
+ {
1245
+ internalType: "bytes32",
1246
+ name: "",
1247
+ type: "bytes32"
1248
+ }
1249
+ ],
1250
+ stateMutability: "view",
1251
+ type: "function"
1252
+ },
1253
+ {
1254
+ inputs: [
1255
+ {
1256
+ internalType: "bytes32",
1257
+ name: "role",
1258
+ type: "bytes32"
1259
+ },
1260
+ {
1261
+ internalType: "address",
1262
+ name: "account",
1263
+ type: "address"
1264
+ }
1265
+ ],
1266
+ name: "grantRole",
1267
+ outputs: [],
1268
+ stateMutability: "nonpayable",
1269
+ type: "function"
1270
+ },
1271
+ {
1272
+ inputs: [
1273
+ {
1274
+ internalType: "bytes32",
1275
+ name: "role",
1276
+ type: "bytes32"
1277
+ },
1278
+ {
1279
+ internalType: "address",
1280
+ name: "account",
1281
+ type: "address"
1282
+ }
1283
+ ],
1284
+ name: "hasRole",
1285
+ outputs: [
1286
+ {
1287
+ internalType: "bool",
1288
+ name: "",
1289
+ type: "bool"
1290
+ }
1291
+ ],
832
1292
  stateMutability: "view",
833
1293
  type: "function"
834
1294
  },
835
1295
  {
836
1296
  inputs: [
837
- { internalType: "bytes32", name: "role", type: "bytes32" },
838
- { internalType: "address", name: "account", type: "address" }
1297
+ {
1298
+ internalType: "address",
1299
+ name: "paymentTokenAddress",
1300
+ type: "address"
1301
+ },
1302
+ {
1303
+ internalType: "uint256",
1304
+ name: "evaluatorFeeBP_",
1305
+ type: "uint256"
1306
+ },
1307
+ {
1308
+ internalType: "uint256",
1309
+ name: "platformFeeBP_",
1310
+ type: "uint256"
1311
+ },
1312
+ {
1313
+ internalType: "address",
1314
+ name: "platformTreasury_",
1315
+ type: "address"
1316
+ }
1317
+ ],
1318
+ name: "initialize",
1319
+ outputs: [],
1320
+ stateMutability: "nonpayable",
1321
+ type: "function"
1322
+ },
1323
+ {
1324
+ inputs: [
1325
+ {
1326
+ internalType: "uint256",
1327
+ name: "jobId",
1328
+ type: "uint256"
1329
+ },
1330
+ {
1331
+ internalType: "address",
1332
+ name: "account",
1333
+ type: "address"
1334
+ }
1335
+ ],
1336
+ name: "isJobEvaluator",
1337
+ outputs: [
1338
+ {
1339
+ internalType: "bool",
1340
+ name: "",
1341
+ type: "bool"
1342
+ }
1343
+ ],
1344
+ stateMutability: "view",
1345
+ type: "function"
1346
+ },
1347
+ {
1348
+ inputs: [
1349
+ {
1350
+ internalType: "uint256",
1351
+ name: "memoId",
1352
+ type: "uint256"
1353
+ }
1354
+ ],
1355
+ name: "isPayableMemo",
1356
+ outputs: [
1357
+ {
1358
+ internalType: "bool",
1359
+ name: "",
1360
+ type: "bool"
1361
+ }
1362
+ ],
1363
+ stateMutability: "view",
1364
+ type: "function"
1365
+ },
1366
+ {
1367
+ inputs: [
1368
+ {
1369
+ internalType: "uint256",
1370
+ name: "jobId",
1371
+ type: "uint256"
1372
+ }
1373
+ ],
1374
+ name: "jobAdditionalFees",
1375
+ outputs: [
1376
+ {
1377
+ internalType: "uint256",
1378
+ name: "",
1379
+ type: "uint256"
1380
+ }
1381
+ ],
1382
+ stateMutability: "view",
1383
+ type: "function"
1384
+ },
1385
+ {
1386
+ inputs: [],
1387
+ name: "jobCounter",
1388
+ outputs: [
1389
+ {
1390
+ internalType: "uint256",
1391
+ name: "",
1392
+ type: "uint256"
1393
+ }
1394
+ ],
1395
+ stateMutability: "view",
1396
+ type: "function"
1397
+ },
1398
+ {
1399
+ inputs: [
1400
+ {
1401
+ internalType: "uint256",
1402
+ name: "jobId",
1403
+ type: "uint256"
1404
+ },
1405
+ {
1406
+ internalType: "uint8",
1407
+ name: "phase",
1408
+ type: "uint8"
1409
+ },
1410
+ {
1411
+ internalType: "uint256",
1412
+ name: "",
1413
+ type: "uint256"
1414
+ }
1415
+ ],
1416
+ name: "jobMemoIds",
1417
+ outputs: [
1418
+ {
1419
+ internalType: "uint256",
1420
+ name: "memoIds",
1421
+ type: "uint256"
1422
+ }
1423
+ ],
1424
+ stateMutability: "view",
1425
+ type: "function"
1426
+ },
1427
+ {
1428
+ inputs: [
1429
+ {
1430
+ internalType: "uint256",
1431
+ name: "",
1432
+ type: "uint256"
1433
+ }
1434
+ ],
1435
+ name: "jobs",
1436
+ outputs: [
1437
+ {
1438
+ internalType: "uint256",
1439
+ name: "id",
1440
+ type: "uint256"
1441
+ },
1442
+ {
1443
+ internalType: "address",
1444
+ name: "client",
1445
+ type: "address"
1446
+ },
1447
+ {
1448
+ internalType: "address",
1449
+ name: "provider",
1450
+ type: "address"
1451
+ },
1452
+ {
1453
+ internalType: "uint256",
1454
+ name: "budget",
1455
+ type: "uint256"
1456
+ },
1457
+ {
1458
+ internalType: "uint256",
1459
+ name: "amountClaimed",
1460
+ type: "uint256"
1461
+ },
1462
+ {
1463
+ internalType: "uint8",
1464
+ name: "phase",
1465
+ type: "uint8"
1466
+ },
1467
+ {
1468
+ internalType: "uint256",
1469
+ name: "memoCount",
1470
+ type: "uint256"
1471
+ },
1472
+ {
1473
+ internalType: "uint256",
1474
+ name: "expiredAt",
1475
+ type: "uint256"
1476
+ },
1477
+ {
1478
+ internalType: "address",
1479
+ name: "evaluator",
1480
+ type: "address"
1481
+ },
1482
+ {
1483
+ internalType: "contract IERC20",
1484
+ name: "jobPaymentToken",
1485
+ type: "address"
1486
+ }
1487
+ ],
1488
+ stateMutability: "view",
1489
+ type: "function"
1490
+ },
1491
+ {
1492
+ inputs: [],
1493
+ name: "memoCounter",
1494
+ outputs: [
1495
+ {
1496
+ internalType: "uint256",
1497
+ name: "",
1498
+ type: "uint256"
1499
+ }
1500
+ ],
1501
+ stateMutability: "view",
1502
+ type: "function"
1503
+ },
1504
+ {
1505
+ inputs: [
1506
+ {
1507
+ internalType: "uint256",
1508
+ name: "memoId",
1509
+ type: "uint256"
1510
+ }
1511
+ ],
1512
+ name: "memoExpiredAt",
1513
+ outputs: [
1514
+ {
1515
+ internalType: "uint256",
1516
+ name: "expiredAt",
1517
+ type: "uint256"
1518
+ }
1519
+ ],
1520
+ stateMutability: "view",
1521
+ type: "function"
1522
+ },
1523
+ {
1524
+ inputs: [
1525
+ {
1526
+ internalType: "uint256",
1527
+ name: "",
1528
+ type: "uint256"
1529
+ }
1530
+ ],
1531
+ name: "memos",
1532
+ outputs: [
1533
+ {
1534
+ internalType: "string",
1535
+ name: "content",
1536
+ type: "string"
1537
+ },
1538
+ {
1539
+ internalType: "enum InteractionLedger.MemoType",
1540
+ name: "memoType",
1541
+ type: "uint8"
1542
+ },
1543
+ {
1544
+ internalType: "bool",
1545
+ name: "isSecured",
1546
+ type: "bool"
1547
+ },
1548
+ {
1549
+ internalType: "uint8",
1550
+ name: "nextPhase",
1551
+ type: "uint8"
1552
+ },
1553
+ {
1554
+ internalType: "uint256",
1555
+ name: "jobId",
1556
+ type: "uint256"
1557
+ },
1558
+ {
1559
+ internalType: "address",
1560
+ name: "sender",
1561
+ type: "address"
1562
+ }
1563
+ ],
1564
+ stateMutability: "view",
1565
+ type: "function"
1566
+ },
1567
+ {
1568
+ inputs: [],
1569
+ name: "numEvaluatorsPerJob",
1570
+ outputs: [
1571
+ {
1572
+ internalType: "uint8",
1573
+ name: "",
1574
+ type: "uint8"
1575
+ }
1576
+ ],
1577
+ stateMutability: "view",
1578
+ type: "function"
1579
+ },
1580
+ {
1581
+ inputs: [
1582
+ {
1583
+ internalType: "uint256",
1584
+ name: "memoId",
1585
+ type: "uint256"
1586
+ }
1587
+ ],
1588
+ name: "payableDetails",
1589
+ outputs: [
1590
+ {
1591
+ internalType: "address",
1592
+ name: "token",
1593
+ type: "address"
1594
+ },
1595
+ {
1596
+ internalType: "uint256",
1597
+ name: "amount",
1598
+ type: "uint256"
1599
+ },
1600
+ {
1601
+ internalType: "address",
1602
+ name: "recipient",
1603
+ type: "address"
1604
+ },
1605
+ {
1606
+ internalType: "uint256",
1607
+ name: "feeAmount",
1608
+ type: "uint256"
1609
+ },
1610
+ {
1611
+ internalType: "enum ACPSimple.FeeType",
1612
+ name: "feeType",
1613
+ type: "uint8"
1614
+ },
1615
+ {
1616
+ internalType: "bool",
1617
+ name: "isExecuted",
1618
+ type: "bool"
1619
+ }
1620
+ ],
1621
+ stateMutability: "view",
1622
+ type: "function"
1623
+ },
1624
+ {
1625
+ inputs: [],
1626
+ name: "paymentToken",
1627
+ outputs: [
1628
+ {
1629
+ internalType: "contract IERC20",
1630
+ name: "",
1631
+ type: "address"
1632
+ }
1633
+ ],
1634
+ stateMutability: "view",
1635
+ type: "function"
1636
+ },
1637
+ {
1638
+ inputs: [],
1639
+ name: "platformFeeBP",
1640
+ outputs: [
1641
+ {
1642
+ internalType: "uint256",
1643
+ name: "",
1644
+ type: "uint256"
1645
+ }
1646
+ ],
1647
+ stateMutability: "view",
1648
+ type: "function"
1649
+ },
1650
+ {
1651
+ inputs: [],
1652
+ name: "platformTreasury",
1653
+ outputs: [
1654
+ {
1655
+ internalType: "address",
1656
+ name: "",
1657
+ type: "address"
1658
+ }
1659
+ ],
1660
+ stateMutability: "view",
1661
+ type: "function"
1662
+ },
1663
+ {
1664
+ inputs: [
1665
+ {
1666
+ internalType: "bytes32",
1667
+ name: "role",
1668
+ type: "bytes32"
1669
+ },
1670
+ {
1671
+ internalType: "address",
1672
+ name: "callerConfirmation",
1673
+ type: "address"
1674
+ }
1675
+ ],
1676
+ name: "renounceRole",
1677
+ outputs: [],
1678
+ stateMutability: "nonpayable",
1679
+ type: "function"
1680
+ },
1681
+ {
1682
+ inputs: [
1683
+ {
1684
+ internalType: "bytes32",
1685
+ name: "role",
1686
+ type: "bytes32"
1687
+ },
1688
+ {
1689
+ internalType: "address",
1690
+ name: "account",
1691
+ type: "address"
1692
+ }
1693
+ ],
1694
+ name: "revokeRole",
1695
+ outputs: [],
1696
+ stateMutability: "nonpayable",
1697
+ type: "function"
1698
+ },
1699
+ {
1700
+ inputs: [
1701
+ {
1702
+ internalType: "uint256",
1703
+ name: "jobId",
1704
+ type: "uint256"
1705
+ },
1706
+ {
1707
+ internalType: "uint256",
1708
+ name: "amount",
1709
+ type: "uint256"
1710
+ }
1711
+ ],
1712
+ name: "setBudget",
1713
+ outputs: [],
1714
+ stateMutability: "nonpayable",
1715
+ type: "function"
1716
+ },
1717
+ {
1718
+ inputs: [
1719
+ {
1720
+ internalType: "uint256",
1721
+ name: "jobId",
1722
+ type: "uint256"
1723
+ },
1724
+ {
1725
+ internalType: "uint256",
1726
+ name: "amount",
1727
+ type: "uint256"
1728
+ },
1729
+ {
1730
+ internalType: "contract IERC20",
1731
+ name: "jobPaymentToken_",
1732
+ type: "address"
1733
+ }
1734
+ ],
1735
+ name: "setBudgetWithPaymentToken",
1736
+ outputs: [],
1737
+ stateMutability: "nonpayable",
1738
+ type: "function"
1739
+ },
1740
+ {
1741
+ inputs: [
1742
+ {
1743
+ internalType: "uint256",
1744
+ name: "memoId",
1745
+ type: "uint256"
1746
+ },
1747
+ {
1748
+ internalType: "bool",
1749
+ name: "isApproved",
1750
+ type: "bool"
1751
+ },
1752
+ {
1753
+ internalType: "string",
1754
+ name: "reason",
1755
+ type: "string"
1756
+ }
1757
+ ],
1758
+ name: "signMemo",
1759
+ outputs: [],
1760
+ stateMutability: "nonpayable",
1761
+ type: "function"
1762
+ },
1763
+ {
1764
+ inputs: [
1765
+ {
1766
+ internalType: "uint256",
1767
+ name: "memoId",
1768
+ type: "uint256"
1769
+ },
1770
+ {
1771
+ internalType: "address",
1772
+ name: "signer",
1773
+ type: "address"
1774
+ }
1775
+ ],
1776
+ name: "signatories",
1777
+ outputs: [
1778
+ {
1779
+ internalType: "uint8",
1780
+ name: "res",
1781
+ type: "uint8"
1782
+ }
1783
+ ],
1784
+ stateMutability: "view",
1785
+ type: "function"
1786
+ },
1787
+ {
1788
+ inputs: [
1789
+ {
1790
+ internalType: "bytes4",
1791
+ name: "interfaceId",
1792
+ type: "bytes4"
1793
+ }
1794
+ ],
1795
+ name: "supportsInterface",
1796
+ outputs: [
1797
+ {
1798
+ internalType: "bool",
1799
+ name: "",
1800
+ type: "bool"
1801
+ }
1802
+ ],
1803
+ stateMutability: "view",
1804
+ type: "function"
1805
+ },
1806
+ {
1807
+ inputs: [
1808
+ {
1809
+ internalType: "uint256",
1810
+ name: "evaluatorFeeBP_",
1811
+ type: "uint256"
1812
+ }
1813
+ ],
1814
+ name: "updateEvaluatorFee",
1815
+ outputs: [],
1816
+ stateMutability: "nonpayable",
1817
+ type: "function"
1818
+ },
1819
+ {
1820
+ inputs: [
1821
+ {
1822
+ internalType: "uint256",
1823
+ name: "platformFeeBP_",
1824
+ type: "uint256"
1825
+ },
1826
+ {
1827
+ internalType: "address",
1828
+ name: "platformTreasury_",
1829
+ type: "address"
1830
+ }
1831
+ ],
1832
+ name: "updatePlatformFee",
1833
+ outputs: [],
1834
+ stateMutability: "nonpayable",
1835
+ type: "function"
1836
+ },
1837
+ {
1838
+ inputs: [
1839
+ {
1840
+ internalType: "uint256",
1841
+ name: "memoId",
1842
+ type: "uint256"
1843
+ }
1844
+ ],
1845
+ name: "withdrawEscrowedFunds",
1846
+ outputs: [],
1847
+ stateMutability: "nonpayable",
1848
+ type: "function"
1849
+ }
1850
+ ];
1851
+ var acpAbi_default = ACP_ABI;
1852
+
1853
+ // src/acpClient.ts
1854
+ import { io } from "socket.io-client";
1855
+
1856
+ // src/acpContractClient.ts
1857
+ import { LocalAccountSigner } from "@aa-sdk/core";
1858
+ import { alchemy } from "@account-kit/infra";
1859
+ import {
1860
+ createModularAccountV2Client
1861
+ } from "@account-kit/smart-contracts";
1862
+ import { decodeEventLog, encodeFunctionData, erc20Abi, fromHex } from "viem";
1863
+
1864
+ // src/acpConfigs.ts
1865
+ import { baseSepolia, base } from "@account-kit/infra";
1866
+
1867
+ // src/acpFare.ts
1868
+ import { ethAddress, parseUnits } from "viem";
1869
+ var Fare = class {
1870
+ constructor(contractAddress, decimals) {
1871
+ this.contractAddress = contractAddress;
1872
+ this.decimals = decimals;
1873
+ }
1874
+ formatAmount(amount) {
1875
+ return parseUnits(amount.toString(), this.decimals);
1876
+ }
1877
+ };
1878
+ var FareAmount = class _FareAmount {
1879
+ constructor(fareAmount, fare) {
1880
+ this.amount = fare.formatAmount(
1881
+ this.truncateTo6Decimals(fareAmount.toString())
1882
+ );
1883
+ this.fare = fare;
1884
+ }
1885
+ truncateTo6Decimals(input) {
1886
+ const [intPart, decPart = ""] = input.split(".");
1887
+ if (decPart === "") {
1888
+ return parseFloat(intPart);
1889
+ }
1890
+ const truncated = decPart.slice(0, 6).padEnd(6, "0");
1891
+ return parseFloat(`${intPart}.${truncated}`);
1892
+ }
1893
+ add(other) {
1894
+ if (this.fare.contractAddress !== other.fare.contractAddress) {
1895
+ throw new Error("Token addresses do not match");
1896
+ }
1897
+ return new _FareAmount(Number(this.amount + other.amount), this.fare);
1898
+ }
1899
+ };
1900
+ var FareBigInt = class _FareBigInt {
1901
+ constructor(amount, fare) {
1902
+ this.amount = amount;
1903
+ this.fare = fare;
1904
+ }
1905
+ add(other) {
1906
+ if (this.fare.contractAddress !== other.fare.contractAddress) {
1907
+ throw new Error("Token addresses do not match");
1908
+ }
1909
+ return new _FareBigInt(this.amount + other.amount, this.fare);
1910
+ }
1911
+ };
1912
+ var wethFare = new Fare("0x4200000000000000000000000000000000000006", 18);
1913
+ var ethFare = new Fare(ethAddress, 18);
1914
+
1915
+ // src/acpConfigs.ts
1916
+ var AcpContractConfig = class {
1917
+ constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, rpcEndpoint) {
1918
+ this.chain = chain;
1919
+ this.contractAddress = contractAddress;
1920
+ this.baseFare = baseFare;
1921
+ this.alchemyRpcUrl = alchemyRpcUrl;
1922
+ this.acpUrl = acpUrl;
1923
+ this.rpcEndpoint = rpcEndpoint;
1924
+ }
1925
+ };
1926
+ var baseSepoliaAcpConfig = new AcpContractConfig(
1927
+ baseSepolia,
1928
+ "0x8Db6B1c839Fc8f6bd35777E194677B67b4D51928",
1929
+ new Fare("0x036CbD53842c5426634e7929541eC2318f3dCF7e", 6),
1930
+ "https://alchemy-proxy.virtuals.io/api/proxy/rpc",
1931
+ "https://acpx.virtuals.gg"
1932
+ );
1933
+ var baseAcpConfig = new AcpContractConfig(
1934
+ base,
1935
+ "0x6a1FE26D54ab0d3E1e3168f2e0c0cDa5cC0A0A4A",
1936
+ new Fare("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", 6),
1937
+ "https://alchemy-proxy-prod.virtuals.io/api/proxy/rpc",
1938
+ "https://acpx.virtuals.io"
1939
+ );
1940
+
1941
+ // src/wethAbi.ts
1942
+ var WETH_ABI = [
1943
+ {
1944
+ anonymous: false,
1945
+ inputs: [
1946
+ { indexed: true, internalType: "address", name: "src", type: "address" },
1947
+ { indexed: true, internalType: "address", name: "guy", type: "address" },
1948
+ { indexed: false, internalType: "uint256", name: "wad", type: "uint256" }
839
1949
  ],
840
- name: "grantRole",
841
- outputs: [],
842
- stateMutability: "nonpayable",
843
- type: "function"
1950
+ name: "Approval",
1951
+ type: "event"
844
1952
  },
845
1953
  {
1954
+ anonymous: false,
846
1955
  inputs: [
847
- { internalType: "bytes32", name: "role", type: "bytes32" },
848
- { internalType: "address", name: "account", type: "address" }
1956
+ { indexed: true, internalType: "address", name: "dst", type: "address" },
1957
+ { indexed: false, internalType: "uint256", name: "wad", type: "uint256" }
849
1958
  ],
850
- name: "hasRole",
851
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
852
- stateMutability: "view",
853
- type: "function"
1959
+ name: "Deposit",
1960
+ type: "event"
854
1961
  },
855
1962
  {
1963
+ anonymous: false,
856
1964
  inputs: [
857
- { internalType: "address", name: "paymentTokenAddress", type: "address" },
858
- { internalType: "uint256", name: "evaluatorFeeBP_", type: "uint256" },
859
- { internalType: "uint256", name: "platformFeeBP_", type: "uint256" },
860
- { internalType: "address", name: "platformTreasury_", type: "address" }
1965
+ { indexed: true, internalType: "address", name: "src", type: "address" },
1966
+ { indexed: true, internalType: "address", name: "dst", type: "address" },
1967
+ { indexed: false, internalType: "uint256", name: "wad", type: "uint256" }
861
1968
  ],
862
- name: "initialize",
863
- outputs: [],
864
- stateMutability: "nonpayable",
865
- type: "function"
1969
+ name: "Transfer",
1970
+ type: "event"
866
1971
  },
867
1972
  {
1973
+ anonymous: false,
868
1974
  inputs: [
869
- { internalType: "uint256", name: "jobId", type: "uint256" },
870
- { internalType: "address", name: "account", type: "address" }
1975
+ { indexed: true, internalType: "address", name: "src", type: "address" },
1976
+ { indexed: false, internalType: "uint256", name: "wad", type: "uint256" }
871
1977
  ],
872
- name: "isJobEvaluator",
873
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
874
- stateMutability: "view",
875
- type: "function"
876
- },
877
- {
878
- inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
879
- name: "isPayableMemo",
880
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
881
- stateMutability: "view",
882
- type: "function"
883
- },
884
- {
885
- inputs: [{ internalType: "uint256", name: "jobId", type: "uint256" }],
886
- name: "jobAdditionalFees",
887
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
888
- stateMutability: "view",
889
- type: "function"
890
- },
891
- {
892
- inputs: [],
893
- name: "jobCounter",
894
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
895
- stateMutability: "view",
896
- type: "function"
1978
+ name: "Withdrawal",
1979
+ type: "event"
897
1980
  },
1981
+ { payable: true, stateMutability: "payable", type: "fallback" },
898
1982
  {
1983
+ constant: true,
899
1984
  inputs: [
900
- { internalType: "uint256", name: "jobId", type: "uint256" },
901
- { internalType: "uint8", name: "phase", type: "uint8" },
902
- { internalType: "uint256", name: "", type: "uint256" }
903
- ],
904
- name: "jobMemoIds",
905
- outputs: [{ internalType: "uint256", name: "memoIds", type: "uint256" }],
906
- stateMutability: "view",
907
- type: "function"
908
- },
909
- {
910
- inputs: [{ internalType: "uint256", name: "jobId", type: "uint256" }],
911
- name: "jobPayment",
912
- outputs: [
913
- { internalType: "address", name: "paymentToken", type: "address" }
1985
+ { internalType: "address", name: "", type: "address" },
1986
+ { internalType: "address", name: "", type: "address" }
914
1987
  ],
1988
+ name: "allowance",
1989
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1990
+ payable: false,
915
1991
  stateMutability: "view",
916
1992
  type: "function"
917
1993
  },
918
1994
  {
919
- inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
920
- name: "jobs",
921
- outputs: [
922
- { internalType: "uint256", name: "id", type: "uint256" },
923
- { internalType: "address", name: "client", type: "address" },
924
- { internalType: "address", name: "provider", type: "address" },
925
- { internalType: "uint256", name: "budget", type: "uint256" },
926
- { internalType: "uint256", name: "amountClaimed", type: "uint256" },
927
- { internalType: "uint8", name: "phase", type: "uint8" },
928
- { internalType: "uint256", name: "memoCount", type: "uint256" },
929
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
930
- { internalType: "address", name: "evaluator", type: "address" }
1995
+ constant: false,
1996
+ inputs: [
1997
+ { internalType: "address", name: "guy", type: "address" },
1998
+ { internalType: "uint256", name: "wad", type: "uint256" }
931
1999
  ],
932
- stateMutability: "view",
2000
+ name: "approve",
2001
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
2002
+ payable: false,
2003
+ stateMutability: "nonpayable",
933
2004
  type: "function"
934
2005
  },
935
2006
  {
936
- inputs: [],
937
- name: "memoCounter",
2007
+ constant: true,
2008
+ inputs: [{ internalType: "address", name: "", type: "address" }],
2009
+ name: "balanceOf",
938
2010
  outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
2011
+ payable: false,
939
2012
  stateMutability: "view",
940
2013
  type: "function"
941
2014
  },
942
2015
  {
943
- inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
944
- name: "memoExpiredAt",
945
- outputs: [{ internalType: "uint256", name: "expiredAt", type: "uint256" }],
946
- stateMutability: "view",
947
- type: "function"
948
- },
949
- {
950
- inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
951
- name: "memos",
952
- outputs: [
953
- { internalType: "string", name: "content", type: "string" },
954
- {
955
- internalType: "enum InteractionLedger.MemoType",
956
- name: "memoType",
957
- type: "uint8"
958
- },
959
- { internalType: "bool", name: "isSecured", type: "bool" },
960
- { internalType: "uint8", name: "nextPhase", type: "uint8" },
961
- { internalType: "uint256", name: "jobId", type: "uint256" },
962
- { internalType: "address", name: "sender", type: "address" }
963
- ],
964
- stateMutability: "view",
965
- type: "function"
966
- },
967
- {
2016
+ constant: true,
968
2017
  inputs: [],
969
- name: "numEvaluatorsPerJob",
2018
+ name: "decimals",
970
2019
  outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
2020
+ payable: false,
971
2021
  stateMutability: "view",
972
2022
  type: "function"
973
2023
  },
974
2024
  {
975
- inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
976
- name: "payableDetails",
977
- outputs: [
978
- { internalType: "address", name: "token", type: "address" },
979
- { internalType: "uint256", name: "amount", type: "uint256" },
980
- { internalType: "address", name: "recipient", type: "address" },
981
- { internalType: "uint256", name: "feeAmount", type: "uint256" },
982
- {
983
- internalType: "enum ACPSimple.FeeType",
984
- name: "feeType",
985
- type: "uint8"
986
- },
987
- { internalType: "bool", name: "isExecuted", type: "bool" }
988
- ],
989
- stateMutability: "view",
2025
+ constant: false,
2026
+ inputs: [],
2027
+ name: "deposit",
2028
+ outputs: [],
2029
+ payable: true,
2030
+ stateMutability: "payable",
990
2031
  type: "function"
991
2032
  },
992
2033
  {
2034
+ constant: true,
993
2035
  inputs: [],
994
- name: "paymentToken",
995
- outputs: [{ internalType: "contract IERC20", name: "", type: "address" }],
2036
+ name: "name",
2037
+ outputs: [{ internalType: "string", name: "", type: "string" }],
2038
+ payable: false,
996
2039
  stateMutability: "view",
997
2040
  type: "function"
998
2041
  },
999
2042
  {
2043
+ constant: true,
1000
2044
  inputs: [],
1001
- name: "platformFeeBP",
1002
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
2045
+ name: "symbol",
2046
+ outputs: [{ internalType: "string", name: "", type: "string" }],
2047
+ payable: false,
1003
2048
  stateMutability: "view",
1004
2049
  type: "function"
1005
2050
  },
1006
2051
  {
2052
+ constant: true,
1007
2053
  inputs: [],
1008
- name: "platformTreasury",
1009
- outputs: [{ internalType: "address", name: "", type: "address" }],
2054
+ name: "totalSupply",
2055
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
2056
+ payable: false,
1010
2057
  stateMutability: "view",
1011
2058
  type: "function"
1012
2059
  },
1013
2060
  {
2061
+ constant: false,
1014
2062
  inputs: [
1015
- { internalType: "bytes32", name: "role", type: "bytes32" },
1016
- { internalType: "address", name: "callerConfirmation", type: "address" }
1017
- ],
1018
- name: "renounceRole",
1019
- outputs: [],
1020
- stateMutability: "nonpayable",
1021
- type: "function"
1022
- },
1023
- {
1024
- inputs: [
1025
- { internalType: "bytes32", name: "role", type: "bytes32" },
1026
- { internalType: "address", name: "account", type: "address" }
1027
- ],
1028
- name: "revokeRole",
1029
- outputs: [],
1030
- stateMutability: "nonpayable",
1031
- type: "function"
1032
- },
1033
- {
1034
- inputs: [
1035
- { internalType: "uint256", name: "jobId", type: "uint256" },
1036
- { internalType: "uint256", name: "amount", type: "uint256" }
1037
- ],
1038
- name: "setBudget",
1039
- outputs: [],
1040
- stateMutability: "nonpayable",
1041
- type: "function"
1042
- },
1043
- {
1044
- inputs: [
1045
- { internalType: "uint256", name: "memoId", type: "uint256" },
1046
- { internalType: "bool", name: "isApproved", type: "bool" },
1047
- { internalType: "string", name: "reason", type: "string" }
1048
- ],
1049
- name: "signMemo",
1050
- outputs: [],
1051
- stateMutability: "nonpayable",
1052
- type: "function"
1053
- },
1054
- {
1055
- inputs: [
1056
- { internalType: "uint256", name: "memoId", type: "uint256" },
1057
- { internalType: "address", name: "signer", type: "address" }
2063
+ { internalType: "address", name: "dst", type: "address" },
2064
+ { internalType: "uint256", name: "wad", type: "uint256" }
1058
2065
  ],
1059
- name: "signatories",
1060
- outputs: [{ internalType: "uint8", name: "res", type: "uint8" }],
1061
- stateMutability: "view",
1062
- type: "function"
1063
- },
1064
- {
1065
- inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
1066
- name: "supportsInterface",
2066
+ name: "transfer",
1067
2067
  outputs: [{ internalType: "bool", name: "", type: "bool" }],
1068
- stateMutability: "view",
1069
- type: "function"
1070
- },
1071
- {
1072
- inputs: [
1073
- { internalType: "uint256", name: "evaluatorFeeBP_", type: "uint256" }
1074
- ],
1075
- name: "updateEvaluatorFee",
1076
- outputs: [],
2068
+ payable: false,
1077
2069
  stateMutability: "nonpayable",
1078
2070
  type: "function"
1079
2071
  },
1080
2072
  {
2073
+ constant: false,
1081
2074
  inputs: [
1082
- { internalType: "uint256", name: "platformFeeBP_", type: "uint256" },
1083
- { internalType: "address", name: "platformTreasury_", type: "address" }
2075
+ { internalType: "address", name: "src", type: "address" },
2076
+ { internalType: "address", name: "dst", type: "address" },
2077
+ { internalType: "uint256", name: "wad", type: "uint256" }
1084
2078
  ],
1085
- name: "updatePlatformFee",
1086
- outputs: [],
2079
+ name: "transferFrom",
2080
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
2081
+ payable: false,
1087
2082
  stateMutability: "nonpayable",
1088
2083
  type: "function"
1089
2084
  },
1090
2085
  {
1091
- inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
1092
- name: "withdrawEscrowedFunds",
2086
+ constant: false,
2087
+ inputs: [{ internalType: "uint256", name: "wad", type: "uint256" }],
2088
+ name: "withdraw",
1093
2089
  outputs: [],
2090
+ payable: false,
1094
2091
  stateMutability: "nonpayable",
1095
2092
  type: "function"
1096
2093
  }
1097
2094
  ];
1098
- var acpAbi_default = ACP_ABI;
1099
-
1100
- // src/acpClient.ts
1101
- import { parseEther } from "viem";
1102
- import { io } from "socket.io-client";
1103
-
1104
- // src/acpContractClient.ts
1105
- import { LocalAccountSigner } from "@aa-sdk/core";
1106
- import { alchemy } from "@account-kit/infra";
1107
- import {
1108
- createModularAccountV2Client
1109
- } from "@account-kit/smart-contracts";
1110
-
1111
- // src/configs.ts
1112
- import { baseSepolia, base } from "@account-kit/infra";
1113
- var baseSepoliaAcpConfig = {
1114
- chain: baseSepolia,
1115
- contractAddress: "0x8Db6B1c839Fc8f6bd35777E194677B67b4D51928",
1116
- virtualsTokenAddress: "0xbfAB80ccc15DF6fb7185f9498d6039317331846a",
1117
- alchemyRpcUrl: "https://alchemy-proxy.virtuals.io/api/proxy/rpc",
1118
- acpUrl: "https://acpx.virtuals.gg",
1119
- priorityFeeMultiplier: 2,
1120
- maxFeePerGas: 2e7,
1121
- maxPriorityFeePerGas: 21e6
1122
- };
1123
- var baseAcpConfig = {
1124
- chain: base,
1125
- contractAddress: "0x6a1FE26D54ab0d3E1e3168f2e0c0cDa5cC0A0A4A",
1126
- virtualsTokenAddress: "0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b",
1127
- alchemyRpcUrl: "https://alchemy-proxy-prod.virtuals.io/api/proxy/rpc",
1128
- acpUrl: "https://acpx.virtuals.io",
1129
- priorityFeeMultiplier: 2,
1130
- maxFeePerGas: 2e7,
1131
- maxPriorityFeePerGas: 21e6
1132
- };
2095
+ var wethAbi_default = WETH_ABI;
1133
2096
 
1134
2097
  // src/acpContractClient.ts
1135
- import {
1136
- createPublicClient,
1137
- decodeEventLog,
1138
- encodeFunctionData,
1139
- erc20Abi,
1140
- fromHex,
1141
- http
1142
- } from "viem";
1143
- import { publicActionsL2 } from "viem/op-stack";
1144
2098
  var MemoType = /* @__PURE__ */ ((MemoType2) => {
1145
2099
  MemoType2[MemoType2["MESSAGE"] = 0] = "MESSAGE";
1146
2100
  MemoType2[MemoType2["CONTEXT_URL"] = 1] = "CONTEXT_URL";
@@ -1164,30 +2118,26 @@ var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
1164
2118
  return AcpJobPhases2;
1165
2119
  })(AcpJobPhases || {});
1166
2120
  var AcpContractClient = class _AcpContractClient {
1167
- constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig, customRpcUrl) {
2121
+ // private paymentTokenAddress: Address;
2122
+ constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
1168
2123
  this.walletPrivateKey = walletPrivateKey;
1169
2124
  this.sessionEntityKeyId = sessionEntityKeyId;
1170
2125
  this.agentWalletAddress = agentWalletAddress;
1171
2126
  this.config = config;
1172
- this.customRpcUrl = customRpcUrl;
1173
2127
  this.MAX_RETRIES = 3;
2128
+ this.PRIORITY_FEE_MULTIPLIER = 2;
2129
+ this.MAX_FEE_PER_GAS = 2e7;
2130
+ this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
1174
2131
  this.chain = config.chain;
1175
2132
  this.contractAddress = config.contractAddress;
1176
- this.virtualsTokenAddress = config.virtualsTokenAddress;
1177
- this.customRpcUrl = customRpcUrl;
1178
- this.customRpcClient = createPublicClient({
1179
- chain: this.chain,
1180
- transport: this.customRpcUrl ? http(this.customRpcUrl) : http()
1181
- }).extend(publicActionsL2());
1182
- }
1183
- static build(_0, _1, _2, _3) {
1184
- return __async(this, arguments, function* (walletPrivateKey, sessionEntityKeyId, agentWalletAddress, customRpcUrl, config = baseAcpConfig) {
2133
+ }
2134
+ static build(_0, _1, _2) {
2135
+ return __async(this, arguments, function* (walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
1185
2136
  const acpContractClient = new _AcpContractClient(
1186
2137
  walletPrivateKey,
1187
2138
  sessionEntityKeyId,
1188
2139
  agentWalletAddress,
1189
- config,
1190
- customRpcUrl
2140
+ config
1191
2141
  );
1192
2142
  yield acpContractClient.init();
1193
2143
  return acpContractClient;
@@ -1222,21 +2172,17 @@ var AcpContractClient = class _AcpContractClient {
1222
2172
  }
1223
2173
  calculateGasFees() {
1224
2174
  return __async(this, null, function* () {
1225
- const { maxFeePerGas, maxPriorityFeePerGas } = yield this.customRpcClient.estimateFeesPerGas();
1226
- let finalMaxFeePerGas = maxFeePerGas;
1227
- let priorityFeeMultiplier = Number(this.config.priorityFeeMultiplier) || 2;
1228
- const overrideMaxFeePerGas = this.config.maxFeePerGas || maxFeePerGas;
1229
- const overrideMaxPriorityFeePerGas = this.config.maxPriorityFeePerGas || maxPriorityFeePerGas;
1230
- finalMaxFeePerGas = BigInt(overrideMaxFeePerGas) + BigInt(overrideMaxPriorityFeePerGas) * BigInt(Math.max(0, priorityFeeMultiplier - 1));
2175
+ const finalMaxFeePerGas = BigInt(this.MAX_FEE_PER_GAS) + BigInt(this.MAX_PRIORITY_FEE_PER_GAS) * BigInt(Math.max(0, this.PRIORITY_FEE_MULTIPLIER - 1));
1231
2176
  return finalMaxFeePerGas;
1232
2177
  });
1233
2178
  }
1234
2179
  handleSendUserOperation(_0) {
1235
- return __async(this, arguments, function* (data, contractAddress = this.contractAddress) {
2180
+ return __async(this, arguments, function* (data, contractAddress = this.contractAddress, value) {
1236
2181
  const payload = {
1237
2182
  uo: {
1238
2183
  target: contractAddress,
1239
- data
2184
+ data,
2185
+ value
1240
2186
  },
1241
2187
  overrides: {}
1242
2188
  };
@@ -1304,18 +2250,15 @@ var AcpContractClient = class _AcpContractClient {
1304
2250
  }
1305
2251
  });
1306
2252
  }
1307
- approveAllowance(priceInWei) {
1308
- return __async(this, null, function* () {
2253
+ approveAllowance(_0) {
2254
+ return __async(this, arguments, function* (amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
1309
2255
  try {
1310
2256
  const data = encodeFunctionData({
1311
2257
  abi: erc20Abi,
1312
2258
  functionName: "approve",
1313
- args: [this.contractAddress, priceInWei]
2259
+ args: [this.contractAddress, amountBaseUnit]
1314
2260
  });
1315
- return yield this.handleSendUserOperation(
1316
- data,
1317
- this.virtualsTokenAddress
1318
- );
2261
+ return yield this.handleSendUserOperation(data, paymentTokenAddress);
1319
2262
  } catch (error) {
1320
2263
  console.error(`Failed to approve allowance ${error}`);
1321
2264
  throw new Error("Failed to approve allowance");
@@ -1323,7 +2266,7 @@ var AcpContractClient = class _AcpContractClient {
1323
2266
  });
1324
2267
  }
1325
2268
  createPayableMemo(_0, _1, _2, _3, _4, _5, _6, _7, _8) {
1326
- return __async(this, arguments, function* (jobId, content, amount, recipient, feeAmount, feeType, nextPhase, type, expiredAt, token = this.config.virtualsTokenAddress) {
2269
+ return __async(this, arguments, function* (jobId, content, amountBaseUnit, recipient, feeAmountBaseUnit, feeType, nextPhase, type, expiredAt, token = this.config.baseFare.contractAddress) {
1327
2270
  let retries = 3;
1328
2271
  while (retries > 0) {
1329
2272
  try {
@@ -1334,9 +2277,9 @@ var AcpContractClient = class _AcpContractClient {
1334
2277
  jobId,
1335
2278
  content,
1336
2279
  token,
1337
- amount,
2280
+ amountBaseUnit,
1338
2281
  recipient,
1339
- feeAmount,
2282
+ feeAmountBaseUnit,
1340
2283
  feeType,
1341
2284
  type,
1342
2285
  nextPhase,
@@ -1417,13 +2360,28 @@ var AcpContractClient = class _AcpContractClient {
1417
2360
  }
1418
2361
  });
1419
2362
  }
1420
- setBudget(jobId, budget) {
2363
+ setBudget(jobId, budgetBaseUnit) {
1421
2364
  return __async(this, null, function* () {
1422
2365
  try {
1423
2366
  const data = encodeFunctionData({
1424
2367
  abi: acpAbi_default,
1425
2368
  functionName: "setBudget",
1426
- args: [jobId, budget]
2369
+ args: [jobId, budgetBaseUnit]
2370
+ });
2371
+ return yield this.handleSendUserOperation(data);
2372
+ } catch (error) {
2373
+ console.error(`Failed to set budget ${error}`);
2374
+ throw new Error("Failed to set budget");
2375
+ }
2376
+ });
2377
+ }
2378
+ setBudgetWithPaymentToken(_0, _1) {
2379
+ return __async(this, arguments, function* (jobId, budgetBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
2380
+ try {
2381
+ const data = encodeFunctionData({
2382
+ abi: acpAbi_default,
2383
+ functionName: "setBudgetWithPaymentToken",
2384
+ args: [jobId, budgetBaseUnit, paymentTokenAddress]
1427
2385
  });
1428
2386
  return yield this.handleSendUserOperation(data);
1429
2387
  } catch (error) {
@@ -1432,6 +2390,24 @@ var AcpContractClient = class _AcpContractClient {
1432
2390
  }
1433
2391
  });
1434
2392
  }
2393
+ wrapEth(amountBaseUnit) {
2394
+ return __async(this, null, function* () {
2395
+ try {
2396
+ const data = encodeFunctionData({
2397
+ abi: wethAbi_default,
2398
+ functionName: "deposit"
2399
+ });
2400
+ return yield this.handleSendUserOperation(
2401
+ data,
2402
+ wethFare.contractAddress,
2403
+ amountBaseUnit
2404
+ );
2405
+ } catch (error) {
2406
+ console.error(`Failed to wrap eth ${error}`);
2407
+ throw new Error("Failed to wrap eth");
2408
+ }
2409
+ });
2410
+ }
1435
2411
  };
1436
2412
  var acpContractClient_default = AcpContractClient;
1437
2413
 
@@ -1464,6 +2440,8 @@ var AcpOnlineStatus = /* @__PURE__ */ ((AcpOnlineStatus2) => {
1464
2440
  var PayloadType = /* @__PURE__ */ ((PayloadType2) => {
1465
2441
  PayloadType2["FUND_RESPONSE"] = "fund_response";
1466
2442
  PayloadType2["OPEN_POSITION"] = "open_position";
2443
+ PayloadType2["SWAP_TOKEN"] = "swap_token";
2444
+ PayloadType2["RESPONSE_SWAP_TOKEN"] = "response_swap_token";
1467
2445
  PayloadType2["CLOSE_PARTIAL_POSITION"] = "close_partial_position";
1468
2446
  PayloadType2["CLOSE_POSITION"] = "close_position";
1469
2447
  PayloadType2["POSITION_FULFILLED"] = "position_fulfilled";
@@ -1471,6 +2449,11 @@ var PayloadType = /* @__PURE__ */ ((PayloadType2) => {
1471
2449
  PayloadType2["UNFULFILLED_POSITION"] = "unfulfilled_position";
1472
2450
  return PayloadType2;
1473
2451
  })(PayloadType || {});
2452
+ var PositionDirection = /* @__PURE__ */ ((PositionDirection2) => {
2453
+ PositionDirection2["LONG"] = "long";
2454
+ PositionDirection2["SHORT"] = "short";
2455
+ return PositionDirection2;
2456
+ })(PositionDirection || {});
1474
2457
 
1475
2458
  // src/utils.ts
1476
2459
  function tryParseJson(content) {
@@ -1483,20 +2466,46 @@ function tryParseJson(content) {
1483
2466
 
1484
2467
  // src/acpJob.ts
1485
2468
  var AcpJob = class {
1486
- constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, memos, phase, context) {
2469
+ constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, priceTokenAddress, memos, phase, context) {
1487
2470
  this.acpClient = acpClient;
1488
2471
  this.id = id;
1489
2472
  this.clientAddress = clientAddress;
1490
2473
  this.providerAddress = providerAddress;
1491
2474
  this.evaluatorAddress = evaluatorAddress;
1492
2475
  this.price = price;
2476
+ this.priceTokenAddress = priceTokenAddress;
1493
2477
  this.memos = memos;
1494
2478
  this.phase = phase;
1495
2479
  this.context = context;
2480
+ this.baseFare = acpClient.acpContractClient.config.baseFare;
1496
2481
  }
1497
2482
  get serviceRequirement() {
1498
2483
  var _a;
1499
- return (_a = this.memos.find((m) => m.nextPhase === 1 /* NEGOTIATION */)) == null ? void 0 : _a.content;
2484
+ const content = (_a = this.memos.find(
2485
+ (m) => m.nextPhase === 1 /* NEGOTIATION */
2486
+ )) == null ? void 0 : _a.content;
2487
+ if (!content) {
2488
+ return void 0;
2489
+ }
2490
+ const contentObj = tryParseJson(content);
2491
+ if (!contentObj) {
2492
+ return content;
2493
+ }
2494
+ if (contentObj.serviceRequirement) {
2495
+ return contentObj.serviceRequirement;
2496
+ }
2497
+ return contentObj;
2498
+ }
2499
+ get serviceName() {
2500
+ var _a;
2501
+ const content = (_a = this.memos.find(
2502
+ (m) => m.nextPhase === 1 /* NEGOTIATION */
2503
+ )) == null ? void 0 : _a.content;
2504
+ if (!content) {
2505
+ return void 0;
2506
+ }
2507
+ const contentObj = tryParseJson(content);
2508
+ return contentObj == null ? void 0 : contentObj.serviceName;
1500
2509
  }
1501
2510
  get deliverable() {
1502
2511
  var _a;
@@ -1522,7 +2531,12 @@ var AcpJob = class {
1522
2531
  if (!memo) {
1523
2532
  throw new Error("No transaction memo found");
1524
2533
  }
1525
- return yield this.acpClient.payJob(this.id, amount, memo.id, reason);
2534
+ return yield this.acpClient.payJob(
2535
+ this.id,
2536
+ this.baseFare.formatAmount(amount),
2537
+ memo.id,
2538
+ reason
2539
+ );
1526
2540
  });
1527
2541
  }
1528
2542
  respond(accept, payload, reason) {
@@ -1567,11 +2581,12 @@ var AcpJob = class {
1567
2581
  if (payload.length === 0) {
1568
2582
  throw new Error("No positions to open");
1569
2583
  }
2584
+ const sumAmount = payload.reduce((acc, curr) => acc + curr.amount, 0);
1570
2585
  return yield this.acpClient.transferFunds(
1571
2586
  this.id,
1572
- payload.reduce((acc, curr) => acc + curr.amount, 0),
2587
+ new FareAmount(sumAmount, this.baseFare),
1573
2588
  walletAddress || this.providerAddress,
1574
- feeAmount,
2589
+ new FareAmount(feeAmount, this.baseFare),
1575
2590
  1 /* IMMEDIATE_FEE */,
1576
2591
  {
1577
2592
  type: "open_position" /* OPEN_POSITION */,
@@ -1582,6 +2597,55 @@ var AcpJob = class {
1582
2597
  );
1583
2598
  });
1584
2599
  }
2600
+ swapToken(payload, decimals, feeAmount, walletAddress) {
2601
+ return __async(this, null, function* () {
2602
+ return yield this.acpClient.transferFunds(
2603
+ this.id,
2604
+ new FareAmount(
2605
+ payload.amount,
2606
+ new Fare(payload.fromContractAddress, decimals)
2607
+ ),
2608
+ walletAddress || this.providerAddress,
2609
+ new FareAmount(feeAmount, this.baseFare),
2610
+ 1 /* IMMEDIATE_FEE */,
2611
+ {
2612
+ type: "swap_token" /* SWAP_TOKEN */,
2613
+ data: payload
2614
+ },
2615
+ 2 /* TRANSACTION */,
2616
+ new Date(Date.now() + 1e3 * 60 * 30)
2617
+ );
2618
+ });
2619
+ }
2620
+ responseSwapToken(memoId, accept, reason) {
2621
+ return __async(this, null, function* () {
2622
+ const memo = this.memos.find((m) => m.id === memoId);
2623
+ if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
2624
+ throw new Error("No swap token memo found");
2625
+ }
2626
+ const payload = tryParseJson(
2627
+ memo.content
2628
+ );
2629
+ if ((payload == null ? void 0 : payload.type) !== "swap_token" /* SWAP_TOKEN */) {
2630
+ throw new Error("Invalid swap token memo");
2631
+ }
2632
+ return yield memo.sign(accept, reason);
2633
+ });
2634
+ }
2635
+ transferFunds(_0, _1, _2) {
2636
+ return __async(this, arguments, function* (payload, fareAmount, walletAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 30)) {
2637
+ return yield this.acpClient.transferFunds(
2638
+ this.id,
2639
+ fareAmount,
2640
+ walletAddress || this.clientAddress,
2641
+ new FareAmount(0, this.baseFare),
2642
+ 0 /* NO_FEE */,
2643
+ payload,
2644
+ 2 /* TRANSACTION */,
2645
+ expiredAt
2646
+ );
2647
+ });
2648
+ }
1585
2649
  responseOpenPosition(memoId, accept, reason) {
1586
2650
  return __async(this, null, function* () {
1587
2651
  const memo = this.memos.find((m) => m.id === memoId);
@@ -1601,9 +2665,9 @@ var AcpJob = class {
1601
2665
  return __async(this, arguments, function* (payload, expireAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
1602
2666
  return yield this.acpClient.requestFunds(
1603
2667
  this.id,
1604
- payload.amount,
2668
+ new FareAmount(payload.amount, this.baseFare),
1605
2669
  this.clientAddress,
1606
- 0,
2670
+ new FareAmount(0, this.baseFare),
1607
2671
  0 /* NO_FEE */,
1608
2672
  {
1609
2673
  type: "close_partial_position" /* CLOSE_PARTIAL_POSITION */,
@@ -1629,7 +2693,7 @@ var AcpJob = class {
1629
2693
  return yield this.acpClient.responseFundsRequest(
1630
2694
  memo.id,
1631
2695
  accept,
1632
- payload.data.amount,
2696
+ this.baseFare.formatAmount(payload.data.amount),
1633
2697
  reason
1634
2698
  );
1635
2699
  });
@@ -1660,9 +2724,9 @@ var AcpJob = class {
1660
2724
  if (accept) {
1661
2725
  return yield this.acpClient.transferFunds(
1662
2726
  this.id,
1663
- payload.amount,
2727
+ new FareAmount(payload.amount, this.baseFare),
1664
2728
  this.clientAddress,
1665
- 0,
2729
+ new FareAmount(0, this.baseFare),
1666
2730
  0 /* NO_FEE */,
1667
2731
  {
1668
2732
  type: "close_position" /* CLOSE_POSITION */,
@@ -1693,9 +2757,9 @@ var AcpJob = class {
1693
2757
  return __async(this, arguments, function* (payload, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
1694
2758
  return yield this.acpClient.transferFunds(
1695
2759
  this.id,
1696
- payload.amount,
2760
+ new FareAmount(payload.amount, this.baseFare),
1697
2761
  this.clientAddress,
1698
- 0,
2762
+ new FareAmount(0, this.baseFare),
1699
2763
  0 /* NO_FEE */,
1700
2764
  {
1701
2765
  type: "position_fulfilled" /* POSITION_FULFILLED */,
@@ -1710,9 +2774,9 @@ var AcpJob = class {
1710
2774
  return __async(this, arguments, function* (payload, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
1711
2775
  return yield this.acpClient.transferFunds(
1712
2776
  this.id,
1713
- payload.amount,
2777
+ new FareAmount(payload.amount, this.baseFare),
1714
2778
  this.clientAddress,
1715
- 0,
2779
+ new FareAmount(0, this.baseFare),
1716
2780
  0 /* NO_FEE */,
1717
2781
  {
1718
2782
  type: "unfulfilled_position" /* UNFULFILLED_POSITION */,
@@ -1799,9 +2863,9 @@ var AcpJob = class {
1799
2863
  }
1800
2864
  return yield this.acpClient.transferFunds(
1801
2865
  this.id,
1802
- fulfilledPositions.reduce((acc, curr) => acc + curr.amount, 0),
2866
+ new FareAmount(totalAmount, this.baseFare),
1803
2867
  this.clientAddress,
1804
- 0,
2868
+ new FareAmount(0, this.baseFare),
1805
2869
  0 /* NO_FEE */,
1806
2870
  {
1807
2871
  type: "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */,
@@ -1832,7 +2896,7 @@ var acpJob_default = AcpJob;
1832
2896
 
1833
2897
  // src/acpMemo.ts
1834
2898
  var AcpMemo = class {
1835
- constructor(acpClient, id, type, content, nextPhase, status, signedReason, expiry) {
2899
+ constructor(acpClient, id, type, content, nextPhase, status, signedReason, expiry, payableDetails) {
1836
2900
  this.acpClient = acpClient;
1837
2901
  this.id = id;
1838
2902
  this.type = type;
@@ -1841,6 +2905,11 @@ var AcpMemo = class {
1841
2905
  this.status = status;
1842
2906
  this.signedReason = signedReason;
1843
2907
  this.expiry = expiry;
2908
+ this.payableDetails = payableDetails;
2909
+ if (this.payableDetails) {
2910
+ this.payableDetails.amount = BigInt(this.payableDetails.amount);
2911
+ this.payableDetails.feeAmount = BigInt(this.payableDetails.feeAmount);
2912
+ }
1844
2913
  this.structuredContent = tryParseJson(this.content) || void 0;
1845
2914
  }
1846
2915
  get payloadType() {
@@ -1908,7 +2977,10 @@ var AcpJobOffering = class {
1908
2977
  return yield this.acpClient.initiateJob(
1909
2978
  this.providerAddress,
1910
2979
  finalServiceRequirement,
1911
- this.price,
2980
+ new FareAmount(
2981
+ this.price,
2982
+ this.acpClient.acpContractClient.config.baseFare
2983
+ ),
1912
2984
  evaluatorAddress,
1913
2985
  expiredAt
1914
2986
  );
@@ -1962,6 +3034,7 @@ var AcpClient = class {
1962
3034
  data.providerAddress,
1963
3035
  data.evaluatorAddress,
1964
3036
  data.price,
3037
+ data.priceTokenAddress,
1965
3038
  data.memos.map((memo) => {
1966
3039
  return new acpMemo_default(
1967
3040
  this,
@@ -1971,7 +3044,8 @@ var AcpClient = class {
1971
3044
  memo.nextPhase,
1972
3045
  memo.status,
1973
3046
  memo.signedReason,
1974
- memo.expiry ? new Date(parseInt(memo.expiry)) : void 0
3047
+ memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
3048
+ memo.payableDetails
1975
3049
  );
1976
3050
  }),
1977
3051
  data.phase,
@@ -1993,6 +3067,7 @@ var AcpClient = class {
1993
3067
  data.providerAddress,
1994
3068
  data.evaluatorAddress,
1995
3069
  data.price,
3070
+ data.priceTokenAddress,
1996
3071
  data.memos.map((memo) => {
1997
3072
  return new acpMemo_default(
1998
3073
  this,
@@ -2002,7 +3077,8 @@ var AcpClient = class {
2002
3077
  memo.nextPhase,
2003
3078
  memo.status,
2004
3079
  memo.signedReason,
2005
- memo.expiry ? new Date(parseInt(memo.expiry)) : void 0
3080
+ memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
3081
+ memo.payableDetails
2006
3082
  );
2007
3083
  }),
2008
3084
  data.phase,
@@ -2060,7 +3136,7 @@ var AcpClient = class {
2060
3136
  this,
2061
3137
  agent.walletAddress,
2062
3138
  offering.name,
2063
- offering.price,
3139
+ offering.priceUsd,
2064
3140
  offering.requirementSchema
2065
3141
  );
2066
3142
  }),
@@ -2072,18 +3148,22 @@ var AcpClient = class {
2072
3148
  });
2073
3149
  }
2074
3150
  initiateJob(_0, _1, _2, _3) {
2075
- return __async(this, arguments, function* (providerAddress, serviceRequirement, amount, evaluatorAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
3151
+ return __async(this, arguments, function* (providerAddress, serviceRequirement, fareAmount, evaluatorAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
3152
+ if (providerAddress === this.acpContractClient.walletAddress) {
3153
+ throw new Error(
3154
+ "Provider address cannot be the same as the client address"
3155
+ );
3156
+ }
2076
3157
  const { jobId } = yield this.acpContractClient.createJob(
2077
3158
  providerAddress,
2078
3159
  evaluatorAddress || this.acpContractClient.walletAddress,
2079
3160
  expiredAt
2080
3161
  );
2081
- if (amount > 0) {
2082
- yield this.acpContractClient.setBudget(
2083
- jobId,
2084
- parseEther(amount.toString())
2085
- );
2086
- }
3162
+ yield this.acpContractClient.setBudgetWithPaymentToken(
3163
+ jobId,
3164
+ fareAmount.amount,
3165
+ fareAmount.fare.contractAddress
3166
+ );
2087
3167
  yield this.acpContractClient.createMemo(
2088
3168
  jobId,
2089
3169
  typeof serviceRequirement === "string" ? serviceRequirement : JSON.stringify(serviceRequirement),
@@ -2109,31 +3189,29 @@ var AcpClient = class {
2109
3189
  );
2110
3190
  });
2111
3191
  }
2112
- payJob(jobId, amount, memoId, reason) {
3192
+ payJob(jobId, amountBaseUnit, memoId, reason) {
2113
3193
  return __async(this, null, function* () {
2114
- if (amount > 0) {
2115
- yield this.acpContractClient.approveAllowance(
2116
- parseEther(amount.toString())
2117
- );
3194
+ if (amountBaseUnit > BigInt(0)) {
3195
+ yield this.acpContractClient.approveAllowance(amountBaseUnit);
2118
3196
  }
2119
3197
  yield this.acpContractClient.signMemo(memoId, true, reason);
2120
3198
  return yield this.acpContractClient.createMemo(
2121
3199
  jobId,
2122
- `Payment of ${amount} made. ${reason != null ? reason : ""}`,
3200
+ `Payment made. ${reason != null ? reason : ""}`,
2123
3201
  0 /* MESSAGE */,
2124
3202
  false,
2125
3203
  3 /* EVALUATION */
2126
3204
  );
2127
3205
  });
2128
3206
  }
2129
- requestFunds(jobId, amount, recipient, feeAmount, feeType, reason, nextPhase, expiredAt) {
3207
+ requestFunds(jobId, transferFareAmount, recipient, feeFareAmount, feeType, reason, nextPhase, expiredAt) {
2130
3208
  return __async(this, null, function* () {
2131
3209
  return yield this.acpContractClient.createPayableMemo(
2132
3210
  jobId,
2133
3211
  JSON.stringify(reason),
2134
- parseEther(amount.toString()),
3212
+ transferFareAmount.amount,
2135
3213
  recipient,
2136
- parseEther(feeAmount.toString()),
3214
+ feeFareAmount.amount,
2137
3215
  feeType,
2138
3216
  nextPhase,
2139
3217
  6 /* PAYABLE_REQUEST */,
@@ -2141,37 +3219,49 @@ var AcpClient = class {
2141
3219
  );
2142
3220
  });
2143
3221
  }
2144
- responseFundsRequest(memoId, accept, amount, reason) {
3222
+ responseFundsRequest(memoId, accept, amountBaseUnit, reason) {
2145
3223
  return __async(this, null, function* () {
2146
3224
  if (!accept) {
2147
3225
  return yield this.acpContractClient.signMemo(memoId, accept, reason);
2148
3226
  }
2149
- if (amount > 0) {
2150
- yield this.acpContractClient.approveAllowance(
2151
- parseEther(amount.toString())
2152
- );
3227
+ if (amountBaseUnit > BigInt(0)) {
3228
+ yield this.acpContractClient.approveAllowance(amountBaseUnit);
2153
3229
  }
2154
3230
  return yield this.acpContractClient.signMemo(memoId, true, reason);
2155
3231
  });
2156
3232
  }
2157
- transferFunds(jobId, amount, recipient, feeAmount, feeType, reason, nextPhase, expiredAt) {
3233
+ transferFunds(jobId, transferFareAmount, recipient, feeFareAmount, feeType, reason, nextPhase, expiredAt) {
2158
3234
  return __async(this, null, function* () {
2159
- const totalAmount = amount + feeAmount;
2160
- if (totalAmount > 0) {
3235
+ if (transferFareAmount.fare.contractAddress === ethFare.contractAddress) {
3236
+ yield this.acpContractClient.wrapEth(transferFareAmount.amount);
3237
+ transferFareAmount = new FareBigInt(transferFareAmount.amount, wethFare);
3238
+ }
3239
+ if (feeFareAmount.amount > 0 && feeFareAmount.fare.contractAddress !== this.acpContractClient.config.baseFare.contractAddress) {
3240
+ throw new Error("Fee token address is not the same as the base fare");
3241
+ }
3242
+ const isFeeTokenDifferent = feeFareAmount.fare.contractAddress !== transferFareAmount.fare.contractAddress;
3243
+ if (isFeeTokenDifferent) {
2161
3244
  yield this.acpContractClient.approveAllowance(
2162
- parseEther(totalAmount.toString())
3245
+ feeFareAmount.amount,
3246
+ feeFareAmount.fare.contractAddress
2163
3247
  );
2164
3248
  }
3249
+ const finalAmount = isFeeTokenDifferent ? transferFareAmount : transferFareAmount.add(feeFareAmount);
3250
+ yield this.acpContractClient.approveAllowance(
3251
+ finalAmount.amount,
3252
+ transferFareAmount.fare.contractAddress
3253
+ );
2165
3254
  return yield this.acpContractClient.createPayableMemo(
2166
3255
  jobId,
2167
3256
  JSON.stringify(reason),
2168
- parseEther(amount.toString()),
3257
+ transferFareAmount.amount,
2169
3258
  recipient,
2170
- parseEther(feeAmount.toString()),
3259
+ feeFareAmount.amount,
2171
3260
  feeType,
2172
3261
  nextPhase,
2173
3262
  8 /* PAYABLE_TRANSFER_ESCROW */,
2174
- expiredAt
3263
+ expiredAt,
3264
+ transferFareAmount.fare.contractAddress
2175
3265
  );
2176
3266
  });
2177
3267
  }
@@ -2223,6 +3313,7 @@ var AcpClient = class {
2223
3313
  job.providerAddress,
2224
3314
  job.evaluatorAddress,
2225
3315
  job.price,
3316
+ job.priceTokenAddress,
2226
3317
  job.memos.map((memo) => {
2227
3318
  return new acpMemo_default(
2228
3319
  this,
@@ -2232,7 +3323,8 @@ var AcpClient = class {
2232
3323
  memo.nextPhase,
2233
3324
  memo.status,
2234
3325
  memo.signedReason,
2235
- memo.expiry ? new Date(parseInt(memo.expiry)) : void 0
3326
+ memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
3327
+ memo.payableDetails
2236
3328
  );
2237
3329
  }),
2238
3330
  job.phase,
@@ -2265,6 +3357,7 @@ var AcpClient = class {
2265
3357
  job.providerAddress,
2266
3358
  job.evaluatorAddress,
2267
3359
  job.price,
3360
+ job.priceTokenAddress,
2268
3361
  job.memos.map((memo) => {
2269
3362
  return new acpMemo_default(
2270
3363
  this,
@@ -2274,7 +3367,8 @@ var AcpClient = class {
2274
3367
  memo.nextPhase,
2275
3368
  memo.status,
2276
3369
  memo.signedReason,
2277
- memo.expiry ? new Date(parseInt(memo.expiry)) : void 0
3370
+ memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
3371
+ memo.payableDetails
2278
3372
  );
2279
3373
  }),
2280
3374
  job.phase,
@@ -2307,6 +3401,7 @@ var AcpClient = class {
2307
3401
  job.providerAddress,
2308
3402
  job.evaluatorAddress,
2309
3403
  job.price,
3404
+ job.priceTokenAddress,
2310
3405
  job.memos.map((memo) => {
2311
3406
  return new acpMemo_default(
2312
3407
  this,
@@ -2316,7 +3411,8 @@ var AcpClient = class {
2316
3411
  memo.nextPhase,
2317
3412
  memo.status,
2318
3413
  memo.signedReason,
2319
- memo.expiry ? new Date(parseInt(memo.expiry)) : void 0
3414
+ memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
3415
+ memo.payableDetails
2320
3416
  );
2321
3417
  }),
2322
3418
  job.phase,
@@ -2352,6 +3448,7 @@ var AcpClient = class {
2352
3448
  job.providerAddress,
2353
3449
  job.evaluatorAddress,
2354
3450
  job.price,
3451
+ job.priceTokenAddress,
2355
3452
  job.memos.map((memo) => {
2356
3453
  return new acpMemo_default(
2357
3454
  this,
@@ -2361,7 +3458,8 @@ var AcpClient = class {
2361
3458
  memo.nextPhase,
2362
3459
  memo.status,
2363
3460
  memo.signedReason,
2364
- memo.expiry ? new Date(parseInt(memo.expiry)) : void 0
3461
+ memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
3462
+ memo.payableDetails
2365
3463
  );
2366
3464
  }),
2367
3465
  job.phase,
@@ -2397,7 +3495,8 @@ var AcpClient = class {
2397
3495
  memo.nextPhase,
2398
3496
  memo.status,
2399
3497
  memo.signedReason,
2400
- memo.expiry ? new Date(parseInt(memo.expiry)) : void 0
3498
+ memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
3499
+ memo.payableDetails
2401
3500
  );
2402
3501
  } catch (error) {
2403
3502
  throw error;
@@ -2425,15 +3524,22 @@ export {
2425
3524
  acpAbi_default as ACP_ABI,
2426
3525
  AcpAgentSort,
2427
3526
  acpContractClient_default as AcpContractClient,
3527
+ AcpContractConfig,
2428
3528
  AcpGraduationStatus,
2429
3529
  acpJob_default as AcpJob,
2430
3530
  AcpJobPhases,
2431
3531
  acpMemo_default as AcpMemo,
2432
3532
  AcpMemoStatus,
2433
3533
  AcpOnlineStatus,
3534
+ Fare,
3535
+ FareAmount,
3536
+ FareBigInt,
2434
3537
  MemoType,
2435
3538
  PayloadType,
3539
+ PositionDirection,
2436
3540
  baseAcpConfig,
2437
3541
  baseSepoliaAcpConfig,
2438
- index_default as default
3542
+ index_default as default,
3543
+ ethFare,
3544
+ wethFare
2439
3545
  };