@virtuals-protocol/acp-node 0.2.0-beta.1 → 0.2.0-beta.11
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 +42 -21
- package/dist/index.d.mts +285 -214
- package/dist/index.d.ts +285 -214
- package/dist/index.js +1705 -509
- package/dist/index.mjs +1689 -509
- 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.11",
|
|
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
|
+
],
|
|
886
1435
|
stateMutability: "view",
|
|
887
1436
|
type: "function"
|
|
888
1437
|
},
|
|
889
1438
|
{
|
|
890
1439
|
inputs: [],
|
|
891
1440
|
name: "jobCounter",
|
|
892
|
-
outputs: [
|
|
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
|
+
],
|
|
893
1630
|
stateMutability: "view",
|
|
894
1631
|
type: "function"
|
|
895
1632
|
},
|
|
896
1633
|
{
|
|
897
1634
|
inputs: [
|
|
898
|
-
{
|
|
899
|
-
|
|
900
|
-
|
|
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" }
|
|
901
2026
|
],
|
|
902
|
-
name: "
|
|
903
|
-
|
|
904
|
-
stateMutability: "view",
|
|
905
|
-
type: "function"
|
|
2027
|
+
name: "Deposit",
|
|
2028
|
+
type: "event"
|
|
906
2029
|
},
|
|
907
2030
|
{
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
{ internalType: "
|
|
912
|
-
{ internalType: "
|
|
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" }
|
|
2031
|
+
anonymous: false,
|
|
2032
|
+
inputs: [
|
|
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" }
|
|
920
2036
|
],
|
|
921
|
-
|
|
922
|
-
type: "
|
|
2037
|
+
name: "Transfer",
|
|
2038
|
+
type: "event"
|
|
923
2039
|
},
|
|
924
2040
|
{
|
|
925
|
-
|
|
926
|
-
|
|
2041
|
+
anonymous: false,
|
|
2042
|
+
inputs: [
|
|
2043
|
+
{ indexed: true, internalType: "address", name: "src", type: "address" },
|
|
2044
|
+
{ indexed: false, internalType: "uint256", name: "wad", type: "uint256" }
|
|
2045
|
+
],
|
|
2046
|
+
name: "Withdrawal",
|
|
2047
|
+
type: "event"
|
|
2048
|
+
},
|
|
2049
|
+
{ payable: true, stateMutability: "payable", type: "fallback" },
|
|
2050
|
+
{
|
|
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" }
|
|
2131
|
+
{ internalType: "address", name: "dst", type: "address" },
|
|
2132
|
+
{ internalType: "uint256", name: "wad", type: "uint256" }
|
|
1016
2133
|
],
|
|
1017
|
-
name: "
|
|
1018
|
-
outputs: [],
|
|
1019
|
-
|
|
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" }
|
|
1037
|
-
],
|
|
1038
|
-
name: "signMemo",
|
|
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,25 @@ var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
|
|
|
1138
2186
|
return AcpJobPhases2;
|
|
1139
2187
|
})(AcpJobPhases || {});
|
|
1140
2188
|
var AcpContractClient = class _AcpContractClient {
|
|
1141
|
-
constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig
|
|
2189
|
+
constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
|
|
1142
2190
|
this.walletPrivateKey = walletPrivateKey;
|
|
1143
2191
|
this.sessionEntityKeyId = sessionEntityKeyId;
|
|
1144
2192
|
this.agentWalletAddress = agentWalletAddress;
|
|
1145
2193
|
this.config = config;
|
|
1146
|
-
this.customRpcUrl = customRpcUrl;
|
|
1147
2194
|
this.MAX_RETRIES = 3;
|
|
2195
|
+
this.PRIORITY_FEE_MULTIPLIER = 2;
|
|
2196
|
+
this.MAX_FEE_PER_GAS = 2e7;
|
|
2197
|
+
this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
|
|
1148
2198
|
this.chain = config.chain;
|
|
1149
2199
|
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) {
|
|
2200
|
+
}
|
|
2201
|
+
static build(_0, _1, _2) {
|
|
2202
|
+
return __async(this, arguments, function* (walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
|
|
1159
2203
|
const acpContractClient = new _AcpContractClient(
|
|
1160
2204
|
walletPrivateKey,
|
|
1161
2205
|
sessionEntityKeyId,
|
|
1162
2206
|
agentWalletAddress,
|
|
1163
|
-
config
|
|
1164
|
-
customRpcUrl
|
|
2207
|
+
config
|
|
1165
2208
|
);
|
|
1166
2209
|
yield acpContractClient.init();
|
|
1167
2210
|
return acpContractClient;
|
|
@@ -1185,9 +2228,18 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1185
2228
|
});
|
|
1186
2229
|
});
|
|
1187
2230
|
}
|
|
2231
|
+
getRandomNonce(bits = 152) {
|
|
2232
|
+
const bytes = bits / 8;
|
|
2233
|
+
const array = new Uint8Array(bytes);
|
|
2234
|
+
crypto.getRandomValues(array);
|
|
2235
|
+
let hex = Array.from(array, (b) => b.toString(16).padStart(2, "0")).join(
|
|
2236
|
+
""
|
|
2237
|
+
);
|
|
2238
|
+
return BigInt("0x" + hex);
|
|
2239
|
+
}
|
|
1188
2240
|
get sessionKeyClient() {
|
|
1189
2241
|
if (!this._sessionKeyClient) {
|
|
1190
|
-
throw new
|
|
2242
|
+
throw new acpError_default("Session key client not initialized");
|
|
1191
2243
|
}
|
|
1192
2244
|
return this._sessionKeyClient;
|
|
1193
2245
|
}
|
|
@@ -1196,23 +2248,21 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1196
2248
|
}
|
|
1197
2249
|
calculateGasFees() {
|
|
1198
2250
|
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));
|
|
2251
|
+
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
2252
|
return finalMaxFeePerGas;
|
|
1206
2253
|
});
|
|
1207
2254
|
}
|
|
1208
2255
|
handleSendUserOperation(_0) {
|
|
1209
|
-
return __async(this, arguments, function* (data, contractAddress = this.contractAddress) {
|
|
2256
|
+
return __async(this, arguments, function* (data, contractAddress = this.contractAddress, value) {
|
|
1210
2257
|
const payload = {
|
|
1211
2258
|
uo: {
|
|
1212
2259
|
target: contractAddress,
|
|
1213
|
-
data
|
|
2260
|
+
data,
|
|
2261
|
+
value
|
|
1214
2262
|
},
|
|
1215
|
-
overrides: {
|
|
2263
|
+
overrides: {
|
|
2264
|
+
nonceKey: this.getRandomNonce()
|
|
2265
|
+
}
|
|
1216
2266
|
};
|
|
1217
2267
|
let retries = this.MAX_RETRIES;
|
|
1218
2268
|
let finalError;
|
|
@@ -1230,7 +2280,6 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1230
2280
|
});
|
|
1231
2281
|
return hash;
|
|
1232
2282
|
} catch (error) {
|
|
1233
|
-
console.debug("Failed to send user operation", error);
|
|
1234
2283
|
retries -= 1;
|
|
1235
2284
|
if (retries === 0) {
|
|
1236
2285
|
finalError = error;
|
|
@@ -1239,28 +2288,28 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1239
2288
|
yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
|
|
1240
2289
|
}
|
|
1241
2290
|
}
|
|
1242
|
-
throw new
|
|
2291
|
+
throw new acpError_default(`Failed to send user operation`, finalError);
|
|
1243
2292
|
});
|
|
1244
2293
|
}
|
|
1245
2294
|
getJobId(hash) {
|
|
1246
2295
|
return __async(this, null, function* () {
|
|
1247
2296
|
const result = yield this.sessionKeyClient.getUserOperationReceipt(hash);
|
|
1248
2297
|
if (!result) {
|
|
1249
|
-
throw new
|
|
2298
|
+
throw new acpError_default("Failed to get user operation receipt");
|
|
1250
2299
|
}
|
|
1251
2300
|
const contractLogs = result.logs.find(
|
|
1252
2301
|
(log) => log.address.toLowerCase() === this.contractAddress.toLowerCase()
|
|
1253
2302
|
);
|
|
1254
2303
|
if (!contractLogs) {
|
|
1255
|
-
throw new
|
|
2304
|
+
throw new acpError_default("Failed to get contract logs");
|
|
1256
2305
|
}
|
|
1257
|
-
return (0,
|
|
2306
|
+
return (0, import_viem2.fromHex)(contractLogs.data, "number");
|
|
1258
2307
|
});
|
|
1259
2308
|
}
|
|
1260
2309
|
createJob(providerAddress, evaluatorAddress, expireAt) {
|
|
1261
2310
|
return __async(this, null, function* () {
|
|
1262
2311
|
try {
|
|
1263
|
-
const data = (0,
|
|
2312
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
1264
2313
|
abi: acpAbi_default,
|
|
1265
2314
|
functionName: "createJob",
|
|
1266
2315
|
args: [
|
|
@@ -1273,114 +2322,60 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1273
2322
|
const jobId = yield this.getJobId(hash);
|
|
1274
2323
|
return { txHash: hash, jobId };
|
|
1275
2324
|
} catch (error) {
|
|
1276
|
-
|
|
1277
|
-
throw new Error("Failed to create job");
|
|
2325
|
+
throw new acpError_default("Failed to create job", error);
|
|
1278
2326
|
}
|
|
1279
2327
|
});
|
|
1280
2328
|
}
|
|
1281
|
-
approveAllowance(
|
|
1282
|
-
return __async(this,
|
|
2329
|
+
approveAllowance(_0) {
|
|
2330
|
+
return __async(this, arguments, function* (amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
|
|
1283
2331
|
try {
|
|
1284
|
-
const data = (0,
|
|
1285
|
-
abi:
|
|
2332
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2333
|
+
abi: import_viem2.erc20Abi,
|
|
1286
2334
|
functionName: "approve",
|
|
1287
|
-
args: [this.contractAddress,
|
|
2335
|
+
args: [this.contractAddress, amountBaseUnit]
|
|
1288
2336
|
});
|
|
1289
|
-
return yield this.handleSendUserOperation(
|
|
1290
|
-
data,
|
|
1291
|
-
this.virtualsTokenAddress
|
|
1292
|
-
);
|
|
2337
|
+
return yield this.handleSendUserOperation(data, paymentTokenAddress);
|
|
1293
2338
|
} 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
|
-
}
|
|
2339
|
+
throw new acpError_default("Failed to approve allowance", error);
|
|
1326
2340
|
}
|
|
1327
|
-
throw new Error("Failed to create payable fee memo");
|
|
1328
2341
|
});
|
|
1329
2342
|
}
|
|
1330
2343
|
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
|
-
}
|
|
2344
|
+
return __async(this, arguments, function* (jobId, content, amountBaseUnit, recipient, feeAmountBaseUnit, feeType, nextPhase, type, expiredAt, token = this.config.baseFare.contractAddress) {
|
|
2345
|
+
try {
|
|
2346
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2347
|
+
abi: acpAbi_default,
|
|
2348
|
+
functionName: "createPayableMemo",
|
|
2349
|
+
args: [
|
|
2350
|
+
jobId,
|
|
2351
|
+
content,
|
|
2352
|
+
token,
|
|
2353
|
+
amountBaseUnit,
|
|
2354
|
+
recipient,
|
|
2355
|
+
feeAmountBaseUnit,
|
|
2356
|
+
feeType,
|
|
2357
|
+
type,
|
|
2358
|
+
nextPhase,
|
|
2359
|
+
Math.floor(expiredAt.getTime() / 1e3)
|
|
2360
|
+
]
|
|
2361
|
+
});
|
|
2362
|
+
return yield this.handleSendUserOperation(data);
|
|
2363
|
+
} catch (error) {
|
|
2364
|
+
throw new acpError_default("Failed to create payable memo", error);
|
|
1368
2365
|
}
|
|
1369
|
-
throw new Error("Failed to create payable memo");
|
|
1370
2366
|
});
|
|
1371
2367
|
}
|
|
1372
2368
|
createMemo(jobId, content, type, isSecured, nextPhase) {
|
|
1373
2369
|
return __async(this, null, function* () {
|
|
1374
2370
|
try {
|
|
1375
|
-
const data = (0,
|
|
2371
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
1376
2372
|
abi: acpAbi_default,
|
|
1377
2373
|
functionName: "createMemo",
|
|
1378
2374
|
args: [jobId, content, type, isSecured, nextPhase]
|
|
1379
2375
|
});
|
|
1380
2376
|
return yield this.handleSendUserOperation(data);
|
|
1381
2377
|
} catch (error) {
|
|
1382
|
-
|
|
1383
|
-
throw new Error("Failed to create memo");
|
|
2378
|
+
throw new acpError_default("Failed to create memo", error);
|
|
1384
2379
|
}
|
|
1385
2380
|
});
|
|
1386
2381
|
}
|
|
@@ -1388,21 +2383,21 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1388
2383
|
return __async(this, null, function* () {
|
|
1389
2384
|
const result = yield this.sessionKeyClient.getUserOperationReceipt(hash);
|
|
1390
2385
|
if (!result) {
|
|
1391
|
-
throw new
|
|
2386
|
+
throw new acpError_default("Failed to get user operation receipt");
|
|
1392
2387
|
}
|
|
1393
2388
|
const contractLogs = result.logs.find(
|
|
1394
2389
|
(log) => log.address.toLowerCase() === this.contractAddress.toLowerCase()
|
|
1395
2390
|
);
|
|
1396
2391
|
if (!contractLogs) {
|
|
1397
|
-
throw new
|
|
2392
|
+
throw new acpError_default("Failed to get contract logs");
|
|
1398
2393
|
}
|
|
1399
|
-
const decoded = (0,
|
|
2394
|
+
const decoded = (0, import_viem2.decodeEventLog)({
|
|
1400
2395
|
abi: acpAbi_default,
|
|
1401
2396
|
data: contractLogs.data,
|
|
1402
2397
|
topics: contractLogs.topics
|
|
1403
2398
|
});
|
|
1404
2399
|
if (!decoded.args) {
|
|
1405
|
-
throw new
|
|
2400
|
+
throw new acpError_default("Failed to decode event logs");
|
|
1406
2401
|
}
|
|
1407
2402
|
return parseInt(decoded.args.memoId);
|
|
1408
2403
|
});
|
|
@@ -1410,30 +2405,59 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1410
2405
|
signMemo(memoId, isApproved, reason) {
|
|
1411
2406
|
return __async(this, null, function* () {
|
|
1412
2407
|
try {
|
|
1413
|
-
const data = (0,
|
|
2408
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
1414
2409
|
abi: acpAbi_default,
|
|
1415
2410
|
functionName: "signMemo",
|
|
1416
2411
|
args: [memoId, isApproved, reason]
|
|
1417
2412
|
});
|
|
1418
2413
|
return yield this.handleSendUserOperation(data);
|
|
1419
2414
|
} catch (error) {
|
|
1420
|
-
|
|
1421
|
-
throw new Error("Failed to sign memo");
|
|
2415
|
+
throw new acpError_default("Failed to sign memo", error);
|
|
1422
2416
|
}
|
|
1423
2417
|
});
|
|
1424
2418
|
}
|
|
1425
|
-
setBudget(jobId,
|
|
2419
|
+
setBudget(jobId, budgetBaseUnit) {
|
|
1426
2420
|
return __async(this, null, function* () {
|
|
1427
2421
|
try {
|
|
1428
|
-
const data = (0,
|
|
2422
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
1429
2423
|
abi: acpAbi_default,
|
|
1430
2424
|
functionName: "setBudget",
|
|
1431
|
-
args: [jobId,
|
|
2425
|
+
args: [jobId, budgetBaseUnit]
|
|
1432
2426
|
});
|
|
1433
2427
|
return yield this.handleSendUserOperation(data);
|
|
1434
2428
|
} catch (error) {
|
|
1435
|
-
|
|
1436
|
-
|
|
2429
|
+
throw new acpError_default("Failed to set budget", error);
|
|
2430
|
+
}
|
|
2431
|
+
});
|
|
2432
|
+
}
|
|
2433
|
+
setBudgetWithPaymentToken(_0, _1) {
|
|
2434
|
+
return __async(this, arguments, function* (jobId, budgetBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
|
|
2435
|
+
try {
|
|
2436
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2437
|
+
abi: acpAbi_default,
|
|
2438
|
+
functionName: "setBudgetWithPaymentToken",
|
|
2439
|
+
args: [jobId, budgetBaseUnit, paymentTokenAddress]
|
|
2440
|
+
});
|
|
2441
|
+
return yield this.handleSendUserOperation(data);
|
|
2442
|
+
} catch (error) {
|
|
2443
|
+
throw new acpError_default("Failed to set budget", error);
|
|
2444
|
+
}
|
|
2445
|
+
});
|
|
2446
|
+
}
|
|
2447
|
+
wrapEth(amountBaseUnit) {
|
|
2448
|
+
return __async(this, null, function* () {
|
|
2449
|
+
try {
|
|
2450
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2451
|
+
abi: wethAbi_default,
|
|
2452
|
+
functionName: "deposit"
|
|
2453
|
+
});
|
|
2454
|
+
return yield this.handleSendUserOperation(
|
|
2455
|
+
data,
|
|
2456
|
+
wethFare.contractAddress,
|
|
2457
|
+
amountBaseUnit
|
|
2458
|
+
);
|
|
2459
|
+
} catch (error) {
|
|
2460
|
+
throw new acpError_default("Failed to wrap eth", error);
|
|
1437
2461
|
}
|
|
1438
2462
|
});
|
|
1439
2463
|
}
|
|
@@ -1441,6 +2465,12 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1441
2465
|
var acpContractClient_default = AcpContractClient;
|
|
1442
2466
|
|
|
1443
2467
|
// src/interfaces.ts
|
|
2468
|
+
var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
|
|
2469
|
+
AcpMemoStatus2["PENDING"] = "PENDING";
|
|
2470
|
+
AcpMemoStatus2["APPROVED"] = "APPROVED";
|
|
2471
|
+
AcpMemoStatus2["REJECTED"] = "REJECTED";
|
|
2472
|
+
return AcpMemoStatus2;
|
|
2473
|
+
})(AcpMemoStatus || {});
|
|
1444
2474
|
var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
|
|
1445
2475
|
AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
|
|
1446
2476
|
AcpAgentSort2["SUCCESS_RATE"] = "successRate";
|
|
@@ -1463,6 +2493,8 @@ var AcpOnlineStatus = /* @__PURE__ */ ((AcpOnlineStatus2) => {
|
|
|
1463
2493
|
var PayloadType = /* @__PURE__ */ ((PayloadType2) => {
|
|
1464
2494
|
PayloadType2["FUND_RESPONSE"] = "fund_response";
|
|
1465
2495
|
PayloadType2["OPEN_POSITION"] = "open_position";
|
|
2496
|
+
PayloadType2["SWAP_TOKEN"] = "swap_token";
|
|
2497
|
+
PayloadType2["RESPONSE_SWAP_TOKEN"] = "response_swap_token";
|
|
1466
2498
|
PayloadType2["CLOSE_PARTIAL_POSITION"] = "close_partial_position";
|
|
1467
2499
|
PayloadType2["CLOSE_POSITION"] = "close_position";
|
|
1468
2500
|
PayloadType2["POSITION_FULFILLED"] = "position_fulfilled";
|
|
@@ -1470,6 +2502,11 @@ var PayloadType = /* @__PURE__ */ ((PayloadType2) => {
|
|
|
1470
2502
|
PayloadType2["UNFULFILLED_POSITION"] = "unfulfilled_position";
|
|
1471
2503
|
return PayloadType2;
|
|
1472
2504
|
})(PayloadType || {});
|
|
2505
|
+
var PositionDirection = /* @__PURE__ */ ((PositionDirection2) => {
|
|
2506
|
+
PositionDirection2["LONG"] = "long";
|
|
2507
|
+
PositionDirection2["SHORT"] = "short";
|
|
2508
|
+
return PositionDirection2;
|
|
2509
|
+
})(PositionDirection || {});
|
|
1473
2510
|
|
|
1474
2511
|
// src/utils.ts
|
|
1475
2512
|
function tryParseJson(content) {
|
|
@@ -1482,20 +2519,46 @@ function tryParseJson(content) {
|
|
|
1482
2519
|
|
|
1483
2520
|
// src/acpJob.ts
|
|
1484
2521
|
var AcpJob = class {
|
|
1485
|
-
constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, memos, phase, context) {
|
|
2522
|
+
constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, priceTokenAddress, memos, phase, context) {
|
|
1486
2523
|
this.acpClient = acpClient;
|
|
1487
2524
|
this.id = id;
|
|
1488
2525
|
this.clientAddress = clientAddress;
|
|
1489
2526
|
this.providerAddress = providerAddress;
|
|
1490
2527
|
this.evaluatorAddress = evaluatorAddress;
|
|
1491
2528
|
this.price = price;
|
|
2529
|
+
this.priceTokenAddress = priceTokenAddress;
|
|
1492
2530
|
this.memos = memos;
|
|
1493
2531
|
this.phase = phase;
|
|
1494
2532
|
this.context = context;
|
|
2533
|
+
this.baseFare = acpClient.acpContractClient.config.baseFare;
|
|
1495
2534
|
}
|
|
1496
2535
|
get serviceRequirement() {
|
|
1497
2536
|
var _a;
|
|
1498
|
-
|
|
2537
|
+
const content = (_a = this.memos.find(
|
|
2538
|
+
(m) => m.nextPhase === 1 /* NEGOTIATION */
|
|
2539
|
+
)) == null ? void 0 : _a.content;
|
|
2540
|
+
if (!content) {
|
|
2541
|
+
return void 0;
|
|
2542
|
+
}
|
|
2543
|
+
const contentObj = tryParseJson(content);
|
|
2544
|
+
if (!contentObj) {
|
|
2545
|
+
return content;
|
|
2546
|
+
}
|
|
2547
|
+
if (contentObj.serviceRequirement) {
|
|
2548
|
+
return contentObj.serviceRequirement;
|
|
2549
|
+
}
|
|
2550
|
+
return contentObj;
|
|
2551
|
+
}
|
|
2552
|
+
get serviceName() {
|
|
2553
|
+
var _a;
|
|
2554
|
+
const content = (_a = this.memos.find(
|
|
2555
|
+
(m) => m.nextPhase === 1 /* NEGOTIATION */
|
|
2556
|
+
)) == null ? void 0 : _a.content;
|
|
2557
|
+
if (!content) {
|
|
2558
|
+
return void 0;
|
|
2559
|
+
}
|
|
2560
|
+
const contentObj = tryParseJson(content);
|
|
2561
|
+
return contentObj == null ? void 0 : contentObj.serviceName;
|
|
1499
2562
|
}
|
|
1500
2563
|
get deliverable() {
|
|
1501
2564
|
var _a;
|
|
@@ -1519,16 +2582,21 @@ var AcpJob = class {
|
|
|
1519
2582
|
(m) => m.nextPhase === 2 /* TRANSACTION */
|
|
1520
2583
|
);
|
|
1521
2584
|
if (!memo) {
|
|
1522
|
-
throw new
|
|
2585
|
+
throw new acpError_default("No transaction memo found");
|
|
1523
2586
|
}
|
|
1524
|
-
return yield this.acpClient.payJob(
|
|
2587
|
+
return yield this.acpClient.payJob(
|
|
2588
|
+
this.id,
|
|
2589
|
+
this.baseFare.formatAmount(amount),
|
|
2590
|
+
memo.id,
|
|
2591
|
+
reason
|
|
2592
|
+
);
|
|
1525
2593
|
});
|
|
1526
2594
|
}
|
|
1527
2595
|
respond(accept, payload, reason) {
|
|
1528
2596
|
return __async(this, null, function* () {
|
|
1529
2597
|
var _a;
|
|
1530
2598
|
if (((_a = this.latestMemo) == null ? void 0 : _a.nextPhase) !== 1 /* NEGOTIATION */) {
|
|
1531
|
-
throw new
|
|
2599
|
+
throw new acpError_default("No negotiation memo found");
|
|
1532
2600
|
}
|
|
1533
2601
|
return yield this.acpClient.respondJob(
|
|
1534
2602
|
this.id,
|
|
@@ -1543,7 +2611,7 @@ var AcpJob = class {
|
|
|
1543
2611
|
return __async(this, null, function* () {
|
|
1544
2612
|
var _a;
|
|
1545
2613
|
if (((_a = this.latestMemo) == null ? void 0 : _a.nextPhase) !== 3 /* EVALUATION */) {
|
|
1546
|
-
throw new
|
|
2614
|
+
throw new acpError_default("No transaction memo found");
|
|
1547
2615
|
}
|
|
1548
2616
|
return yield this.acpClient.deliverJob(this.id, deliverable);
|
|
1549
2617
|
});
|
|
@@ -1552,7 +2620,7 @@ var AcpJob = class {
|
|
|
1552
2620
|
return __async(this, null, function* () {
|
|
1553
2621
|
var _a;
|
|
1554
2622
|
if (((_a = this.latestMemo) == null ? void 0 : _a.nextPhase) !== 4 /* COMPLETED */) {
|
|
1555
|
-
throw new
|
|
2623
|
+
throw new acpError_default("No evaluation memo found");
|
|
1556
2624
|
}
|
|
1557
2625
|
return yield this.acpClient.acpContractClient.signMemo(
|
|
1558
2626
|
this.latestMemo.id,
|
|
@@ -1561,16 +2629,17 @@ var AcpJob = class {
|
|
|
1561
2629
|
);
|
|
1562
2630
|
});
|
|
1563
2631
|
}
|
|
1564
|
-
openPosition(
|
|
1565
|
-
return __async(this,
|
|
2632
|
+
openPosition(_0, _1) {
|
|
2633
|
+
return __async(this, arguments, function* (payload, feeAmount, expiredAt = new Date(Date.now() + 1e3 * 60 * 3), walletAddress) {
|
|
1566
2634
|
if (payload.length === 0) {
|
|
1567
|
-
throw new
|
|
2635
|
+
throw new acpError_default("No positions to open");
|
|
1568
2636
|
}
|
|
2637
|
+
const sumAmount = payload.reduce((acc, curr) => acc + curr.amount, 0);
|
|
1569
2638
|
return yield this.acpClient.transferFunds(
|
|
1570
2639
|
this.id,
|
|
1571
|
-
|
|
2640
|
+
new FareAmount(sumAmount, this.baseFare),
|
|
1572
2641
|
walletAddress || this.providerAddress,
|
|
1573
|
-
feeAmount,
|
|
2642
|
+
new FareAmount(feeAmount, this.baseFare),
|
|
1574
2643
|
1 /* IMMEDIATE_FEE */,
|
|
1575
2644
|
{
|
|
1576
2645
|
type: "open_position" /* OPEN_POSITION */,
|
|
@@ -1581,34 +2650,84 @@ var AcpJob = class {
|
|
|
1581
2650
|
);
|
|
1582
2651
|
});
|
|
1583
2652
|
}
|
|
2653
|
+
swapToken(payload, decimals, feeAmount, walletAddress) {
|
|
2654
|
+
return __async(this, null, function* () {
|
|
2655
|
+
return yield this.acpClient.transferFunds(
|
|
2656
|
+
this.id,
|
|
2657
|
+
new FareAmount(
|
|
2658
|
+
payload.amount,
|
|
2659
|
+
new Fare(payload.fromContractAddress, decimals)
|
|
2660
|
+
),
|
|
2661
|
+
walletAddress || this.providerAddress,
|
|
2662
|
+
new FareAmount(feeAmount, this.baseFare),
|
|
2663
|
+
1 /* IMMEDIATE_FEE */,
|
|
2664
|
+
{
|
|
2665
|
+
type: "swap_token" /* SWAP_TOKEN */,
|
|
2666
|
+
data: payload
|
|
2667
|
+
},
|
|
2668
|
+
2 /* TRANSACTION */,
|
|
2669
|
+
new Date(Date.now() + 1e3 * 60 * 30)
|
|
2670
|
+
);
|
|
2671
|
+
});
|
|
2672
|
+
}
|
|
2673
|
+
responseSwapToken(memoId, accept, reason) {
|
|
2674
|
+
return __async(this, null, function* () {
|
|
2675
|
+
const memo = this.memos.find((m) => m.id === memoId);
|
|
2676
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
2677
|
+
throw new acpError_default("No swap token memo found");
|
|
2678
|
+
}
|
|
2679
|
+
const payload = tryParseJson(
|
|
2680
|
+
memo.content
|
|
2681
|
+
);
|
|
2682
|
+
if ((payload == null ? void 0 : payload.type) !== "swap_token" /* SWAP_TOKEN */) {
|
|
2683
|
+
throw new acpError_default("Invalid swap token memo");
|
|
2684
|
+
}
|
|
2685
|
+
return yield memo.sign(accept, reason);
|
|
2686
|
+
});
|
|
2687
|
+
}
|
|
2688
|
+
transferFunds(_0, _1, _2) {
|
|
2689
|
+
return __async(this, arguments, function* (payload, fareAmount, walletAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 30)) {
|
|
2690
|
+
return yield this.acpClient.transferFunds(
|
|
2691
|
+
this.id,
|
|
2692
|
+
fareAmount,
|
|
2693
|
+
walletAddress || this.clientAddress,
|
|
2694
|
+
new FareAmount(0, this.baseFare),
|
|
2695
|
+
0 /* NO_FEE */,
|
|
2696
|
+
payload,
|
|
2697
|
+
2 /* TRANSACTION */,
|
|
2698
|
+
expiredAt
|
|
2699
|
+
);
|
|
2700
|
+
});
|
|
2701
|
+
}
|
|
1584
2702
|
responseOpenPosition(memoId, accept, reason) {
|
|
1585
2703
|
return __async(this, null, function* () {
|
|
1586
2704
|
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
|
|
2705
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
2706
|
+
throw new acpError_default("No open position memo found");
|
|
1589
2707
|
}
|
|
1590
2708
|
const payload = tryParseJson(
|
|
1591
2709
|
memo.content
|
|
1592
2710
|
);
|
|
1593
2711
|
if ((payload == null ? void 0 : payload.type) !== "open_position" /* OPEN_POSITION */) {
|
|
1594
|
-
throw new
|
|
2712
|
+
throw new acpError_default("Invalid open position memo");
|
|
1595
2713
|
}
|
|
1596
2714
|
return yield this.acpClient.responseFundsTransfer(memo.id, accept, reason);
|
|
1597
2715
|
});
|
|
1598
2716
|
}
|
|
1599
|
-
closePartialPosition(
|
|
1600
|
-
return __async(this,
|
|
2717
|
+
closePartialPosition(_0) {
|
|
2718
|
+
return __async(this, arguments, function* (payload, expireAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1601
2719
|
return yield this.acpClient.requestFunds(
|
|
1602
2720
|
this.id,
|
|
1603
|
-
payload.amount,
|
|
2721
|
+
new FareAmount(payload.amount, this.baseFare),
|
|
1604
2722
|
this.clientAddress,
|
|
1605
|
-
0,
|
|
2723
|
+
new FareAmount(0, this.baseFare),
|
|
1606
2724
|
0 /* NO_FEE */,
|
|
1607
2725
|
{
|
|
1608
2726
|
type: "close_partial_position" /* CLOSE_PARTIAL_POSITION */,
|
|
1609
2727
|
data: payload
|
|
1610
2728
|
},
|
|
1611
|
-
2 /* TRANSACTION
|
|
2729
|
+
2 /* TRANSACTION */,
|
|
2730
|
+
expireAt
|
|
1612
2731
|
);
|
|
1613
2732
|
});
|
|
1614
2733
|
}
|
|
@@ -1616,18 +2735,18 @@ var AcpJob = class {
|
|
|
1616
2735
|
return __async(this, null, function* () {
|
|
1617
2736
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1618
2737
|
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 6 /* PAYABLE_REQUEST */) {
|
|
1619
|
-
throw new
|
|
2738
|
+
throw new acpError_default("No close position memo found");
|
|
1620
2739
|
}
|
|
1621
2740
|
const payload = tryParseJson(
|
|
1622
2741
|
memo.content
|
|
1623
2742
|
);
|
|
1624
2743
|
if ((payload == null ? void 0 : payload.type) !== "close_partial_position" /* CLOSE_PARTIAL_POSITION */) {
|
|
1625
|
-
throw new
|
|
2744
|
+
throw new acpError_default("Invalid close position memo");
|
|
1626
2745
|
}
|
|
1627
2746
|
return yield this.acpClient.responseFundsRequest(
|
|
1628
2747
|
memo.id,
|
|
1629
2748
|
accept,
|
|
1630
|
-
payload.data.amount,
|
|
2749
|
+
this.baseFare.formatAmount(payload.data.amount),
|
|
1631
2750
|
reason
|
|
1632
2751
|
);
|
|
1633
2752
|
});
|
|
@@ -1644,29 +2763,30 @@ var AcpJob = class {
|
|
|
1644
2763
|
);
|
|
1645
2764
|
});
|
|
1646
2765
|
}
|
|
1647
|
-
responseRequestClosePosition(
|
|
1648
|
-
return __async(this,
|
|
2766
|
+
responseRequestClosePosition(_0, _1, _2, _3) {
|
|
2767
|
+
return __async(this, arguments, function* (memoId, accept, payload, reason, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1649
2768
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1650
2769
|
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 0 /* MESSAGE */) {
|
|
1651
|
-
throw new
|
|
2770
|
+
throw new acpError_default("No message memo found");
|
|
1652
2771
|
}
|
|
1653
2772
|
const messagePayload = tryParseJson(memo.content);
|
|
1654
2773
|
if ((messagePayload == null ? void 0 : messagePayload.type) !== "close_position" /* CLOSE_POSITION */) {
|
|
1655
|
-
throw new
|
|
2774
|
+
throw new acpError_default("Invalid close position memo");
|
|
1656
2775
|
}
|
|
1657
2776
|
yield memo.sign(accept, reason);
|
|
1658
2777
|
if (accept) {
|
|
1659
2778
|
return yield this.acpClient.transferFunds(
|
|
1660
2779
|
this.id,
|
|
1661
|
-
payload.amount,
|
|
2780
|
+
new FareAmount(payload.amount, this.baseFare),
|
|
1662
2781
|
this.clientAddress,
|
|
1663
|
-
0,
|
|
2782
|
+
new FareAmount(0, this.baseFare),
|
|
1664
2783
|
0 /* NO_FEE */,
|
|
1665
2784
|
{
|
|
1666
2785
|
type: "close_position" /* CLOSE_POSITION */,
|
|
1667
2786
|
data: payload
|
|
1668
2787
|
},
|
|
1669
|
-
2 /* TRANSACTION
|
|
2788
|
+
2 /* TRANSACTION */,
|
|
2789
|
+
expiredAt
|
|
1670
2790
|
);
|
|
1671
2791
|
}
|
|
1672
2792
|
});
|
|
@@ -1674,61 +2794,63 @@ var AcpJob = class {
|
|
|
1674
2794
|
confirmClosePosition(memoId, accept, reason) {
|
|
1675
2795
|
return __async(this, null, function* () {
|
|
1676
2796
|
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
|
|
2797
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
2798
|
+
throw new acpError_default("No payable transfer memo found");
|
|
1679
2799
|
}
|
|
1680
2800
|
const payload = tryParseJson(
|
|
1681
2801
|
memo.content
|
|
1682
2802
|
);
|
|
1683
2803
|
if ((payload == null ? void 0 : payload.type) !== "close_position" /* CLOSE_POSITION */) {
|
|
1684
|
-
throw new
|
|
2804
|
+
throw new acpError_default("Invalid close position memo");
|
|
1685
2805
|
}
|
|
1686
2806
|
yield memo.sign(accept, reason);
|
|
1687
2807
|
});
|
|
1688
2808
|
}
|
|
1689
|
-
positionFulfilled(
|
|
1690
|
-
return __async(this,
|
|
2809
|
+
positionFulfilled(_0) {
|
|
2810
|
+
return __async(this, arguments, function* (payload, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1691
2811
|
return yield this.acpClient.transferFunds(
|
|
1692
2812
|
this.id,
|
|
1693
|
-
payload.amount,
|
|
2813
|
+
new FareAmount(payload.amount, this.baseFare),
|
|
1694
2814
|
this.clientAddress,
|
|
1695
|
-
0,
|
|
2815
|
+
new FareAmount(0, this.baseFare),
|
|
1696
2816
|
0 /* NO_FEE */,
|
|
1697
2817
|
{
|
|
1698
2818
|
type: "position_fulfilled" /* POSITION_FULFILLED */,
|
|
1699
2819
|
data: payload
|
|
1700
2820
|
},
|
|
1701
|
-
2 /* TRANSACTION
|
|
2821
|
+
2 /* TRANSACTION */,
|
|
2822
|
+
expiredAt
|
|
1702
2823
|
);
|
|
1703
2824
|
});
|
|
1704
2825
|
}
|
|
1705
|
-
unfulfilledPosition(
|
|
1706
|
-
return __async(this,
|
|
2826
|
+
unfulfilledPosition(_0) {
|
|
2827
|
+
return __async(this, arguments, function* (payload, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1707
2828
|
return yield this.acpClient.transferFunds(
|
|
1708
2829
|
this.id,
|
|
1709
|
-
payload.amount,
|
|
2830
|
+
new FareAmount(payload.amount, this.baseFare),
|
|
1710
2831
|
this.clientAddress,
|
|
1711
|
-
0,
|
|
2832
|
+
new FareAmount(0, this.baseFare),
|
|
1712
2833
|
0 /* NO_FEE */,
|
|
1713
2834
|
{
|
|
1714
2835
|
type: "unfulfilled_position" /* UNFULFILLED_POSITION */,
|
|
1715
2836
|
data: payload
|
|
1716
2837
|
},
|
|
1717
|
-
2 /* TRANSACTION
|
|
2838
|
+
2 /* TRANSACTION */,
|
|
2839
|
+
expiredAt
|
|
1718
2840
|
);
|
|
1719
2841
|
});
|
|
1720
2842
|
}
|
|
1721
2843
|
responseUnfulfilledPosition(memoId, accept, reason) {
|
|
1722
2844
|
return __async(this, null, function* () {
|
|
1723
2845
|
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
|
|
2846
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
2847
|
+
throw new acpError_default("No unfulfilled position memo found");
|
|
1726
2848
|
}
|
|
1727
2849
|
const payload = tryParseJson(
|
|
1728
2850
|
memo.content
|
|
1729
2851
|
);
|
|
1730
2852
|
if ((payload == null ? void 0 : payload.type) !== "unfulfilled_position" /* UNFULFILLED_POSITION */) {
|
|
1731
|
-
throw new
|
|
2853
|
+
throw new acpError_default("Invalid unfulfilled position memo");
|
|
1732
2854
|
}
|
|
1733
2855
|
return yield this.acpClient.responseFundsTransfer(memo.id, accept, reason);
|
|
1734
2856
|
});
|
|
@@ -1736,14 +2858,14 @@ var AcpJob = class {
|
|
|
1736
2858
|
responsePositionFulfilled(memoId, accept, reason) {
|
|
1737
2859
|
return __async(this, null, function* () {
|
|
1738
2860
|
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
|
|
2861
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
2862
|
+
throw new acpError_default("No position fulfilled memo found");
|
|
1741
2863
|
}
|
|
1742
2864
|
const payload = tryParseJson(
|
|
1743
2865
|
memo.content
|
|
1744
2866
|
);
|
|
1745
2867
|
if ((payload == null ? void 0 : payload.type) !== "position_fulfilled" /* POSITION_FULFILLED */) {
|
|
1746
|
-
throw new
|
|
2868
|
+
throw new acpError_default("Invalid position fulfilled memo");
|
|
1747
2869
|
}
|
|
1748
2870
|
return yield this.acpClient.responseFundsTransfer(memo.id, accept, reason);
|
|
1749
2871
|
});
|
|
@@ -1762,17 +2884,17 @@ var AcpJob = class {
|
|
|
1762
2884
|
);
|
|
1763
2885
|
});
|
|
1764
2886
|
}
|
|
1765
|
-
responseCloseJob(
|
|
1766
|
-
return __async(this,
|
|
2887
|
+
responseCloseJob(_0, _1, _2, _3) {
|
|
2888
|
+
return __async(this, arguments, function* (memoId, accept, fulfilledPositions, reason, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1767
2889
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1768
2890
|
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 0 /* MESSAGE */) {
|
|
1769
|
-
throw new
|
|
2891
|
+
throw new acpError_default("No message memo found");
|
|
1770
2892
|
}
|
|
1771
2893
|
const payload = tryParseJson(
|
|
1772
2894
|
memo.content
|
|
1773
2895
|
);
|
|
1774
2896
|
if ((payload == null ? void 0 : payload.type) !== "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */) {
|
|
1775
|
-
throw new
|
|
2897
|
+
throw new acpError_default("Invalid close job and withdraw memo");
|
|
1776
2898
|
}
|
|
1777
2899
|
yield memo.sign(accept, reason);
|
|
1778
2900
|
if (!accept) {
|
|
@@ -1794,15 +2916,16 @@ var AcpJob = class {
|
|
|
1794
2916
|
}
|
|
1795
2917
|
return yield this.acpClient.transferFunds(
|
|
1796
2918
|
this.id,
|
|
1797
|
-
|
|
2919
|
+
new FareAmount(totalAmount, this.baseFare),
|
|
1798
2920
|
this.clientAddress,
|
|
1799
|
-
0,
|
|
2921
|
+
new FareAmount(0, this.baseFare),
|
|
1800
2922
|
0 /* NO_FEE */,
|
|
1801
2923
|
{
|
|
1802
2924
|
type: "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */,
|
|
1803
2925
|
data: fulfilledPositions
|
|
1804
2926
|
},
|
|
1805
|
-
4 /* COMPLETED
|
|
2927
|
+
4 /* COMPLETED */,
|
|
2928
|
+
expiredAt
|
|
1806
2929
|
);
|
|
1807
2930
|
});
|
|
1808
2931
|
}
|
|
@@ -1810,13 +2933,13 @@ var AcpJob = class {
|
|
|
1810
2933
|
return __async(this, null, function* () {
|
|
1811
2934
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1812
2935
|
if (!memo) {
|
|
1813
|
-
throw new
|
|
2936
|
+
throw new acpError_default("Memo not found");
|
|
1814
2937
|
}
|
|
1815
2938
|
const payload = tryParseJson(
|
|
1816
2939
|
memo.content
|
|
1817
2940
|
);
|
|
1818
2941
|
if ((payload == null ? void 0 : payload.type) !== "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */) {
|
|
1819
|
-
throw new
|
|
2942
|
+
throw new acpError_default("Invalid close job and withdraw memo");
|
|
1820
2943
|
}
|
|
1821
2944
|
yield memo.sign(accept, reason);
|
|
1822
2945
|
});
|
|
@@ -1826,13 +2949,20 @@ var acpJob_default = AcpJob;
|
|
|
1826
2949
|
|
|
1827
2950
|
// src/acpMemo.ts
|
|
1828
2951
|
var AcpMemo = class {
|
|
1829
|
-
constructor(acpClient, id, type, content, nextPhase, expiry) {
|
|
2952
|
+
constructor(acpClient, id, type, content, nextPhase, status, signedReason, expiry, payableDetails) {
|
|
1830
2953
|
this.acpClient = acpClient;
|
|
1831
2954
|
this.id = id;
|
|
1832
2955
|
this.type = type;
|
|
1833
2956
|
this.content = content;
|
|
1834
2957
|
this.nextPhase = nextPhase;
|
|
2958
|
+
this.status = status;
|
|
2959
|
+
this.signedReason = signedReason;
|
|
1835
2960
|
this.expiry = expiry;
|
|
2961
|
+
this.payableDetails = payableDetails;
|
|
2962
|
+
if (this.payableDetails) {
|
|
2963
|
+
this.payableDetails.amount = BigInt(this.payableDetails.amount);
|
|
2964
|
+
this.payableDetails.feeAmount = BigInt(this.payableDetails.feeAmount);
|
|
2965
|
+
}
|
|
1836
2966
|
this.structuredContent = tryParseJson(this.content) || void 0;
|
|
1837
2967
|
}
|
|
1838
2968
|
get payloadType() {
|
|
@@ -1868,10 +2998,10 @@ var acpMemo_default = AcpMemo;
|
|
|
1868
2998
|
// src/acpJobOffering.ts
|
|
1869
2999
|
var import_ajv = __toESM(require("ajv"));
|
|
1870
3000
|
var AcpJobOffering = class {
|
|
1871
|
-
constructor(acpClient, providerAddress,
|
|
3001
|
+
constructor(acpClient, providerAddress, name, price, requirementSchema) {
|
|
1872
3002
|
this.acpClient = acpClient;
|
|
1873
3003
|
this.providerAddress = providerAddress;
|
|
1874
|
-
this.
|
|
3004
|
+
this.name = name;
|
|
1875
3005
|
this.price = price;
|
|
1876
3006
|
this.requirementSchema = requirementSchema;
|
|
1877
3007
|
this.ajv = new import_ajv.default({ allErrors: true });
|
|
@@ -1882,13 +3012,28 @@ var AcpJobOffering = class {
|
|
|
1882
3012
|
const validator = this.ajv.compile(this.requirementSchema);
|
|
1883
3013
|
const valid = validator(serviceRequirement);
|
|
1884
3014
|
if (!valid) {
|
|
1885
|
-
throw new
|
|
3015
|
+
throw new acpError_default(this.ajv.errorsText(validator.errors));
|
|
1886
3016
|
}
|
|
1887
3017
|
}
|
|
3018
|
+
let finalServiceRequirement = {
|
|
3019
|
+
serviceName: this.name
|
|
3020
|
+
};
|
|
3021
|
+
if (typeof serviceRequirement === "string") {
|
|
3022
|
+
finalServiceRequirement = __spreadProps(__spreadValues({}, finalServiceRequirement), {
|
|
3023
|
+
message: serviceRequirement
|
|
3024
|
+
});
|
|
3025
|
+
} else {
|
|
3026
|
+
finalServiceRequirement = __spreadProps(__spreadValues({}, finalServiceRequirement), {
|
|
3027
|
+
serviceRequirement
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
1888
3030
|
return yield this.acpClient.initiateJob(
|
|
1889
3031
|
this.providerAddress,
|
|
1890
|
-
|
|
1891
|
-
|
|
3032
|
+
finalServiceRequirement,
|
|
3033
|
+
new FareAmount(
|
|
3034
|
+
this.price,
|
|
3035
|
+
this.acpClient.acpContractClient.config.baseFare
|
|
3036
|
+
),
|
|
1892
3037
|
evaluatorAddress,
|
|
1893
3038
|
expiredAt
|
|
1894
3039
|
);
|
|
@@ -1942,6 +3087,7 @@ var AcpClient = class {
|
|
|
1942
3087
|
data.providerAddress,
|
|
1943
3088
|
data.evaluatorAddress,
|
|
1944
3089
|
data.price,
|
|
3090
|
+
data.priceTokenAddress,
|
|
1945
3091
|
data.memos.map((memo) => {
|
|
1946
3092
|
return new acpMemo_default(
|
|
1947
3093
|
this,
|
|
@@ -1949,7 +3095,10 @@ var AcpClient = class {
|
|
|
1949
3095
|
memo.memoType,
|
|
1950
3096
|
memo.content,
|
|
1951
3097
|
memo.nextPhase,
|
|
1952
|
-
memo.
|
|
3098
|
+
memo.status,
|
|
3099
|
+
memo.signedReason,
|
|
3100
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3101
|
+
memo.payableDetails
|
|
1953
3102
|
);
|
|
1954
3103
|
}),
|
|
1955
3104
|
data.phase,
|
|
@@ -1971,6 +3120,7 @@ var AcpClient = class {
|
|
|
1971
3120
|
data.providerAddress,
|
|
1972
3121
|
data.evaluatorAddress,
|
|
1973
3122
|
data.price,
|
|
3123
|
+
data.priceTokenAddress,
|
|
1974
3124
|
data.memos.map((memo) => {
|
|
1975
3125
|
return new acpMemo_default(
|
|
1976
3126
|
this,
|
|
@@ -1978,7 +3128,10 @@ var AcpClient = class {
|
|
|
1978
3128
|
memo.memoType,
|
|
1979
3129
|
memo.content,
|
|
1980
3130
|
memo.nextPhase,
|
|
1981
|
-
memo.
|
|
3131
|
+
memo.status,
|
|
3132
|
+
memo.signedReason,
|
|
3133
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3134
|
+
memo.payableDetails
|
|
1982
3135
|
);
|
|
1983
3136
|
}),
|
|
1984
3137
|
data.phase,
|
|
@@ -2036,7 +3189,7 @@ var AcpClient = class {
|
|
|
2036
3189
|
this,
|
|
2037
3190
|
agent.walletAddress,
|
|
2038
3191
|
offering.name,
|
|
2039
|
-
offering.
|
|
3192
|
+
offering.priceUsd,
|
|
2040
3193
|
offering.requirementSchema
|
|
2041
3194
|
);
|
|
2042
3195
|
}),
|
|
@@ -2048,18 +3201,22 @@ var AcpClient = class {
|
|
|
2048
3201
|
});
|
|
2049
3202
|
}
|
|
2050
3203
|
initiateJob(_0, _1, _2, _3) {
|
|
2051
|
-
return __async(this, arguments, function* (providerAddress, serviceRequirement,
|
|
3204
|
+
return __async(this, arguments, function* (providerAddress, serviceRequirement, fareAmount, evaluatorAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
3205
|
+
if (providerAddress === this.acpContractClient.walletAddress) {
|
|
3206
|
+
throw new acpError_default(
|
|
3207
|
+
"Provider address cannot be the same as the client address"
|
|
3208
|
+
);
|
|
3209
|
+
}
|
|
2052
3210
|
const { jobId } = yield this.acpContractClient.createJob(
|
|
2053
3211
|
providerAddress,
|
|
2054
3212
|
evaluatorAddress || this.acpContractClient.walletAddress,
|
|
2055
3213
|
expiredAt
|
|
2056
3214
|
);
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
}
|
|
3215
|
+
yield this.acpContractClient.setBudgetWithPaymentToken(
|
|
3216
|
+
jobId,
|
|
3217
|
+
fareAmount.amount,
|
|
3218
|
+
fareAmount.fare.contractAddress
|
|
3219
|
+
);
|
|
2063
3220
|
yield this.acpContractClient.createMemo(
|
|
2064
3221
|
jobId,
|
|
2065
3222
|
typeof serviceRequirement === "string" ? serviceRequirement : JSON.stringify(serviceRequirement),
|
|
@@ -2085,68 +3242,79 @@ var AcpClient = class {
|
|
|
2085
3242
|
);
|
|
2086
3243
|
});
|
|
2087
3244
|
}
|
|
2088
|
-
payJob(jobId,
|
|
3245
|
+
payJob(jobId, amountBaseUnit, memoId, reason) {
|
|
2089
3246
|
return __async(this, null, function* () {
|
|
2090
|
-
if (
|
|
2091
|
-
yield this.acpContractClient.approveAllowance(
|
|
2092
|
-
(0, import_viem2.parseEther)(amount.toString())
|
|
2093
|
-
);
|
|
3247
|
+
if (amountBaseUnit > BigInt(0)) {
|
|
3248
|
+
yield this.acpContractClient.approveAllowance(amountBaseUnit);
|
|
2094
3249
|
}
|
|
2095
3250
|
yield this.acpContractClient.signMemo(memoId, true, reason);
|
|
2096
3251
|
return yield this.acpContractClient.createMemo(
|
|
2097
3252
|
jobId,
|
|
2098
|
-
`Payment
|
|
3253
|
+
`Payment made. ${reason != null ? reason : ""}`,
|
|
2099
3254
|
0 /* MESSAGE */,
|
|
2100
3255
|
false,
|
|
2101
3256
|
3 /* EVALUATION */
|
|
2102
3257
|
);
|
|
2103
3258
|
});
|
|
2104
3259
|
}
|
|
2105
|
-
requestFunds(jobId,
|
|
3260
|
+
requestFunds(jobId, transferFareAmount, recipient, feeFareAmount, feeType, reason, nextPhase, expiredAt) {
|
|
2106
3261
|
return __async(this, null, function* () {
|
|
2107
3262
|
return yield this.acpContractClient.createPayableMemo(
|
|
2108
3263
|
jobId,
|
|
2109
3264
|
JSON.stringify(reason),
|
|
2110
|
-
|
|
3265
|
+
transferFareAmount.amount,
|
|
2111
3266
|
recipient,
|
|
2112
|
-
|
|
3267
|
+
feeFareAmount.amount,
|
|
2113
3268
|
feeType,
|
|
2114
3269
|
nextPhase,
|
|
2115
|
-
6 /* PAYABLE_REQUEST
|
|
3270
|
+
6 /* PAYABLE_REQUEST */,
|
|
3271
|
+
expiredAt
|
|
2116
3272
|
);
|
|
2117
3273
|
});
|
|
2118
3274
|
}
|
|
2119
|
-
responseFundsRequest(memoId, accept,
|
|
3275
|
+
responseFundsRequest(memoId, accept, amountBaseUnit, reason) {
|
|
2120
3276
|
return __async(this, null, function* () {
|
|
2121
3277
|
if (!accept) {
|
|
2122
3278
|
return yield this.acpContractClient.signMemo(memoId, accept, reason);
|
|
2123
3279
|
}
|
|
2124
|
-
if (
|
|
2125
|
-
yield this.acpContractClient.approveAllowance(
|
|
2126
|
-
(0, import_viem2.parseEther)(amount.toString())
|
|
2127
|
-
);
|
|
3280
|
+
if (amountBaseUnit > BigInt(0)) {
|
|
3281
|
+
yield this.acpContractClient.approveAllowance(amountBaseUnit);
|
|
2128
3282
|
}
|
|
2129
3283
|
return yield this.acpContractClient.signMemo(memoId, true, reason);
|
|
2130
3284
|
});
|
|
2131
3285
|
}
|
|
2132
|
-
transferFunds(jobId,
|
|
3286
|
+
transferFunds(jobId, transferFareAmount, recipient, feeFareAmount, feeType, reason, nextPhase, expiredAt) {
|
|
2133
3287
|
return __async(this, null, function* () {
|
|
2134
|
-
|
|
2135
|
-
|
|
3288
|
+
if (transferFareAmount.fare.contractAddress === ethFare.contractAddress) {
|
|
3289
|
+
yield this.acpContractClient.wrapEth(transferFareAmount.amount);
|
|
3290
|
+
transferFareAmount = new FareBigInt(transferFareAmount.amount, wethFare);
|
|
3291
|
+
}
|
|
3292
|
+
if (feeFareAmount.amount > 0 && feeFareAmount.fare.contractAddress !== this.acpContractClient.config.baseFare.contractAddress) {
|
|
3293
|
+
throw new acpError_default("Fee token address is not the same as the base fare");
|
|
3294
|
+
}
|
|
3295
|
+
const isFeeTokenDifferent = feeFareAmount.fare.contractAddress !== transferFareAmount.fare.contractAddress;
|
|
3296
|
+
if (isFeeTokenDifferent) {
|
|
2136
3297
|
yield this.acpContractClient.approveAllowance(
|
|
2137
|
-
|
|
3298
|
+
feeFareAmount.amount,
|
|
3299
|
+
feeFareAmount.fare.contractAddress
|
|
2138
3300
|
);
|
|
2139
3301
|
}
|
|
3302
|
+
const finalAmount = isFeeTokenDifferent ? transferFareAmount : transferFareAmount.add(feeFareAmount);
|
|
3303
|
+
yield this.acpContractClient.approveAllowance(
|
|
3304
|
+
finalAmount.amount,
|
|
3305
|
+
transferFareAmount.fare.contractAddress
|
|
3306
|
+
);
|
|
2140
3307
|
return yield this.acpContractClient.createPayableMemo(
|
|
2141
3308
|
jobId,
|
|
2142
3309
|
JSON.stringify(reason),
|
|
2143
|
-
|
|
3310
|
+
transferFareAmount.amount,
|
|
2144
3311
|
recipient,
|
|
2145
|
-
|
|
3312
|
+
feeFareAmount.amount,
|
|
2146
3313
|
feeType,
|
|
2147
3314
|
nextPhase,
|
|
2148
|
-
|
|
2149
|
-
expiredAt
|
|
3315
|
+
8 /* PAYABLE_TRANSFER_ESCROW */,
|
|
3316
|
+
expiredAt,
|
|
3317
|
+
transferFareAmount.fare.contractAddress
|
|
2150
3318
|
);
|
|
2151
3319
|
});
|
|
2152
3320
|
}
|
|
@@ -2188,7 +3356,7 @@ var AcpClient = class {
|
|
|
2188
3356
|
});
|
|
2189
3357
|
const data = yield response.json();
|
|
2190
3358
|
if (data.error) {
|
|
2191
|
-
throw new
|
|
3359
|
+
throw new acpError_default(data.error.message);
|
|
2192
3360
|
}
|
|
2193
3361
|
return data.data.map((job) => {
|
|
2194
3362
|
return new acpJob_default(
|
|
@@ -2198,6 +3366,7 @@ var AcpClient = class {
|
|
|
2198
3366
|
job.providerAddress,
|
|
2199
3367
|
job.evaluatorAddress,
|
|
2200
3368
|
job.price,
|
|
3369
|
+
job.priceTokenAddress,
|
|
2201
3370
|
job.memos.map((memo) => {
|
|
2202
3371
|
return new acpMemo_default(
|
|
2203
3372
|
this,
|
|
@@ -2205,7 +3374,10 @@ var AcpClient = class {
|
|
|
2205
3374
|
memo.memoType,
|
|
2206
3375
|
memo.content,
|
|
2207
3376
|
memo.nextPhase,
|
|
2208
|
-
memo.
|
|
3377
|
+
memo.status,
|
|
3378
|
+
memo.signedReason,
|
|
3379
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3380
|
+
memo.payableDetails
|
|
2209
3381
|
);
|
|
2210
3382
|
}),
|
|
2211
3383
|
job.phase,
|
|
@@ -2213,7 +3385,7 @@ var AcpClient = class {
|
|
|
2213
3385
|
);
|
|
2214
3386
|
});
|
|
2215
3387
|
} catch (error) {
|
|
2216
|
-
throw error;
|
|
3388
|
+
throw new acpError_default("Failed to get active jobs", error);
|
|
2217
3389
|
}
|
|
2218
3390
|
});
|
|
2219
3391
|
}
|
|
@@ -2228,7 +3400,7 @@ var AcpClient = class {
|
|
|
2228
3400
|
});
|
|
2229
3401
|
const data = yield response.json();
|
|
2230
3402
|
if (data.error) {
|
|
2231
|
-
throw new
|
|
3403
|
+
throw new acpError_default(data.error.message);
|
|
2232
3404
|
}
|
|
2233
3405
|
return data.data.map((job) => {
|
|
2234
3406
|
return new acpJob_default(
|
|
@@ -2238,6 +3410,7 @@ var AcpClient = class {
|
|
|
2238
3410
|
job.providerAddress,
|
|
2239
3411
|
job.evaluatorAddress,
|
|
2240
3412
|
job.price,
|
|
3413
|
+
job.priceTokenAddress,
|
|
2241
3414
|
job.memos.map((memo) => {
|
|
2242
3415
|
return new acpMemo_default(
|
|
2243
3416
|
this,
|
|
@@ -2245,7 +3418,10 @@ var AcpClient = class {
|
|
|
2245
3418
|
memo.memoType,
|
|
2246
3419
|
memo.content,
|
|
2247
3420
|
memo.nextPhase,
|
|
2248
|
-
memo.
|
|
3421
|
+
memo.status,
|
|
3422
|
+
memo.signedReason,
|
|
3423
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3424
|
+
memo.payableDetails
|
|
2249
3425
|
);
|
|
2250
3426
|
}),
|
|
2251
3427
|
job.phase,
|
|
@@ -2253,7 +3429,7 @@ var AcpClient = class {
|
|
|
2253
3429
|
);
|
|
2254
3430
|
});
|
|
2255
3431
|
} catch (error) {
|
|
2256
|
-
throw error;
|
|
3432
|
+
throw new acpError_default("Failed to get completed jobs", error);
|
|
2257
3433
|
}
|
|
2258
3434
|
});
|
|
2259
3435
|
}
|
|
@@ -2268,7 +3444,7 @@ var AcpClient = class {
|
|
|
2268
3444
|
});
|
|
2269
3445
|
const data = yield response.json();
|
|
2270
3446
|
if (data.error) {
|
|
2271
|
-
throw new
|
|
3447
|
+
throw new acpError_default(data.error.message);
|
|
2272
3448
|
}
|
|
2273
3449
|
return data.data.map((job) => {
|
|
2274
3450
|
return new acpJob_default(
|
|
@@ -2278,6 +3454,7 @@ var AcpClient = class {
|
|
|
2278
3454
|
job.providerAddress,
|
|
2279
3455
|
job.evaluatorAddress,
|
|
2280
3456
|
job.price,
|
|
3457
|
+
job.priceTokenAddress,
|
|
2281
3458
|
job.memos.map((memo) => {
|
|
2282
3459
|
return new acpMemo_default(
|
|
2283
3460
|
this,
|
|
@@ -2285,7 +3462,10 @@ var AcpClient = class {
|
|
|
2285
3462
|
memo.memoType,
|
|
2286
3463
|
memo.content,
|
|
2287
3464
|
memo.nextPhase,
|
|
2288
|
-
memo.
|
|
3465
|
+
memo.status,
|
|
3466
|
+
memo.signedReason,
|
|
3467
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3468
|
+
memo.payableDetails
|
|
2289
3469
|
);
|
|
2290
3470
|
}),
|
|
2291
3471
|
job.phase,
|
|
@@ -2293,7 +3473,7 @@ var AcpClient = class {
|
|
|
2293
3473
|
);
|
|
2294
3474
|
});
|
|
2295
3475
|
} catch (error) {
|
|
2296
|
-
throw error;
|
|
3476
|
+
throw new acpError_default("Failed to get cancelled jobs", error);
|
|
2297
3477
|
}
|
|
2298
3478
|
});
|
|
2299
3479
|
}
|
|
@@ -2308,7 +3488,7 @@ var AcpClient = class {
|
|
|
2308
3488
|
});
|
|
2309
3489
|
const data = yield response.json();
|
|
2310
3490
|
if (data.error) {
|
|
2311
|
-
throw new
|
|
3491
|
+
throw new acpError_default(data.error.message);
|
|
2312
3492
|
}
|
|
2313
3493
|
const job = data.data;
|
|
2314
3494
|
if (!job) {
|
|
@@ -2321,6 +3501,7 @@ var AcpClient = class {
|
|
|
2321
3501
|
job.providerAddress,
|
|
2322
3502
|
job.evaluatorAddress,
|
|
2323
3503
|
job.price,
|
|
3504
|
+
job.priceTokenAddress,
|
|
2324
3505
|
job.memos.map((memo) => {
|
|
2325
3506
|
return new acpMemo_default(
|
|
2326
3507
|
this,
|
|
@@ -2328,14 +3509,17 @@ var AcpClient = class {
|
|
|
2328
3509
|
memo.memoType,
|
|
2329
3510
|
memo.content,
|
|
2330
3511
|
memo.nextPhase,
|
|
2331
|
-
memo.
|
|
3512
|
+
memo.status,
|
|
3513
|
+
memo.signedReason,
|
|
3514
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3515
|
+
memo.payableDetails
|
|
2332
3516
|
);
|
|
2333
3517
|
}),
|
|
2334
3518
|
job.phase,
|
|
2335
3519
|
job.context
|
|
2336
3520
|
);
|
|
2337
3521
|
} catch (error) {
|
|
2338
|
-
throw error;
|
|
3522
|
+
throw new acpError_default("Failed to get job by id", error);
|
|
2339
3523
|
}
|
|
2340
3524
|
});
|
|
2341
3525
|
}
|
|
@@ -2350,7 +3534,7 @@ var AcpClient = class {
|
|
|
2350
3534
|
});
|
|
2351
3535
|
const data = yield response.json();
|
|
2352
3536
|
if (data.error) {
|
|
2353
|
-
throw new
|
|
3537
|
+
throw new acpError_default(data.error.message);
|
|
2354
3538
|
}
|
|
2355
3539
|
const memo = data.data;
|
|
2356
3540
|
if (!memo) {
|
|
@@ -2362,10 +3546,13 @@ var AcpClient = class {
|
|
|
2362
3546
|
memo.memoType,
|
|
2363
3547
|
memo.content,
|
|
2364
3548
|
memo.nextPhase,
|
|
2365
|
-
memo.
|
|
3549
|
+
memo.status,
|
|
3550
|
+
memo.signedReason,
|
|
3551
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3552
|
+
memo.payableDetails
|
|
2366
3553
|
);
|
|
2367
3554
|
} catch (error) {
|
|
2368
|
-
throw error;
|
|
3555
|
+
throw new acpError_default("Failed to get memo by id", error);
|
|
2369
3556
|
}
|
|
2370
3557
|
});
|
|
2371
3558
|
}
|
|
@@ -2391,13 +3578,22 @@ var index_default = acpClient_default;
|
|
|
2391
3578
|
ACP_ABI,
|
|
2392
3579
|
AcpAgentSort,
|
|
2393
3580
|
AcpContractClient,
|
|
3581
|
+
AcpContractConfig,
|
|
3582
|
+
AcpError,
|
|
2394
3583
|
AcpGraduationStatus,
|
|
2395
3584
|
AcpJob,
|
|
2396
3585
|
AcpJobPhases,
|
|
2397
3586
|
AcpMemo,
|
|
3587
|
+
AcpMemoStatus,
|
|
2398
3588
|
AcpOnlineStatus,
|
|
3589
|
+
Fare,
|
|
3590
|
+
FareAmount,
|
|
3591
|
+
FareBigInt,
|
|
2399
3592
|
MemoType,
|
|
2400
3593
|
PayloadType,
|
|
3594
|
+
PositionDirection,
|
|
2401
3595
|
baseAcpConfig,
|
|
2402
|
-
baseSepoliaAcpConfig
|
|
3596
|
+
baseSepoliaAcpConfig,
|
|
3597
|
+
ethFare,
|
|
3598
|
+
wethFare
|
|
2403
3599
|
});
|