@lit-protocol/vincent-policy-send-counter 0.1.0 → 0.2.0
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/CHANGELOG.md +22 -0
- package/CONTRIBUTING.md +6 -6
- package/README.md +1 -1
- package/dist/CHANGELOG.md +22 -0
- package/dist/CONTRIBUTING.md +6 -6
- package/dist/README.md +1 -1
- package/dist/package.json +3 -3
- package/dist/src/generated/lit-action.js +2 -2
- package/dist/src/generated/vincent-bundled-policy.d.ts +183 -144
- package/dist/src/generated/vincent-bundled-policy.d.ts.map +1 -1
- package/dist/src/generated/vincent-policy-metadata.json +1 -1
- package/dist/src/lib/abi/counterSignatures.d.ts +82 -0
- package/dist/src/lib/abi/counterSignatures.d.ts.map +1 -0
- package/dist/src/lib/abi/counterSignatures.js +100 -0
- package/dist/src/lib/abi/counterSignatures.js.map +1 -0
- package/dist/src/lib/helpers/index.d.ts +26 -0
- package/dist/src/lib/helpers/index.d.ts.map +1 -0
- package/dist/src/lib/helpers/index.js +107 -0
- package/dist/src/lib/helpers/index.js.map +1 -0
- package/dist/src/lib/schemas.d.ts +115 -64
- package/dist/src/lib/schemas.d.ts.map +1 -1
- package/dist/src/lib/schemas.js +71 -36
- package/dist/src/lib/schemas.js.map +1 -1
- package/dist/src/lib/vincent-policy.d.ts +183 -144
- package/dist/src/lib/vincent-policy.d.ts.map +1 -1
- package/dist/src/lib/vincent-policy.js +145 -74
- package/dist/src/lib/vincent-policy.js.map +1 -1
- package/package.json +5 -5
- package/dist/src/lib/policy-helpers/calculate-usd-value.d.ts +0 -7
- package/dist/src/lib/policy-helpers/calculate-usd-value.d.ts.map +0 -1
- package/dist/src/lib/policy-helpers/calculate-usd-value.js +0 -22
- package/dist/src/lib/policy-helpers/calculate-usd-value.js.map +0 -1
- package/dist/src/lib/policy-helpers/check-spending-limit.d.ts +0 -16
- package/dist/src/lib/policy-helpers/check-spending-limit.d.ts.map +0 -1
- package/dist/src/lib/policy-helpers/check-spending-limit.js +0 -29
- package/dist/src/lib/policy-helpers/check-spending-limit.js.map +0 -1
- package/dist/src/lib/policy-helpers/get-eth-usd-price.d.ts +0 -6
- package/dist/src/lib/policy-helpers/get-eth-usd-price.d.ts.map +0 -1
- package/dist/src/lib/policy-helpers/get-eth-usd-price.js +0 -22
- package/dist/src/lib/policy-helpers/get-eth-usd-price.js.map +0 -1
- package/dist/src/lib/policy-helpers/get-token-amount-in-usd.d.ts +0 -10
- package/dist/src/lib/policy-helpers/get-token-amount-in-usd.d.ts.map +0 -1
- package/dist/src/lib/policy-helpers/get-token-amount-in-usd.js +0 -68
- package/dist/src/lib/policy-helpers/get-token-amount-in-usd.js.map +0 -1
- package/dist/src/lib/policy-helpers/get-uniswap-quote.d.ts +0 -15
- package/dist/src/lib/policy-helpers/get-uniswap-quote.d.ts.map +0 -1
- package/dist/src/lib/policy-helpers/get-uniswap-quote.js +0 -114
- package/dist/src/lib/policy-helpers/get-uniswap-quote.js.map +0 -1
- package/dist/src/lib/policy-helpers/index.d.ts +0 -7
- package/dist/src/lib/policy-helpers/index.d.ts.map +0 -1
- package/dist/src/lib/policy-helpers/index.js +0 -10
- package/dist/src/lib/policy-helpers/index.js.map +0 -1
- package/dist/src/lib/policy-helpers/send-spend-tx.d.ts +0 -9
- package/dist/src/lib/policy-helpers/send-spend-tx.d.ts.map +0 -1
- package/dist/src/lib/policy-helpers/send-spend-tx.js +0 -144
- package/dist/src/lib/policy-helpers/send-spend-tx.js.map +0 -1
- package/dist/src/lib/policy-helpers/sign-tx.d.ts +0 -3
- package/dist/src/lib/policy-helpers/sign-tx.d.ts.map +0 -1
- package/dist/src/lib/policy-helpers/sign-tx.js +0 -28
- package/dist/src/lib/policy-helpers/sign-tx.js.map +0 -1
- package/dist/src/lib/policy-helpers/spending-limit-contract.d.ts +0 -4
- package/dist/src/lib/policy-helpers/spending-limit-contract.d.ts.map +0 -1
- package/dist/src/lib/policy-helpers/spending-limit-contract.js +0 -22
- package/dist/src/lib/policy-helpers/spending-limit-contract.js.map +0 -1
|
@@ -1,209 +1,248 @@
|
|
|
1
|
-
export declare const vincentPolicy: import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/types").VincentPolicy<"@lit-protocol/vincent-policy-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
chainIdForUniswap: import("zod").ZodNumber;
|
|
5
|
-
tokenAddress: import("zod").ZodString;
|
|
6
|
-
tokenDecimals: import("zod").ZodNumber;
|
|
7
|
-
buyAmount: import("zod").ZodNumber;
|
|
1
|
+
export declare const vincentPolicy: import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/types").VincentPolicy<"@lit-protocol/vincent-policy-send-counter-limit", import("zod").ZodObject<{
|
|
2
|
+
to: import("zod").ZodString;
|
|
3
|
+
amount: import("zod").ZodString;
|
|
8
4
|
}, "strip", import("zod").ZodTypeAny, {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
chainIdForUniswap: number;
|
|
12
|
-
tokenAddress: string;
|
|
13
|
-
tokenDecimals: number;
|
|
14
|
-
buyAmount: number;
|
|
5
|
+
to: string;
|
|
6
|
+
amount: string;
|
|
15
7
|
}, {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
chainIdForUniswap: number;
|
|
19
|
-
tokenAddress: string;
|
|
20
|
-
tokenDecimals: number;
|
|
21
|
-
buyAmount: number;
|
|
8
|
+
to: string;
|
|
9
|
+
amount: string;
|
|
22
10
|
}>, import("zod").ZodObject<{
|
|
23
|
-
|
|
11
|
+
maxSends: import("zod").ZodNumber;
|
|
12
|
+
timeWindowSeconds: import("zod").ZodNumber;
|
|
24
13
|
}, "strip", import("zod").ZodTypeAny, {
|
|
25
|
-
|
|
14
|
+
maxSends: number;
|
|
15
|
+
timeWindowSeconds: number;
|
|
26
16
|
}, {
|
|
27
|
-
|
|
17
|
+
maxSends: number;
|
|
18
|
+
timeWindowSeconds: number;
|
|
28
19
|
}>, import("zod").ZodObject<{
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
currentCount: import("zod").ZodNumber;
|
|
21
|
+
maxSends: import("zod").ZodNumber;
|
|
22
|
+
remainingSends: import("zod").ZodNumber;
|
|
23
|
+
timeWindowSeconds: import("zod").ZodNumber;
|
|
31
24
|
}, "strip", import("zod").ZodTypeAny, {
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
currentCount: number;
|
|
26
|
+
remainingSends: number;
|
|
27
|
+
maxSends: number;
|
|
28
|
+
timeWindowSeconds: number;
|
|
34
29
|
}, {
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
currentCount: number;
|
|
31
|
+
remainingSends: number;
|
|
32
|
+
maxSends: number;
|
|
33
|
+
timeWindowSeconds: number;
|
|
37
34
|
}>, import("zod").ZodObject<{
|
|
38
|
-
reason: import("zod").
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
reason: import("zod").ZodString;
|
|
36
|
+
currentCount: import("zod").ZodNumber;
|
|
37
|
+
maxSends: import("zod").ZodNumber;
|
|
38
|
+
secondsUntilReset: import("zod").ZodNumber;
|
|
41
39
|
}, "strip", import("zod").ZodTypeAny, {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
currentCount: number;
|
|
41
|
+
secondsUntilReset: number;
|
|
42
|
+
maxSends: number;
|
|
43
|
+
reason: string;
|
|
45
44
|
}, {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
currentCount: number;
|
|
46
|
+
secondsUntilReset: number;
|
|
47
|
+
maxSends: number;
|
|
48
|
+
reason: string;
|
|
49
49
|
}>, import("zod").ZodObject<{
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
currentCount: import("zod").ZodNumber;
|
|
51
|
+
maxSends: import("zod").ZodNumber;
|
|
52
|
+
remainingSends: import("zod").ZodNumber;
|
|
53
|
+
timeWindowSeconds: import("zod").ZodNumber;
|
|
52
54
|
}, "strip", import("zod").ZodTypeAny, {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
currentCount: number;
|
|
56
|
+
remainingSends: number;
|
|
57
|
+
maxSends: number;
|
|
58
|
+
timeWindowSeconds: number;
|
|
55
59
|
}, {
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
currentCount: number;
|
|
61
|
+
remainingSends: number;
|
|
62
|
+
maxSends: number;
|
|
63
|
+
timeWindowSeconds: number;
|
|
58
64
|
}>, import("zod").ZodObject<{
|
|
59
65
|
reason: import("zod").ZodString;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
currentCount: import("zod").ZodNumber;
|
|
67
|
+
maxSends: import("zod").ZodNumber;
|
|
68
|
+
secondsUntilReset: import("zod").ZodNumber;
|
|
69
|
+
timeWindowSeconds: import("zod").ZodNumber;
|
|
70
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
71
|
+
currentCount: number;
|
|
72
|
+
secondsUntilReset: number;
|
|
73
|
+
maxSends: number;
|
|
74
|
+
timeWindowSeconds: number;
|
|
63
75
|
reason: string;
|
|
64
|
-
maxSpendingLimitInUsd?: number | undefined;
|
|
65
|
-
buyAmountInUsd?: number | undefined;
|
|
66
76
|
}, {
|
|
77
|
+
currentCount: number;
|
|
78
|
+
secondsUntilReset: number;
|
|
79
|
+
maxSends: number;
|
|
80
|
+
timeWindowSeconds: number;
|
|
67
81
|
reason: string;
|
|
68
|
-
maxSpendingLimitInUsd?: number | undefined;
|
|
69
|
-
buyAmountInUsd?: number | undefined;
|
|
70
82
|
}>, import("zod").ZodObject<{
|
|
71
|
-
|
|
72
|
-
|
|
83
|
+
currentCount: import("zod").ZodNumber;
|
|
84
|
+
maxSends: import("zod").ZodNumber;
|
|
85
|
+
remainingSends: import("zod").ZodNumber;
|
|
86
|
+
timeWindowSeconds: import("zod").ZodNumber;
|
|
73
87
|
}, "strip", import("zod").ZodTypeAny, {
|
|
74
|
-
|
|
75
|
-
|
|
88
|
+
currentCount: number;
|
|
89
|
+
remainingSends: number;
|
|
90
|
+
maxSends: number;
|
|
91
|
+
timeWindowSeconds: number;
|
|
76
92
|
}, {
|
|
77
|
-
|
|
78
|
-
|
|
93
|
+
currentCount: number;
|
|
94
|
+
remainingSends: number;
|
|
95
|
+
maxSends: number;
|
|
96
|
+
timeWindowSeconds: number;
|
|
79
97
|
}>, import("zod").ZodObject<{
|
|
80
|
-
|
|
98
|
+
recorded: import("zod").ZodBoolean;
|
|
99
|
+
newCount: import("zod").ZodNumber;
|
|
100
|
+
remainingSends: import("zod").ZodNumber;
|
|
81
101
|
}, "strip", import("zod").ZodTypeAny, {
|
|
82
|
-
|
|
102
|
+
remainingSends: number;
|
|
103
|
+
recorded: boolean;
|
|
104
|
+
newCount: number;
|
|
83
105
|
}, {
|
|
84
|
-
|
|
106
|
+
remainingSends: number;
|
|
107
|
+
recorded: boolean;
|
|
108
|
+
newCount: number;
|
|
85
109
|
}>, import("zod").ZodObject<{
|
|
86
|
-
|
|
110
|
+
reason: import("zod").ZodString;
|
|
87
111
|
}, "strip", import("zod").ZodTypeAny, {
|
|
88
|
-
|
|
112
|
+
reason: string;
|
|
89
113
|
}, {
|
|
90
|
-
|
|
114
|
+
reason: string;
|
|
91
115
|
}>, import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/types").PolicyLifecycleFunction<import("zod").ZodObject<{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
chainIdForUniswap: import("zod").ZodNumber;
|
|
95
|
-
tokenAddress: import("zod").ZodString;
|
|
96
|
-
tokenDecimals: import("zod").ZodNumber;
|
|
97
|
-
buyAmount: import("zod").ZodNumber;
|
|
116
|
+
to: import("zod").ZodString;
|
|
117
|
+
amount: import("zod").ZodString;
|
|
98
118
|
}, "strip", import("zod").ZodTypeAny, {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
chainIdForUniswap: number;
|
|
102
|
-
tokenAddress: string;
|
|
103
|
-
tokenDecimals: number;
|
|
104
|
-
buyAmount: number;
|
|
119
|
+
to: string;
|
|
120
|
+
amount: string;
|
|
105
121
|
}, {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
chainIdForUniswap: number;
|
|
109
|
-
tokenAddress: string;
|
|
110
|
-
tokenDecimals: number;
|
|
111
|
-
buyAmount: number;
|
|
122
|
+
to: string;
|
|
123
|
+
amount: string;
|
|
112
124
|
}>, import("zod").ZodObject<{
|
|
113
|
-
|
|
125
|
+
maxSends: import("zod").ZodNumber;
|
|
126
|
+
timeWindowSeconds: import("zod").ZodNumber;
|
|
114
127
|
}, "strip", import("zod").ZodTypeAny, {
|
|
115
|
-
|
|
128
|
+
maxSends: number;
|
|
129
|
+
timeWindowSeconds: number;
|
|
116
130
|
}, {
|
|
117
|
-
|
|
131
|
+
maxSends: number;
|
|
132
|
+
timeWindowSeconds: number;
|
|
118
133
|
}>, import("zod").ZodObject<{
|
|
119
|
-
|
|
120
|
-
|
|
134
|
+
currentCount: import("zod").ZodNumber;
|
|
135
|
+
maxSends: import("zod").ZodNumber;
|
|
136
|
+
remainingSends: import("zod").ZodNumber;
|
|
137
|
+
timeWindowSeconds: import("zod").ZodNumber;
|
|
121
138
|
}, "strip", import("zod").ZodTypeAny, {
|
|
122
|
-
|
|
123
|
-
|
|
139
|
+
currentCount: number;
|
|
140
|
+
remainingSends: number;
|
|
141
|
+
maxSends: number;
|
|
142
|
+
timeWindowSeconds: number;
|
|
124
143
|
}, {
|
|
125
|
-
|
|
126
|
-
|
|
144
|
+
currentCount: number;
|
|
145
|
+
remainingSends: number;
|
|
146
|
+
maxSends: number;
|
|
147
|
+
timeWindowSeconds: number;
|
|
127
148
|
}>, import("zod").ZodObject<{
|
|
128
149
|
reason: import("zod").ZodString;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
150
|
+
currentCount: import("zod").ZodNumber;
|
|
151
|
+
maxSends: import("zod").ZodNumber;
|
|
152
|
+
secondsUntilReset: import("zod").ZodNumber;
|
|
153
|
+
timeWindowSeconds: import("zod").ZodNumber;
|
|
154
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
155
|
+
currentCount: number;
|
|
156
|
+
secondsUntilReset: number;
|
|
157
|
+
maxSends: number;
|
|
158
|
+
timeWindowSeconds: number;
|
|
132
159
|
reason: string;
|
|
133
|
-
maxSpendingLimitInUsd?: number | undefined;
|
|
134
|
-
buyAmountInUsd?: number | undefined;
|
|
135
160
|
}, {
|
|
161
|
+
currentCount: number;
|
|
162
|
+
secondsUntilReset: number;
|
|
163
|
+
maxSends: number;
|
|
164
|
+
timeWindowSeconds: number;
|
|
136
165
|
reason: string;
|
|
137
|
-
maxSpendingLimitInUsd?: number | undefined;
|
|
138
|
-
buyAmountInUsd?: number | undefined;
|
|
139
166
|
}>>, import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/types").PolicyLifecycleFunction<import("zod").ZodObject<{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
chainIdForUniswap: import("zod").ZodNumber;
|
|
143
|
-
tokenAddress: import("zod").ZodString;
|
|
144
|
-
tokenDecimals: import("zod").ZodNumber;
|
|
145
|
-
buyAmount: import("zod").ZodNumber;
|
|
167
|
+
to: import("zod").ZodString;
|
|
168
|
+
amount: import("zod").ZodString;
|
|
146
169
|
}, "strip", import("zod").ZodTypeAny, {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
chainIdForUniswap: number;
|
|
150
|
-
tokenAddress: string;
|
|
151
|
-
tokenDecimals: number;
|
|
152
|
-
buyAmount: number;
|
|
170
|
+
to: string;
|
|
171
|
+
amount: string;
|
|
153
172
|
}, {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
chainIdForUniswap: number;
|
|
157
|
-
tokenAddress: string;
|
|
158
|
-
tokenDecimals: number;
|
|
159
|
-
buyAmount: number;
|
|
173
|
+
to: string;
|
|
174
|
+
amount: string;
|
|
160
175
|
}>, import("zod").ZodObject<{
|
|
161
|
-
|
|
176
|
+
maxSends: import("zod").ZodNumber;
|
|
177
|
+
timeWindowSeconds: import("zod").ZodNumber;
|
|
162
178
|
}, "strip", import("zod").ZodTypeAny, {
|
|
163
|
-
|
|
179
|
+
maxSends: number;
|
|
180
|
+
timeWindowSeconds: number;
|
|
164
181
|
}, {
|
|
165
|
-
|
|
182
|
+
maxSends: number;
|
|
183
|
+
timeWindowSeconds: number;
|
|
166
184
|
}>, import("zod").ZodObject<{
|
|
167
|
-
|
|
168
|
-
|
|
185
|
+
currentCount: import("zod").ZodNumber;
|
|
186
|
+
maxSends: import("zod").ZodNumber;
|
|
187
|
+
remainingSends: import("zod").ZodNumber;
|
|
188
|
+
timeWindowSeconds: import("zod").ZodNumber;
|
|
169
189
|
}, "strip", import("zod").ZodTypeAny, {
|
|
170
|
-
|
|
171
|
-
|
|
190
|
+
currentCount: number;
|
|
191
|
+
remainingSends: number;
|
|
192
|
+
maxSends: number;
|
|
193
|
+
timeWindowSeconds: number;
|
|
172
194
|
}, {
|
|
173
|
-
|
|
174
|
-
|
|
195
|
+
currentCount: number;
|
|
196
|
+
remainingSends: number;
|
|
197
|
+
maxSends: number;
|
|
198
|
+
timeWindowSeconds: number;
|
|
175
199
|
}>, import("zod").ZodObject<{
|
|
176
|
-
reason: import("zod").
|
|
177
|
-
|
|
178
|
-
|
|
200
|
+
reason: import("zod").ZodString;
|
|
201
|
+
currentCount: import("zod").ZodNumber;
|
|
202
|
+
maxSends: import("zod").ZodNumber;
|
|
203
|
+
secondsUntilReset: import("zod").ZodNumber;
|
|
179
204
|
}, "strip", import("zod").ZodTypeAny, {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
205
|
+
currentCount: number;
|
|
206
|
+
secondsUntilReset: number;
|
|
207
|
+
maxSends: number;
|
|
208
|
+
reason: string;
|
|
183
209
|
}, {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
210
|
+
currentCount: number;
|
|
211
|
+
secondsUntilReset: number;
|
|
212
|
+
maxSends: number;
|
|
213
|
+
reason: string;
|
|
187
214
|
}>>, import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/types").CommitLifecycleFunction<import("zod").ZodObject<{
|
|
188
|
-
|
|
189
|
-
|
|
215
|
+
currentCount: import("zod").ZodNumber;
|
|
216
|
+
maxSends: import("zod").ZodNumber;
|
|
217
|
+
remainingSends: import("zod").ZodNumber;
|
|
218
|
+
timeWindowSeconds: import("zod").ZodNumber;
|
|
190
219
|
}, "strip", import("zod").ZodTypeAny, {
|
|
191
|
-
|
|
192
|
-
|
|
220
|
+
currentCount: number;
|
|
221
|
+
remainingSends: number;
|
|
222
|
+
maxSends: number;
|
|
223
|
+
timeWindowSeconds: number;
|
|
193
224
|
}, {
|
|
194
|
-
|
|
195
|
-
|
|
225
|
+
currentCount: number;
|
|
226
|
+
remainingSends: number;
|
|
227
|
+
maxSends: number;
|
|
228
|
+
timeWindowSeconds: number;
|
|
196
229
|
}>, import("zod").ZodObject<{
|
|
197
|
-
|
|
230
|
+
recorded: import("zod").ZodBoolean;
|
|
231
|
+
newCount: import("zod").ZodNumber;
|
|
232
|
+
remainingSends: import("zod").ZodNumber;
|
|
198
233
|
}, "strip", import("zod").ZodTypeAny, {
|
|
199
|
-
|
|
234
|
+
remainingSends: number;
|
|
235
|
+
recorded: boolean;
|
|
236
|
+
newCount: number;
|
|
200
237
|
}, {
|
|
201
|
-
|
|
238
|
+
remainingSends: number;
|
|
239
|
+
recorded: boolean;
|
|
240
|
+
newCount: number;
|
|
202
241
|
}>, import("zod").ZodObject<{
|
|
203
|
-
|
|
242
|
+
reason: import("zod").ZodString;
|
|
204
243
|
}, "strip", import("zod").ZodTypeAny, {
|
|
205
|
-
|
|
244
|
+
reason: string;
|
|
206
245
|
}, {
|
|
207
|
-
|
|
246
|
+
reason: string;
|
|
208
247
|
}>>>;
|
|
209
248
|
//# sourceMappingURL=vincent-policy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vincent-policy.d.ts","sourceRoot":"","sources":["../../../src/lib/vincent-policy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vincent-policy.d.ts","sourceRoot":"","sources":["../../../src/lib/vincent-policy.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgRxB,CAAC"}
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.vincentPolicy = void 0;
|
|
4
4
|
const vincent_ability_sdk_1 = require("@lit-protocol/vincent-ability-sdk");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const vincent_scaffold_sdk_1 = require("@lit-protocol/vincent-scaffold-sdk");
|
|
6
|
+
const index_1 = require("./helpers/index");
|
|
7
7
|
const schemas_1 = require("./schemas");
|
|
8
|
+
const counterSignatures_1 = require("./abi/counterSignatures");
|
|
8
9
|
exports.vincentPolicy = (0, vincent_ability_sdk_1.createVincentPolicy)({
|
|
9
|
-
packageName: '@lit-protocol/vincent-policy-
|
|
10
|
+
packageName: '@lit-protocol/vincent-policy-send-counter-limit',
|
|
10
11
|
abilityParamsSchema: schemas_1.abilityParamsSchema,
|
|
11
12
|
userParamsSchema: schemas_1.userParamsSchema,
|
|
12
13
|
commitParamsSchema: schemas_1.commitParamsSchema,
|
|
@@ -17,55 +18,75 @@ exports.vincentPolicy = (0, vincent_ability_sdk_1.createVincentPolicy)({
|
|
|
17
18
|
commitAllowResultSchema: schemas_1.commitAllowResultSchema,
|
|
18
19
|
commitDenyResultSchema: schemas_1.commitDenyResultSchema,
|
|
19
20
|
precheck: async ({ abilityParams, userParams }, { allow, deny, appId, delegation: { delegatorPkpInfo } }) => {
|
|
20
|
-
console.log('
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
ethRpcUrl,
|
|
26
|
-
rpcUrlForUniswap,
|
|
27
|
-
chainIdForUniswap,
|
|
28
|
-
tokenAddress: tokenAddress,
|
|
29
|
-
tokenDecimals,
|
|
30
|
-
buyAmount,
|
|
31
|
-
maxDailySpendingLimitInUsdCents,
|
|
32
|
-
pkpEthAddress: ethAddress,
|
|
21
|
+
console.log('[@lit-protocol/vincent-policy-send-counter-limit/precheck] 🔍 POLICY PRECHECK CALLED');
|
|
22
|
+
console.log('[@lit-protocol/vincent-policy-send-counter-limit/precheck] 🔍 Policy precheck params:', {
|
|
23
|
+
abilityParams,
|
|
24
|
+
userParams,
|
|
25
|
+
ethAddress: delegatorPkpInfo.ethAddress,
|
|
33
26
|
appId,
|
|
34
27
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
// Only use what we actually need - no defaults in policy logic
|
|
29
|
+
const { maxSends, timeWindowSeconds } = userParams;
|
|
30
|
+
const { ethAddress } = delegatorPkpInfo;
|
|
31
|
+
try {
|
|
32
|
+
// Check current send limit for the user
|
|
33
|
+
const limitCheck = await (0, index_1.checkSendLimit)(ethAddress, maxSends, timeWindowSeconds);
|
|
34
|
+
if (!limitCheck.allowed) {
|
|
35
|
+
const denyResult = {
|
|
36
|
+
reason: `Send limit exceeded. Maximum ${maxSends} sends per ${timeWindowSeconds} seconds. Try again in ${limitCheck.secondsUntilReset} seconds.`,
|
|
37
|
+
currentCount: limitCheck.currentCount,
|
|
38
|
+
maxSends: maxSends,
|
|
39
|
+
secondsUntilReset: limitCheck.secondsUntilReset || 0,
|
|
40
|
+
};
|
|
41
|
+
console.log('[@lit-protocol/vincent-policy-send-counter-limit/precheck] 🚫 POLICY PRECHECK DENYING REQUEST:');
|
|
42
|
+
console.log('[@lit-protocol/vincent-policy-send-counter-limit/precheck] 🚫 Deny result:', JSON.stringify(denyResult, null, 2));
|
|
43
|
+
console.log('[@lit-protocol/vincent-policy-send-counter-limit/precheck] 🚫 Current count:', limitCheck.currentCount);
|
|
44
|
+
console.log('[@lit-protocol/vincent-policy-send-counter-limit/precheck] 🚫 Max sends:', maxSends);
|
|
45
|
+
console.log('[@lit-protocol/vincent-policy-send-counter-limit/precheck] 🚫 Limit check result:', JSON.stringify(limitCheck, null, 2));
|
|
46
|
+
console.log('[@lit-protocol/vincent-policy-send-counter-limit/precheck] 🚫 About to call deny() function...');
|
|
47
|
+
const denyResponse = deny(denyResult);
|
|
48
|
+
console.log('[@lit-protocol/vincent-policy-send-counter-limit/precheck] 🚫 POLICY PRECHECK DENY RESPONSE:', JSON.stringify(denyResponse, null, 2));
|
|
49
|
+
return denyResponse;
|
|
50
|
+
}
|
|
51
|
+
const allowResult = {
|
|
52
|
+
maxSends,
|
|
53
|
+
timeWindowSeconds,
|
|
54
|
+
currentCount: limitCheck.currentCount,
|
|
55
|
+
remainingSends: limitCheck.remainingSends,
|
|
56
|
+
};
|
|
57
|
+
console.log('[SendLimitPolicy/precheck] ✅ POLICY PRECHECK ALLOWING REQUEST:');
|
|
58
|
+
console.log('[SendLimitPolicy/precheck] ✅ Allow result:', JSON.stringify(allowResult, null, 2));
|
|
59
|
+
console.log('[SendLimitPolicy/precheck] ✅ Current count:', limitCheck.currentCount);
|
|
60
|
+
console.log('[SendLimitPolicy/precheck] ✅ Max sends:', maxSends);
|
|
61
|
+
console.log('[SendLimitPolicy/precheck] ✅ Remaining sends:', limitCheck.remainingSends);
|
|
62
|
+
const allowResponse = allow(allowResult);
|
|
63
|
+
console.log('[SendLimitPolicy/precheck] ✅ POLICY PRECHECK ALLOW RESPONSE:', JSON.stringify(allowResponse, null, 2));
|
|
64
|
+
return allowResponse;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error('[SendLimitPolicy/precheck] Error in precheck:', error);
|
|
68
|
+
return deny({
|
|
69
|
+
maxSends,
|
|
70
|
+
reason: `Policy error: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
71
|
+
currentCount: 0,
|
|
72
|
+
secondsUntilReset: 0,
|
|
44
73
|
});
|
|
74
|
+
}
|
|
45
75
|
},
|
|
46
|
-
evaluate: async ({ abilityParams, userParams }, { allow, deny,
|
|
76
|
+
evaluate: async ({ abilityParams, userParams }, { allow, deny, delegation: { delegatorPkpInfo } }) => {
|
|
77
|
+
console.log('[@lit-protocol/vincent-policy-send-counter-limit/evaluate] Evaluating send limit policy', {
|
|
78
|
+
abilityParams,
|
|
79
|
+
userParams,
|
|
80
|
+
});
|
|
81
|
+
// Only use what we actually need - no defaults in policy logic
|
|
82
|
+
const { maxSends, timeWindowSeconds } = userParams;
|
|
47
83
|
const { ethAddress } = delegatorPkpInfo;
|
|
48
|
-
|
|
49
|
-
const { buyAmount, ethRpcUrl, rpcUrlForUniswap, chainIdForUniswap, tokenAddress, tokenDecimals, } = abilityParams;
|
|
50
|
-
const { maxDailySpendingLimitInUsdCents } = userParams;
|
|
51
|
-
const checkBuyAmountResponse = await Lit.Actions.runOnce({ waitForResponse: true, name: 'checkBuyAmount' }, async () => {
|
|
84
|
+
const checkSendResponse = await Lit.Actions.runOnce({ waitForResponse: true, name: 'checkSendLimit' }, async () => {
|
|
52
85
|
try {
|
|
53
|
-
const
|
|
54
|
-
ethRpcUrl,
|
|
55
|
-
rpcUrlForUniswap,
|
|
56
|
-
chainIdForUniswap,
|
|
57
|
-
tokenAddress: tokenAddress,
|
|
58
|
-
tokenDecimals,
|
|
59
|
-
buyAmount,
|
|
60
|
-
maxDailySpendingLimitInUsdCents,
|
|
61
|
-
pkpEthAddress: ethAddress,
|
|
62
|
-
appId,
|
|
63
|
-
});
|
|
86
|
+
const limitCheck = await (0, index_1.checkSendLimit)(ethAddress, maxSends, timeWindowSeconds);
|
|
64
87
|
return JSON.stringify({
|
|
65
88
|
status: 'success',
|
|
66
|
-
|
|
67
|
-
buyAmountInUsd: buyAmountInUsd.toString(),
|
|
68
|
-
adjustedMaxDailySpendingLimit: adjustedMaxDailySpendingLimit.toString(),
|
|
89
|
+
...limitCheck,
|
|
69
90
|
});
|
|
70
91
|
}
|
|
71
92
|
catch (error) {
|
|
@@ -75,43 +96,93 @@ exports.vincentPolicy = (0, vincent_ability_sdk_1.createVincentPolicy)({
|
|
|
75
96
|
});
|
|
76
97
|
}
|
|
77
98
|
});
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
99
|
+
const parsedResponse = JSON.parse(checkSendResponse);
|
|
100
|
+
if (parsedResponse.status === 'error') {
|
|
80
101
|
return deny({
|
|
81
|
-
|
|
102
|
+
maxSends,
|
|
103
|
+
timeWindowSeconds,
|
|
104
|
+
reason: `Error checking send limit: ${parsedResponse.error} (evaluate)`,
|
|
105
|
+
currentCount: 0,
|
|
106
|
+
secondsUntilReset: 0,
|
|
82
107
|
});
|
|
83
108
|
}
|
|
84
|
-
const {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
maxSpendingLimitInUsd: Number(adjustedMaxDailySpendingLimit),
|
|
93
|
-
buyAmountInUsd: Number(buyAmountInUsd),
|
|
94
|
-
})
|
|
95
|
-
: deny({
|
|
96
|
-
reason: 'Attempted buy amount exceeds daily limit',
|
|
97
|
-
maxSpendingLimitInUsd: Number(adjustedMaxDailySpendingLimit),
|
|
98
|
-
buyAmountInUsd: Number(buyAmountInUsd),
|
|
109
|
+
const { allowed, currentCount, remainingSends, secondsUntilReset } = parsedResponse;
|
|
110
|
+
if (!allowed) {
|
|
111
|
+
return deny({
|
|
112
|
+
reason: `Send limit exceeded during evaluation. Maximum ${maxSends} sends per ${timeWindowSeconds} seconds. Try again in ${secondsUntilReset} seconds.`,
|
|
113
|
+
currentCount,
|
|
114
|
+
maxSends,
|
|
115
|
+
timeWindowSeconds,
|
|
116
|
+
secondsUntilReset: secondsUntilReset || 0,
|
|
99
117
|
});
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
appId,
|
|
106
|
-
amountSpentUsd,
|
|
107
|
-
maxSpendingLimitInUsd,
|
|
108
|
-
spendingLimitDuration: 86400, // number of seconds in a day
|
|
109
|
-
pkpEthAddress: ethAddress,
|
|
110
|
-
pkpPubKey: publicKey,
|
|
118
|
+
}
|
|
119
|
+
console.log('[@lit-protocol/vincent-policy-send-counter-limit/evaluate] Evaluated send limit policy', {
|
|
120
|
+
currentCount,
|
|
121
|
+
maxSends,
|
|
122
|
+
remainingSends,
|
|
111
123
|
});
|
|
112
124
|
return allow({
|
|
113
|
-
|
|
125
|
+
currentCount,
|
|
126
|
+
maxSends,
|
|
127
|
+
remainingSends,
|
|
128
|
+
timeWindowSeconds,
|
|
114
129
|
});
|
|
115
130
|
},
|
|
131
|
+
commit: async ({ currentCount, maxSends, timeWindowSeconds }, { allow, appId, delegation: { delegatorPkpInfo } }) => {
|
|
132
|
+
const { ethAddress } = delegatorPkpInfo;
|
|
133
|
+
console.log('[@lit-protocol/vincent-policy-send-counter-limit/commit] 🚀 IM COMMITING!');
|
|
134
|
+
// Check if we need to reset the counter first
|
|
135
|
+
const checkResponse = await (0, index_1.checkSendLimit)(ethAddress, maxSends, timeWindowSeconds);
|
|
136
|
+
if (checkResponse.shouldReset) {
|
|
137
|
+
console.log(`[@lit-protocol/vincent-policy-send-counter-limit/commit] Resetting counter for ${ethAddress} due to time window expiration`);
|
|
138
|
+
try {
|
|
139
|
+
await (0, index_1.resetSendCounter)(ethAddress, delegatorPkpInfo.publicKey);
|
|
140
|
+
console.log(`[@lit-protocol/vincent-policy-send-counter-limit/commit] Counter reset successful for ${ethAddress}`);
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
console.warn(`Counter reset failed for ${ethAddress}:`, error);
|
|
144
|
+
// Continue anyway, the counter will still work
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
// Record the send to the smart contract
|
|
149
|
+
console.log(`[@lit-protocol/vincent-policy-send-counter-limit/commit] Recording send to contract for ${ethAddress} (appId: ${appId})`);
|
|
150
|
+
// Execute the contract call to increment the counter directly
|
|
151
|
+
console.log(`[@lit-protocol/vincent-policy-send-counter-limit/commit] Calling incrementByAddress(${ethAddress}) on contract ${counterSignatures_1.counterSignatures.address}`);
|
|
152
|
+
// Call contract directly without Lit.Actions.runOnce wrapper
|
|
153
|
+
const txHash = await vincent_scaffold_sdk_1.laUtils.transaction.handler.contractCall({
|
|
154
|
+
provider: new ethers.providers.JsonRpcProvider(await Lit.Actions.getRpcUrl({ chain: 'yellowstone' })),
|
|
155
|
+
pkpPublicKey: delegatorPkpInfo.publicKey,
|
|
156
|
+
callerAddress: ethAddress,
|
|
157
|
+
abi: [counterSignatures_1.counterSignatures.methods.increment],
|
|
158
|
+
contractAddress: counterSignatures_1.counterSignatures.address,
|
|
159
|
+
functionName: 'increment',
|
|
160
|
+
args: [],
|
|
161
|
+
});
|
|
162
|
+
const newCount = currentCount + 1;
|
|
163
|
+
const remainingSends = maxSends - newCount;
|
|
164
|
+
console.log('[@lit-protocol/vincent-policy-send-counter-limit/commit] Policy commit successful', {
|
|
165
|
+
ethAddress,
|
|
166
|
+
newCount,
|
|
167
|
+
maxSends,
|
|
168
|
+
remainingSends,
|
|
169
|
+
txHash,
|
|
170
|
+
});
|
|
171
|
+
return allow({
|
|
172
|
+
recorded: true,
|
|
173
|
+
newCount,
|
|
174
|
+
remainingSends: Math.max(0, remainingSends),
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
console.error('[@lit-protocol/vincent-policy-send-counter-limit/commit] Error in commit phase:', error);
|
|
179
|
+
// Still return success since the transaction itself succeeded
|
|
180
|
+
return allow({
|
|
181
|
+
recorded: false,
|
|
182
|
+
newCount: currentCount + 1,
|
|
183
|
+
remainingSends: Math.max(0, maxSends - currentCount - 1),
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
},
|
|
116
187
|
});
|
|
117
188
|
//# sourceMappingURL=vincent-policy.js.map
|