@virtuals-protocol/acp-node 0.2.0-beta.1 → 0.2.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -8
- package/dist/index.d.mts +284 -214
- package/dist/index.d.ts +284 -214
- package/dist/index.js +1698 -512
- package/dist/index.mjs +1678 -508
- package/package.json +1 -1
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,7 @@ var __spreadValues = (a, b) => {
|
|
|
19
21
|
}
|
|
20
22
|
return a;
|
|
21
23
|
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
25
|
var __commonJS = (cb, mod) => function __require() {
|
|
23
26
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
24
27
|
};
|
|
@@ -69,7 +72,7 @@ var require_package = __commonJS({
|
|
|
69
72
|
"package.json"(exports2, module2) {
|
|
70
73
|
module2.exports = {
|
|
71
74
|
name: "@virtuals-protocol/acp-node",
|
|
72
|
-
version: "0.2.0-beta.
|
|
75
|
+
version: "0.2.0-beta.10",
|
|
73
76
|
main: "./dist/index.js",
|
|
74
77
|
module: "./dist/index.mjs",
|
|
75
78
|
types: "./dist/index.d.ts",
|
|
@@ -105,47 +108,106 @@ __export(index_exports, {
|
|
|
105
108
|
ACP_ABI: () => acpAbi_default,
|
|
106
109
|
AcpAgentSort: () => AcpAgentSort,
|
|
107
110
|
AcpContractClient: () => acpContractClient_default,
|
|
111
|
+
AcpContractConfig: () => AcpContractConfig,
|
|
112
|
+
AcpError: () => acpError_default,
|
|
108
113
|
AcpGraduationStatus: () => AcpGraduationStatus,
|
|
109
114
|
AcpJob: () => acpJob_default,
|
|
110
115
|
AcpJobPhases: () => AcpJobPhases,
|
|
111
116
|
AcpMemo: () => acpMemo_default,
|
|
117
|
+
AcpMemoStatus: () => AcpMemoStatus,
|
|
112
118
|
AcpOnlineStatus: () => AcpOnlineStatus,
|
|
119
|
+
Fare: () => Fare,
|
|
120
|
+
FareAmount: () => FareAmount,
|
|
121
|
+
FareBigInt: () => FareBigInt,
|
|
113
122
|
MemoType: () => MemoType,
|
|
114
123
|
PayloadType: () => PayloadType,
|
|
124
|
+
PositionDirection: () => PositionDirection,
|
|
115
125
|
baseAcpConfig: () => baseAcpConfig,
|
|
116
126
|
baseSepoliaAcpConfig: () => baseSepoliaAcpConfig,
|
|
117
|
-
default: () => index_default
|
|
127
|
+
default: () => index_default,
|
|
128
|
+
ethFare: () => ethFare,
|
|
129
|
+
wethFare: () => wethFare
|
|
118
130
|
});
|
|
119
131
|
module.exports = __toCommonJS(index_exports);
|
|
120
132
|
|
|
121
133
|
// src/acpAbi.ts
|
|
122
134
|
var ACP_ABI = [
|
|
123
|
-
{
|
|
124
|
-
|
|
135
|
+
{
|
|
136
|
+
inputs: [],
|
|
137
|
+
stateMutability: "nonpayable",
|
|
138
|
+
type: "constructor"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
inputs: [],
|
|
142
|
+
name: "AccessControlBadConfirmation",
|
|
143
|
+
type: "error"
|
|
144
|
+
},
|
|
125
145
|
{
|
|
126
146
|
inputs: [
|
|
127
|
-
{
|
|
128
|
-
|
|
147
|
+
{
|
|
148
|
+
internalType: "address",
|
|
149
|
+
name: "account",
|
|
150
|
+
type: "address"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
internalType: "bytes32",
|
|
154
|
+
name: "neededRole",
|
|
155
|
+
type: "bytes32"
|
|
156
|
+
}
|
|
129
157
|
],
|
|
130
158
|
name: "AccessControlUnauthorizedAccount",
|
|
131
159
|
type: "error"
|
|
132
160
|
},
|
|
133
161
|
{
|
|
134
|
-
inputs: [
|
|
162
|
+
inputs: [
|
|
163
|
+
{
|
|
164
|
+
internalType: "address",
|
|
165
|
+
name: "target",
|
|
166
|
+
type: "address"
|
|
167
|
+
}
|
|
168
|
+
],
|
|
135
169
|
name: "AddressEmptyCode",
|
|
136
170
|
type: "error"
|
|
137
171
|
},
|
|
138
172
|
{
|
|
139
|
-
inputs: [
|
|
173
|
+
inputs: [
|
|
174
|
+
{
|
|
175
|
+
internalType: "address",
|
|
176
|
+
name: "account",
|
|
177
|
+
type: "address"
|
|
178
|
+
}
|
|
179
|
+
],
|
|
140
180
|
name: "AddressInsufficientBalance",
|
|
141
181
|
type: "error"
|
|
142
182
|
},
|
|
143
|
-
{ inputs: [], name: "FailedInnerCall", type: "error" },
|
|
144
|
-
{ inputs: [], name: "InvalidInitialization", type: "error" },
|
|
145
|
-
{ inputs: [], name: "NotInitializing", type: "error" },
|
|
146
|
-
{ inputs: [], name: "ReentrancyGuardReentrantCall", type: "error" },
|
|
147
183
|
{
|
|
148
|
-
inputs: [
|
|
184
|
+
inputs: [],
|
|
185
|
+
name: "FailedInnerCall",
|
|
186
|
+
type: "error"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
inputs: [],
|
|
190
|
+
name: "InvalidInitialization",
|
|
191
|
+
type: "error"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
inputs: [],
|
|
195
|
+
name: "NotInitializing",
|
|
196
|
+
type: "error"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
inputs: [],
|
|
200
|
+
name: "ReentrancyGuardReentrantCall",
|
|
201
|
+
type: "error"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
inputs: [
|
|
205
|
+
{
|
|
206
|
+
internalType: "address",
|
|
207
|
+
name: "token",
|
|
208
|
+
type: "address"
|
|
209
|
+
}
|
|
210
|
+
],
|
|
149
211
|
name: "SafeERC20FailedOperation",
|
|
150
212
|
type: "error"
|
|
151
213
|
},
|
|
@@ -262,6 +324,25 @@ var ACP_ABI = [
|
|
|
262
324
|
name: "JobCreated",
|
|
263
325
|
type: "event"
|
|
264
326
|
},
|
|
327
|
+
{
|
|
328
|
+
anonymous: false,
|
|
329
|
+
inputs: [
|
|
330
|
+
{
|
|
331
|
+
indexed: true,
|
|
332
|
+
internalType: "uint256",
|
|
333
|
+
name: "jobId",
|
|
334
|
+
type: "uint256"
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
indexed: true,
|
|
338
|
+
internalType: "address",
|
|
339
|
+
name: "paymentToken",
|
|
340
|
+
type: "address"
|
|
341
|
+
}
|
|
342
|
+
],
|
|
343
|
+
name: "JobPaymentTokenSet",
|
|
344
|
+
type: "event"
|
|
345
|
+
},
|
|
265
346
|
{
|
|
266
347
|
anonymous: false,
|
|
267
348
|
inputs: [
|
|
@@ -277,7 +358,12 @@ var ACP_ABI = [
|
|
|
277
358
|
name: "oldPhase",
|
|
278
359
|
type: "uint8"
|
|
279
360
|
},
|
|
280
|
-
{
|
|
361
|
+
{
|
|
362
|
+
indexed: false,
|
|
363
|
+
internalType: "uint8",
|
|
364
|
+
name: "phase",
|
|
365
|
+
type: "uint8"
|
|
366
|
+
}
|
|
281
367
|
],
|
|
282
368
|
name: "JobPhaseUpdated",
|
|
283
369
|
type: "event"
|
|
@@ -421,8 +507,61 @@ var ACP_ABI = [
|
|
|
421
507
|
name: "memoId",
|
|
422
508
|
type: "uint256"
|
|
423
509
|
},
|
|
424
|
-
{
|
|
425
|
-
|
|
510
|
+
{
|
|
511
|
+
indexed: true,
|
|
512
|
+
internalType: "address",
|
|
513
|
+
name: "sender",
|
|
514
|
+
type: "address"
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
indexed: false,
|
|
518
|
+
internalType: "address",
|
|
519
|
+
name: "token",
|
|
520
|
+
type: "address"
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
indexed: false,
|
|
524
|
+
internalType: "uint256",
|
|
525
|
+
name: "amount",
|
|
526
|
+
type: "uint256"
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
indexed: false,
|
|
530
|
+
internalType: "uint256",
|
|
531
|
+
name: "feeAmount",
|
|
532
|
+
type: "uint256"
|
|
533
|
+
}
|
|
534
|
+
],
|
|
535
|
+
name: "PayableFundsEscrowed",
|
|
536
|
+
type: "event"
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
anonymous: false,
|
|
540
|
+
inputs: [
|
|
541
|
+
{
|
|
542
|
+
indexed: true,
|
|
543
|
+
internalType: "uint256",
|
|
544
|
+
name: "jobId",
|
|
545
|
+
type: "uint256"
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
indexed: true,
|
|
549
|
+
internalType: "uint256",
|
|
550
|
+
name: "memoId",
|
|
551
|
+
type: "uint256"
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
indexed: true,
|
|
555
|
+
internalType: "address",
|
|
556
|
+
name: "from",
|
|
557
|
+
type: "address"
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
indexed: false,
|
|
561
|
+
internalType: "address",
|
|
562
|
+
name: "to",
|
|
563
|
+
type: "address"
|
|
564
|
+
},
|
|
426
565
|
{
|
|
427
566
|
indexed: false,
|
|
428
567
|
internalType: "address",
|
|
@@ -454,8 +593,18 @@ var ACP_ABI = [
|
|
|
454
593
|
name: "memoId",
|
|
455
594
|
type: "uint256"
|
|
456
595
|
},
|
|
457
|
-
{
|
|
458
|
-
|
|
596
|
+
{
|
|
597
|
+
indexed: true,
|
|
598
|
+
internalType: "address",
|
|
599
|
+
name: "from",
|
|
600
|
+
type: "address"
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
indexed: false,
|
|
604
|
+
internalType: "address",
|
|
605
|
+
name: "to",
|
|
606
|
+
type: "address"
|
|
607
|
+
},
|
|
459
608
|
{
|
|
460
609
|
indexed: false,
|
|
461
610
|
internalType: "address",
|
|
@@ -525,7 +674,12 @@ var ACP_ABI = [
|
|
|
525
674
|
{
|
|
526
675
|
anonymous: false,
|
|
527
676
|
inputs: [
|
|
528
|
-
{
|
|
677
|
+
{
|
|
678
|
+
indexed: true,
|
|
679
|
+
internalType: "bytes32",
|
|
680
|
+
name: "role",
|
|
681
|
+
type: "bytes32"
|
|
682
|
+
},
|
|
529
683
|
{
|
|
530
684
|
indexed: true,
|
|
531
685
|
internalType: "bytes32",
|
|
@@ -545,7 +699,12 @@ var ACP_ABI = [
|
|
|
545
699
|
{
|
|
546
700
|
anonymous: false,
|
|
547
701
|
inputs: [
|
|
548
|
-
{
|
|
702
|
+
{
|
|
703
|
+
indexed: true,
|
|
704
|
+
internalType: "bytes32",
|
|
705
|
+
name: "role",
|
|
706
|
+
type: "bytes32"
|
|
707
|
+
},
|
|
549
708
|
{
|
|
550
709
|
indexed: true,
|
|
551
710
|
internalType: "address",
|
|
@@ -565,7 +724,12 @@ var ACP_ABI = [
|
|
|
565
724
|
{
|
|
566
725
|
anonymous: false,
|
|
567
726
|
inputs: [
|
|
568
|
-
{
|
|
727
|
+
{
|
|
728
|
+
indexed: true,
|
|
729
|
+
internalType: "bytes32",
|
|
730
|
+
name: "role",
|
|
731
|
+
type: "bytes32"
|
|
732
|
+
},
|
|
569
733
|
{
|
|
570
734
|
indexed: true,
|
|
571
735
|
internalType: "address",
|
|
@@ -585,87 +749,192 @@ var ACP_ABI = [
|
|
|
585
749
|
{
|
|
586
750
|
inputs: [],
|
|
587
751
|
name: "ADMIN_ROLE",
|
|
588
|
-
outputs: [
|
|
752
|
+
outputs: [
|
|
753
|
+
{
|
|
754
|
+
internalType: "bytes32",
|
|
755
|
+
name: "",
|
|
756
|
+
type: "bytes32"
|
|
757
|
+
}
|
|
758
|
+
],
|
|
589
759
|
stateMutability: "view",
|
|
590
760
|
type: "function"
|
|
591
761
|
},
|
|
592
762
|
{
|
|
593
763
|
inputs: [],
|
|
594
764
|
name: "DEFAULT_ADMIN_ROLE",
|
|
595
|
-
outputs: [
|
|
765
|
+
outputs: [
|
|
766
|
+
{
|
|
767
|
+
internalType: "bytes32",
|
|
768
|
+
name: "",
|
|
769
|
+
type: "bytes32"
|
|
770
|
+
}
|
|
771
|
+
],
|
|
596
772
|
stateMutability: "view",
|
|
597
773
|
type: "function"
|
|
598
774
|
},
|
|
599
775
|
{
|
|
600
776
|
inputs: [],
|
|
601
777
|
name: "PHASE_COMPLETED",
|
|
602
|
-
outputs: [
|
|
778
|
+
outputs: [
|
|
779
|
+
{
|
|
780
|
+
internalType: "uint8",
|
|
781
|
+
name: "",
|
|
782
|
+
type: "uint8"
|
|
783
|
+
}
|
|
784
|
+
],
|
|
603
785
|
stateMutability: "view",
|
|
604
786
|
type: "function"
|
|
605
787
|
},
|
|
606
788
|
{
|
|
607
789
|
inputs: [],
|
|
608
790
|
name: "PHASE_EVALUATION",
|
|
609
|
-
outputs: [
|
|
791
|
+
outputs: [
|
|
792
|
+
{
|
|
793
|
+
internalType: "uint8",
|
|
794
|
+
name: "",
|
|
795
|
+
type: "uint8"
|
|
796
|
+
}
|
|
797
|
+
],
|
|
610
798
|
stateMutability: "view",
|
|
611
799
|
type: "function"
|
|
612
800
|
},
|
|
613
801
|
{
|
|
614
802
|
inputs: [],
|
|
615
803
|
name: "PHASE_EXPIRED",
|
|
616
|
-
outputs: [
|
|
804
|
+
outputs: [
|
|
805
|
+
{
|
|
806
|
+
internalType: "uint8",
|
|
807
|
+
name: "",
|
|
808
|
+
type: "uint8"
|
|
809
|
+
}
|
|
810
|
+
],
|
|
617
811
|
stateMutability: "view",
|
|
618
812
|
type: "function"
|
|
619
813
|
},
|
|
620
814
|
{
|
|
621
815
|
inputs: [],
|
|
622
816
|
name: "PHASE_NEGOTIATION",
|
|
623
|
-
outputs: [
|
|
817
|
+
outputs: [
|
|
818
|
+
{
|
|
819
|
+
internalType: "uint8",
|
|
820
|
+
name: "",
|
|
821
|
+
type: "uint8"
|
|
822
|
+
}
|
|
823
|
+
],
|
|
624
824
|
stateMutability: "view",
|
|
625
825
|
type: "function"
|
|
626
826
|
},
|
|
627
827
|
{
|
|
628
828
|
inputs: [],
|
|
629
829
|
name: "PHASE_REJECTED",
|
|
630
|
-
outputs: [
|
|
830
|
+
outputs: [
|
|
831
|
+
{
|
|
832
|
+
internalType: "uint8",
|
|
833
|
+
name: "",
|
|
834
|
+
type: "uint8"
|
|
835
|
+
}
|
|
836
|
+
],
|
|
631
837
|
stateMutability: "view",
|
|
632
838
|
type: "function"
|
|
633
839
|
},
|
|
634
840
|
{
|
|
635
841
|
inputs: [],
|
|
636
842
|
name: "PHASE_REQUEST",
|
|
637
|
-
outputs: [
|
|
843
|
+
outputs: [
|
|
844
|
+
{
|
|
845
|
+
internalType: "uint8",
|
|
846
|
+
name: "",
|
|
847
|
+
type: "uint8"
|
|
848
|
+
}
|
|
849
|
+
],
|
|
638
850
|
stateMutability: "view",
|
|
639
851
|
type: "function"
|
|
640
852
|
},
|
|
641
853
|
{
|
|
642
854
|
inputs: [],
|
|
643
855
|
name: "PHASE_TRANSACTION",
|
|
644
|
-
outputs: [
|
|
856
|
+
outputs: [
|
|
857
|
+
{
|
|
858
|
+
internalType: "uint8",
|
|
859
|
+
name: "",
|
|
860
|
+
type: "uint8"
|
|
861
|
+
}
|
|
862
|
+
],
|
|
645
863
|
stateMutability: "view",
|
|
646
864
|
type: "function"
|
|
647
865
|
},
|
|
648
866
|
{
|
|
649
867
|
inputs: [],
|
|
650
868
|
name: "TOTAL_PHASES",
|
|
651
|
-
outputs: [
|
|
869
|
+
outputs: [
|
|
870
|
+
{
|
|
871
|
+
internalType: "uint8",
|
|
872
|
+
name: "",
|
|
873
|
+
type: "uint8"
|
|
874
|
+
}
|
|
875
|
+
],
|
|
652
876
|
stateMutability: "view",
|
|
653
877
|
type: "function"
|
|
654
878
|
},
|
|
655
879
|
{
|
|
656
880
|
inputs: [
|
|
657
|
-
{
|
|
881
|
+
{
|
|
882
|
+
internalType: "address",
|
|
883
|
+
name: "account",
|
|
884
|
+
type: "address"
|
|
885
|
+
},
|
|
658
886
|
{
|
|
659
887
|
components: [
|
|
660
|
-
{
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
{
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
888
|
+
{
|
|
889
|
+
internalType: "uint256",
|
|
890
|
+
name: "id",
|
|
891
|
+
type: "uint256"
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
internalType: "address",
|
|
895
|
+
name: "client",
|
|
896
|
+
type: "address"
|
|
897
|
+
},
|
|
898
|
+
{
|
|
899
|
+
internalType: "address",
|
|
900
|
+
name: "provider",
|
|
901
|
+
type: "address"
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
internalType: "uint256",
|
|
905
|
+
name: "budget",
|
|
906
|
+
type: "uint256"
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
internalType: "uint256",
|
|
910
|
+
name: "amountClaimed",
|
|
911
|
+
type: "uint256"
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
internalType: "uint8",
|
|
915
|
+
name: "phase",
|
|
916
|
+
type: "uint8"
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
internalType: "uint256",
|
|
920
|
+
name: "memoCount",
|
|
921
|
+
type: "uint256"
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
internalType: "uint256",
|
|
925
|
+
name: "expiredAt",
|
|
926
|
+
type: "uint256"
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
internalType: "address",
|
|
930
|
+
name: "evaluator",
|
|
931
|
+
type: "address"
|
|
932
|
+
},
|
|
933
|
+
{
|
|
934
|
+
internalType: "contract IERC20",
|
|
935
|
+
name: "jobPaymentToken",
|
|
936
|
+
type: "address"
|
|
937
|
+
}
|
|
669
938
|
],
|
|
670
939
|
internalType: "struct ACPSimple.Job",
|
|
671
940
|
name: "job",
|
|
@@ -673,12 +942,24 @@ var ACP_ABI = [
|
|
|
673
942
|
}
|
|
674
943
|
],
|
|
675
944
|
name: "canSign",
|
|
676
|
-
outputs: [
|
|
945
|
+
outputs: [
|
|
946
|
+
{
|
|
947
|
+
internalType: "bool",
|
|
948
|
+
name: "",
|
|
949
|
+
type: "bool"
|
|
950
|
+
}
|
|
951
|
+
],
|
|
677
952
|
stateMutability: "pure",
|
|
678
953
|
type: "function"
|
|
679
954
|
},
|
|
680
955
|
{
|
|
681
|
-
inputs: [
|
|
956
|
+
inputs: [
|
|
957
|
+
{
|
|
958
|
+
internalType: "uint256",
|
|
959
|
+
name: "id",
|
|
960
|
+
type: "uint256"
|
|
961
|
+
}
|
|
962
|
+
],
|
|
682
963
|
name: "claimBudget",
|
|
683
964
|
outputs: [],
|
|
684
965
|
stateMutability: "nonpayable",
|
|
@@ -686,40 +967,104 @@ var ACP_ABI = [
|
|
|
686
967
|
},
|
|
687
968
|
{
|
|
688
969
|
inputs: [
|
|
689
|
-
{
|
|
690
|
-
|
|
691
|
-
|
|
970
|
+
{
|
|
971
|
+
internalType: "address",
|
|
972
|
+
name: "provider",
|
|
973
|
+
type: "address"
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
internalType: "address",
|
|
977
|
+
name: "evaluator",
|
|
978
|
+
type: "address"
|
|
979
|
+
},
|
|
980
|
+
{
|
|
981
|
+
internalType: "uint256",
|
|
982
|
+
name: "expiredAt",
|
|
983
|
+
type: "uint256"
|
|
984
|
+
}
|
|
692
985
|
],
|
|
693
986
|
name: "createJob",
|
|
694
|
-
outputs: [
|
|
987
|
+
outputs: [
|
|
988
|
+
{
|
|
989
|
+
internalType: "uint256",
|
|
990
|
+
name: "",
|
|
991
|
+
type: "uint256"
|
|
992
|
+
}
|
|
993
|
+
],
|
|
695
994
|
stateMutability: "nonpayable",
|
|
696
995
|
type: "function"
|
|
697
996
|
},
|
|
698
997
|
{
|
|
699
998
|
inputs: [
|
|
700
|
-
{
|
|
701
|
-
|
|
999
|
+
{
|
|
1000
|
+
internalType: "uint256",
|
|
1001
|
+
name: "jobId",
|
|
1002
|
+
type: "uint256"
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
internalType: "string",
|
|
1006
|
+
name: "content",
|
|
1007
|
+
type: "string"
|
|
1008
|
+
},
|
|
702
1009
|
{
|
|
703
1010
|
internalType: "enum InteractionLedger.MemoType",
|
|
704
1011
|
name: "memoType",
|
|
705
1012
|
type: "uint8"
|
|
706
1013
|
},
|
|
707
|
-
{
|
|
708
|
-
|
|
1014
|
+
{
|
|
1015
|
+
internalType: "bool",
|
|
1016
|
+
name: "isSecured",
|
|
1017
|
+
type: "bool"
|
|
1018
|
+
},
|
|
1019
|
+
{
|
|
1020
|
+
internalType: "uint8",
|
|
1021
|
+
name: "nextPhase",
|
|
1022
|
+
type: "uint8"
|
|
1023
|
+
}
|
|
709
1024
|
],
|
|
710
1025
|
name: "createMemo",
|
|
711
|
-
outputs: [
|
|
1026
|
+
outputs: [
|
|
1027
|
+
{
|
|
1028
|
+
internalType: "uint256",
|
|
1029
|
+
name: "",
|
|
1030
|
+
type: "uint256"
|
|
1031
|
+
}
|
|
1032
|
+
],
|
|
712
1033
|
stateMutability: "nonpayable",
|
|
713
1034
|
type: "function"
|
|
714
1035
|
},
|
|
715
1036
|
{
|
|
716
1037
|
inputs: [
|
|
717
|
-
{
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
{
|
|
1038
|
+
{
|
|
1039
|
+
internalType: "uint256",
|
|
1040
|
+
name: "jobId",
|
|
1041
|
+
type: "uint256"
|
|
1042
|
+
},
|
|
1043
|
+
{
|
|
1044
|
+
internalType: "string",
|
|
1045
|
+
name: "content",
|
|
1046
|
+
type: "string"
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
internalType: "address",
|
|
1050
|
+
name: "token",
|
|
1051
|
+
type: "address"
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
internalType: "uint256",
|
|
1055
|
+
name: "amount",
|
|
1056
|
+
type: "uint256"
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
internalType: "address",
|
|
1060
|
+
name: "recipient",
|
|
1061
|
+
type: "address"
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
internalType: "uint256",
|
|
1065
|
+
name: "feeAmount",
|
|
1066
|
+
type: "uint256"
|
|
1067
|
+
},
|
|
723
1068
|
{
|
|
724
1069
|
internalType: "enum ACPSimple.FeeType",
|
|
725
1070
|
name: "feeType",
|
|
@@ -730,88 +1075,198 @@ var ACP_ABI = [
|
|
|
730
1075
|
name: "memoType",
|
|
731
1076
|
type: "uint8"
|
|
732
1077
|
},
|
|
733
|
-
{
|
|
734
|
-
|
|
1078
|
+
{
|
|
1079
|
+
internalType: "uint8",
|
|
1080
|
+
name: "nextPhase",
|
|
1081
|
+
type: "uint8"
|
|
1082
|
+
},
|
|
1083
|
+
{
|
|
1084
|
+
internalType: "uint256",
|
|
1085
|
+
name: "expiredAt",
|
|
1086
|
+
type: "uint256"
|
|
1087
|
+
}
|
|
735
1088
|
],
|
|
736
1089
|
name: "createPayableMemo",
|
|
737
|
-
outputs: [
|
|
1090
|
+
outputs: [
|
|
1091
|
+
{
|
|
1092
|
+
internalType: "uint256",
|
|
1093
|
+
name: "",
|
|
1094
|
+
type: "uint256"
|
|
1095
|
+
}
|
|
1096
|
+
],
|
|
738
1097
|
stateMutability: "nonpayable",
|
|
739
1098
|
type: "function"
|
|
740
1099
|
},
|
|
741
1100
|
{
|
|
742
1101
|
inputs: [],
|
|
743
1102
|
name: "evaluatorFeeBP",
|
|
744
|
-
outputs: [
|
|
1103
|
+
outputs: [
|
|
1104
|
+
{
|
|
1105
|
+
internalType: "uint256",
|
|
1106
|
+
name: "",
|
|
1107
|
+
type: "uint256"
|
|
1108
|
+
}
|
|
1109
|
+
],
|
|
745
1110
|
stateMutability: "view",
|
|
746
1111
|
type: "function"
|
|
747
1112
|
},
|
|
748
1113
|
{
|
|
749
1114
|
inputs: [
|
|
750
|
-
{
|
|
751
|
-
|
|
752
|
-
|
|
1115
|
+
{
|
|
1116
|
+
internalType: "uint256",
|
|
1117
|
+
name: "jobId",
|
|
1118
|
+
type: "uint256"
|
|
1119
|
+
},
|
|
1120
|
+
{
|
|
1121
|
+
internalType: "uint256",
|
|
1122
|
+
name: "offset",
|
|
1123
|
+
type: "uint256"
|
|
1124
|
+
},
|
|
1125
|
+
{
|
|
1126
|
+
internalType: "uint256",
|
|
1127
|
+
name: "limit",
|
|
1128
|
+
type: "uint256"
|
|
1129
|
+
}
|
|
753
1130
|
],
|
|
754
1131
|
name: "getAllMemos",
|
|
755
1132
|
outputs: [
|
|
756
1133
|
{
|
|
757
1134
|
components: [
|
|
758
|
-
{
|
|
1135
|
+
{
|
|
1136
|
+
internalType: "string",
|
|
1137
|
+
name: "content",
|
|
1138
|
+
type: "string"
|
|
1139
|
+
},
|
|
759
1140
|
{
|
|
760
1141
|
internalType: "enum InteractionLedger.MemoType",
|
|
761
1142
|
name: "memoType",
|
|
762
1143
|
type: "uint8"
|
|
763
1144
|
},
|
|
764
|
-
{
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
1145
|
+
{
|
|
1146
|
+
internalType: "bool",
|
|
1147
|
+
name: "isSecured",
|
|
1148
|
+
type: "bool"
|
|
1149
|
+
},
|
|
1150
|
+
{
|
|
1151
|
+
internalType: "uint8",
|
|
1152
|
+
name: "nextPhase",
|
|
1153
|
+
type: "uint8"
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
internalType: "uint256",
|
|
1157
|
+
name: "jobId",
|
|
1158
|
+
type: "uint256"
|
|
1159
|
+
},
|
|
1160
|
+
{
|
|
1161
|
+
internalType: "address",
|
|
1162
|
+
name: "sender",
|
|
1163
|
+
type: "address"
|
|
1164
|
+
}
|
|
768
1165
|
],
|
|
769
1166
|
internalType: "struct InteractionLedger.Memo[]",
|
|
770
1167
|
name: "",
|
|
771
1168
|
type: "tuple[]"
|
|
772
1169
|
},
|
|
773
|
-
{
|
|
1170
|
+
{
|
|
1171
|
+
internalType: "uint256",
|
|
1172
|
+
name: "total",
|
|
1173
|
+
type: "uint256"
|
|
1174
|
+
}
|
|
774
1175
|
],
|
|
775
1176
|
stateMutability: "view",
|
|
776
1177
|
type: "function"
|
|
777
1178
|
},
|
|
778
1179
|
{
|
|
779
1180
|
inputs: [
|
|
780
|
-
{
|
|
781
|
-
|
|
1181
|
+
{
|
|
1182
|
+
internalType: "uint256",
|
|
1183
|
+
name: "jobId",
|
|
1184
|
+
type: "uint256"
|
|
1185
|
+
},
|
|
1186
|
+
{
|
|
1187
|
+
internalType: "uint8",
|
|
1188
|
+
name: "phase",
|
|
1189
|
+
type: "uint8"
|
|
1190
|
+
}
|
|
782
1191
|
],
|
|
783
1192
|
name: "getJobPhaseMemoIds",
|
|
784
|
-
outputs: [
|
|
1193
|
+
outputs: [
|
|
1194
|
+
{
|
|
1195
|
+
internalType: "uint256[]",
|
|
1196
|
+
name: "",
|
|
1197
|
+
type: "uint256[]"
|
|
1198
|
+
}
|
|
1199
|
+
],
|
|
785
1200
|
stateMutability: "view",
|
|
786
1201
|
type: "function"
|
|
787
1202
|
},
|
|
788
1203
|
{
|
|
789
1204
|
inputs: [
|
|
790
|
-
{
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
1205
|
+
{
|
|
1206
|
+
internalType: "uint256",
|
|
1207
|
+
name: "jobId",
|
|
1208
|
+
type: "uint256"
|
|
1209
|
+
},
|
|
1210
|
+
{
|
|
1211
|
+
internalType: "uint8",
|
|
1212
|
+
name: "phase",
|
|
1213
|
+
type: "uint8"
|
|
1214
|
+
},
|
|
1215
|
+
{
|
|
1216
|
+
internalType: "uint256",
|
|
1217
|
+
name: "offset",
|
|
1218
|
+
type: "uint256"
|
|
1219
|
+
},
|
|
1220
|
+
{
|
|
1221
|
+
internalType: "uint256",
|
|
1222
|
+
name: "limit",
|
|
1223
|
+
type: "uint256"
|
|
1224
|
+
}
|
|
794
1225
|
],
|
|
795
1226
|
name: "getMemosForPhase",
|
|
796
1227
|
outputs: [
|
|
797
1228
|
{
|
|
798
1229
|
components: [
|
|
799
|
-
{
|
|
1230
|
+
{
|
|
1231
|
+
internalType: "string",
|
|
1232
|
+
name: "content",
|
|
1233
|
+
type: "string"
|
|
1234
|
+
},
|
|
800
1235
|
{
|
|
801
1236
|
internalType: "enum InteractionLedger.MemoType",
|
|
802
1237
|
name: "memoType",
|
|
803
1238
|
type: "uint8"
|
|
804
1239
|
},
|
|
805
|
-
{
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
1240
|
+
{
|
|
1241
|
+
internalType: "bool",
|
|
1242
|
+
name: "isSecured",
|
|
1243
|
+
type: "bool"
|
|
1244
|
+
},
|
|
1245
|
+
{
|
|
1246
|
+
internalType: "uint8",
|
|
1247
|
+
name: "nextPhase",
|
|
1248
|
+
type: "uint8"
|
|
1249
|
+
},
|
|
1250
|
+
{
|
|
1251
|
+
internalType: "uint256",
|
|
1252
|
+
name: "jobId",
|
|
1253
|
+
type: "uint256"
|
|
1254
|
+
},
|
|
1255
|
+
{
|
|
1256
|
+
internalType: "address",
|
|
1257
|
+
name: "sender",
|
|
1258
|
+
type: "address"
|
|
1259
|
+
}
|
|
809
1260
|
],
|
|
810
1261
|
internalType: "struct InteractionLedger.Memo[]",
|
|
811
1262
|
name: "",
|
|
812
1263
|
type: "tuple[]"
|
|
813
1264
|
},
|
|
814
|
-
{
|
|
1265
|
+
{
|
|
1266
|
+
internalType: "uint256",
|
|
1267
|
+
name: "total",
|
|
1268
|
+
type: "uint256"
|
|
1269
|
+
}
|
|
815
1270
|
],
|
|
816
1271
|
stateMutability: "view",
|
|
817
1272
|
type: "function"
|
|
@@ -819,21 +1274,47 @@ var ACP_ABI = [
|
|
|
819
1274
|
{
|
|
820
1275
|
inputs: [],
|
|
821
1276
|
name: "getPhases",
|
|
822
|
-
outputs: [
|
|
1277
|
+
outputs: [
|
|
1278
|
+
{
|
|
1279
|
+
internalType: "string[7]",
|
|
1280
|
+
name: "",
|
|
1281
|
+
type: "string[7]"
|
|
1282
|
+
}
|
|
1283
|
+
],
|
|
823
1284
|
stateMutability: "pure",
|
|
824
1285
|
type: "function"
|
|
825
1286
|
},
|
|
826
1287
|
{
|
|
827
|
-
inputs: [
|
|
1288
|
+
inputs: [
|
|
1289
|
+
{
|
|
1290
|
+
internalType: "bytes32",
|
|
1291
|
+
name: "role",
|
|
1292
|
+
type: "bytes32"
|
|
1293
|
+
}
|
|
1294
|
+
],
|
|
828
1295
|
name: "getRoleAdmin",
|
|
829
|
-
outputs: [
|
|
1296
|
+
outputs: [
|
|
1297
|
+
{
|
|
1298
|
+
internalType: "bytes32",
|
|
1299
|
+
name: "",
|
|
1300
|
+
type: "bytes32"
|
|
1301
|
+
}
|
|
1302
|
+
],
|
|
830
1303
|
stateMutability: "view",
|
|
831
1304
|
type: "function"
|
|
832
1305
|
},
|
|
833
1306
|
{
|
|
834
1307
|
inputs: [
|
|
835
|
-
{
|
|
836
|
-
|
|
1308
|
+
{
|
|
1309
|
+
internalType: "bytes32",
|
|
1310
|
+
name: "role",
|
|
1311
|
+
type: "bytes32"
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
internalType: "address",
|
|
1315
|
+
name: "account",
|
|
1316
|
+
type: "address"
|
|
1317
|
+
}
|
|
837
1318
|
],
|
|
838
1319
|
name: "grantRole",
|
|
839
1320
|
outputs: [],
|
|
@@ -842,20 +1323,50 @@ var ACP_ABI = [
|
|
|
842
1323
|
},
|
|
843
1324
|
{
|
|
844
1325
|
inputs: [
|
|
845
|
-
{
|
|
846
|
-
|
|
1326
|
+
{
|
|
1327
|
+
internalType: "bytes32",
|
|
1328
|
+
name: "role",
|
|
1329
|
+
type: "bytes32"
|
|
1330
|
+
},
|
|
1331
|
+
{
|
|
1332
|
+
internalType: "address",
|
|
1333
|
+
name: "account",
|
|
1334
|
+
type: "address"
|
|
1335
|
+
}
|
|
847
1336
|
],
|
|
848
1337
|
name: "hasRole",
|
|
849
|
-
outputs: [
|
|
1338
|
+
outputs: [
|
|
1339
|
+
{
|
|
1340
|
+
internalType: "bool",
|
|
1341
|
+
name: "",
|
|
1342
|
+
type: "bool"
|
|
1343
|
+
}
|
|
1344
|
+
],
|
|
850
1345
|
stateMutability: "view",
|
|
851
1346
|
type: "function"
|
|
852
1347
|
},
|
|
853
1348
|
{
|
|
854
1349
|
inputs: [
|
|
855
|
-
{
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
1350
|
+
{
|
|
1351
|
+
internalType: "address",
|
|
1352
|
+
name: "paymentTokenAddress",
|
|
1353
|
+
type: "address"
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
internalType: "uint256",
|
|
1357
|
+
name: "evaluatorFeeBP_",
|
|
1358
|
+
type: "uint256"
|
|
1359
|
+
},
|
|
1360
|
+
{
|
|
1361
|
+
internalType: "uint256",
|
|
1362
|
+
name: "platformFeeBP_",
|
|
1363
|
+
type: "uint256"
|
|
1364
|
+
},
|
|
1365
|
+
{
|
|
1366
|
+
internalType: "address",
|
|
1367
|
+
name: "platformTreasury_",
|
|
1368
|
+
type: "address"
|
|
1369
|
+
}
|
|
859
1370
|
],
|
|
860
1371
|
name: "initialize",
|
|
861
1372
|
outputs: [],
|
|
@@ -864,256 +1375,794 @@ var ACP_ABI = [
|
|
|
864
1375
|
},
|
|
865
1376
|
{
|
|
866
1377
|
inputs: [
|
|
867
|
-
{
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
1378
|
+
{
|
|
1379
|
+
internalType: "uint256",
|
|
1380
|
+
name: "jobId",
|
|
1381
|
+
type: "uint256"
|
|
1382
|
+
},
|
|
1383
|
+
{
|
|
1384
|
+
internalType: "address",
|
|
1385
|
+
name: "account",
|
|
1386
|
+
type: "address"
|
|
1387
|
+
}
|
|
1388
|
+
],
|
|
1389
|
+
name: "isJobEvaluator",
|
|
1390
|
+
outputs: [
|
|
1391
|
+
{
|
|
1392
|
+
internalType: "bool",
|
|
1393
|
+
name: "",
|
|
1394
|
+
type: "bool"
|
|
1395
|
+
}
|
|
1396
|
+
],
|
|
1397
|
+
stateMutability: "view",
|
|
1398
|
+
type: "function"
|
|
1399
|
+
},
|
|
1400
|
+
{
|
|
1401
|
+
inputs: [
|
|
1402
|
+
{
|
|
1403
|
+
internalType: "uint256",
|
|
1404
|
+
name: "memoId",
|
|
1405
|
+
type: "uint256"
|
|
1406
|
+
}
|
|
1407
|
+
],
|
|
1408
|
+
name: "isPayableMemo",
|
|
1409
|
+
outputs: [
|
|
1410
|
+
{
|
|
1411
|
+
internalType: "bool",
|
|
1412
|
+
name: "",
|
|
1413
|
+
type: "bool"
|
|
1414
|
+
}
|
|
1415
|
+
],
|
|
879
1416
|
stateMutability: "view",
|
|
880
1417
|
type: "function"
|
|
881
1418
|
},
|
|
882
1419
|
{
|
|
883
|
-
inputs: [
|
|
1420
|
+
inputs: [
|
|
1421
|
+
{
|
|
1422
|
+
internalType: "uint256",
|
|
1423
|
+
name: "jobId",
|
|
1424
|
+
type: "uint256"
|
|
1425
|
+
}
|
|
1426
|
+
],
|
|
884
1427
|
name: "jobAdditionalFees",
|
|
885
|
-
outputs: [
|
|
1428
|
+
outputs: [
|
|
1429
|
+
{
|
|
1430
|
+
internalType: "uint256",
|
|
1431
|
+
name: "",
|
|
1432
|
+
type: "uint256"
|
|
1433
|
+
}
|
|
1434
|
+
],
|
|
1435
|
+
stateMutability: "view",
|
|
1436
|
+
type: "function"
|
|
1437
|
+
},
|
|
1438
|
+
{
|
|
1439
|
+
inputs: [],
|
|
1440
|
+
name: "jobCounter",
|
|
1441
|
+
outputs: [
|
|
1442
|
+
{
|
|
1443
|
+
internalType: "uint256",
|
|
1444
|
+
name: "",
|
|
1445
|
+
type: "uint256"
|
|
1446
|
+
}
|
|
1447
|
+
],
|
|
1448
|
+
stateMutability: "view",
|
|
1449
|
+
type: "function"
|
|
1450
|
+
},
|
|
1451
|
+
{
|
|
1452
|
+
inputs: [
|
|
1453
|
+
{
|
|
1454
|
+
internalType: "uint256",
|
|
1455
|
+
name: "jobId",
|
|
1456
|
+
type: "uint256"
|
|
1457
|
+
},
|
|
1458
|
+
{
|
|
1459
|
+
internalType: "uint8",
|
|
1460
|
+
name: "phase",
|
|
1461
|
+
type: "uint8"
|
|
1462
|
+
},
|
|
1463
|
+
{
|
|
1464
|
+
internalType: "uint256",
|
|
1465
|
+
name: "",
|
|
1466
|
+
type: "uint256"
|
|
1467
|
+
}
|
|
1468
|
+
],
|
|
1469
|
+
name: "jobMemoIds",
|
|
1470
|
+
outputs: [
|
|
1471
|
+
{
|
|
1472
|
+
internalType: "uint256",
|
|
1473
|
+
name: "memoIds",
|
|
1474
|
+
type: "uint256"
|
|
1475
|
+
}
|
|
1476
|
+
],
|
|
1477
|
+
stateMutability: "view",
|
|
1478
|
+
type: "function"
|
|
1479
|
+
},
|
|
1480
|
+
{
|
|
1481
|
+
inputs: [
|
|
1482
|
+
{
|
|
1483
|
+
internalType: "uint256",
|
|
1484
|
+
name: "",
|
|
1485
|
+
type: "uint256"
|
|
1486
|
+
}
|
|
1487
|
+
],
|
|
1488
|
+
name: "jobs",
|
|
1489
|
+
outputs: [
|
|
1490
|
+
{
|
|
1491
|
+
internalType: "uint256",
|
|
1492
|
+
name: "id",
|
|
1493
|
+
type: "uint256"
|
|
1494
|
+
},
|
|
1495
|
+
{
|
|
1496
|
+
internalType: "address",
|
|
1497
|
+
name: "client",
|
|
1498
|
+
type: "address"
|
|
1499
|
+
},
|
|
1500
|
+
{
|
|
1501
|
+
internalType: "address",
|
|
1502
|
+
name: "provider",
|
|
1503
|
+
type: "address"
|
|
1504
|
+
},
|
|
1505
|
+
{
|
|
1506
|
+
internalType: "uint256",
|
|
1507
|
+
name: "budget",
|
|
1508
|
+
type: "uint256"
|
|
1509
|
+
},
|
|
1510
|
+
{
|
|
1511
|
+
internalType: "uint256",
|
|
1512
|
+
name: "amountClaimed",
|
|
1513
|
+
type: "uint256"
|
|
1514
|
+
},
|
|
1515
|
+
{
|
|
1516
|
+
internalType: "uint8",
|
|
1517
|
+
name: "phase",
|
|
1518
|
+
type: "uint8"
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
internalType: "uint256",
|
|
1522
|
+
name: "memoCount",
|
|
1523
|
+
type: "uint256"
|
|
1524
|
+
},
|
|
1525
|
+
{
|
|
1526
|
+
internalType: "uint256",
|
|
1527
|
+
name: "expiredAt",
|
|
1528
|
+
type: "uint256"
|
|
1529
|
+
},
|
|
1530
|
+
{
|
|
1531
|
+
internalType: "address",
|
|
1532
|
+
name: "evaluator",
|
|
1533
|
+
type: "address"
|
|
1534
|
+
},
|
|
1535
|
+
{
|
|
1536
|
+
internalType: "contract IERC20",
|
|
1537
|
+
name: "jobPaymentToken",
|
|
1538
|
+
type: "address"
|
|
1539
|
+
}
|
|
1540
|
+
],
|
|
1541
|
+
stateMutability: "view",
|
|
1542
|
+
type: "function"
|
|
1543
|
+
},
|
|
1544
|
+
{
|
|
1545
|
+
inputs: [],
|
|
1546
|
+
name: "memoCounter",
|
|
1547
|
+
outputs: [
|
|
1548
|
+
{
|
|
1549
|
+
internalType: "uint256",
|
|
1550
|
+
name: "",
|
|
1551
|
+
type: "uint256"
|
|
1552
|
+
}
|
|
1553
|
+
],
|
|
1554
|
+
stateMutability: "view",
|
|
1555
|
+
type: "function"
|
|
1556
|
+
},
|
|
1557
|
+
{
|
|
1558
|
+
inputs: [
|
|
1559
|
+
{
|
|
1560
|
+
internalType: "uint256",
|
|
1561
|
+
name: "memoId",
|
|
1562
|
+
type: "uint256"
|
|
1563
|
+
}
|
|
1564
|
+
],
|
|
1565
|
+
name: "memoExpiredAt",
|
|
1566
|
+
outputs: [
|
|
1567
|
+
{
|
|
1568
|
+
internalType: "uint256",
|
|
1569
|
+
name: "expiredAt",
|
|
1570
|
+
type: "uint256"
|
|
1571
|
+
}
|
|
1572
|
+
],
|
|
1573
|
+
stateMutability: "view",
|
|
1574
|
+
type: "function"
|
|
1575
|
+
},
|
|
1576
|
+
{
|
|
1577
|
+
inputs: [
|
|
1578
|
+
{
|
|
1579
|
+
internalType: "uint256",
|
|
1580
|
+
name: "",
|
|
1581
|
+
type: "uint256"
|
|
1582
|
+
}
|
|
1583
|
+
],
|
|
1584
|
+
name: "memos",
|
|
1585
|
+
outputs: [
|
|
1586
|
+
{
|
|
1587
|
+
internalType: "string",
|
|
1588
|
+
name: "content",
|
|
1589
|
+
type: "string"
|
|
1590
|
+
},
|
|
1591
|
+
{
|
|
1592
|
+
internalType: "enum InteractionLedger.MemoType",
|
|
1593
|
+
name: "memoType",
|
|
1594
|
+
type: "uint8"
|
|
1595
|
+
},
|
|
1596
|
+
{
|
|
1597
|
+
internalType: "bool",
|
|
1598
|
+
name: "isSecured",
|
|
1599
|
+
type: "bool"
|
|
1600
|
+
},
|
|
1601
|
+
{
|
|
1602
|
+
internalType: "uint8",
|
|
1603
|
+
name: "nextPhase",
|
|
1604
|
+
type: "uint8"
|
|
1605
|
+
},
|
|
1606
|
+
{
|
|
1607
|
+
internalType: "uint256",
|
|
1608
|
+
name: "jobId",
|
|
1609
|
+
type: "uint256"
|
|
1610
|
+
},
|
|
1611
|
+
{
|
|
1612
|
+
internalType: "address",
|
|
1613
|
+
name: "sender",
|
|
1614
|
+
type: "address"
|
|
1615
|
+
}
|
|
1616
|
+
],
|
|
1617
|
+
stateMutability: "view",
|
|
1618
|
+
type: "function"
|
|
1619
|
+
},
|
|
1620
|
+
{
|
|
1621
|
+
inputs: [],
|
|
1622
|
+
name: "numEvaluatorsPerJob",
|
|
1623
|
+
outputs: [
|
|
1624
|
+
{
|
|
1625
|
+
internalType: "uint8",
|
|
1626
|
+
name: "",
|
|
1627
|
+
type: "uint8"
|
|
1628
|
+
}
|
|
1629
|
+
],
|
|
886
1630
|
stateMutability: "view",
|
|
887
1631
|
type: "function"
|
|
888
1632
|
},
|
|
889
1633
|
{
|
|
890
|
-
inputs: [
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
1634
|
+
inputs: [
|
|
1635
|
+
{
|
|
1636
|
+
internalType: "uint256",
|
|
1637
|
+
name: "memoId",
|
|
1638
|
+
type: "uint256"
|
|
1639
|
+
}
|
|
1640
|
+
],
|
|
1641
|
+
name: "payableDetails",
|
|
1642
|
+
outputs: [
|
|
1643
|
+
{
|
|
1644
|
+
internalType: "address",
|
|
1645
|
+
name: "token",
|
|
1646
|
+
type: "address"
|
|
1647
|
+
},
|
|
1648
|
+
{
|
|
1649
|
+
internalType: "uint256",
|
|
1650
|
+
name: "amount",
|
|
1651
|
+
type: "uint256"
|
|
1652
|
+
},
|
|
1653
|
+
{
|
|
1654
|
+
internalType: "address",
|
|
1655
|
+
name: "recipient",
|
|
1656
|
+
type: "address"
|
|
1657
|
+
},
|
|
1658
|
+
{
|
|
1659
|
+
internalType: "uint256",
|
|
1660
|
+
name: "feeAmount",
|
|
1661
|
+
type: "uint256"
|
|
1662
|
+
},
|
|
1663
|
+
{
|
|
1664
|
+
internalType: "enum ACPSimple.FeeType",
|
|
1665
|
+
name: "feeType",
|
|
1666
|
+
type: "uint8"
|
|
1667
|
+
},
|
|
1668
|
+
{
|
|
1669
|
+
internalType: "bool",
|
|
1670
|
+
name: "isExecuted",
|
|
1671
|
+
type: "bool"
|
|
1672
|
+
}
|
|
1673
|
+
],
|
|
1674
|
+
stateMutability: "view",
|
|
1675
|
+
type: "function"
|
|
1676
|
+
},
|
|
1677
|
+
{
|
|
1678
|
+
inputs: [],
|
|
1679
|
+
name: "paymentToken",
|
|
1680
|
+
outputs: [
|
|
1681
|
+
{
|
|
1682
|
+
internalType: "contract IERC20",
|
|
1683
|
+
name: "",
|
|
1684
|
+
type: "address"
|
|
1685
|
+
}
|
|
1686
|
+
],
|
|
1687
|
+
stateMutability: "view",
|
|
1688
|
+
type: "function"
|
|
1689
|
+
},
|
|
1690
|
+
{
|
|
1691
|
+
inputs: [],
|
|
1692
|
+
name: "platformFeeBP",
|
|
1693
|
+
outputs: [
|
|
1694
|
+
{
|
|
1695
|
+
internalType: "uint256",
|
|
1696
|
+
name: "",
|
|
1697
|
+
type: "uint256"
|
|
1698
|
+
}
|
|
1699
|
+
],
|
|
1700
|
+
stateMutability: "view",
|
|
1701
|
+
type: "function"
|
|
1702
|
+
},
|
|
1703
|
+
{
|
|
1704
|
+
inputs: [],
|
|
1705
|
+
name: "platformTreasury",
|
|
1706
|
+
outputs: [
|
|
1707
|
+
{
|
|
1708
|
+
internalType: "address",
|
|
1709
|
+
name: "",
|
|
1710
|
+
type: "address"
|
|
1711
|
+
}
|
|
1712
|
+
],
|
|
1713
|
+
stateMutability: "view",
|
|
1714
|
+
type: "function"
|
|
1715
|
+
},
|
|
1716
|
+
{
|
|
1717
|
+
inputs: [
|
|
1718
|
+
{
|
|
1719
|
+
internalType: "bytes32",
|
|
1720
|
+
name: "role",
|
|
1721
|
+
type: "bytes32"
|
|
1722
|
+
},
|
|
1723
|
+
{
|
|
1724
|
+
internalType: "address",
|
|
1725
|
+
name: "callerConfirmation",
|
|
1726
|
+
type: "address"
|
|
1727
|
+
}
|
|
1728
|
+
],
|
|
1729
|
+
name: "renounceRole",
|
|
1730
|
+
outputs: [],
|
|
1731
|
+
stateMutability: "nonpayable",
|
|
1732
|
+
type: "function"
|
|
1733
|
+
},
|
|
1734
|
+
{
|
|
1735
|
+
inputs: [
|
|
1736
|
+
{
|
|
1737
|
+
internalType: "bytes32",
|
|
1738
|
+
name: "role",
|
|
1739
|
+
type: "bytes32"
|
|
1740
|
+
},
|
|
1741
|
+
{
|
|
1742
|
+
internalType: "address",
|
|
1743
|
+
name: "account",
|
|
1744
|
+
type: "address"
|
|
1745
|
+
}
|
|
1746
|
+
],
|
|
1747
|
+
name: "revokeRole",
|
|
1748
|
+
outputs: [],
|
|
1749
|
+
stateMutability: "nonpayable",
|
|
1750
|
+
type: "function"
|
|
1751
|
+
},
|
|
1752
|
+
{
|
|
1753
|
+
inputs: [
|
|
1754
|
+
{
|
|
1755
|
+
internalType: "uint256",
|
|
1756
|
+
name: "jobId",
|
|
1757
|
+
type: "uint256"
|
|
1758
|
+
},
|
|
1759
|
+
{
|
|
1760
|
+
internalType: "uint256",
|
|
1761
|
+
name: "amount",
|
|
1762
|
+
type: "uint256"
|
|
1763
|
+
}
|
|
1764
|
+
],
|
|
1765
|
+
name: "setBudget",
|
|
1766
|
+
outputs: [],
|
|
1767
|
+
stateMutability: "nonpayable",
|
|
1768
|
+
type: "function"
|
|
1769
|
+
},
|
|
1770
|
+
{
|
|
1771
|
+
inputs: [
|
|
1772
|
+
{
|
|
1773
|
+
internalType: "uint256",
|
|
1774
|
+
name: "jobId",
|
|
1775
|
+
type: "uint256"
|
|
1776
|
+
},
|
|
1777
|
+
{
|
|
1778
|
+
internalType: "uint256",
|
|
1779
|
+
name: "amount",
|
|
1780
|
+
type: "uint256"
|
|
1781
|
+
},
|
|
1782
|
+
{
|
|
1783
|
+
internalType: "contract IERC20",
|
|
1784
|
+
name: "jobPaymentToken_",
|
|
1785
|
+
type: "address"
|
|
1786
|
+
}
|
|
1787
|
+
],
|
|
1788
|
+
name: "setBudgetWithPaymentToken",
|
|
1789
|
+
outputs: [],
|
|
1790
|
+
stateMutability: "nonpayable",
|
|
1791
|
+
type: "function"
|
|
1792
|
+
},
|
|
1793
|
+
{
|
|
1794
|
+
inputs: [
|
|
1795
|
+
{
|
|
1796
|
+
internalType: "uint256",
|
|
1797
|
+
name: "memoId",
|
|
1798
|
+
type: "uint256"
|
|
1799
|
+
},
|
|
1800
|
+
{
|
|
1801
|
+
internalType: "bool",
|
|
1802
|
+
name: "isApproved",
|
|
1803
|
+
type: "bool"
|
|
1804
|
+
},
|
|
1805
|
+
{
|
|
1806
|
+
internalType: "string",
|
|
1807
|
+
name: "reason",
|
|
1808
|
+
type: "string"
|
|
1809
|
+
}
|
|
1810
|
+
],
|
|
1811
|
+
name: "signMemo",
|
|
1812
|
+
outputs: [],
|
|
1813
|
+
stateMutability: "nonpayable",
|
|
1814
|
+
type: "function"
|
|
1815
|
+
},
|
|
1816
|
+
{
|
|
1817
|
+
inputs: [
|
|
1818
|
+
{
|
|
1819
|
+
internalType: "uint256",
|
|
1820
|
+
name: "memoId",
|
|
1821
|
+
type: "uint256"
|
|
1822
|
+
},
|
|
1823
|
+
{
|
|
1824
|
+
internalType: "address",
|
|
1825
|
+
name: "signer",
|
|
1826
|
+
type: "address"
|
|
1827
|
+
}
|
|
1828
|
+
],
|
|
1829
|
+
name: "signatories",
|
|
1830
|
+
outputs: [
|
|
1831
|
+
{
|
|
1832
|
+
internalType: "uint8",
|
|
1833
|
+
name: "res",
|
|
1834
|
+
type: "uint8"
|
|
1835
|
+
}
|
|
1836
|
+
],
|
|
1837
|
+
stateMutability: "view",
|
|
1838
|
+
type: "function"
|
|
1839
|
+
},
|
|
1840
|
+
{
|
|
1841
|
+
inputs: [
|
|
1842
|
+
{
|
|
1843
|
+
internalType: "bytes4",
|
|
1844
|
+
name: "interfaceId",
|
|
1845
|
+
type: "bytes4"
|
|
1846
|
+
}
|
|
1847
|
+
],
|
|
1848
|
+
name: "supportsInterface",
|
|
1849
|
+
outputs: [
|
|
1850
|
+
{
|
|
1851
|
+
internalType: "bool",
|
|
1852
|
+
name: "",
|
|
1853
|
+
type: "bool"
|
|
1854
|
+
}
|
|
1855
|
+
],
|
|
1856
|
+
stateMutability: "view",
|
|
1857
|
+
type: "function"
|
|
1858
|
+
},
|
|
1859
|
+
{
|
|
1860
|
+
inputs: [
|
|
1861
|
+
{
|
|
1862
|
+
internalType: "uint256",
|
|
1863
|
+
name: "evaluatorFeeBP_",
|
|
1864
|
+
type: "uint256"
|
|
1865
|
+
}
|
|
1866
|
+
],
|
|
1867
|
+
name: "updateEvaluatorFee",
|
|
1868
|
+
outputs: [],
|
|
1869
|
+
stateMutability: "nonpayable",
|
|
1870
|
+
type: "function"
|
|
1871
|
+
},
|
|
1872
|
+
{
|
|
1873
|
+
inputs: [
|
|
1874
|
+
{
|
|
1875
|
+
internalType: "uint256",
|
|
1876
|
+
name: "platformFeeBP_",
|
|
1877
|
+
type: "uint256"
|
|
1878
|
+
},
|
|
1879
|
+
{
|
|
1880
|
+
internalType: "address",
|
|
1881
|
+
name: "platformTreasury_",
|
|
1882
|
+
type: "address"
|
|
1883
|
+
}
|
|
1884
|
+
],
|
|
1885
|
+
name: "updatePlatformFee",
|
|
1886
|
+
outputs: [],
|
|
1887
|
+
stateMutability: "nonpayable",
|
|
1888
|
+
type: "function"
|
|
1889
|
+
},
|
|
1890
|
+
{
|
|
1891
|
+
inputs: [
|
|
1892
|
+
{
|
|
1893
|
+
internalType: "uint256",
|
|
1894
|
+
name: "memoId",
|
|
1895
|
+
type: "uint256"
|
|
1896
|
+
}
|
|
1897
|
+
],
|
|
1898
|
+
name: "withdrawEscrowedFunds",
|
|
1899
|
+
outputs: [],
|
|
1900
|
+
stateMutability: "nonpayable",
|
|
1901
|
+
type: "function"
|
|
1902
|
+
}
|
|
1903
|
+
];
|
|
1904
|
+
var acpAbi_default = ACP_ABI;
|
|
1905
|
+
|
|
1906
|
+
// src/acpClient.ts
|
|
1907
|
+
var import_socket = require("socket.io-client");
|
|
1908
|
+
|
|
1909
|
+
// src/acpContractClient.ts
|
|
1910
|
+
var import_core = require("@aa-sdk/core");
|
|
1911
|
+
var import_infra2 = require("@account-kit/infra");
|
|
1912
|
+
var import_smart_contracts = require("@account-kit/smart-contracts");
|
|
1913
|
+
var import_viem2 = require("viem");
|
|
1914
|
+
|
|
1915
|
+
// src/acpConfigs.ts
|
|
1916
|
+
var import_infra = require("@account-kit/infra");
|
|
1917
|
+
|
|
1918
|
+
// src/acpFare.ts
|
|
1919
|
+
var import_viem = require("viem");
|
|
1920
|
+
|
|
1921
|
+
// src/acpError.ts
|
|
1922
|
+
var AcpError = class _AcpError extends Error {
|
|
1923
|
+
constructor(message, originalError) {
|
|
1924
|
+
super();
|
|
1925
|
+
this.message = message;
|
|
1926
|
+
this.name = "AcpError";
|
|
1927
|
+
if (originalError && typeof originalError === "object" && "stack" in originalError) {
|
|
1928
|
+
this.stack += `
|
|
1929
|
+
Caused by: ${originalError.stack}`;
|
|
1930
|
+
}
|
|
1931
|
+
Object.setPrototypeOf(this, _AcpError.prototype);
|
|
1932
|
+
}
|
|
1933
|
+
};
|
|
1934
|
+
var acpError_default = AcpError;
|
|
1935
|
+
|
|
1936
|
+
// src/acpFare.ts
|
|
1937
|
+
var Fare = class {
|
|
1938
|
+
constructor(contractAddress, decimals) {
|
|
1939
|
+
this.contractAddress = contractAddress;
|
|
1940
|
+
this.decimals = decimals;
|
|
1941
|
+
}
|
|
1942
|
+
formatAmount(amount) {
|
|
1943
|
+
return (0, import_viem.parseUnits)(amount.toString(), this.decimals);
|
|
1944
|
+
}
|
|
1945
|
+
};
|
|
1946
|
+
var FareAmount = class _FareAmount {
|
|
1947
|
+
constructor(fareAmount, fare) {
|
|
1948
|
+
this.amount = fare.formatAmount(
|
|
1949
|
+
this.truncateTo6Decimals(fareAmount.toString())
|
|
1950
|
+
);
|
|
1951
|
+
this.fare = fare;
|
|
1952
|
+
}
|
|
1953
|
+
truncateTo6Decimals(input) {
|
|
1954
|
+
const [intPart, decPart = ""] = input.split(".");
|
|
1955
|
+
if (decPart === "") {
|
|
1956
|
+
return parseFloat(intPart);
|
|
1957
|
+
}
|
|
1958
|
+
const truncated = decPart.slice(0, 6).padEnd(6, "0");
|
|
1959
|
+
return parseFloat(`${intPart}.${truncated}`);
|
|
1960
|
+
}
|
|
1961
|
+
add(other) {
|
|
1962
|
+
if (this.fare.contractAddress !== other.fare.contractAddress) {
|
|
1963
|
+
throw new acpError_default("Token addresses do not match");
|
|
1964
|
+
}
|
|
1965
|
+
return new _FareAmount(Number(this.amount + other.amount), this.fare);
|
|
1966
|
+
}
|
|
1967
|
+
};
|
|
1968
|
+
var FareBigInt = class _FareBigInt {
|
|
1969
|
+
constructor(amount, fare) {
|
|
1970
|
+
this.amount = amount;
|
|
1971
|
+
this.fare = fare;
|
|
1972
|
+
}
|
|
1973
|
+
add(other) {
|
|
1974
|
+
if (this.fare.contractAddress !== other.fare.contractAddress) {
|
|
1975
|
+
throw new acpError_default("Token addresses do not match");
|
|
1976
|
+
}
|
|
1977
|
+
return new _FareBigInt(this.amount + other.amount, this.fare);
|
|
1978
|
+
}
|
|
1979
|
+
};
|
|
1980
|
+
var wethFare = new Fare("0x4200000000000000000000000000000000000006", 18);
|
|
1981
|
+
var ethFare = new Fare(import_viem.ethAddress, 18);
|
|
1982
|
+
|
|
1983
|
+
// src/acpConfigs.ts
|
|
1984
|
+
var AcpContractConfig = class {
|
|
1985
|
+
constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, rpcEndpoint) {
|
|
1986
|
+
this.chain = chain;
|
|
1987
|
+
this.contractAddress = contractAddress;
|
|
1988
|
+
this.baseFare = baseFare;
|
|
1989
|
+
this.alchemyRpcUrl = alchemyRpcUrl;
|
|
1990
|
+
this.acpUrl = acpUrl;
|
|
1991
|
+
this.rpcEndpoint = rpcEndpoint;
|
|
1992
|
+
}
|
|
1993
|
+
};
|
|
1994
|
+
var baseSepoliaAcpConfig = new AcpContractConfig(
|
|
1995
|
+
import_infra.baseSepolia,
|
|
1996
|
+
"0x8Db6B1c839Fc8f6bd35777E194677B67b4D51928",
|
|
1997
|
+
new Fare("0x036CbD53842c5426634e7929541eC2318f3dCF7e", 6),
|
|
1998
|
+
"https://alchemy-proxy.virtuals.io/api/proxy/rpc",
|
|
1999
|
+
"https://acpx.virtuals.gg"
|
|
2000
|
+
);
|
|
2001
|
+
var baseAcpConfig = new AcpContractConfig(
|
|
2002
|
+
import_infra.base,
|
|
2003
|
+
"0x6a1FE26D54ab0d3E1e3168f2e0c0cDa5cC0A0A4A",
|
|
2004
|
+
new Fare("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", 6),
|
|
2005
|
+
"https://alchemy-proxy-prod.virtuals.io/api/proxy/rpc",
|
|
2006
|
+
"https://acpx.virtuals.io"
|
|
2007
|
+
);
|
|
2008
|
+
|
|
2009
|
+
// src/wethAbi.ts
|
|
2010
|
+
var WETH_ABI = [
|
|
2011
|
+
{
|
|
2012
|
+
anonymous: false,
|
|
2013
|
+
inputs: [
|
|
2014
|
+
{ indexed: true, internalType: "address", name: "src", type: "address" },
|
|
2015
|
+
{ indexed: true, internalType: "address", name: "guy", type: "address" },
|
|
2016
|
+
{ indexed: false, internalType: "uint256", name: "wad", type: "uint256" }
|
|
2017
|
+
],
|
|
2018
|
+
name: "Approval",
|
|
2019
|
+
type: "event"
|
|
2020
|
+
},
|
|
2021
|
+
{
|
|
2022
|
+
anonymous: false,
|
|
2023
|
+
inputs: [
|
|
2024
|
+
{ indexed: true, internalType: "address", name: "dst", type: "address" },
|
|
2025
|
+
{ indexed: false, internalType: "uint256", name: "wad", type: "uint256" }
|
|
2026
|
+
],
|
|
2027
|
+
name: "Deposit",
|
|
2028
|
+
type: "event"
|
|
895
2029
|
},
|
|
896
2030
|
{
|
|
2031
|
+
anonymous: false,
|
|
897
2032
|
inputs: [
|
|
898
|
-
{ internalType: "
|
|
899
|
-
{ internalType: "
|
|
900
|
-
{ internalType: "uint256", name: "", type: "uint256" }
|
|
2033
|
+
{ indexed: true, internalType: "address", name: "src", type: "address" },
|
|
2034
|
+
{ indexed: true, internalType: "address", name: "dst", type: "address" },
|
|
2035
|
+
{ indexed: false, internalType: "uint256", name: "wad", type: "uint256" }
|
|
901
2036
|
],
|
|
902
|
-
name: "
|
|
903
|
-
|
|
904
|
-
stateMutability: "view",
|
|
905
|
-
type: "function"
|
|
2037
|
+
name: "Transfer",
|
|
2038
|
+
type: "event"
|
|
906
2039
|
},
|
|
907
2040
|
{
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
{ internalType: "uint256", name: "
|
|
912
|
-
{ internalType: "address", name: "client", type: "address" },
|
|
913
|
-
{ internalType: "address", name: "provider", type: "address" },
|
|
914
|
-
{ internalType: "uint256", name: "budget", type: "uint256" },
|
|
915
|
-
{ internalType: "uint256", name: "amountClaimed", type: "uint256" },
|
|
916
|
-
{ internalType: "uint8", name: "phase", type: "uint8" },
|
|
917
|
-
{ internalType: "uint256", name: "memoCount", type: "uint256" },
|
|
918
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
919
|
-
{ internalType: "address", name: "evaluator", type: "address" }
|
|
2041
|
+
anonymous: false,
|
|
2042
|
+
inputs: [
|
|
2043
|
+
{ indexed: true, internalType: "address", name: "src", type: "address" },
|
|
2044
|
+
{ indexed: false, internalType: "uint256", name: "wad", type: "uint256" }
|
|
920
2045
|
],
|
|
921
|
-
|
|
922
|
-
type: "
|
|
2046
|
+
name: "Withdrawal",
|
|
2047
|
+
type: "event"
|
|
923
2048
|
},
|
|
2049
|
+
{ payable: true, stateMutability: "payable", type: "fallback" },
|
|
924
2050
|
{
|
|
925
|
-
|
|
926
|
-
|
|
2051
|
+
constant: true,
|
|
2052
|
+
inputs: [
|
|
2053
|
+
{ internalType: "address", name: "", type: "address" },
|
|
2054
|
+
{ internalType: "address", name: "", type: "address" }
|
|
2055
|
+
],
|
|
2056
|
+
name: "allowance",
|
|
927
2057
|
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
2058
|
+
payable: false,
|
|
928
2059
|
stateMutability: "view",
|
|
929
2060
|
type: "function"
|
|
930
2061
|
},
|
|
931
2062
|
{
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
2063
|
+
constant: false,
|
|
2064
|
+
inputs: [
|
|
2065
|
+
{ internalType: "address", name: "guy", type: "address" },
|
|
2066
|
+
{ internalType: "uint256", name: "wad", type: "uint256" }
|
|
2067
|
+
],
|
|
2068
|
+
name: "approve",
|
|
2069
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
2070
|
+
payable: false,
|
|
2071
|
+
stateMutability: "nonpayable",
|
|
936
2072
|
type: "function"
|
|
937
2073
|
},
|
|
938
2074
|
{
|
|
939
|
-
|
|
940
|
-
name: "
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
internalType: "enum InteractionLedger.MemoType",
|
|
945
|
-
name: "memoType",
|
|
946
|
-
type: "uint8"
|
|
947
|
-
},
|
|
948
|
-
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
949
|
-
{ internalType: "uint8", name: "nextPhase", type: "uint8" },
|
|
950
|
-
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
951
|
-
{ internalType: "address", name: "sender", type: "address" }
|
|
952
|
-
],
|
|
2075
|
+
constant: true,
|
|
2076
|
+
inputs: [{ internalType: "address", name: "", type: "address" }],
|
|
2077
|
+
name: "balanceOf",
|
|
2078
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
2079
|
+
payable: false,
|
|
953
2080
|
stateMutability: "view",
|
|
954
2081
|
type: "function"
|
|
955
2082
|
},
|
|
956
2083
|
{
|
|
2084
|
+
constant: true,
|
|
957
2085
|
inputs: [],
|
|
958
|
-
name: "
|
|
2086
|
+
name: "decimals",
|
|
959
2087
|
outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
|
|
2088
|
+
payable: false,
|
|
960
2089
|
stateMutability: "view",
|
|
961
2090
|
type: "function"
|
|
962
2091
|
},
|
|
963
2092
|
{
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
{ internalType: "uint256", name: "feeAmount", type: "uint256" },
|
|
971
|
-
{
|
|
972
|
-
internalType: "enum ACPSimple.FeeType",
|
|
973
|
-
name: "feeType",
|
|
974
|
-
type: "uint8"
|
|
975
|
-
},
|
|
976
|
-
{ internalType: "bool", name: "isExecuted", type: "bool" }
|
|
977
|
-
],
|
|
978
|
-
stateMutability: "view",
|
|
2093
|
+
constant: false,
|
|
2094
|
+
inputs: [],
|
|
2095
|
+
name: "deposit",
|
|
2096
|
+
outputs: [],
|
|
2097
|
+
payable: true,
|
|
2098
|
+
stateMutability: "payable",
|
|
979
2099
|
type: "function"
|
|
980
2100
|
},
|
|
981
2101
|
{
|
|
2102
|
+
constant: true,
|
|
982
2103
|
inputs: [],
|
|
983
|
-
name: "
|
|
984
|
-
outputs: [{ internalType: "
|
|
2104
|
+
name: "name",
|
|
2105
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
2106
|
+
payable: false,
|
|
985
2107
|
stateMutability: "view",
|
|
986
2108
|
type: "function"
|
|
987
2109
|
},
|
|
988
2110
|
{
|
|
2111
|
+
constant: true,
|
|
989
2112
|
inputs: [],
|
|
990
|
-
name: "
|
|
991
|
-
outputs: [{ internalType: "
|
|
2113
|
+
name: "symbol",
|
|
2114
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
2115
|
+
payable: false,
|
|
992
2116
|
stateMutability: "view",
|
|
993
2117
|
type: "function"
|
|
994
2118
|
},
|
|
995
2119
|
{
|
|
2120
|
+
constant: true,
|
|
996
2121
|
inputs: [],
|
|
997
|
-
name: "
|
|
998
|
-
outputs: [{ internalType: "
|
|
2122
|
+
name: "totalSupply",
|
|
2123
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
2124
|
+
payable: false,
|
|
999
2125
|
stateMutability: "view",
|
|
1000
2126
|
type: "function"
|
|
1001
2127
|
},
|
|
1002
2128
|
{
|
|
2129
|
+
constant: false,
|
|
1003
2130
|
inputs: [
|
|
1004
|
-
{ internalType: "
|
|
1005
|
-
{ internalType: "
|
|
1006
|
-
],
|
|
1007
|
-
name: "renounceRole",
|
|
1008
|
-
outputs: [],
|
|
1009
|
-
stateMutability: "nonpayable",
|
|
1010
|
-
type: "function"
|
|
1011
|
-
},
|
|
1012
|
-
{
|
|
1013
|
-
inputs: [
|
|
1014
|
-
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
1015
|
-
{ internalType: "address", name: "account", type: "address" }
|
|
1016
|
-
],
|
|
1017
|
-
name: "revokeRole",
|
|
1018
|
-
outputs: [],
|
|
1019
|
-
stateMutability: "nonpayable",
|
|
1020
|
-
type: "function"
|
|
1021
|
-
},
|
|
1022
|
-
{
|
|
1023
|
-
inputs: [
|
|
1024
|
-
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
1025
|
-
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
1026
|
-
],
|
|
1027
|
-
name: "setBudget",
|
|
1028
|
-
outputs: [],
|
|
1029
|
-
stateMutability: "nonpayable",
|
|
1030
|
-
type: "function"
|
|
1031
|
-
},
|
|
1032
|
-
{
|
|
1033
|
-
inputs: [
|
|
1034
|
-
{ internalType: "uint256", name: "memoId", type: "uint256" },
|
|
1035
|
-
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
1036
|
-
{ internalType: "string", name: "reason", type: "string" }
|
|
2131
|
+
{ internalType: "address", name: "dst", type: "address" },
|
|
2132
|
+
{ internalType: "uint256", name: "wad", type: "uint256" }
|
|
1037
2133
|
],
|
|
1038
|
-
name: "
|
|
1039
|
-
outputs: [],
|
|
2134
|
+
name: "transfer",
|
|
2135
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
2136
|
+
payable: false,
|
|
1040
2137
|
stateMutability: "nonpayable",
|
|
1041
2138
|
type: "function"
|
|
1042
2139
|
},
|
|
1043
2140
|
{
|
|
2141
|
+
constant: false,
|
|
1044
2142
|
inputs: [
|
|
1045
|
-
{ internalType: "
|
|
1046
|
-
{ internalType: "address", name: "
|
|
2143
|
+
{ internalType: "address", name: "src", type: "address" },
|
|
2144
|
+
{ internalType: "address", name: "dst", type: "address" },
|
|
2145
|
+
{ internalType: "uint256", name: "wad", type: "uint256" }
|
|
1047
2146
|
],
|
|
1048
|
-
name: "
|
|
1049
|
-
outputs: [{ internalType: "uint8", name: "res", type: "uint8" }],
|
|
1050
|
-
stateMutability: "view",
|
|
1051
|
-
type: "function"
|
|
1052
|
-
},
|
|
1053
|
-
{
|
|
1054
|
-
inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
|
|
1055
|
-
name: "supportsInterface",
|
|
2147
|
+
name: "transferFrom",
|
|
1056
2148
|
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
1057
|
-
|
|
1058
|
-
type: "function"
|
|
1059
|
-
},
|
|
1060
|
-
{
|
|
1061
|
-
inputs: [
|
|
1062
|
-
{ internalType: "uint256", name: "evaluatorFeeBP_", type: "uint256" }
|
|
1063
|
-
],
|
|
1064
|
-
name: "updateEvaluatorFee",
|
|
1065
|
-
outputs: [],
|
|
2149
|
+
payable: false,
|
|
1066
2150
|
stateMutability: "nonpayable",
|
|
1067
2151
|
type: "function"
|
|
1068
2152
|
},
|
|
1069
2153
|
{
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
],
|
|
1074
|
-
name: "updatePlatformFee",
|
|
2154
|
+
constant: false,
|
|
2155
|
+
inputs: [{ internalType: "uint256", name: "wad", type: "uint256" }],
|
|
2156
|
+
name: "withdraw",
|
|
1075
2157
|
outputs: [],
|
|
2158
|
+
payable: false,
|
|
1076
2159
|
stateMutability: "nonpayable",
|
|
1077
2160
|
type: "function"
|
|
1078
2161
|
}
|
|
1079
2162
|
];
|
|
1080
|
-
var
|
|
1081
|
-
|
|
1082
|
-
// src/acpClient.ts
|
|
1083
|
-
var import_viem2 = require("viem");
|
|
1084
|
-
var import_socket = require("socket.io-client");
|
|
1085
|
-
|
|
1086
|
-
// src/acpContractClient.ts
|
|
1087
|
-
var import_core = require("@aa-sdk/core");
|
|
1088
|
-
var import_infra2 = require("@account-kit/infra");
|
|
1089
|
-
var import_smart_contracts = require("@account-kit/smart-contracts");
|
|
1090
|
-
|
|
1091
|
-
// src/configs.ts
|
|
1092
|
-
var import_infra = require("@account-kit/infra");
|
|
1093
|
-
var baseSepoliaAcpConfig = {
|
|
1094
|
-
chain: import_infra.baseSepolia,
|
|
1095
|
-
contractAddress: "0x8Db6B1c839Fc8f6bd35777E194677B67b4D51928",
|
|
1096
|
-
virtualsTokenAddress: "0xbfAB80ccc15DF6fb7185f9498d6039317331846a",
|
|
1097
|
-
alchemyRpcUrl: "https://alchemy-proxy.virtuals.io/api/proxy/rpc",
|
|
1098
|
-
acpUrl: "https://acpx.virtuals.gg",
|
|
1099
|
-
priorityFeeMultiplier: 2,
|
|
1100
|
-
maxFeePerGas: 2e7,
|
|
1101
|
-
maxPriorityFeePerGas: 21e6
|
|
1102
|
-
};
|
|
1103
|
-
var baseAcpConfig = {
|
|
1104
|
-
chain: import_infra.base,
|
|
1105
|
-
contractAddress: "0x6a1FE26D54ab0d3E1e3168f2e0c0cDa5cC0A0A4A",
|
|
1106
|
-
virtualsTokenAddress: "0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b",
|
|
1107
|
-
alchemyRpcUrl: "https://alchemy-proxy-prod.virtuals.io/api/proxy/rpc",
|
|
1108
|
-
acpUrl: "https://acpx.virtuals.io",
|
|
1109
|
-
priorityFeeMultiplier: 2,
|
|
1110
|
-
maxFeePerGas: 2e7,
|
|
1111
|
-
maxPriorityFeePerGas: 21e6
|
|
1112
|
-
};
|
|
2163
|
+
var wethAbi_default = WETH_ABI;
|
|
1113
2164
|
|
|
1114
2165
|
// src/acpContractClient.ts
|
|
1115
|
-
var import_viem = require("viem");
|
|
1116
|
-
var import_op_stack = require("viem/op-stack");
|
|
1117
2166
|
var MemoType = /* @__PURE__ */ ((MemoType2) => {
|
|
1118
2167
|
MemoType2[MemoType2["MESSAGE"] = 0] = "MESSAGE";
|
|
1119
2168
|
MemoType2[MemoType2["CONTEXT_URL"] = 1] = "CONTEXT_URL";
|
|
@@ -1123,8 +2172,7 @@ var MemoType = /* @__PURE__ */ ((MemoType2) => {
|
|
|
1123
2172
|
MemoType2[MemoType2["TXHASH"] = 5] = "TXHASH";
|
|
1124
2173
|
MemoType2[MemoType2["PAYABLE_REQUEST"] = 6] = "PAYABLE_REQUEST";
|
|
1125
2174
|
MemoType2[MemoType2["PAYABLE_TRANSFER"] = 7] = "PAYABLE_TRANSFER";
|
|
1126
|
-
MemoType2[MemoType2["
|
|
1127
|
-
MemoType2[MemoType2["PAYABLE_FEE_REQUEST"] = 9] = "PAYABLE_FEE_REQUEST";
|
|
2175
|
+
MemoType2[MemoType2["PAYABLE_TRANSFER_ESCROW"] = 8] = "PAYABLE_TRANSFER_ESCROW";
|
|
1128
2176
|
return MemoType2;
|
|
1129
2177
|
})(MemoType || {});
|
|
1130
2178
|
var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
|
|
@@ -1138,30 +2186,26 @@ var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
|
|
|
1138
2186
|
return AcpJobPhases2;
|
|
1139
2187
|
})(AcpJobPhases || {});
|
|
1140
2188
|
var AcpContractClient = class _AcpContractClient {
|
|
1141
|
-
|
|
2189
|
+
// private paymentTokenAddress: Address;
|
|
2190
|
+
constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
|
|
1142
2191
|
this.walletPrivateKey = walletPrivateKey;
|
|
1143
2192
|
this.sessionEntityKeyId = sessionEntityKeyId;
|
|
1144
2193
|
this.agentWalletAddress = agentWalletAddress;
|
|
1145
2194
|
this.config = config;
|
|
1146
|
-
this.customRpcUrl = customRpcUrl;
|
|
1147
2195
|
this.MAX_RETRIES = 3;
|
|
2196
|
+
this.PRIORITY_FEE_MULTIPLIER = 2;
|
|
2197
|
+
this.MAX_FEE_PER_GAS = 2e7;
|
|
2198
|
+
this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
|
|
1148
2199
|
this.chain = config.chain;
|
|
1149
2200
|
this.contractAddress = config.contractAddress;
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
this
|
|
1153
|
-
chain: this.chain,
|
|
1154
|
-
transport: this.customRpcUrl ? (0, import_viem.http)(this.customRpcUrl) : (0, import_viem.http)()
|
|
1155
|
-
}).extend((0, import_op_stack.publicActionsL2)());
|
|
1156
|
-
}
|
|
1157
|
-
static build(_0, _1, _2, _3) {
|
|
1158
|
-
return __async(this, arguments, function* (walletPrivateKey, sessionEntityKeyId, agentWalletAddress, customRpcUrl, config = baseAcpConfig) {
|
|
2201
|
+
}
|
|
2202
|
+
static build(_0, _1, _2) {
|
|
2203
|
+
return __async(this, arguments, function* (walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
|
|
1159
2204
|
const acpContractClient = new _AcpContractClient(
|
|
1160
2205
|
walletPrivateKey,
|
|
1161
2206
|
sessionEntityKeyId,
|
|
1162
2207
|
agentWalletAddress,
|
|
1163
|
-
config
|
|
1164
|
-
customRpcUrl
|
|
2208
|
+
config
|
|
1165
2209
|
);
|
|
1166
2210
|
yield acpContractClient.init();
|
|
1167
2211
|
return acpContractClient;
|
|
@@ -1187,7 +2231,7 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1187
2231
|
}
|
|
1188
2232
|
get sessionKeyClient() {
|
|
1189
2233
|
if (!this._sessionKeyClient) {
|
|
1190
|
-
throw new
|
|
2234
|
+
throw new acpError_default("Session key client not initialized");
|
|
1191
2235
|
}
|
|
1192
2236
|
return this._sessionKeyClient;
|
|
1193
2237
|
}
|
|
@@ -1196,21 +2240,17 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1196
2240
|
}
|
|
1197
2241
|
calculateGasFees() {
|
|
1198
2242
|
return __async(this, null, function* () {
|
|
1199
|
-
const
|
|
1200
|
-
let finalMaxFeePerGas = maxFeePerGas;
|
|
1201
|
-
let priorityFeeMultiplier = Number(this.config.priorityFeeMultiplier) || 2;
|
|
1202
|
-
const overrideMaxFeePerGas = this.config.maxFeePerGas || maxFeePerGas;
|
|
1203
|
-
const overrideMaxPriorityFeePerGas = this.config.maxPriorityFeePerGas || maxPriorityFeePerGas;
|
|
1204
|
-
finalMaxFeePerGas = BigInt(overrideMaxFeePerGas) + BigInt(overrideMaxPriorityFeePerGas) * BigInt(Math.max(0, priorityFeeMultiplier - 1));
|
|
2243
|
+
const finalMaxFeePerGas = BigInt(this.MAX_FEE_PER_GAS) + BigInt(this.MAX_PRIORITY_FEE_PER_GAS) * BigInt(Math.max(0, this.PRIORITY_FEE_MULTIPLIER - 1));
|
|
1205
2244
|
return finalMaxFeePerGas;
|
|
1206
2245
|
});
|
|
1207
2246
|
}
|
|
1208
2247
|
handleSendUserOperation(_0) {
|
|
1209
|
-
return __async(this, arguments, function* (data, contractAddress = this.contractAddress) {
|
|
2248
|
+
return __async(this, arguments, function* (data, contractAddress = this.contractAddress, value) {
|
|
1210
2249
|
const payload = {
|
|
1211
2250
|
uo: {
|
|
1212
2251
|
target: contractAddress,
|
|
1213
|
-
data
|
|
2252
|
+
data,
|
|
2253
|
+
value
|
|
1214
2254
|
},
|
|
1215
2255
|
overrides: {}
|
|
1216
2256
|
};
|
|
@@ -1230,7 +2270,6 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1230
2270
|
});
|
|
1231
2271
|
return hash;
|
|
1232
2272
|
} catch (error) {
|
|
1233
|
-
console.debug("Failed to send user operation", error);
|
|
1234
2273
|
retries -= 1;
|
|
1235
2274
|
if (retries === 0) {
|
|
1236
2275
|
finalError = error;
|
|
@@ -1239,28 +2278,28 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1239
2278
|
yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
|
|
1240
2279
|
}
|
|
1241
2280
|
}
|
|
1242
|
-
throw new
|
|
2281
|
+
throw new acpError_default(`Failed to send user operation`, finalError);
|
|
1243
2282
|
});
|
|
1244
2283
|
}
|
|
1245
2284
|
getJobId(hash) {
|
|
1246
2285
|
return __async(this, null, function* () {
|
|
1247
2286
|
const result = yield this.sessionKeyClient.getUserOperationReceipt(hash);
|
|
1248
2287
|
if (!result) {
|
|
1249
|
-
throw new
|
|
2288
|
+
throw new acpError_default("Failed to get user operation receipt");
|
|
1250
2289
|
}
|
|
1251
2290
|
const contractLogs = result.logs.find(
|
|
1252
2291
|
(log) => log.address.toLowerCase() === this.contractAddress.toLowerCase()
|
|
1253
2292
|
);
|
|
1254
2293
|
if (!contractLogs) {
|
|
1255
|
-
throw new
|
|
2294
|
+
throw new acpError_default("Failed to get contract logs");
|
|
1256
2295
|
}
|
|
1257
|
-
return (0,
|
|
2296
|
+
return (0, import_viem2.fromHex)(contractLogs.data, "number");
|
|
1258
2297
|
});
|
|
1259
2298
|
}
|
|
1260
2299
|
createJob(providerAddress, evaluatorAddress, expireAt) {
|
|
1261
2300
|
return __async(this, null, function* () {
|
|
1262
2301
|
try {
|
|
1263
|
-
const data = (0,
|
|
2302
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
1264
2303
|
abi: acpAbi_default,
|
|
1265
2304
|
functionName: "createJob",
|
|
1266
2305
|
args: [
|
|
@@ -1273,114 +2312,60 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1273
2312
|
const jobId = yield this.getJobId(hash);
|
|
1274
2313
|
return { txHash: hash, jobId };
|
|
1275
2314
|
} catch (error) {
|
|
1276
|
-
|
|
1277
|
-
throw new Error("Failed to create job");
|
|
2315
|
+
throw new acpError_default("Failed to create job", error);
|
|
1278
2316
|
}
|
|
1279
2317
|
});
|
|
1280
2318
|
}
|
|
1281
|
-
approveAllowance(
|
|
1282
|
-
return __async(this,
|
|
2319
|
+
approveAllowance(_0) {
|
|
2320
|
+
return __async(this, arguments, function* (amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
|
|
1283
2321
|
try {
|
|
1284
|
-
const data = (0,
|
|
1285
|
-
abi:
|
|
2322
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2323
|
+
abi: import_viem2.erc20Abi,
|
|
1286
2324
|
functionName: "approve",
|
|
1287
|
-
args: [this.contractAddress,
|
|
2325
|
+
args: [this.contractAddress, amountBaseUnit]
|
|
1288
2326
|
});
|
|
1289
|
-
return yield this.handleSendUserOperation(
|
|
1290
|
-
data,
|
|
1291
|
-
this.virtualsTokenAddress
|
|
1292
|
-
);
|
|
2327
|
+
return yield this.handleSendUserOperation(data, paymentTokenAddress);
|
|
1293
2328
|
} catch (error) {
|
|
1294
|
-
|
|
1295
|
-
throw new Error("Failed to approve allowance");
|
|
1296
|
-
}
|
|
1297
|
-
});
|
|
1298
|
-
}
|
|
1299
|
-
createPayableFeeMemo(jobId, content, amount, memoType, nextPhase) {
|
|
1300
|
-
return __async(this, null, function* () {
|
|
1301
|
-
let retries = 3;
|
|
1302
|
-
while (retries > 0) {
|
|
1303
|
-
try {
|
|
1304
|
-
const data = (0, import_viem.encodeFunctionData)({
|
|
1305
|
-
abi: acpAbi_default,
|
|
1306
|
-
functionName: "createPayableFeeMemo",
|
|
1307
|
-
args: [jobId, content, amount, memoType, nextPhase]
|
|
1308
|
-
});
|
|
1309
|
-
const { hash } = yield this.sessionKeyClient.sendUserOperation({
|
|
1310
|
-
uo: {
|
|
1311
|
-
target: this.contractAddress,
|
|
1312
|
-
data
|
|
1313
|
-
}
|
|
1314
|
-
});
|
|
1315
|
-
yield this.sessionKeyClient.waitForUserOperationTransaction({
|
|
1316
|
-
hash
|
|
1317
|
-
});
|
|
1318
|
-
return hash;
|
|
1319
|
-
} catch (error) {
|
|
1320
|
-
console.error(
|
|
1321
|
-
`failed to create payable fee memo ${jobId} ${content} ${error}`
|
|
1322
|
-
);
|
|
1323
|
-
retries -= 1;
|
|
1324
|
-
yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
|
|
1325
|
-
}
|
|
2329
|
+
throw new acpError_default("Failed to approve allowance", error);
|
|
1326
2330
|
}
|
|
1327
|
-
throw new Error("Failed to create payable fee memo");
|
|
1328
2331
|
});
|
|
1329
2332
|
}
|
|
1330
2333
|
createPayableMemo(_0, _1, _2, _3, _4, _5, _6, _7, _8) {
|
|
1331
|
-
return __async(this, arguments, function* (jobId, content,
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
uo: {
|
|
1353
|
-
target: this.contractAddress,
|
|
1354
|
-
data
|
|
1355
|
-
}
|
|
1356
|
-
});
|
|
1357
|
-
yield this.sessionKeyClient.waitForUserOperationTransaction({
|
|
1358
|
-
hash
|
|
1359
|
-
});
|
|
1360
|
-
return hash;
|
|
1361
|
-
} catch (error) {
|
|
1362
|
-
console.error(
|
|
1363
|
-
`failed to create payable memo ${jobId} ${content} ${error}`
|
|
1364
|
-
);
|
|
1365
|
-
retries -= 1;
|
|
1366
|
-
yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
|
|
1367
|
-
}
|
|
2334
|
+
return __async(this, arguments, function* (jobId, content, amountBaseUnit, recipient, feeAmountBaseUnit, feeType, nextPhase, type, expiredAt, token = this.config.baseFare.contractAddress) {
|
|
2335
|
+
try {
|
|
2336
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2337
|
+
abi: acpAbi_default,
|
|
2338
|
+
functionName: "createPayableMemo",
|
|
2339
|
+
args: [
|
|
2340
|
+
jobId,
|
|
2341
|
+
content,
|
|
2342
|
+
token,
|
|
2343
|
+
amountBaseUnit,
|
|
2344
|
+
recipient,
|
|
2345
|
+
feeAmountBaseUnit,
|
|
2346
|
+
feeType,
|
|
2347
|
+
type,
|
|
2348
|
+
nextPhase,
|
|
2349
|
+
Math.floor(expiredAt.getTime() / 1e3)
|
|
2350
|
+
]
|
|
2351
|
+
});
|
|
2352
|
+
return yield this.handleSendUserOperation(data);
|
|
2353
|
+
} catch (error) {
|
|
2354
|
+
throw new acpError_default("Failed to create payable memo", error);
|
|
1368
2355
|
}
|
|
1369
|
-
throw new Error("Failed to create payable memo");
|
|
1370
2356
|
});
|
|
1371
2357
|
}
|
|
1372
2358
|
createMemo(jobId, content, type, isSecured, nextPhase) {
|
|
1373
2359
|
return __async(this, null, function* () {
|
|
1374
2360
|
try {
|
|
1375
|
-
const data = (0,
|
|
2361
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
1376
2362
|
abi: acpAbi_default,
|
|
1377
2363
|
functionName: "createMemo",
|
|
1378
2364
|
args: [jobId, content, type, isSecured, nextPhase]
|
|
1379
2365
|
});
|
|
1380
2366
|
return yield this.handleSendUserOperation(data);
|
|
1381
2367
|
} catch (error) {
|
|
1382
|
-
|
|
1383
|
-
throw new Error("Failed to create memo");
|
|
2368
|
+
throw new acpError_default("Failed to create memo", error);
|
|
1384
2369
|
}
|
|
1385
2370
|
});
|
|
1386
2371
|
}
|
|
@@ -1388,21 +2373,21 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1388
2373
|
return __async(this, null, function* () {
|
|
1389
2374
|
const result = yield this.sessionKeyClient.getUserOperationReceipt(hash);
|
|
1390
2375
|
if (!result) {
|
|
1391
|
-
throw new
|
|
2376
|
+
throw new acpError_default("Failed to get user operation receipt");
|
|
1392
2377
|
}
|
|
1393
2378
|
const contractLogs = result.logs.find(
|
|
1394
2379
|
(log) => log.address.toLowerCase() === this.contractAddress.toLowerCase()
|
|
1395
2380
|
);
|
|
1396
2381
|
if (!contractLogs) {
|
|
1397
|
-
throw new
|
|
2382
|
+
throw new acpError_default("Failed to get contract logs");
|
|
1398
2383
|
}
|
|
1399
|
-
const decoded = (0,
|
|
2384
|
+
const decoded = (0, import_viem2.decodeEventLog)({
|
|
1400
2385
|
abi: acpAbi_default,
|
|
1401
2386
|
data: contractLogs.data,
|
|
1402
2387
|
topics: contractLogs.topics
|
|
1403
2388
|
});
|
|
1404
2389
|
if (!decoded.args) {
|
|
1405
|
-
throw new
|
|
2390
|
+
throw new acpError_default("Failed to decode event logs");
|
|
1406
2391
|
}
|
|
1407
2392
|
return parseInt(decoded.args.memoId);
|
|
1408
2393
|
});
|
|
@@ -1410,30 +2395,59 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1410
2395
|
signMemo(memoId, isApproved, reason) {
|
|
1411
2396
|
return __async(this, null, function* () {
|
|
1412
2397
|
try {
|
|
1413
|
-
const data = (0,
|
|
2398
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
1414
2399
|
abi: acpAbi_default,
|
|
1415
2400
|
functionName: "signMemo",
|
|
1416
2401
|
args: [memoId, isApproved, reason]
|
|
1417
2402
|
});
|
|
1418
2403
|
return yield this.handleSendUserOperation(data);
|
|
1419
2404
|
} catch (error) {
|
|
1420
|
-
|
|
1421
|
-
throw new Error("Failed to sign memo");
|
|
2405
|
+
throw new acpError_default("Failed to sign memo", error);
|
|
1422
2406
|
}
|
|
1423
2407
|
});
|
|
1424
2408
|
}
|
|
1425
|
-
setBudget(jobId,
|
|
2409
|
+
setBudget(jobId, budgetBaseUnit) {
|
|
1426
2410
|
return __async(this, null, function* () {
|
|
1427
2411
|
try {
|
|
1428
|
-
const data = (0,
|
|
2412
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
1429
2413
|
abi: acpAbi_default,
|
|
1430
2414
|
functionName: "setBudget",
|
|
1431
|
-
args: [jobId,
|
|
2415
|
+
args: [jobId, budgetBaseUnit]
|
|
1432
2416
|
});
|
|
1433
2417
|
return yield this.handleSendUserOperation(data);
|
|
1434
2418
|
} catch (error) {
|
|
1435
|
-
|
|
1436
|
-
|
|
2419
|
+
throw new acpError_default("Failed to set budget", error);
|
|
2420
|
+
}
|
|
2421
|
+
});
|
|
2422
|
+
}
|
|
2423
|
+
setBudgetWithPaymentToken(_0, _1) {
|
|
2424
|
+
return __async(this, arguments, function* (jobId, budgetBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
|
|
2425
|
+
try {
|
|
2426
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2427
|
+
abi: acpAbi_default,
|
|
2428
|
+
functionName: "setBudgetWithPaymentToken",
|
|
2429
|
+
args: [jobId, budgetBaseUnit, paymentTokenAddress]
|
|
2430
|
+
});
|
|
2431
|
+
return yield this.handleSendUserOperation(data);
|
|
2432
|
+
} catch (error) {
|
|
2433
|
+
throw new acpError_default("Failed to set budget", error);
|
|
2434
|
+
}
|
|
2435
|
+
});
|
|
2436
|
+
}
|
|
2437
|
+
wrapEth(amountBaseUnit) {
|
|
2438
|
+
return __async(this, null, function* () {
|
|
2439
|
+
try {
|
|
2440
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2441
|
+
abi: wethAbi_default,
|
|
2442
|
+
functionName: "deposit"
|
|
2443
|
+
});
|
|
2444
|
+
return yield this.handleSendUserOperation(
|
|
2445
|
+
data,
|
|
2446
|
+
wethFare.contractAddress,
|
|
2447
|
+
amountBaseUnit
|
|
2448
|
+
);
|
|
2449
|
+
} catch (error) {
|
|
2450
|
+
throw new acpError_default("Failed to wrap eth", error);
|
|
1437
2451
|
}
|
|
1438
2452
|
});
|
|
1439
2453
|
}
|
|
@@ -1441,6 +2455,12 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1441
2455
|
var acpContractClient_default = AcpContractClient;
|
|
1442
2456
|
|
|
1443
2457
|
// src/interfaces.ts
|
|
2458
|
+
var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
|
|
2459
|
+
AcpMemoStatus2["PENDING"] = "PENDING";
|
|
2460
|
+
AcpMemoStatus2["APPROVED"] = "APPROVED";
|
|
2461
|
+
AcpMemoStatus2["REJECTED"] = "REJECTED";
|
|
2462
|
+
return AcpMemoStatus2;
|
|
2463
|
+
})(AcpMemoStatus || {});
|
|
1444
2464
|
var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
|
|
1445
2465
|
AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
|
|
1446
2466
|
AcpAgentSort2["SUCCESS_RATE"] = "successRate";
|
|
@@ -1463,6 +2483,8 @@ var AcpOnlineStatus = /* @__PURE__ */ ((AcpOnlineStatus2) => {
|
|
|
1463
2483
|
var PayloadType = /* @__PURE__ */ ((PayloadType2) => {
|
|
1464
2484
|
PayloadType2["FUND_RESPONSE"] = "fund_response";
|
|
1465
2485
|
PayloadType2["OPEN_POSITION"] = "open_position";
|
|
2486
|
+
PayloadType2["SWAP_TOKEN"] = "swap_token";
|
|
2487
|
+
PayloadType2["RESPONSE_SWAP_TOKEN"] = "response_swap_token";
|
|
1466
2488
|
PayloadType2["CLOSE_PARTIAL_POSITION"] = "close_partial_position";
|
|
1467
2489
|
PayloadType2["CLOSE_POSITION"] = "close_position";
|
|
1468
2490
|
PayloadType2["POSITION_FULFILLED"] = "position_fulfilled";
|
|
@@ -1470,6 +2492,11 @@ var PayloadType = /* @__PURE__ */ ((PayloadType2) => {
|
|
|
1470
2492
|
PayloadType2["UNFULFILLED_POSITION"] = "unfulfilled_position";
|
|
1471
2493
|
return PayloadType2;
|
|
1472
2494
|
})(PayloadType || {});
|
|
2495
|
+
var PositionDirection = /* @__PURE__ */ ((PositionDirection2) => {
|
|
2496
|
+
PositionDirection2["LONG"] = "long";
|
|
2497
|
+
PositionDirection2["SHORT"] = "short";
|
|
2498
|
+
return PositionDirection2;
|
|
2499
|
+
})(PositionDirection || {});
|
|
1473
2500
|
|
|
1474
2501
|
// src/utils.ts
|
|
1475
2502
|
function tryParseJson(content) {
|
|
@@ -1482,20 +2509,46 @@ function tryParseJson(content) {
|
|
|
1482
2509
|
|
|
1483
2510
|
// src/acpJob.ts
|
|
1484
2511
|
var AcpJob = class {
|
|
1485
|
-
constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, memos, phase, context) {
|
|
2512
|
+
constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, priceTokenAddress, memos, phase, context) {
|
|
1486
2513
|
this.acpClient = acpClient;
|
|
1487
2514
|
this.id = id;
|
|
1488
2515
|
this.clientAddress = clientAddress;
|
|
1489
2516
|
this.providerAddress = providerAddress;
|
|
1490
2517
|
this.evaluatorAddress = evaluatorAddress;
|
|
1491
2518
|
this.price = price;
|
|
2519
|
+
this.priceTokenAddress = priceTokenAddress;
|
|
1492
2520
|
this.memos = memos;
|
|
1493
2521
|
this.phase = phase;
|
|
1494
2522
|
this.context = context;
|
|
2523
|
+
this.baseFare = acpClient.acpContractClient.config.baseFare;
|
|
1495
2524
|
}
|
|
1496
2525
|
get serviceRequirement() {
|
|
1497
2526
|
var _a;
|
|
1498
|
-
|
|
2527
|
+
const content = (_a = this.memos.find(
|
|
2528
|
+
(m) => m.nextPhase === 1 /* NEGOTIATION */
|
|
2529
|
+
)) == null ? void 0 : _a.content;
|
|
2530
|
+
if (!content) {
|
|
2531
|
+
return void 0;
|
|
2532
|
+
}
|
|
2533
|
+
const contentObj = tryParseJson(content);
|
|
2534
|
+
if (!contentObj) {
|
|
2535
|
+
return content;
|
|
2536
|
+
}
|
|
2537
|
+
if (contentObj.serviceRequirement) {
|
|
2538
|
+
return contentObj.serviceRequirement;
|
|
2539
|
+
}
|
|
2540
|
+
return contentObj;
|
|
2541
|
+
}
|
|
2542
|
+
get serviceName() {
|
|
2543
|
+
var _a;
|
|
2544
|
+
const content = (_a = this.memos.find(
|
|
2545
|
+
(m) => m.nextPhase === 1 /* NEGOTIATION */
|
|
2546
|
+
)) == null ? void 0 : _a.content;
|
|
2547
|
+
if (!content) {
|
|
2548
|
+
return void 0;
|
|
2549
|
+
}
|
|
2550
|
+
const contentObj = tryParseJson(content);
|
|
2551
|
+
return contentObj == null ? void 0 : contentObj.serviceName;
|
|
1499
2552
|
}
|
|
1500
2553
|
get deliverable() {
|
|
1501
2554
|
var _a;
|
|
@@ -1519,16 +2572,21 @@ var AcpJob = class {
|
|
|
1519
2572
|
(m) => m.nextPhase === 2 /* TRANSACTION */
|
|
1520
2573
|
);
|
|
1521
2574
|
if (!memo) {
|
|
1522
|
-
throw new
|
|
2575
|
+
throw new acpError_default("No transaction memo found");
|
|
1523
2576
|
}
|
|
1524
|
-
return yield this.acpClient.payJob(
|
|
2577
|
+
return yield this.acpClient.payJob(
|
|
2578
|
+
this.id,
|
|
2579
|
+
this.baseFare.formatAmount(amount),
|
|
2580
|
+
memo.id,
|
|
2581
|
+
reason
|
|
2582
|
+
);
|
|
1525
2583
|
});
|
|
1526
2584
|
}
|
|
1527
2585
|
respond(accept, payload, reason) {
|
|
1528
2586
|
return __async(this, null, function* () {
|
|
1529
2587
|
var _a;
|
|
1530
2588
|
if (((_a = this.latestMemo) == null ? void 0 : _a.nextPhase) !== 1 /* NEGOTIATION */) {
|
|
1531
|
-
throw new
|
|
2589
|
+
throw new acpError_default("No negotiation memo found");
|
|
1532
2590
|
}
|
|
1533
2591
|
return yield this.acpClient.respondJob(
|
|
1534
2592
|
this.id,
|
|
@@ -1543,7 +2601,7 @@ var AcpJob = class {
|
|
|
1543
2601
|
return __async(this, null, function* () {
|
|
1544
2602
|
var _a;
|
|
1545
2603
|
if (((_a = this.latestMemo) == null ? void 0 : _a.nextPhase) !== 3 /* EVALUATION */) {
|
|
1546
|
-
throw new
|
|
2604
|
+
throw new acpError_default("No transaction memo found");
|
|
1547
2605
|
}
|
|
1548
2606
|
return yield this.acpClient.deliverJob(this.id, deliverable);
|
|
1549
2607
|
});
|
|
@@ -1552,7 +2610,7 @@ var AcpJob = class {
|
|
|
1552
2610
|
return __async(this, null, function* () {
|
|
1553
2611
|
var _a;
|
|
1554
2612
|
if (((_a = this.latestMemo) == null ? void 0 : _a.nextPhase) !== 4 /* COMPLETED */) {
|
|
1555
|
-
throw new
|
|
2613
|
+
throw new acpError_default("No evaluation memo found");
|
|
1556
2614
|
}
|
|
1557
2615
|
return yield this.acpClient.acpContractClient.signMemo(
|
|
1558
2616
|
this.latestMemo.id,
|
|
@@ -1561,16 +2619,17 @@ var AcpJob = class {
|
|
|
1561
2619
|
);
|
|
1562
2620
|
});
|
|
1563
2621
|
}
|
|
1564
|
-
openPosition(
|
|
1565
|
-
return __async(this,
|
|
2622
|
+
openPosition(_0, _1) {
|
|
2623
|
+
return __async(this, arguments, function* (payload, feeAmount, expiredAt = new Date(Date.now() + 1e3 * 60 * 3), walletAddress) {
|
|
1566
2624
|
if (payload.length === 0) {
|
|
1567
|
-
throw new
|
|
2625
|
+
throw new acpError_default("No positions to open");
|
|
1568
2626
|
}
|
|
2627
|
+
const sumAmount = payload.reduce((acc, curr) => acc + curr.amount, 0);
|
|
1569
2628
|
return yield this.acpClient.transferFunds(
|
|
1570
2629
|
this.id,
|
|
1571
|
-
|
|
2630
|
+
new FareAmount(sumAmount, this.baseFare),
|
|
1572
2631
|
walletAddress || this.providerAddress,
|
|
1573
|
-
feeAmount,
|
|
2632
|
+
new FareAmount(feeAmount, this.baseFare),
|
|
1574
2633
|
1 /* IMMEDIATE_FEE */,
|
|
1575
2634
|
{
|
|
1576
2635
|
type: "open_position" /* OPEN_POSITION */,
|
|
@@ -1581,34 +2640,84 @@ var AcpJob = class {
|
|
|
1581
2640
|
);
|
|
1582
2641
|
});
|
|
1583
2642
|
}
|
|
2643
|
+
swapToken(payload, decimals, feeAmount, walletAddress) {
|
|
2644
|
+
return __async(this, null, function* () {
|
|
2645
|
+
return yield this.acpClient.transferFunds(
|
|
2646
|
+
this.id,
|
|
2647
|
+
new FareAmount(
|
|
2648
|
+
payload.amount,
|
|
2649
|
+
new Fare(payload.fromContractAddress, decimals)
|
|
2650
|
+
),
|
|
2651
|
+
walletAddress || this.providerAddress,
|
|
2652
|
+
new FareAmount(feeAmount, this.baseFare),
|
|
2653
|
+
1 /* IMMEDIATE_FEE */,
|
|
2654
|
+
{
|
|
2655
|
+
type: "swap_token" /* SWAP_TOKEN */,
|
|
2656
|
+
data: payload
|
|
2657
|
+
},
|
|
2658
|
+
2 /* TRANSACTION */,
|
|
2659
|
+
new Date(Date.now() + 1e3 * 60 * 30)
|
|
2660
|
+
);
|
|
2661
|
+
});
|
|
2662
|
+
}
|
|
2663
|
+
responseSwapToken(memoId, accept, reason) {
|
|
2664
|
+
return __async(this, null, function* () {
|
|
2665
|
+
const memo = this.memos.find((m) => m.id === memoId);
|
|
2666
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
2667
|
+
throw new acpError_default("No swap token memo found");
|
|
2668
|
+
}
|
|
2669
|
+
const payload = tryParseJson(
|
|
2670
|
+
memo.content
|
|
2671
|
+
);
|
|
2672
|
+
if ((payload == null ? void 0 : payload.type) !== "swap_token" /* SWAP_TOKEN */) {
|
|
2673
|
+
throw new acpError_default("Invalid swap token memo");
|
|
2674
|
+
}
|
|
2675
|
+
return yield memo.sign(accept, reason);
|
|
2676
|
+
});
|
|
2677
|
+
}
|
|
2678
|
+
transferFunds(_0, _1, _2) {
|
|
2679
|
+
return __async(this, arguments, function* (payload, fareAmount, walletAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 30)) {
|
|
2680
|
+
return yield this.acpClient.transferFunds(
|
|
2681
|
+
this.id,
|
|
2682
|
+
fareAmount,
|
|
2683
|
+
walletAddress || this.clientAddress,
|
|
2684
|
+
new FareAmount(0, this.baseFare),
|
|
2685
|
+
0 /* NO_FEE */,
|
|
2686
|
+
payload,
|
|
2687
|
+
2 /* TRANSACTION */,
|
|
2688
|
+
expiredAt
|
|
2689
|
+
);
|
|
2690
|
+
});
|
|
2691
|
+
}
|
|
1584
2692
|
responseOpenPosition(memoId, accept, reason) {
|
|
1585
2693
|
return __async(this, null, function* () {
|
|
1586
2694
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1587
|
-
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !==
|
|
1588
|
-
throw new
|
|
2695
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
2696
|
+
throw new acpError_default("No open position memo found");
|
|
1589
2697
|
}
|
|
1590
2698
|
const payload = tryParseJson(
|
|
1591
2699
|
memo.content
|
|
1592
2700
|
);
|
|
1593
2701
|
if ((payload == null ? void 0 : payload.type) !== "open_position" /* OPEN_POSITION */) {
|
|
1594
|
-
throw new
|
|
2702
|
+
throw new acpError_default("Invalid open position memo");
|
|
1595
2703
|
}
|
|
1596
2704
|
return yield this.acpClient.responseFundsTransfer(memo.id, accept, reason);
|
|
1597
2705
|
});
|
|
1598
2706
|
}
|
|
1599
|
-
closePartialPosition(
|
|
1600
|
-
return __async(this,
|
|
2707
|
+
closePartialPosition(_0) {
|
|
2708
|
+
return __async(this, arguments, function* (payload, expireAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1601
2709
|
return yield this.acpClient.requestFunds(
|
|
1602
2710
|
this.id,
|
|
1603
|
-
payload.amount,
|
|
2711
|
+
new FareAmount(payload.amount, this.baseFare),
|
|
1604
2712
|
this.clientAddress,
|
|
1605
|
-
0,
|
|
2713
|
+
new FareAmount(0, this.baseFare),
|
|
1606
2714
|
0 /* NO_FEE */,
|
|
1607
2715
|
{
|
|
1608
2716
|
type: "close_partial_position" /* CLOSE_PARTIAL_POSITION */,
|
|
1609
2717
|
data: payload
|
|
1610
2718
|
},
|
|
1611
|
-
2 /* TRANSACTION
|
|
2719
|
+
2 /* TRANSACTION */,
|
|
2720
|
+
expireAt
|
|
1612
2721
|
);
|
|
1613
2722
|
});
|
|
1614
2723
|
}
|
|
@@ -1616,18 +2725,18 @@ var AcpJob = class {
|
|
|
1616
2725
|
return __async(this, null, function* () {
|
|
1617
2726
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1618
2727
|
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 6 /* PAYABLE_REQUEST */) {
|
|
1619
|
-
throw new
|
|
2728
|
+
throw new acpError_default("No close position memo found");
|
|
1620
2729
|
}
|
|
1621
2730
|
const payload = tryParseJson(
|
|
1622
2731
|
memo.content
|
|
1623
2732
|
);
|
|
1624
2733
|
if ((payload == null ? void 0 : payload.type) !== "close_partial_position" /* CLOSE_PARTIAL_POSITION */) {
|
|
1625
|
-
throw new
|
|
2734
|
+
throw new acpError_default("Invalid close position memo");
|
|
1626
2735
|
}
|
|
1627
2736
|
return yield this.acpClient.responseFundsRequest(
|
|
1628
2737
|
memo.id,
|
|
1629
2738
|
accept,
|
|
1630
|
-
payload.data.amount,
|
|
2739
|
+
this.baseFare.formatAmount(payload.data.amount),
|
|
1631
2740
|
reason
|
|
1632
2741
|
);
|
|
1633
2742
|
});
|
|
@@ -1644,29 +2753,30 @@ var AcpJob = class {
|
|
|
1644
2753
|
);
|
|
1645
2754
|
});
|
|
1646
2755
|
}
|
|
1647
|
-
responseRequestClosePosition(
|
|
1648
|
-
return __async(this,
|
|
2756
|
+
responseRequestClosePosition(_0, _1, _2, _3) {
|
|
2757
|
+
return __async(this, arguments, function* (memoId, accept, payload, reason, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1649
2758
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1650
2759
|
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 0 /* MESSAGE */) {
|
|
1651
|
-
throw new
|
|
2760
|
+
throw new acpError_default("No message memo found");
|
|
1652
2761
|
}
|
|
1653
2762
|
const messagePayload = tryParseJson(memo.content);
|
|
1654
2763
|
if ((messagePayload == null ? void 0 : messagePayload.type) !== "close_position" /* CLOSE_POSITION */) {
|
|
1655
|
-
throw new
|
|
2764
|
+
throw new acpError_default("Invalid close position memo");
|
|
1656
2765
|
}
|
|
1657
2766
|
yield memo.sign(accept, reason);
|
|
1658
2767
|
if (accept) {
|
|
1659
2768
|
return yield this.acpClient.transferFunds(
|
|
1660
2769
|
this.id,
|
|
1661
|
-
payload.amount,
|
|
2770
|
+
new FareAmount(payload.amount, this.baseFare),
|
|
1662
2771
|
this.clientAddress,
|
|
1663
|
-
0,
|
|
2772
|
+
new FareAmount(0, this.baseFare),
|
|
1664
2773
|
0 /* NO_FEE */,
|
|
1665
2774
|
{
|
|
1666
2775
|
type: "close_position" /* CLOSE_POSITION */,
|
|
1667
2776
|
data: payload
|
|
1668
2777
|
},
|
|
1669
|
-
2 /* TRANSACTION
|
|
2778
|
+
2 /* TRANSACTION */,
|
|
2779
|
+
expiredAt
|
|
1670
2780
|
);
|
|
1671
2781
|
}
|
|
1672
2782
|
});
|
|
@@ -1674,61 +2784,63 @@ var AcpJob = class {
|
|
|
1674
2784
|
confirmClosePosition(memoId, accept, reason) {
|
|
1675
2785
|
return __async(this, null, function* () {
|
|
1676
2786
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1677
|
-
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !==
|
|
1678
|
-
throw new
|
|
2787
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
2788
|
+
throw new acpError_default("No payable transfer memo found");
|
|
1679
2789
|
}
|
|
1680
2790
|
const payload = tryParseJson(
|
|
1681
2791
|
memo.content
|
|
1682
2792
|
);
|
|
1683
2793
|
if ((payload == null ? void 0 : payload.type) !== "close_position" /* CLOSE_POSITION */) {
|
|
1684
|
-
throw new
|
|
2794
|
+
throw new acpError_default("Invalid close position memo");
|
|
1685
2795
|
}
|
|
1686
2796
|
yield memo.sign(accept, reason);
|
|
1687
2797
|
});
|
|
1688
2798
|
}
|
|
1689
|
-
positionFulfilled(
|
|
1690
|
-
return __async(this,
|
|
2799
|
+
positionFulfilled(_0) {
|
|
2800
|
+
return __async(this, arguments, function* (payload, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1691
2801
|
return yield this.acpClient.transferFunds(
|
|
1692
2802
|
this.id,
|
|
1693
|
-
payload.amount,
|
|
2803
|
+
new FareAmount(payload.amount, this.baseFare),
|
|
1694
2804
|
this.clientAddress,
|
|
1695
|
-
0,
|
|
2805
|
+
new FareAmount(0, this.baseFare),
|
|
1696
2806
|
0 /* NO_FEE */,
|
|
1697
2807
|
{
|
|
1698
2808
|
type: "position_fulfilled" /* POSITION_FULFILLED */,
|
|
1699
2809
|
data: payload
|
|
1700
2810
|
},
|
|
1701
|
-
2 /* TRANSACTION
|
|
2811
|
+
2 /* TRANSACTION */,
|
|
2812
|
+
expiredAt
|
|
1702
2813
|
);
|
|
1703
2814
|
});
|
|
1704
2815
|
}
|
|
1705
|
-
unfulfilledPosition(
|
|
1706
|
-
return __async(this,
|
|
2816
|
+
unfulfilledPosition(_0) {
|
|
2817
|
+
return __async(this, arguments, function* (payload, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1707
2818
|
return yield this.acpClient.transferFunds(
|
|
1708
2819
|
this.id,
|
|
1709
|
-
payload.amount,
|
|
2820
|
+
new FareAmount(payload.amount, this.baseFare),
|
|
1710
2821
|
this.clientAddress,
|
|
1711
|
-
0,
|
|
2822
|
+
new FareAmount(0, this.baseFare),
|
|
1712
2823
|
0 /* NO_FEE */,
|
|
1713
2824
|
{
|
|
1714
2825
|
type: "unfulfilled_position" /* UNFULFILLED_POSITION */,
|
|
1715
2826
|
data: payload
|
|
1716
2827
|
},
|
|
1717
|
-
2 /* TRANSACTION
|
|
2828
|
+
2 /* TRANSACTION */,
|
|
2829
|
+
expiredAt
|
|
1718
2830
|
);
|
|
1719
2831
|
});
|
|
1720
2832
|
}
|
|
1721
2833
|
responseUnfulfilledPosition(memoId, accept, reason) {
|
|
1722
2834
|
return __async(this, null, function* () {
|
|
1723
2835
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1724
|
-
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !==
|
|
1725
|
-
throw new
|
|
2836
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
2837
|
+
throw new acpError_default("No unfulfilled position memo found");
|
|
1726
2838
|
}
|
|
1727
2839
|
const payload = tryParseJson(
|
|
1728
2840
|
memo.content
|
|
1729
2841
|
);
|
|
1730
2842
|
if ((payload == null ? void 0 : payload.type) !== "unfulfilled_position" /* UNFULFILLED_POSITION */) {
|
|
1731
|
-
throw new
|
|
2843
|
+
throw new acpError_default("Invalid unfulfilled position memo");
|
|
1732
2844
|
}
|
|
1733
2845
|
return yield this.acpClient.responseFundsTransfer(memo.id, accept, reason);
|
|
1734
2846
|
});
|
|
@@ -1736,14 +2848,14 @@ var AcpJob = class {
|
|
|
1736
2848
|
responsePositionFulfilled(memoId, accept, reason) {
|
|
1737
2849
|
return __async(this, null, function* () {
|
|
1738
2850
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1739
|
-
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !==
|
|
1740
|
-
throw new
|
|
2851
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
2852
|
+
throw new acpError_default("No position fulfilled memo found");
|
|
1741
2853
|
}
|
|
1742
2854
|
const payload = tryParseJson(
|
|
1743
2855
|
memo.content
|
|
1744
2856
|
);
|
|
1745
2857
|
if ((payload == null ? void 0 : payload.type) !== "position_fulfilled" /* POSITION_FULFILLED */) {
|
|
1746
|
-
throw new
|
|
2858
|
+
throw new acpError_default("Invalid position fulfilled memo");
|
|
1747
2859
|
}
|
|
1748
2860
|
return yield this.acpClient.responseFundsTransfer(memo.id, accept, reason);
|
|
1749
2861
|
});
|
|
@@ -1762,17 +2874,17 @@ var AcpJob = class {
|
|
|
1762
2874
|
);
|
|
1763
2875
|
});
|
|
1764
2876
|
}
|
|
1765
|
-
responseCloseJob(
|
|
1766
|
-
return __async(this,
|
|
2877
|
+
responseCloseJob(_0, _1, _2, _3) {
|
|
2878
|
+
return __async(this, arguments, function* (memoId, accept, fulfilledPositions, reason, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1767
2879
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1768
2880
|
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 0 /* MESSAGE */) {
|
|
1769
|
-
throw new
|
|
2881
|
+
throw new acpError_default("No message memo found");
|
|
1770
2882
|
}
|
|
1771
2883
|
const payload = tryParseJson(
|
|
1772
2884
|
memo.content
|
|
1773
2885
|
);
|
|
1774
2886
|
if ((payload == null ? void 0 : payload.type) !== "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */) {
|
|
1775
|
-
throw new
|
|
2887
|
+
throw new acpError_default("Invalid close job and withdraw memo");
|
|
1776
2888
|
}
|
|
1777
2889
|
yield memo.sign(accept, reason);
|
|
1778
2890
|
if (!accept) {
|
|
@@ -1794,15 +2906,16 @@ var AcpJob = class {
|
|
|
1794
2906
|
}
|
|
1795
2907
|
return yield this.acpClient.transferFunds(
|
|
1796
2908
|
this.id,
|
|
1797
|
-
|
|
2909
|
+
new FareAmount(totalAmount, this.baseFare),
|
|
1798
2910
|
this.clientAddress,
|
|
1799
|
-
0,
|
|
2911
|
+
new FareAmount(0, this.baseFare),
|
|
1800
2912
|
0 /* NO_FEE */,
|
|
1801
2913
|
{
|
|
1802
2914
|
type: "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */,
|
|
1803
2915
|
data: fulfilledPositions
|
|
1804
2916
|
},
|
|
1805
|
-
4 /* COMPLETED
|
|
2917
|
+
4 /* COMPLETED */,
|
|
2918
|
+
expiredAt
|
|
1806
2919
|
);
|
|
1807
2920
|
});
|
|
1808
2921
|
}
|
|
@@ -1810,13 +2923,13 @@ var AcpJob = class {
|
|
|
1810
2923
|
return __async(this, null, function* () {
|
|
1811
2924
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1812
2925
|
if (!memo) {
|
|
1813
|
-
throw new
|
|
2926
|
+
throw new acpError_default("Memo not found");
|
|
1814
2927
|
}
|
|
1815
2928
|
const payload = tryParseJson(
|
|
1816
2929
|
memo.content
|
|
1817
2930
|
);
|
|
1818
2931
|
if ((payload == null ? void 0 : payload.type) !== "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */) {
|
|
1819
|
-
throw new
|
|
2932
|
+
throw new acpError_default("Invalid close job and withdraw memo");
|
|
1820
2933
|
}
|
|
1821
2934
|
yield memo.sign(accept, reason);
|
|
1822
2935
|
});
|
|
@@ -1826,13 +2939,20 @@ var acpJob_default = AcpJob;
|
|
|
1826
2939
|
|
|
1827
2940
|
// src/acpMemo.ts
|
|
1828
2941
|
var AcpMemo = class {
|
|
1829
|
-
constructor(acpClient, id, type, content, nextPhase, expiry) {
|
|
2942
|
+
constructor(acpClient, id, type, content, nextPhase, status, signedReason, expiry, payableDetails) {
|
|
1830
2943
|
this.acpClient = acpClient;
|
|
1831
2944
|
this.id = id;
|
|
1832
2945
|
this.type = type;
|
|
1833
2946
|
this.content = content;
|
|
1834
2947
|
this.nextPhase = nextPhase;
|
|
2948
|
+
this.status = status;
|
|
2949
|
+
this.signedReason = signedReason;
|
|
1835
2950
|
this.expiry = expiry;
|
|
2951
|
+
this.payableDetails = payableDetails;
|
|
2952
|
+
if (this.payableDetails) {
|
|
2953
|
+
this.payableDetails.amount = BigInt(this.payableDetails.amount);
|
|
2954
|
+
this.payableDetails.feeAmount = BigInt(this.payableDetails.feeAmount);
|
|
2955
|
+
}
|
|
1836
2956
|
this.structuredContent = tryParseJson(this.content) || void 0;
|
|
1837
2957
|
}
|
|
1838
2958
|
get payloadType() {
|
|
@@ -1868,10 +2988,10 @@ var acpMemo_default = AcpMemo;
|
|
|
1868
2988
|
// src/acpJobOffering.ts
|
|
1869
2989
|
var import_ajv = __toESM(require("ajv"));
|
|
1870
2990
|
var AcpJobOffering = class {
|
|
1871
|
-
constructor(acpClient, providerAddress,
|
|
2991
|
+
constructor(acpClient, providerAddress, name, price, requirementSchema) {
|
|
1872
2992
|
this.acpClient = acpClient;
|
|
1873
2993
|
this.providerAddress = providerAddress;
|
|
1874
|
-
this.
|
|
2994
|
+
this.name = name;
|
|
1875
2995
|
this.price = price;
|
|
1876
2996
|
this.requirementSchema = requirementSchema;
|
|
1877
2997
|
this.ajv = new import_ajv.default({ allErrors: true });
|
|
@@ -1882,13 +3002,28 @@ var AcpJobOffering = class {
|
|
|
1882
3002
|
const validator = this.ajv.compile(this.requirementSchema);
|
|
1883
3003
|
const valid = validator(serviceRequirement);
|
|
1884
3004
|
if (!valid) {
|
|
1885
|
-
throw new
|
|
3005
|
+
throw new acpError_default(this.ajv.errorsText(validator.errors));
|
|
1886
3006
|
}
|
|
1887
3007
|
}
|
|
3008
|
+
let finalServiceRequirement = {
|
|
3009
|
+
serviceName: this.name
|
|
3010
|
+
};
|
|
3011
|
+
if (typeof serviceRequirement === "string") {
|
|
3012
|
+
finalServiceRequirement = __spreadProps(__spreadValues({}, finalServiceRequirement), {
|
|
3013
|
+
message: serviceRequirement
|
|
3014
|
+
});
|
|
3015
|
+
} else {
|
|
3016
|
+
finalServiceRequirement = __spreadProps(__spreadValues({}, finalServiceRequirement), {
|
|
3017
|
+
serviceRequirement
|
|
3018
|
+
});
|
|
3019
|
+
}
|
|
1888
3020
|
return yield this.acpClient.initiateJob(
|
|
1889
3021
|
this.providerAddress,
|
|
1890
|
-
|
|
1891
|
-
|
|
3022
|
+
finalServiceRequirement,
|
|
3023
|
+
new FareAmount(
|
|
3024
|
+
this.price,
|
|
3025
|
+
this.acpClient.acpContractClient.config.baseFare
|
|
3026
|
+
),
|
|
1892
3027
|
evaluatorAddress,
|
|
1893
3028
|
expiredAt
|
|
1894
3029
|
);
|
|
@@ -1942,6 +3077,7 @@ var AcpClient = class {
|
|
|
1942
3077
|
data.providerAddress,
|
|
1943
3078
|
data.evaluatorAddress,
|
|
1944
3079
|
data.price,
|
|
3080
|
+
data.priceTokenAddress,
|
|
1945
3081
|
data.memos.map((memo) => {
|
|
1946
3082
|
return new acpMemo_default(
|
|
1947
3083
|
this,
|
|
@@ -1949,7 +3085,10 @@ var AcpClient = class {
|
|
|
1949
3085
|
memo.memoType,
|
|
1950
3086
|
memo.content,
|
|
1951
3087
|
memo.nextPhase,
|
|
1952
|
-
memo.
|
|
3088
|
+
memo.status,
|
|
3089
|
+
memo.signedReason,
|
|
3090
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3091
|
+
memo.payableDetails
|
|
1953
3092
|
);
|
|
1954
3093
|
}),
|
|
1955
3094
|
data.phase,
|
|
@@ -1971,6 +3110,7 @@ var AcpClient = class {
|
|
|
1971
3110
|
data.providerAddress,
|
|
1972
3111
|
data.evaluatorAddress,
|
|
1973
3112
|
data.price,
|
|
3113
|
+
data.priceTokenAddress,
|
|
1974
3114
|
data.memos.map((memo) => {
|
|
1975
3115
|
return new acpMemo_default(
|
|
1976
3116
|
this,
|
|
@@ -1978,7 +3118,10 @@ var AcpClient = class {
|
|
|
1978
3118
|
memo.memoType,
|
|
1979
3119
|
memo.content,
|
|
1980
3120
|
memo.nextPhase,
|
|
1981
|
-
memo.
|
|
3121
|
+
memo.status,
|
|
3122
|
+
memo.signedReason,
|
|
3123
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3124
|
+
memo.payableDetails
|
|
1982
3125
|
);
|
|
1983
3126
|
}),
|
|
1984
3127
|
data.phase,
|
|
@@ -2036,7 +3179,7 @@ var AcpClient = class {
|
|
|
2036
3179
|
this,
|
|
2037
3180
|
agent.walletAddress,
|
|
2038
3181
|
offering.name,
|
|
2039
|
-
offering.
|
|
3182
|
+
offering.priceUsd,
|
|
2040
3183
|
offering.requirementSchema
|
|
2041
3184
|
);
|
|
2042
3185
|
}),
|
|
@@ -2048,18 +3191,22 @@ var AcpClient = class {
|
|
|
2048
3191
|
});
|
|
2049
3192
|
}
|
|
2050
3193
|
initiateJob(_0, _1, _2, _3) {
|
|
2051
|
-
return __async(this, arguments, function* (providerAddress, serviceRequirement,
|
|
3194
|
+
return __async(this, arguments, function* (providerAddress, serviceRequirement, fareAmount, evaluatorAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
3195
|
+
if (providerAddress === this.acpContractClient.walletAddress) {
|
|
3196
|
+
throw new acpError_default(
|
|
3197
|
+
"Provider address cannot be the same as the client address"
|
|
3198
|
+
);
|
|
3199
|
+
}
|
|
2052
3200
|
const { jobId } = yield this.acpContractClient.createJob(
|
|
2053
3201
|
providerAddress,
|
|
2054
3202
|
evaluatorAddress || this.acpContractClient.walletAddress,
|
|
2055
3203
|
expiredAt
|
|
2056
3204
|
);
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
}
|
|
3205
|
+
yield this.acpContractClient.setBudgetWithPaymentToken(
|
|
3206
|
+
jobId,
|
|
3207
|
+
fareAmount.amount,
|
|
3208
|
+
fareAmount.fare.contractAddress
|
|
3209
|
+
);
|
|
2063
3210
|
yield this.acpContractClient.createMemo(
|
|
2064
3211
|
jobId,
|
|
2065
3212
|
typeof serviceRequirement === "string" ? serviceRequirement : JSON.stringify(serviceRequirement),
|
|
@@ -2085,68 +3232,79 @@ var AcpClient = class {
|
|
|
2085
3232
|
);
|
|
2086
3233
|
});
|
|
2087
3234
|
}
|
|
2088
|
-
payJob(jobId,
|
|
3235
|
+
payJob(jobId, amountBaseUnit, memoId, reason) {
|
|
2089
3236
|
return __async(this, null, function* () {
|
|
2090
|
-
if (
|
|
2091
|
-
yield this.acpContractClient.approveAllowance(
|
|
2092
|
-
(0, import_viem2.parseEther)(amount.toString())
|
|
2093
|
-
);
|
|
3237
|
+
if (amountBaseUnit > BigInt(0)) {
|
|
3238
|
+
yield this.acpContractClient.approveAllowance(amountBaseUnit);
|
|
2094
3239
|
}
|
|
2095
3240
|
yield this.acpContractClient.signMemo(memoId, true, reason);
|
|
2096
3241
|
return yield this.acpContractClient.createMemo(
|
|
2097
3242
|
jobId,
|
|
2098
|
-
`Payment
|
|
3243
|
+
`Payment made. ${reason != null ? reason : ""}`,
|
|
2099
3244
|
0 /* MESSAGE */,
|
|
2100
3245
|
false,
|
|
2101
3246
|
3 /* EVALUATION */
|
|
2102
3247
|
);
|
|
2103
3248
|
});
|
|
2104
3249
|
}
|
|
2105
|
-
requestFunds(jobId,
|
|
3250
|
+
requestFunds(jobId, transferFareAmount, recipient, feeFareAmount, feeType, reason, nextPhase, expiredAt) {
|
|
2106
3251
|
return __async(this, null, function* () {
|
|
2107
3252
|
return yield this.acpContractClient.createPayableMemo(
|
|
2108
3253
|
jobId,
|
|
2109
3254
|
JSON.stringify(reason),
|
|
2110
|
-
|
|
3255
|
+
transferFareAmount.amount,
|
|
2111
3256
|
recipient,
|
|
2112
|
-
|
|
3257
|
+
feeFareAmount.amount,
|
|
2113
3258
|
feeType,
|
|
2114
3259
|
nextPhase,
|
|
2115
|
-
6 /* PAYABLE_REQUEST
|
|
3260
|
+
6 /* PAYABLE_REQUEST */,
|
|
3261
|
+
expiredAt
|
|
2116
3262
|
);
|
|
2117
3263
|
});
|
|
2118
3264
|
}
|
|
2119
|
-
responseFundsRequest(memoId, accept,
|
|
3265
|
+
responseFundsRequest(memoId, accept, amountBaseUnit, reason) {
|
|
2120
3266
|
return __async(this, null, function* () {
|
|
2121
3267
|
if (!accept) {
|
|
2122
3268
|
return yield this.acpContractClient.signMemo(memoId, accept, reason);
|
|
2123
3269
|
}
|
|
2124
|
-
if (
|
|
2125
|
-
yield this.acpContractClient.approveAllowance(
|
|
2126
|
-
(0, import_viem2.parseEther)(amount.toString())
|
|
2127
|
-
);
|
|
3270
|
+
if (amountBaseUnit > BigInt(0)) {
|
|
3271
|
+
yield this.acpContractClient.approveAllowance(amountBaseUnit);
|
|
2128
3272
|
}
|
|
2129
3273
|
return yield this.acpContractClient.signMemo(memoId, true, reason);
|
|
2130
3274
|
});
|
|
2131
3275
|
}
|
|
2132
|
-
transferFunds(jobId,
|
|
3276
|
+
transferFunds(jobId, transferFareAmount, recipient, feeFareAmount, feeType, reason, nextPhase, expiredAt) {
|
|
2133
3277
|
return __async(this, null, function* () {
|
|
2134
|
-
|
|
2135
|
-
|
|
3278
|
+
if (transferFareAmount.fare.contractAddress === ethFare.contractAddress) {
|
|
3279
|
+
yield this.acpContractClient.wrapEth(transferFareAmount.amount);
|
|
3280
|
+
transferFareAmount = new FareBigInt(transferFareAmount.amount, wethFare);
|
|
3281
|
+
}
|
|
3282
|
+
if (feeFareAmount.amount > 0 && feeFareAmount.fare.contractAddress !== this.acpContractClient.config.baseFare.contractAddress) {
|
|
3283
|
+
throw new acpError_default("Fee token address is not the same as the base fare");
|
|
3284
|
+
}
|
|
3285
|
+
const isFeeTokenDifferent = feeFareAmount.fare.contractAddress !== transferFareAmount.fare.contractAddress;
|
|
3286
|
+
if (isFeeTokenDifferent) {
|
|
2136
3287
|
yield this.acpContractClient.approveAllowance(
|
|
2137
|
-
|
|
3288
|
+
feeFareAmount.amount,
|
|
3289
|
+
feeFareAmount.fare.contractAddress
|
|
2138
3290
|
);
|
|
2139
3291
|
}
|
|
3292
|
+
const finalAmount = isFeeTokenDifferent ? transferFareAmount : transferFareAmount.add(feeFareAmount);
|
|
3293
|
+
yield this.acpContractClient.approveAllowance(
|
|
3294
|
+
finalAmount.amount,
|
|
3295
|
+
transferFareAmount.fare.contractAddress
|
|
3296
|
+
);
|
|
2140
3297
|
return yield this.acpContractClient.createPayableMemo(
|
|
2141
3298
|
jobId,
|
|
2142
3299
|
JSON.stringify(reason),
|
|
2143
|
-
|
|
3300
|
+
transferFareAmount.amount,
|
|
2144
3301
|
recipient,
|
|
2145
|
-
|
|
3302
|
+
feeFareAmount.amount,
|
|
2146
3303
|
feeType,
|
|
2147
3304
|
nextPhase,
|
|
2148
|
-
|
|
2149
|
-
expiredAt
|
|
3305
|
+
8 /* PAYABLE_TRANSFER_ESCROW */,
|
|
3306
|
+
expiredAt,
|
|
3307
|
+
transferFareAmount.fare.contractAddress
|
|
2150
3308
|
);
|
|
2151
3309
|
});
|
|
2152
3310
|
}
|
|
@@ -2188,7 +3346,7 @@ var AcpClient = class {
|
|
|
2188
3346
|
});
|
|
2189
3347
|
const data = yield response.json();
|
|
2190
3348
|
if (data.error) {
|
|
2191
|
-
throw new
|
|
3349
|
+
throw new acpError_default(data.error.message);
|
|
2192
3350
|
}
|
|
2193
3351
|
return data.data.map((job) => {
|
|
2194
3352
|
return new acpJob_default(
|
|
@@ -2198,6 +3356,7 @@ var AcpClient = class {
|
|
|
2198
3356
|
job.providerAddress,
|
|
2199
3357
|
job.evaluatorAddress,
|
|
2200
3358
|
job.price,
|
|
3359
|
+
job.priceTokenAddress,
|
|
2201
3360
|
job.memos.map((memo) => {
|
|
2202
3361
|
return new acpMemo_default(
|
|
2203
3362
|
this,
|
|
@@ -2205,7 +3364,10 @@ var AcpClient = class {
|
|
|
2205
3364
|
memo.memoType,
|
|
2206
3365
|
memo.content,
|
|
2207
3366
|
memo.nextPhase,
|
|
2208
|
-
memo.
|
|
3367
|
+
memo.status,
|
|
3368
|
+
memo.signedReason,
|
|
3369
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3370
|
+
memo.payableDetails
|
|
2209
3371
|
);
|
|
2210
3372
|
}),
|
|
2211
3373
|
job.phase,
|
|
@@ -2213,7 +3375,7 @@ var AcpClient = class {
|
|
|
2213
3375
|
);
|
|
2214
3376
|
});
|
|
2215
3377
|
} catch (error) {
|
|
2216
|
-
throw error;
|
|
3378
|
+
throw new acpError_default("Failed to get active jobs", error);
|
|
2217
3379
|
}
|
|
2218
3380
|
});
|
|
2219
3381
|
}
|
|
@@ -2228,7 +3390,7 @@ var AcpClient = class {
|
|
|
2228
3390
|
});
|
|
2229
3391
|
const data = yield response.json();
|
|
2230
3392
|
if (data.error) {
|
|
2231
|
-
throw new
|
|
3393
|
+
throw new acpError_default(data.error.message);
|
|
2232
3394
|
}
|
|
2233
3395
|
return data.data.map((job) => {
|
|
2234
3396
|
return new acpJob_default(
|
|
@@ -2238,6 +3400,7 @@ var AcpClient = class {
|
|
|
2238
3400
|
job.providerAddress,
|
|
2239
3401
|
job.evaluatorAddress,
|
|
2240
3402
|
job.price,
|
|
3403
|
+
job.priceTokenAddress,
|
|
2241
3404
|
job.memos.map((memo) => {
|
|
2242
3405
|
return new acpMemo_default(
|
|
2243
3406
|
this,
|
|
@@ -2245,7 +3408,10 @@ var AcpClient = class {
|
|
|
2245
3408
|
memo.memoType,
|
|
2246
3409
|
memo.content,
|
|
2247
3410
|
memo.nextPhase,
|
|
2248
|
-
memo.
|
|
3411
|
+
memo.status,
|
|
3412
|
+
memo.signedReason,
|
|
3413
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3414
|
+
memo.payableDetails
|
|
2249
3415
|
);
|
|
2250
3416
|
}),
|
|
2251
3417
|
job.phase,
|
|
@@ -2253,7 +3419,7 @@ var AcpClient = class {
|
|
|
2253
3419
|
);
|
|
2254
3420
|
});
|
|
2255
3421
|
} catch (error) {
|
|
2256
|
-
throw error;
|
|
3422
|
+
throw new acpError_default("Failed to get completed jobs", error);
|
|
2257
3423
|
}
|
|
2258
3424
|
});
|
|
2259
3425
|
}
|
|
@@ -2268,7 +3434,7 @@ var AcpClient = class {
|
|
|
2268
3434
|
});
|
|
2269
3435
|
const data = yield response.json();
|
|
2270
3436
|
if (data.error) {
|
|
2271
|
-
throw new
|
|
3437
|
+
throw new acpError_default(data.error.message);
|
|
2272
3438
|
}
|
|
2273
3439
|
return data.data.map((job) => {
|
|
2274
3440
|
return new acpJob_default(
|
|
@@ -2278,6 +3444,7 @@ var AcpClient = class {
|
|
|
2278
3444
|
job.providerAddress,
|
|
2279
3445
|
job.evaluatorAddress,
|
|
2280
3446
|
job.price,
|
|
3447
|
+
job.priceTokenAddress,
|
|
2281
3448
|
job.memos.map((memo) => {
|
|
2282
3449
|
return new acpMemo_default(
|
|
2283
3450
|
this,
|
|
@@ -2285,7 +3452,10 @@ var AcpClient = class {
|
|
|
2285
3452
|
memo.memoType,
|
|
2286
3453
|
memo.content,
|
|
2287
3454
|
memo.nextPhase,
|
|
2288
|
-
memo.
|
|
3455
|
+
memo.status,
|
|
3456
|
+
memo.signedReason,
|
|
3457
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3458
|
+
memo.payableDetails
|
|
2289
3459
|
);
|
|
2290
3460
|
}),
|
|
2291
3461
|
job.phase,
|
|
@@ -2293,7 +3463,7 @@ var AcpClient = class {
|
|
|
2293
3463
|
);
|
|
2294
3464
|
});
|
|
2295
3465
|
} catch (error) {
|
|
2296
|
-
throw error;
|
|
3466
|
+
throw new acpError_default("Failed to get cancelled jobs", error);
|
|
2297
3467
|
}
|
|
2298
3468
|
});
|
|
2299
3469
|
}
|
|
@@ -2308,7 +3478,7 @@ var AcpClient = class {
|
|
|
2308
3478
|
});
|
|
2309
3479
|
const data = yield response.json();
|
|
2310
3480
|
if (data.error) {
|
|
2311
|
-
throw new
|
|
3481
|
+
throw new acpError_default(data.error.message);
|
|
2312
3482
|
}
|
|
2313
3483
|
const job = data.data;
|
|
2314
3484
|
if (!job) {
|
|
@@ -2321,6 +3491,7 @@ var AcpClient = class {
|
|
|
2321
3491
|
job.providerAddress,
|
|
2322
3492
|
job.evaluatorAddress,
|
|
2323
3493
|
job.price,
|
|
3494
|
+
job.priceTokenAddress,
|
|
2324
3495
|
job.memos.map((memo) => {
|
|
2325
3496
|
return new acpMemo_default(
|
|
2326
3497
|
this,
|
|
@@ -2328,14 +3499,17 @@ var AcpClient = class {
|
|
|
2328
3499
|
memo.memoType,
|
|
2329
3500
|
memo.content,
|
|
2330
3501
|
memo.nextPhase,
|
|
2331
|
-
memo.
|
|
3502
|
+
memo.status,
|
|
3503
|
+
memo.signedReason,
|
|
3504
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3505
|
+
memo.payableDetails
|
|
2332
3506
|
);
|
|
2333
3507
|
}),
|
|
2334
3508
|
job.phase,
|
|
2335
3509
|
job.context
|
|
2336
3510
|
);
|
|
2337
3511
|
} catch (error) {
|
|
2338
|
-
throw error;
|
|
3512
|
+
throw new acpError_default("Failed to get job by id", error);
|
|
2339
3513
|
}
|
|
2340
3514
|
});
|
|
2341
3515
|
}
|
|
@@ -2350,7 +3524,7 @@ var AcpClient = class {
|
|
|
2350
3524
|
});
|
|
2351
3525
|
const data = yield response.json();
|
|
2352
3526
|
if (data.error) {
|
|
2353
|
-
throw new
|
|
3527
|
+
throw new acpError_default(data.error.message);
|
|
2354
3528
|
}
|
|
2355
3529
|
const memo = data.data;
|
|
2356
3530
|
if (!memo) {
|
|
@@ -2362,10 +3536,13 @@ var AcpClient = class {
|
|
|
2362
3536
|
memo.memoType,
|
|
2363
3537
|
memo.content,
|
|
2364
3538
|
memo.nextPhase,
|
|
2365
|
-
memo.
|
|
3539
|
+
memo.status,
|
|
3540
|
+
memo.signedReason,
|
|
3541
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3542
|
+
memo.payableDetails
|
|
2366
3543
|
);
|
|
2367
3544
|
} catch (error) {
|
|
2368
|
-
throw error;
|
|
3545
|
+
throw new acpError_default("Failed to get memo by id", error);
|
|
2369
3546
|
}
|
|
2370
3547
|
});
|
|
2371
3548
|
}
|
|
@@ -2391,13 +3568,22 @@ var index_default = acpClient_default;
|
|
|
2391
3568
|
ACP_ABI,
|
|
2392
3569
|
AcpAgentSort,
|
|
2393
3570
|
AcpContractClient,
|
|
3571
|
+
AcpContractConfig,
|
|
3572
|
+
AcpError,
|
|
2394
3573
|
AcpGraduationStatus,
|
|
2395
3574
|
AcpJob,
|
|
2396
3575
|
AcpJobPhases,
|
|
2397
3576
|
AcpMemo,
|
|
3577
|
+
AcpMemoStatus,
|
|
2398
3578
|
AcpOnlineStatus,
|
|
3579
|
+
Fare,
|
|
3580
|
+
FareAmount,
|
|
3581
|
+
FareBigInt,
|
|
2399
3582
|
MemoType,
|
|
2400
3583
|
PayloadType,
|
|
3584
|
+
PositionDirection,
|
|
2401
3585
|
baseAcpConfig,
|
|
2402
|
-
baseSepoliaAcpConfig
|
|
3586
|
+
baseSepoliaAcpConfig,
|
|
3587
|
+
ethFare,
|
|
3588
|
+
wethFare
|
|
2403
3589
|
});
|