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