@nucypher/taco 0.5.0 → 0.6.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/conditions/base/contract.d.ts +2 -428
- package/dist/cjs/conditions/base/contract.js +7 -80
- package/dist/cjs/conditions/base/contract.js.map +1 -1
- package/dist/cjs/conditions/base/index.d.ts +1 -0
- package/dist/cjs/conditions/base/index.js +2 -1
- package/dist/cjs/conditions/base/index.js.map +1 -1
- package/dist/cjs/conditions/base/json-api.d.ts +7 -0
- package/dist/cjs/conditions/base/json-api.js +19 -0
- package/dist/cjs/conditions/base/json-api.js.map +1 -0
- package/dist/cjs/conditions/base/rpc.d.ts +2 -42
- package/dist/cjs/conditions/base/rpc.js +7 -22
- package/dist/cjs/conditions/base/rpc.js.map +1 -1
- package/dist/cjs/conditions/base/time.d.ts +2 -40
- package/dist/cjs/conditions/base/time.js +8 -15
- package/dist/cjs/conditions/base/time.js.map +1 -1
- package/dist/cjs/conditions/compound-condition.d.ts +2 -4
- package/dist/cjs/conditions/compound-condition.js +7 -38
- package/dist/cjs/conditions/compound-condition.js.map +1 -1
- package/dist/cjs/conditions/condition-factory.js +11 -0
- package/dist/cjs/conditions/condition-factory.js.map +1 -1
- package/dist/cjs/conditions/condition.d.ts +1 -1
- package/dist/cjs/conditions/condition.js +3 -1
- package/dist/cjs/conditions/condition.js.map +1 -1
- package/dist/cjs/conditions/const.d.ts +1 -0
- package/dist/cjs/conditions/const.js +5 -2
- package/dist/cjs/conditions/const.js.map +1 -1
- package/dist/cjs/conditions/context/context.js +22 -1
- package/dist/cjs/conditions/context/context.js.map +1 -1
- package/dist/cjs/conditions/context/providers.d.ts +16 -0
- package/dist/cjs/conditions/context/providers.js +111 -0
- package/dist/cjs/conditions/context/providers.js.map +1 -0
- package/dist/cjs/conditions/if-then-else-condition.d.ts +7 -0
- package/dist/cjs/conditions/if-then-else-condition.js +18 -0
- package/dist/cjs/conditions/if-then-else-condition.js.map +1 -0
- package/dist/cjs/conditions/index.d.ts +2 -0
- package/dist/cjs/conditions/index.js +3 -1
- package/dist/cjs/conditions/index.js.map +1 -1
- package/dist/cjs/conditions/multi-condition.d.ts +2 -0
- package/dist/cjs/conditions/multi-condition.js +35 -0
- package/dist/cjs/conditions/multi-condition.js.map +1 -0
- package/dist/cjs/conditions/schemas/common.d.ts +12 -0
- package/dist/cjs/conditions/schemas/common.js +36 -0
- package/dist/cjs/conditions/schemas/common.js.map +1 -0
- package/dist/cjs/conditions/schemas/compound.d.ts +4 -0
- package/dist/cjs/conditions/schemas/compound.js +36 -0
- package/dist/cjs/conditions/schemas/compound.js.map +1 -0
- package/dist/cjs/conditions/schemas/context.d.ts +3 -0
- package/dist/cjs/conditions/schemas/context.js +16 -0
- package/dist/cjs/conditions/schemas/context.js.map +1 -0
- package/dist/cjs/conditions/schemas/contract.d.ts +428 -0
- package/dist/cjs/conditions/schemas/contract.js +81 -0
- package/dist/cjs/conditions/schemas/contract.js.map +1 -0
- package/dist/cjs/conditions/schemas/if-then-else.d.ts +4 -0
- package/dist/cjs/conditions/schemas/if-then-else.js +40 -0
- package/dist/cjs/conditions/schemas/if-then-else.js.map +1 -0
- package/dist/cjs/conditions/schemas/json-api.d.ts +46 -0
- package/dist/cjs/conditions/schemas/json-api.js +37 -0
- package/dist/cjs/conditions/schemas/json-api.js.map +1 -0
- package/dist/cjs/conditions/schemas/return-value-test.d.ts +15 -0
- package/dist/cjs/conditions/schemas/return-value-test.js +11 -0
- package/dist/cjs/conditions/schemas/return-value-test.js.map +1 -0
- package/dist/cjs/conditions/schemas/rpc.d.ts +42 -0
- package/dist/cjs/conditions/schemas/rpc.js +58 -0
- package/dist/cjs/conditions/schemas/rpc.js.map +1 -0
- package/dist/cjs/conditions/schemas/sequential.d.ts +6 -0
- package/dist/cjs/conditions/schemas/sequential.js +39 -0
- package/dist/cjs/conditions/schemas/sequential.js.map +1 -0
- package/dist/cjs/conditions/schemas/time.d.ts +40 -0
- package/dist/cjs/conditions/schemas/time.js +16 -0
- package/dist/cjs/conditions/schemas/time.js.map +1 -0
- package/dist/cjs/conditions/schemas/utils.d.ts +2 -0
- package/dist/cjs/conditions/schemas/utils.js +21 -0
- package/dist/cjs/conditions/schemas/utils.js.map +1 -0
- package/dist/cjs/conditions/sequential.d.ts +7 -0
- package/dist/cjs/conditions/sequential.js +18 -0
- package/dist/cjs/conditions/sequential.js.map +1 -0
- package/dist/cjs/conditions/shared.d.ts +2 -19
- package/dist/cjs/conditions/shared.js +6 -32
- package/dist/cjs/conditions/shared.js.map +1 -1
- package/dist/cjs/web3.d.ts +33 -0
- package/dist/cjs/web3.js +3 -0
- package/dist/cjs/web3.js.map +1 -0
- package/dist/es/conditions/base/contract.d.ts +2 -428
- package/dist/es/conditions/base/contract.js +2 -77
- package/dist/es/conditions/base/contract.js.map +1 -1
- package/dist/es/conditions/base/index.d.ts +1 -0
- package/dist/es/conditions/base/index.js +1 -0
- package/dist/es/conditions/base/index.js.map +1 -1
- package/dist/es/conditions/base/json-api.d.ts +7 -0
- package/dist/es/conditions/base/json-api.js +12 -0
- package/dist/es/conditions/base/json-api.js.map +1 -0
- package/dist/es/conditions/base/rpc.d.ts +2 -42
- package/dist/es/conditions/base/rpc.js +2 -16
- package/dist/es/conditions/base/rpc.js.map +1 -1
- package/dist/es/conditions/base/time.d.ts +2 -40
- package/dist/es/conditions/base/time.js +2 -12
- package/dist/es/conditions/base/time.js.map +1 -1
- package/dist/es/conditions/compound-condition.d.ts +2 -4
- package/dist/es/conditions/compound-condition.js +2 -35
- package/dist/es/conditions/compound-condition.js.map +1 -1
- package/dist/es/conditions/condition-factory.js +11 -0
- package/dist/es/conditions/condition-factory.js.map +1 -1
- package/dist/es/conditions/condition.d.ts +1 -1
- package/dist/es/conditions/condition.js +1 -0
- package/dist/es/conditions/condition.js.map +1 -1
- package/dist/es/conditions/const.d.ts +1 -0
- package/dist/es/conditions/const.js +4 -1
- package/dist/es/conditions/const.js.map +1 -1
- package/dist/es/conditions/context/context.js +23 -2
- package/dist/es/conditions/context/context.js.map +1 -1
- package/dist/es/conditions/context/providers.d.ts +16 -0
- package/dist/es/conditions/context/providers.js +107 -0
- package/dist/es/conditions/context/providers.js.map +1 -0
- package/dist/es/conditions/if-then-else-condition.d.ts +7 -0
- package/dist/es/conditions/if-then-else-condition.js +12 -0
- package/dist/es/conditions/if-then-else-condition.js.map +1 -0
- package/dist/es/conditions/index.d.ts +2 -0
- package/dist/es/conditions/index.js +2 -0
- package/dist/es/conditions/index.js.map +1 -1
- package/dist/es/conditions/multi-condition.d.ts +2 -0
- package/dist/es/conditions/multi-condition.js +31 -0
- package/dist/es/conditions/multi-condition.js.map +1 -0
- package/dist/es/conditions/schemas/common.d.ts +12 -0
- package/dist/es/conditions/schemas/common.js +33 -0
- package/dist/es/conditions/schemas/common.js.map +1 -0
- package/dist/es/conditions/schemas/compound.d.ts +4 -0
- package/dist/es/conditions/schemas/compound.js +33 -0
- package/dist/es/conditions/schemas/compound.js.map +1 -0
- package/dist/es/conditions/schemas/context.d.ts +3 -0
- package/dist/es/conditions/schemas/context.js +13 -0
- package/dist/es/conditions/schemas/context.js.map +1 -0
- package/dist/es/conditions/schemas/contract.d.ts +428 -0
- package/dist/es/conditions/schemas/contract.js +78 -0
- package/dist/es/conditions/schemas/contract.js.map +1 -0
- package/dist/es/conditions/schemas/if-then-else.d.ts +4 -0
- package/dist/es/conditions/schemas/if-then-else.js +37 -0
- package/dist/es/conditions/schemas/if-then-else.js.map +1 -0
- package/dist/es/conditions/schemas/json-api.d.ts +46 -0
- package/dist/es/conditions/schemas/json-api.js +34 -0
- package/dist/es/conditions/schemas/json-api.js.map +1 -0
- package/dist/es/conditions/schemas/return-value-test.d.ts +15 -0
- package/dist/es/conditions/schemas/return-value-test.js +8 -0
- package/dist/es/conditions/schemas/return-value-test.js.map +1 -0
- package/dist/es/conditions/schemas/rpc.d.ts +42 -0
- package/dist/es/conditions/schemas/rpc.js +32 -0
- package/dist/es/conditions/schemas/rpc.js.map +1 -0
- package/dist/es/conditions/schemas/sequential.d.ts +6 -0
- package/dist/es/conditions/schemas/sequential.js +36 -0
- package/dist/es/conditions/schemas/sequential.js.map +1 -0
- package/dist/es/conditions/schemas/time.d.ts +40 -0
- package/dist/es/conditions/schemas/time.js +13 -0
- package/dist/es/conditions/schemas/time.js.map +1 -0
- package/dist/es/conditions/schemas/utils.d.ts +2 -0
- package/dist/es/conditions/schemas/utils.js +18 -0
- package/dist/es/conditions/schemas/utils.js.map +1 -0
- package/dist/es/conditions/sequential.d.ts +7 -0
- package/dist/es/conditions/sequential.js +12 -0
- package/dist/es/conditions/sequential.js.map +1 -0
- package/dist/es/conditions/shared.d.ts +2 -19
- package/dist/es/conditions/shared.js +2 -31
- package/dist/es/conditions/shared.js.map +1 -1
- package/dist/es/web3.d.ts +33 -0
- package/dist/es/web3.js +2 -0
- package/dist/es/web3.js.map +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.es.tsbuildinfo +1 -1
- package/package.json +4 -3
|
@@ -1,433 +1,7 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { Condition } from '../condition';
|
|
2
|
+
import { ContractConditionProps } from '../schemas/contract';
|
|
3
3
|
import { OmitConditionType } from '../shared';
|
|
4
|
-
|
|
5
|
-
name: z.ZodString;
|
|
6
|
-
type: z.ZodLiteral<"function">;
|
|
7
|
-
inputs: z.ZodArray<z.ZodObject<{
|
|
8
|
-
name: z.ZodString;
|
|
9
|
-
type: z.ZodEnum<[string, ...string[]]>;
|
|
10
|
-
internalType: z.ZodEnum<[string, ...string[]]>;
|
|
11
|
-
}, "strict", z.ZodTypeAny, {
|
|
12
|
-
type: string;
|
|
13
|
-
name: string;
|
|
14
|
-
internalType: string;
|
|
15
|
-
}, {
|
|
16
|
-
type: string;
|
|
17
|
-
name: string;
|
|
18
|
-
internalType: string;
|
|
19
|
-
}>, "many">;
|
|
20
|
-
outputs: z.ZodArray<z.ZodObject<{
|
|
21
|
-
name: z.ZodString;
|
|
22
|
-
type: z.ZodEnum<[string, ...string[]]>;
|
|
23
|
-
internalType: z.ZodEnum<[string, ...string[]]>;
|
|
24
|
-
}, "strict", z.ZodTypeAny, {
|
|
25
|
-
type: string;
|
|
26
|
-
name: string;
|
|
27
|
-
internalType: string;
|
|
28
|
-
}, {
|
|
29
|
-
type: string;
|
|
30
|
-
name: string;
|
|
31
|
-
internalType: string;
|
|
32
|
-
}>, "atleastone">;
|
|
33
|
-
stateMutability: z.ZodUnion<[z.ZodLiteral<"view">, z.ZodLiteral<"pure">]>;
|
|
34
|
-
}, "strict", z.ZodTypeAny, {
|
|
35
|
-
type: "function";
|
|
36
|
-
name: string;
|
|
37
|
-
inputs: {
|
|
38
|
-
type: string;
|
|
39
|
-
name: string;
|
|
40
|
-
internalType: string;
|
|
41
|
-
}[];
|
|
42
|
-
outputs: [{
|
|
43
|
-
type: string;
|
|
44
|
-
name: string;
|
|
45
|
-
internalType: string;
|
|
46
|
-
}, ...{
|
|
47
|
-
type: string;
|
|
48
|
-
name: string;
|
|
49
|
-
internalType: string;
|
|
50
|
-
}[]];
|
|
51
|
-
stateMutability: "view" | "pure";
|
|
52
|
-
}, {
|
|
53
|
-
type: "function";
|
|
54
|
-
name: string;
|
|
55
|
-
inputs: {
|
|
56
|
-
type: string;
|
|
57
|
-
name: string;
|
|
58
|
-
internalType: string;
|
|
59
|
-
}[];
|
|
60
|
-
outputs: [{
|
|
61
|
-
type: string;
|
|
62
|
-
name: string;
|
|
63
|
-
internalType: string;
|
|
64
|
-
}, ...{
|
|
65
|
-
type: string;
|
|
66
|
-
name: string;
|
|
67
|
-
internalType: string;
|
|
68
|
-
}[]];
|
|
69
|
-
stateMutability: "view" | "pure";
|
|
70
|
-
}>, {
|
|
71
|
-
type: "function";
|
|
72
|
-
name: string;
|
|
73
|
-
inputs: {
|
|
74
|
-
type: string;
|
|
75
|
-
name: string;
|
|
76
|
-
internalType: string;
|
|
77
|
-
}[];
|
|
78
|
-
outputs: [{
|
|
79
|
-
type: string;
|
|
80
|
-
name: string;
|
|
81
|
-
internalType: string;
|
|
82
|
-
}, ...{
|
|
83
|
-
type: string;
|
|
84
|
-
name: string;
|
|
85
|
-
internalType: string;
|
|
86
|
-
}[]];
|
|
87
|
-
stateMutability: "view" | "pure";
|
|
88
|
-
}, {
|
|
89
|
-
type: "function";
|
|
90
|
-
name: string;
|
|
91
|
-
inputs: {
|
|
92
|
-
type: string;
|
|
93
|
-
name: string;
|
|
94
|
-
internalType: string;
|
|
95
|
-
}[];
|
|
96
|
-
outputs: [{
|
|
97
|
-
type: string;
|
|
98
|
-
name: string;
|
|
99
|
-
internalType: string;
|
|
100
|
-
}, ...{
|
|
101
|
-
type: string;
|
|
102
|
-
name: string;
|
|
103
|
-
internalType: string;
|
|
104
|
-
}[]];
|
|
105
|
-
stateMutability: "view" | "pure";
|
|
106
|
-
}>, {
|
|
107
|
-
type: "function";
|
|
108
|
-
name: string;
|
|
109
|
-
inputs: {
|
|
110
|
-
type: string;
|
|
111
|
-
name: string;
|
|
112
|
-
internalType: string;
|
|
113
|
-
}[];
|
|
114
|
-
outputs: [{
|
|
115
|
-
type: string;
|
|
116
|
-
name: string;
|
|
117
|
-
internalType: string;
|
|
118
|
-
}, ...{
|
|
119
|
-
type: string;
|
|
120
|
-
name: string;
|
|
121
|
-
internalType: string;
|
|
122
|
-
}[]];
|
|
123
|
-
stateMutability: "view" | "pure";
|
|
124
|
-
}, {
|
|
125
|
-
type: "function";
|
|
126
|
-
name: string;
|
|
127
|
-
inputs: {
|
|
128
|
-
type: string;
|
|
129
|
-
name: string;
|
|
130
|
-
internalType: string;
|
|
131
|
-
}[];
|
|
132
|
-
outputs: [{
|
|
133
|
-
type: string;
|
|
134
|
-
name: string;
|
|
135
|
-
internalType: string;
|
|
136
|
-
}, ...{
|
|
137
|
-
type: string;
|
|
138
|
-
name: string;
|
|
139
|
-
internalType: string;
|
|
140
|
-
}[]];
|
|
141
|
-
stateMutability: "view" | "pure";
|
|
142
|
-
}>;
|
|
143
|
-
export type FunctionAbiProps = z.infer<typeof functionAbiSchema>;
|
|
144
|
-
export declare const ContractConditionType = "contract";
|
|
145
|
-
export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<{
|
|
146
|
-
chain: z.ZodNever | z.ZodLiteral<z.Primitive> | z.ZodUnion<[z.ZodLiteral<z.Primitive>, z.ZodLiteral<z.Primitive>, ...z.ZodLiteral<z.Primitive>[]]>;
|
|
147
|
-
returnValueTest: z.ZodObject<{
|
|
148
|
-
index: z.ZodOptional<z.ZodNumber>;
|
|
149
|
-
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!="]>;
|
|
150
|
-
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
151
|
-
}, "strip", z.ZodTypeAny, {
|
|
152
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
153
|
-
index?: number | undefined;
|
|
154
|
-
value?: any;
|
|
155
|
-
}, {
|
|
156
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
157
|
-
index?: number | undefined;
|
|
158
|
-
value?: any;
|
|
159
|
-
}>;
|
|
160
|
-
conditionType: z.ZodDefault<z.ZodLiteral<"contract">>;
|
|
161
|
-
contractAddress: z.ZodString;
|
|
162
|
-
standardContractType: z.ZodOptional<z.ZodEnum<["ERC20", "ERC721"]>>;
|
|
163
|
-
method: z.ZodString;
|
|
164
|
-
functionAbi: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
165
|
-
name: z.ZodString;
|
|
166
|
-
type: z.ZodLiteral<"function">;
|
|
167
|
-
inputs: z.ZodArray<z.ZodObject<{
|
|
168
|
-
name: z.ZodString;
|
|
169
|
-
type: z.ZodEnum<[string, ...string[]]>;
|
|
170
|
-
internalType: z.ZodEnum<[string, ...string[]]>;
|
|
171
|
-
}, "strict", z.ZodTypeAny, {
|
|
172
|
-
type: string;
|
|
173
|
-
name: string;
|
|
174
|
-
internalType: string;
|
|
175
|
-
}, {
|
|
176
|
-
type: string;
|
|
177
|
-
name: string;
|
|
178
|
-
internalType: string;
|
|
179
|
-
}>, "many">;
|
|
180
|
-
outputs: z.ZodArray<z.ZodObject<{
|
|
181
|
-
name: z.ZodString;
|
|
182
|
-
type: z.ZodEnum<[string, ...string[]]>;
|
|
183
|
-
internalType: z.ZodEnum<[string, ...string[]]>;
|
|
184
|
-
}, "strict", z.ZodTypeAny, {
|
|
185
|
-
type: string;
|
|
186
|
-
name: string;
|
|
187
|
-
internalType: string;
|
|
188
|
-
}, {
|
|
189
|
-
type: string;
|
|
190
|
-
name: string;
|
|
191
|
-
internalType: string;
|
|
192
|
-
}>, "atleastone">;
|
|
193
|
-
stateMutability: z.ZodUnion<[z.ZodLiteral<"view">, z.ZodLiteral<"pure">]>;
|
|
194
|
-
}, "strict", z.ZodTypeAny, {
|
|
195
|
-
type: "function";
|
|
196
|
-
name: string;
|
|
197
|
-
inputs: {
|
|
198
|
-
type: string;
|
|
199
|
-
name: string;
|
|
200
|
-
internalType: string;
|
|
201
|
-
}[];
|
|
202
|
-
outputs: [{
|
|
203
|
-
type: string;
|
|
204
|
-
name: string;
|
|
205
|
-
internalType: string;
|
|
206
|
-
}, ...{
|
|
207
|
-
type: string;
|
|
208
|
-
name: string;
|
|
209
|
-
internalType: string;
|
|
210
|
-
}[]];
|
|
211
|
-
stateMutability: "view" | "pure";
|
|
212
|
-
}, {
|
|
213
|
-
type: "function";
|
|
214
|
-
name: string;
|
|
215
|
-
inputs: {
|
|
216
|
-
type: string;
|
|
217
|
-
name: string;
|
|
218
|
-
internalType: string;
|
|
219
|
-
}[];
|
|
220
|
-
outputs: [{
|
|
221
|
-
type: string;
|
|
222
|
-
name: string;
|
|
223
|
-
internalType: string;
|
|
224
|
-
}, ...{
|
|
225
|
-
type: string;
|
|
226
|
-
name: string;
|
|
227
|
-
internalType: string;
|
|
228
|
-
}[]];
|
|
229
|
-
stateMutability: "view" | "pure";
|
|
230
|
-
}>, {
|
|
231
|
-
type: "function";
|
|
232
|
-
name: string;
|
|
233
|
-
inputs: {
|
|
234
|
-
type: string;
|
|
235
|
-
name: string;
|
|
236
|
-
internalType: string;
|
|
237
|
-
}[];
|
|
238
|
-
outputs: [{
|
|
239
|
-
type: string;
|
|
240
|
-
name: string;
|
|
241
|
-
internalType: string;
|
|
242
|
-
}, ...{
|
|
243
|
-
type: string;
|
|
244
|
-
name: string;
|
|
245
|
-
internalType: string;
|
|
246
|
-
}[]];
|
|
247
|
-
stateMutability: "view" | "pure";
|
|
248
|
-
}, {
|
|
249
|
-
type: "function";
|
|
250
|
-
name: string;
|
|
251
|
-
inputs: {
|
|
252
|
-
type: string;
|
|
253
|
-
name: string;
|
|
254
|
-
internalType: string;
|
|
255
|
-
}[];
|
|
256
|
-
outputs: [{
|
|
257
|
-
type: string;
|
|
258
|
-
name: string;
|
|
259
|
-
internalType: string;
|
|
260
|
-
}, ...{
|
|
261
|
-
type: string;
|
|
262
|
-
name: string;
|
|
263
|
-
internalType: string;
|
|
264
|
-
}[]];
|
|
265
|
-
stateMutability: "view" | "pure";
|
|
266
|
-
}>, {
|
|
267
|
-
type: "function";
|
|
268
|
-
name: string;
|
|
269
|
-
inputs: {
|
|
270
|
-
type: string;
|
|
271
|
-
name: string;
|
|
272
|
-
internalType: string;
|
|
273
|
-
}[];
|
|
274
|
-
outputs: [{
|
|
275
|
-
type: string;
|
|
276
|
-
name: string;
|
|
277
|
-
internalType: string;
|
|
278
|
-
}, ...{
|
|
279
|
-
type: string;
|
|
280
|
-
name: string;
|
|
281
|
-
internalType: string;
|
|
282
|
-
}[]];
|
|
283
|
-
stateMutability: "view" | "pure";
|
|
284
|
-
}, {
|
|
285
|
-
type: "function";
|
|
286
|
-
name: string;
|
|
287
|
-
inputs: {
|
|
288
|
-
type: string;
|
|
289
|
-
name: string;
|
|
290
|
-
internalType: string;
|
|
291
|
-
}[];
|
|
292
|
-
outputs: [{
|
|
293
|
-
type: string;
|
|
294
|
-
name: string;
|
|
295
|
-
internalType: string;
|
|
296
|
-
}, ...{
|
|
297
|
-
type: string;
|
|
298
|
-
name: string;
|
|
299
|
-
internalType: string;
|
|
300
|
-
}[]];
|
|
301
|
-
stateMutability: "view" | "pure";
|
|
302
|
-
}>>;
|
|
303
|
-
parameters: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
|
|
304
|
-
}, "strip", z.ZodTypeAny, {
|
|
305
|
-
conditionType: "contract";
|
|
306
|
-
method: string;
|
|
307
|
-
parameters: any[];
|
|
308
|
-
returnValueTest: {
|
|
309
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
310
|
-
index?: number | undefined;
|
|
311
|
-
value?: any;
|
|
312
|
-
};
|
|
313
|
-
contractAddress: string;
|
|
314
|
-
chain?: z.Primitive;
|
|
315
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
316
|
-
functionAbi?: {
|
|
317
|
-
type: "function";
|
|
318
|
-
name: string;
|
|
319
|
-
inputs: {
|
|
320
|
-
type: string;
|
|
321
|
-
name: string;
|
|
322
|
-
internalType: string;
|
|
323
|
-
}[];
|
|
324
|
-
outputs: [{
|
|
325
|
-
type: string;
|
|
326
|
-
name: string;
|
|
327
|
-
internalType: string;
|
|
328
|
-
}, ...{
|
|
329
|
-
type: string;
|
|
330
|
-
name: string;
|
|
331
|
-
internalType: string;
|
|
332
|
-
}[]];
|
|
333
|
-
stateMutability: "view" | "pure";
|
|
334
|
-
} | undefined;
|
|
335
|
-
}, {
|
|
336
|
-
method: string;
|
|
337
|
-
parameters: any[];
|
|
338
|
-
returnValueTest: {
|
|
339
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
340
|
-
index?: number | undefined;
|
|
341
|
-
value?: any;
|
|
342
|
-
};
|
|
343
|
-
contractAddress: string;
|
|
344
|
-
chain?: z.Primitive;
|
|
345
|
-
conditionType?: "contract" | undefined;
|
|
346
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
347
|
-
functionAbi?: {
|
|
348
|
-
type: "function";
|
|
349
|
-
name: string;
|
|
350
|
-
inputs: {
|
|
351
|
-
type: string;
|
|
352
|
-
name: string;
|
|
353
|
-
internalType: string;
|
|
354
|
-
}[];
|
|
355
|
-
outputs: [{
|
|
356
|
-
type: string;
|
|
357
|
-
name: string;
|
|
358
|
-
internalType: string;
|
|
359
|
-
}, ...{
|
|
360
|
-
type: string;
|
|
361
|
-
name: string;
|
|
362
|
-
internalType: string;
|
|
363
|
-
}[]];
|
|
364
|
-
stateMutability: "view" | "pure";
|
|
365
|
-
} | undefined;
|
|
366
|
-
}>, {
|
|
367
|
-
conditionType: "contract";
|
|
368
|
-
method: string;
|
|
369
|
-
parameters: any[];
|
|
370
|
-
returnValueTest: {
|
|
371
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
372
|
-
index?: number | undefined;
|
|
373
|
-
value?: any;
|
|
374
|
-
};
|
|
375
|
-
contractAddress: string;
|
|
376
|
-
chain?: z.Primitive;
|
|
377
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
378
|
-
functionAbi?: {
|
|
379
|
-
type: "function";
|
|
380
|
-
name: string;
|
|
381
|
-
inputs: {
|
|
382
|
-
type: string;
|
|
383
|
-
name: string;
|
|
384
|
-
internalType: string;
|
|
385
|
-
}[];
|
|
386
|
-
outputs: [{
|
|
387
|
-
type: string;
|
|
388
|
-
name: string;
|
|
389
|
-
internalType: string;
|
|
390
|
-
}, ...{
|
|
391
|
-
type: string;
|
|
392
|
-
name: string;
|
|
393
|
-
internalType: string;
|
|
394
|
-
}[]];
|
|
395
|
-
stateMutability: "view" | "pure";
|
|
396
|
-
} | undefined;
|
|
397
|
-
}, {
|
|
398
|
-
method: string;
|
|
399
|
-
parameters: any[];
|
|
400
|
-
returnValueTest: {
|
|
401
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
402
|
-
index?: number | undefined;
|
|
403
|
-
value?: any;
|
|
404
|
-
};
|
|
405
|
-
contractAddress: string;
|
|
406
|
-
chain?: z.Primitive;
|
|
407
|
-
conditionType?: "contract" | undefined;
|
|
408
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
409
|
-
functionAbi?: {
|
|
410
|
-
type: "function";
|
|
411
|
-
name: string;
|
|
412
|
-
inputs: {
|
|
413
|
-
type: string;
|
|
414
|
-
name: string;
|
|
415
|
-
internalType: string;
|
|
416
|
-
}[];
|
|
417
|
-
outputs: [{
|
|
418
|
-
type: string;
|
|
419
|
-
name: string;
|
|
420
|
-
internalType: string;
|
|
421
|
-
}, ...{
|
|
422
|
-
type: string;
|
|
423
|
-
name: string;
|
|
424
|
-
internalType: string;
|
|
425
|
-
}[]];
|
|
426
|
-
stateMutability: "view" | "pure";
|
|
427
|
-
} | undefined;
|
|
428
|
-
}>;
|
|
429
|
-
export type ContractConditionProps = z.infer<typeof contractConditionSchema>;
|
|
4
|
+
export { ContractConditionProps, contractConditionSchema, ContractConditionType, FunctionAbiProps, } from '../schemas/contract';
|
|
430
5
|
export declare class ContractCondition extends Condition {
|
|
431
6
|
constructor(value: OmitConditionType<ContractConditionProps>);
|
|
432
7
|
}
|
|
433
|
-
export {};
|
|
@@ -1,81 +1,6 @@
|
|
|
1
|
-
import { ETH_ADDRESS_REGEXP } from '@nucypher/shared';
|
|
2
|
-
import { ethers } from 'ethers';
|
|
3
|
-
import { z } from 'zod';
|
|
4
1
|
import { Condition } from '../condition';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
// TODO: Consider replacing with `z.unknown`:
|
|
8
|
-
// Since Solidity types are tied to Solidity version, we may not be able to accurately represent them in Zod.
|
|
9
|
-
// Alternatively, find a TS Solidity type lib.
|
|
10
|
-
const EthBaseTypes = [
|
|
11
|
-
'bool',
|
|
12
|
-
'string',
|
|
13
|
-
'address',
|
|
14
|
-
'address payable',
|
|
15
|
-
...Array.from({ length: 32 }, (_v, i) => `bytes${i + 1}`), // bytes1 through bytes32
|
|
16
|
-
'bytes',
|
|
17
|
-
...Array.from({ length: 32 }, (_v, i) => `uint${8 * (i + 1)}`), // uint8 through uint256
|
|
18
|
-
...Array.from({ length: 32 }, (_v, i) => `int${8 * (i + 1)}`), // int8 through int256
|
|
19
|
-
];
|
|
20
|
-
const functionAbiVariableSchema = z
|
|
21
|
-
.object({
|
|
22
|
-
name: z.string(),
|
|
23
|
-
type: z.enum(EthBaseTypes),
|
|
24
|
-
internalType: z.enum(EthBaseTypes), // TODO: Do we need to validate this?
|
|
25
|
-
})
|
|
26
|
-
.strict();
|
|
27
|
-
const functionAbiSchema = z
|
|
28
|
-
.object({
|
|
29
|
-
name: z.string(),
|
|
30
|
-
type: z.literal('function'),
|
|
31
|
-
inputs: z.array(functionAbiVariableSchema).min(0),
|
|
32
|
-
outputs: z.array(functionAbiVariableSchema).nonempty(),
|
|
33
|
-
stateMutability: z.union([z.literal('view'), z.literal('pure')]),
|
|
34
|
-
})
|
|
35
|
-
.strict()
|
|
36
|
-
.refine((functionAbi) => {
|
|
37
|
-
let asInterface;
|
|
38
|
-
try {
|
|
39
|
-
// `stringify` here because ethers.utils.Interface doesn't accept a Zod schema
|
|
40
|
-
asInterface = new ethers.utils.Interface(JSON.stringify([functionAbi]));
|
|
41
|
-
}
|
|
42
|
-
catch (e) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
const functionsInAbi = Object.values(asInterface.functions || {});
|
|
46
|
-
return functionsInAbi.length === 1;
|
|
47
|
-
}, {
|
|
48
|
-
message: '"functionAbi" must contain a single function definition',
|
|
49
|
-
path: ['functionAbi'],
|
|
50
|
-
})
|
|
51
|
-
.refine((functionAbi) => {
|
|
52
|
-
const asInterface = new ethers.utils.Interface(JSON.stringify([functionAbi]));
|
|
53
|
-
const nrOfInputs = asInterface.fragments[0].inputs.length;
|
|
54
|
-
return functionAbi.inputs.length === nrOfInputs;
|
|
55
|
-
}, {
|
|
56
|
-
message: '"parameters" must have the same length as "functionAbi.inputs"',
|
|
57
|
-
path: ['parameters'],
|
|
58
|
-
});
|
|
59
|
-
export const ContractConditionType = 'contract';
|
|
60
|
-
export const contractConditionSchema = rpcConditionSchema
|
|
61
|
-
.extend({
|
|
62
|
-
conditionType: z
|
|
63
|
-
.literal(ContractConditionType)
|
|
64
|
-
.default(ContractConditionType),
|
|
65
|
-
contractAddress: z.string().regex(ETH_ADDRESS_REGEXP).length(42),
|
|
66
|
-
standardContractType: z.enum(['ERC20', 'ERC721']).optional(),
|
|
67
|
-
method: z.string(),
|
|
68
|
-
functionAbi: functionAbiSchema.optional(),
|
|
69
|
-
parameters: z.array(paramOrContextParamSchema),
|
|
70
|
-
})
|
|
71
|
-
// Adding this custom logic causes the return type to be ZodEffects instead of ZodObject
|
|
72
|
-
// https://github.com/colinhacks/zod/issues/2474
|
|
73
|
-
.refine(
|
|
74
|
-
// A check to see if either 'standardContractType' or 'functionAbi' is set
|
|
75
|
-
(data) => Boolean(data.standardContractType) !== Boolean(data.functionAbi), {
|
|
76
|
-
message: "At most one of the fields 'standardContractType' and 'functionAbi' must be defined",
|
|
77
|
-
path: ['standardContractType'],
|
|
78
|
-
});
|
|
2
|
+
import { contractConditionSchema, ContractConditionType, } from '../schemas/contract';
|
|
3
|
+
export { contractConditionSchema, ContractConditionType, } from '../schemas/contract';
|
|
79
4
|
export class ContractCondition extends Condition {
|
|
80
5
|
constructor(value) {
|
|
81
6
|
super(contractConditionSchema, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../../src/conditions/base/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../../src/conditions/base/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAEL,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAEL,uBAAuB,EACvB,qBAAqB,GAEtB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC9C,YAAY,KAAgD;QAC1D,KAAK,CAAC,uBAAuB,EAAE;YAC7B,aAAa,EAAE,qBAAqB;YACpC,GAAG,KAAK;SACT,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Exporting classes here instead of their respective schema files to
|
|
2
2
|
// avoid circular dependency on Condition class.
|
|
3
3
|
export * as contract from './contract';
|
|
4
|
+
export * as jsonApi from './json-api';
|
|
4
5
|
export * as rpc from './rpc';
|
|
5
6
|
export * as time from './time';
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/conditions/base/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,gDAAgD;AAEhD,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/conditions/base/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,gDAAgD;AAEhD,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Condition } from '../condition';
|
|
2
|
+
import { JsonApiConditionProps } from '../schemas/json-api';
|
|
3
|
+
import { OmitConditionType } from '../shared';
|
|
4
|
+
export { JsonApiConditionProps, jsonApiConditionSchema, JsonApiConditionType, jsonPathSchema, } from '../schemas/json-api';
|
|
5
|
+
export declare class JsonApiCondition extends Condition {
|
|
6
|
+
constructor(value: OmitConditionType<JsonApiConditionProps>);
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Condition } from '../condition';
|
|
2
|
+
import { jsonApiConditionSchema, JsonApiConditionType, } from '../schemas/json-api';
|
|
3
|
+
export { jsonApiConditionSchema, JsonApiConditionType, jsonPathSchema, } from '../schemas/json-api';
|
|
4
|
+
export class JsonApiCondition extends Condition {
|
|
5
|
+
constructor(value) {
|
|
6
|
+
super(jsonApiConditionSchema, {
|
|
7
|
+
conditionType: JsonApiConditionType,
|
|
8
|
+
...value,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=json-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-api.js","sourceRoot":"","sources":["../../../../src/conditions/base/json-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAEL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAEL,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAC7C,YAAY,KAA+C;QACzD,KAAK,CAAC,sBAAsB,EAAE;YAC5B,aAAa,EAAE,oBAAoB;YACnC,GAAG,KAAK;SACT,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,47 +1,7 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { Condition } from '../condition';
|
|
2
|
+
import { RpcConditionProps } from '../schemas/rpc';
|
|
3
3
|
import { OmitConditionType } from '../shared';
|
|
4
|
-
export
|
|
5
|
-
export declare const rpcConditionSchema: z.ZodObject<{
|
|
6
|
-
conditionType: z.ZodDefault<z.ZodLiteral<"rpc">>;
|
|
7
|
-
chain: z.ZodNever | z.ZodLiteral<z.Primitive> | z.ZodUnion<[z.ZodLiteral<z.Primitive>, z.ZodLiteral<z.Primitive>, ...z.ZodLiteral<z.Primitive>[]]>;
|
|
8
|
-
method: z.ZodEnum<["eth_getBalance"]>;
|
|
9
|
-
parameters: z.ZodUnion<[z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEnum<[":userAddress", ":userAddressExternalEIP4361"]>]>, "atleastone">, z.ZodTuple<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEnum<[":userAddress", ":userAddressExternalEIP4361"]>]>, z.ZodType<any, z.ZodTypeDef, any>], null>]>;
|
|
10
|
-
returnValueTest: z.ZodObject<{
|
|
11
|
-
index: z.ZodOptional<z.ZodNumber>;
|
|
12
|
-
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!="]>;
|
|
13
|
-
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
14
|
-
}, "strip", z.ZodTypeAny, {
|
|
15
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
16
|
-
index?: number | undefined;
|
|
17
|
-
value?: any;
|
|
18
|
-
}, {
|
|
19
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
20
|
-
index?: number | undefined;
|
|
21
|
-
value?: any;
|
|
22
|
-
}>;
|
|
23
|
-
}, "strip", z.ZodTypeAny, {
|
|
24
|
-
conditionType: "rpc";
|
|
25
|
-
method: "eth_getBalance";
|
|
26
|
-
parameters: ([string, ...string[]] | [string, any]) & ([string, ...string[]] | [string, any] | undefined);
|
|
27
|
-
returnValueTest: {
|
|
28
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
29
|
-
index?: number | undefined;
|
|
30
|
-
value?: any;
|
|
31
|
-
};
|
|
32
|
-
chain?: z.Primitive;
|
|
33
|
-
}, {
|
|
34
|
-
method: "eth_getBalance";
|
|
35
|
-
parameters: ([string, ...string[]] | [string, any]) & ([string, ...string[]] | [string, any] | undefined);
|
|
36
|
-
returnValueTest: {
|
|
37
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
38
|
-
index?: number | undefined;
|
|
39
|
-
value?: any;
|
|
40
|
-
};
|
|
41
|
-
conditionType?: "rpc" | undefined;
|
|
42
|
-
chain?: z.Primitive;
|
|
43
|
-
}>;
|
|
44
|
-
export type RpcConditionProps = z.infer<typeof rpcConditionSchema>;
|
|
4
|
+
export { RpcConditionProps, rpcConditionSchema, RpcConditionType, } from '../schemas/rpc';
|
|
45
5
|
export declare class RpcCondition extends Condition {
|
|
46
6
|
constructor(value: OmitConditionType<RpcConditionProps>);
|
|
47
7
|
}
|
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { Condition } from '../condition';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import createUnionSchema from '../zod';
|
|
6
|
-
export const RpcConditionType = 'rpc';
|
|
7
|
-
export const rpcConditionSchema = z.object({
|
|
8
|
-
conditionType: z.literal(RpcConditionType).default(RpcConditionType),
|
|
9
|
-
chain: createUnionSchema(SUPPORTED_CHAIN_IDS),
|
|
10
|
-
method: z.enum(['eth_getBalance']),
|
|
11
|
-
parameters: z.union([
|
|
12
|
-
z.array(EthAddressOrUserAddressSchema).nonempty(),
|
|
13
|
-
// Using tuple here because ordering matters
|
|
14
|
-
z.tuple([EthAddressOrUserAddressSchema, paramOrContextParamSchema]),
|
|
15
|
-
]),
|
|
16
|
-
returnValueTest: returnValueTestSchema, // Update to allow multiple return values after expanding supported methods
|
|
17
|
-
});
|
|
2
|
+
import { rpcConditionSchema, RpcConditionType, } from '../schemas/rpc';
|
|
3
|
+
export { rpcConditionSchema, RpcConditionType, } from '../schemas/rpc';
|
|
18
4
|
export class RpcCondition extends Condition {
|
|
19
5
|
constructor(value) {
|
|
20
6
|
super(rpcConditionSchema, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc.js","sourceRoot":"","sources":["../../../../src/conditions/base/rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"rpc.js","sourceRoot":"","sources":["../../../../src/conditions/base/rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAEL,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAEL,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAExB,MAAM,OAAO,YAAa,SAAQ,SAAS;IACzC,YAAY,KAA2C;QACrD,KAAK,CAAC,kBAAkB,EAAE;YACxB,aAAa,EAAE,gBAAgB;YAC/B,GAAG,KAAK;SACT,CAAC,CAAC;IACL,CAAC;CACF"}
|