@1shotapi/client-sdk 1.0.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/README.md +162 -0
- package/dist/categories/chains.d.ts +21 -0
- package/dist/categories/chains.js +44 -0
- package/dist/categories/chains.js.map +1 -0
- package/dist/categories/contractEvents.d.ts +103 -0
- package/dist/categories/contractEvents.js +115 -0
- package/dist/categories/contractEvents.js.map +1 -0
- package/dist/categories/contractMethods.d.ts +377 -0
- package/dist/categories/contractMethods.js +317 -0
- package/dist/categories/contractMethods.js.map +1 -0
- package/dist/categories/structs.d.ts +40 -0
- package/dist/categories/structs.js +68 -0
- package/dist/categories/structs.js.map +1 -0
- package/dist/categories/transactions.d.ts +31 -0
- package/dist/categories/transactions.js +51 -0
- package/dist/categories/transactions.js.map +1 -0
- package/dist/categories/wallets.d.ts +167 -0
- package/dist/categories/wallets.js +238 -0
- package/dist/categories/wallets.js.map +1 -0
- package/dist/client.d.ts +22 -0
- package/dist/client.js +61 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/types/abi.d.ts +32 -0
- package/dist/types/abi.js +2 -0
- package/dist/types/abi.js.map +1 -0
- package/dist/types/chain.d.ts +26 -0
- package/dist/types/chain.js +2 -0
- package/dist/types/chain.js.map +1 -0
- package/dist/types/client.d.ts +13 -0
- package/dist/types/client.js +2 -0
- package/dist/types/client.js.map +1 -0
- package/dist/types/common.d.ts +8 -0
- package/dist/types/common.js +2 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/contract.d.ts +5 -0
- package/dist/types/contract.js +2 -0
- package/dist/types/contract.js.map +1 -0
- package/dist/types/contractEvent.d.ts +46 -0
- package/dist/types/contractEvent.js +2 -0
- package/dist/types/contractEvent.js.map +1 -0
- package/dist/types/contractMethod.d.ts +31 -0
- package/dist/types/contractMethod.js +2 -0
- package/dist/types/contractMethod.js.map +1 -0
- package/dist/types/struct.d.ts +8 -0
- package/dist/types/struct.js +2 -0
- package/dist/types/struct.js.map +1 -0
- package/dist/types/transaction.d.ts +12 -0
- package/dist/types/transaction.js +2 -0
- package/dist/types/transaction.js.map +1 -0
- package/dist/types/wallet.d.ts +30 -0
- package/dist/types/wallet.js +2 -0
- package/dist/types/wallet.js.map +1 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/webhook.d.ts +19 -0
- package/dist/utils/webhook.js +66 -0
- package/dist/utils/webhook.js.map +1 -0
- package/dist/validation/abi.d.ts +470 -0
- package/dist/validation/abi.js +99 -0
- package/dist/validation/abi.js.map +1 -0
- package/dist/validation/chain.d.ts +157 -0
- package/dist/validation/chain.js +71 -0
- package/dist/validation/chain.js.map +1 -0
- package/dist/validation/common.d.ts +17 -0
- package/dist/validation/common.js +16 -0
- package/dist/validation/common.js.map +1 -0
- package/dist/validation/contractEvent.d.ts +323 -0
- package/dist/validation/contractEvent.js +148 -0
- package/dist/validation/contractEvent.js.map +1 -0
- package/dist/validation/contractMethod.d.ts +2746 -0
- package/dist/validation/contractMethod.js +787 -0
- package/dist/validation/contractMethod.js.map +1 -0
- package/dist/validation/struct.d.ts +495 -0
- package/dist/validation/struct.js +291 -0
- package/dist/validation/struct.js.map +1 -0
- package/dist/validation/transaction.d.ts +359 -0
- package/dist/validation/transaction.js +206 -0
- package/dist/validation/transaction.js.map +1 -0
- package/dist/validation/wallet.d.ts +537 -0
- package/dist/validation/wallet.js +287 -0
- package/dist/validation/wallet.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Schema for validating function parameters, event parameters, and struct fields
|
|
4
|
+
* Uses z.lazy() to handle the circular dependency in the components property
|
|
5
|
+
*/
|
|
6
|
+
export declare const abiParameterSchema: z.ZodType<{
|
|
7
|
+
name?: string;
|
|
8
|
+
type: string;
|
|
9
|
+
internalType?: string;
|
|
10
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
11
|
+
indexed?: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Schema for validating the structure of a smart contract function
|
|
15
|
+
*/
|
|
16
|
+
export declare const abiFunctionSchema: z.ZodObject<{
|
|
17
|
+
/** Type identifier (always 'function') */
|
|
18
|
+
type: z.ZodLiteral<"function">;
|
|
19
|
+
/** Name of the function */
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
/** State mutability of the function */
|
|
22
|
+
stateMutability: z.ZodEnum<["pure", "view", "nonpayable", "payable"]>;
|
|
23
|
+
/** Array of input parameters */
|
|
24
|
+
inputs: z.ZodArray<z.ZodType<{
|
|
25
|
+
name?: string;
|
|
26
|
+
type: string;
|
|
27
|
+
internalType?: string;
|
|
28
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
29
|
+
indexed?: boolean;
|
|
30
|
+
}, z.ZodTypeDef, {
|
|
31
|
+
name?: string;
|
|
32
|
+
type: string;
|
|
33
|
+
internalType?: string;
|
|
34
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
35
|
+
indexed?: boolean;
|
|
36
|
+
}>, "many">;
|
|
37
|
+
/** Array of output parameters */
|
|
38
|
+
outputs: z.ZodArray<z.ZodType<{
|
|
39
|
+
name?: string;
|
|
40
|
+
type: string;
|
|
41
|
+
internalType?: string;
|
|
42
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
43
|
+
indexed?: boolean;
|
|
44
|
+
}, z.ZodTypeDef, {
|
|
45
|
+
name?: string;
|
|
46
|
+
type: string;
|
|
47
|
+
internalType?: string;
|
|
48
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
49
|
+
indexed?: boolean;
|
|
50
|
+
}>, "many">;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
type: "function";
|
|
53
|
+
name: string;
|
|
54
|
+
stateMutability: "pure" | "view" | "nonpayable" | "payable";
|
|
55
|
+
inputs: {
|
|
56
|
+
name?: string;
|
|
57
|
+
type: string;
|
|
58
|
+
internalType?: string;
|
|
59
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
60
|
+
indexed?: boolean;
|
|
61
|
+
}[];
|
|
62
|
+
outputs: {
|
|
63
|
+
name?: string;
|
|
64
|
+
type: string;
|
|
65
|
+
internalType?: string;
|
|
66
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
67
|
+
indexed?: boolean;
|
|
68
|
+
}[];
|
|
69
|
+
}, {
|
|
70
|
+
type: "function";
|
|
71
|
+
name: string;
|
|
72
|
+
stateMutability: "pure" | "view" | "nonpayable" | "payable";
|
|
73
|
+
inputs: {
|
|
74
|
+
name?: string;
|
|
75
|
+
type: string;
|
|
76
|
+
internalType?: string;
|
|
77
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
78
|
+
indexed?: boolean;
|
|
79
|
+
}[];
|
|
80
|
+
outputs: {
|
|
81
|
+
name?: string;
|
|
82
|
+
type: string;
|
|
83
|
+
internalType?: string;
|
|
84
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
85
|
+
indexed?: boolean;
|
|
86
|
+
}[];
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* Schema for validating the structure of a smart contract event
|
|
90
|
+
*/
|
|
91
|
+
export declare const abiEventSchema: z.ZodObject<{
|
|
92
|
+
/** Type identifier (always 'event') */
|
|
93
|
+
type: z.ZodLiteral<"event">;
|
|
94
|
+
/** Name of the event */
|
|
95
|
+
name: z.ZodString;
|
|
96
|
+
/** Array of event parameters */
|
|
97
|
+
inputs: z.ZodArray<z.ZodType<{
|
|
98
|
+
name?: string;
|
|
99
|
+
type: string;
|
|
100
|
+
internalType?: string;
|
|
101
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
102
|
+
indexed?: boolean;
|
|
103
|
+
}, z.ZodTypeDef, {
|
|
104
|
+
name?: string;
|
|
105
|
+
type: string;
|
|
106
|
+
internalType?: string;
|
|
107
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
108
|
+
indexed?: boolean;
|
|
109
|
+
}>, "many">;
|
|
110
|
+
/** Whether the event is anonymous */
|
|
111
|
+
anonymous: z.ZodOptional<z.ZodBoolean>;
|
|
112
|
+
}, "strip", z.ZodTypeAny, {
|
|
113
|
+
type: "event";
|
|
114
|
+
name: string;
|
|
115
|
+
inputs: {
|
|
116
|
+
name?: string;
|
|
117
|
+
type: string;
|
|
118
|
+
internalType?: string;
|
|
119
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
120
|
+
indexed?: boolean;
|
|
121
|
+
}[];
|
|
122
|
+
anonymous?: boolean | undefined;
|
|
123
|
+
}, {
|
|
124
|
+
type: "event";
|
|
125
|
+
name: string;
|
|
126
|
+
inputs: {
|
|
127
|
+
name?: string;
|
|
128
|
+
type: string;
|
|
129
|
+
internalType?: string;
|
|
130
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
131
|
+
indexed?: boolean;
|
|
132
|
+
}[];
|
|
133
|
+
anonymous?: boolean | undefined;
|
|
134
|
+
}>;
|
|
135
|
+
/**
|
|
136
|
+
* Schema for validating the structure of a smart contract constructor
|
|
137
|
+
*/
|
|
138
|
+
export declare const abiConstructorSchema: z.ZodObject<{
|
|
139
|
+
/** Type identifier (always 'constructor') */
|
|
140
|
+
type: z.ZodLiteral<"constructor">;
|
|
141
|
+
/** Array of constructor parameters */
|
|
142
|
+
inputs: z.ZodArray<z.ZodType<{
|
|
143
|
+
name?: string;
|
|
144
|
+
type: string;
|
|
145
|
+
internalType?: string;
|
|
146
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
147
|
+
indexed?: boolean;
|
|
148
|
+
}, z.ZodTypeDef, {
|
|
149
|
+
name?: string;
|
|
150
|
+
type: string;
|
|
151
|
+
internalType?: string;
|
|
152
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
153
|
+
indexed?: boolean;
|
|
154
|
+
}>, "many">;
|
|
155
|
+
/** State mutability of the constructor */
|
|
156
|
+
stateMutability: z.ZodEnum<["nonpayable", "payable"]>;
|
|
157
|
+
}, "strip", z.ZodTypeAny, {
|
|
158
|
+
type: "constructor";
|
|
159
|
+
stateMutability: "nonpayable" | "payable";
|
|
160
|
+
inputs: {
|
|
161
|
+
name?: string;
|
|
162
|
+
type: string;
|
|
163
|
+
internalType?: string;
|
|
164
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
165
|
+
indexed?: boolean;
|
|
166
|
+
}[];
|
|
167
|
+
}, {
|
|
168
|
+
type: "constructor";
|
|
169
|
+
stateMutability: "nonpayable" | "payable";
|
|
170
|
+
inputs: {
|
|
171
|
+
name?: string;
|
|
172
|
+
type: string;
|
|
173
|
+
internalType?: string;
|
|
174
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
175
|
+
indexed?: boolean;
|
|
176
|
+
}[];
|
|
177
|
+
}>;
|
|
178
|
+
/**
|
|
179
|
+
* Schema for validating the structure of a smart contract fallback function
|
|
180
|
+
*/
|
|
181
|
+
export declare const abiFallbackSchema: z.ZodObject<{
|
|
182
|
+
/** Type identifier (always 'fallback') */
|
|
183
|
+
type: z.ZodLiteral<"fallback">;
|
|
184
|
+
/** State mutability of the fallback function */
|
|
185
|
+
stateMutability: z.ZodEnum<["nonpayable", "payable"]>;
|
|
186
|
+
}, "strip", z.ZodTypeAny, {
|
|
187
|
+
type: "fallback";
|
|
188
|
+
stateMutability: "nonpayable" | "payable";
|
|
189
|
+
}, {
|
|
190
|
+
type: "fallback";
|
|
191
|
+
stateMutability: "nonpayable" | "payable";
|
|
192
|
+
}>;
|
|
193
|
+
/**
|
|
194
|
+
* Schema for validating an error
|
|
195
|
+
*/
|
|
196
|
+
export declare const abiErrorSchema: z.ZodObject<{
|
|
197
|
+
/** Type identifier (always 'error') */
|
|
198
|
+
type: z.ZodLiteral<"error">;
|
|
199
|
+
/** Name of the error */
|
|
200
|
+
name: z.ZodString;
|
|
201
|
+
/** Array of error parameters */
|
|
202
|
+
inputs: z.ZodArray<z.ZodType<{
|
|
203
|
+
name?: string;
|
|
204
|
+
type: string;
|
|
205
|
+
internalType?: string;
|
|
206
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
207
|
+
indexed?: boolean;
|
|
208
|
+
}, z.ZodTypeDef, {
|
|
209
|
+
name?: string;
|
|
210
|
+
type: string;
|
|
211
|
+
internalType?: string;
|
|
212
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
213
|
+
indexed?: boolean;
|
|
214
|
+
}>, "many">;
|
|
215
|
+
}, "strip", z.ZodTypeAny, {
|
|
216
|
+
type: "error";
|
|
217
|
+
name: string;
|
|
218
|
+
inputs: {
|
|
219
|
+
name?: string;
|
|
220
|
+
type: string;
|
|
221
|
+
internalType?: string;
|
|
222
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
223
|
+
indexed?: boolean;
|
|
224
|
+
}[];
|
|
225
|
+
}, {
|
|
226
|
+
type: "error";
|
|
227
|
+
name: string;
|
|
228
|
+
inputs: {
|
|
229
|
+
name?: string;
|
|
230
|
+
type: string;
|
|
231
|
+
internalType?: string;
|
|
232
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
233
|
+
indexed?: boolean;
|
|
234
|
+
}[];
|
|
235
|
+
}>;
|
|
236
|
+
/**
|
|
237
|
+
* Schema for validating the structure of a smart contract receive function
|
|
238
|
+
* This is a special function that is used to receive native tokens
|
|
239
|
+
*/
|
|
240
|
+
export declare const abiReceiveSchema: z.ZodObject<{
|
|
241
|
+
/** Type identifier (always 'receive') */
|
|
242
|
+
type: z.ZodLiteral<"receive">;
|
|
243
|
+
/** State mutability of the receive function */
|
|
244
|
+
stateMutability: z.ZodLiteral<"payable">;
|
|
245
|
+
}, "strip", z.ZodTypeAny, {
|
|
246
|
+
type: "receive";
|
|
247
|
+
stateMutability: "payable";
|
|
248
|
+
}, {
|
|
249
|
+
type: "receive";
|
|
250
|
+
stateMutability: "payable";
|
|
251
|
+
}>;
|
|
252
|
+
/**
|
|
253
|
+
* Schema for validating an Ethereum ABI
|
|
254
|
+
* Uses a discriminated union based on the 'type' property to validate different ABI entries
|
|
255
|
+
*/
|
|
256
|
+
export declare const ethereumAbiSchema: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
257
|
+
/** Type identifier (always 'function') */
|
|
258
|
+
type: z.ZodLiteral<"function">;
|
|
259
|
+
/** Name of the function */
|
|
260
|
+
name: z.ZodString;
|
|
261
|
+
/** State mutability of the function */
|
|
262
|
+
stateMutability: z.ZodEnum<["pure", "view", "nonpayable", "payable"]>;
|
|
263
|
+
/** Array of input parameters */
|
|
264
|
+
inputs: z.ZodArray<z.ZodType<{
|
|
265
|
+
name?: string;
|
|
266
|
+
type: string;
|
|
267
|
+
internalType?: string;
|
|
268
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
269
|
+
indexed?: boolean;
|
|
270
|
+
}, z.ZodTypeDef, {
|
|
271
|
+
name?: string;
|
|
272
|
+
type: string;
|
|
273
|
+
internalType?: string;
|
|
274
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
275
|
+
indexed?: boolean;
|
|
276
|
+
}>, "many">;
|
|
277
|
+
/** Array of output parameters */
|
|
278
|
+
outputs: z.ZodArray<z.ZodType<{
|
|
279
|
+
name?: string;
|
|
280
|
+
type: string;
|
|
281
|
+
internalType?: string;
|
|
282
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
283
|
+
indexed?: boolean;
|
|
284
|
+
}, z.ZodTypeDef, {
|
|
285
|
+
name?: string;
|
|
286
|
+
type: string;
|
|
287
|
+
internalType?: string;
|
|
288
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
289
|
+
indexed?: boolean;
|
|
290
|
+
}>, "many">;
|
|
291
|
+
}, "strip", z.ZodTypeAny, {
|
|
292
|
+
type: "function";
|
|
293
|
+
name: string;
|
|
294
|
+
stateMutability: "pure" | "view" | "nonpayable" | "payable";
|
|
295
|
+
inputs: {
|
|
296
|
+
name?: string;
|
|
297
|
+
type: string;
|
|
298
|
+
internalType?: string;
|
|
299
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
300
|
+
indexed?: boolean;
|
|
301
|
+
}[];
|
|
302
|
+
outputs: {
|
|
303
|
+
name?: string;
|
|
304
|
+
type: string;
|
|
305
|
+
internalType?: string;
|
|
306
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
307
|
+
indexed?: boolean;
|
|
308
|
+
}[];
|
|
309
|
+
}, {
|
|
310
|
+
type: "function";
|
|
311
|
+
name: string;
|
|
312
|
+
stateMutability: "pure" | "view" | "nonpayable" | "payable";
|
|
313
|
+
inputs: {
|
|
314
|
+
name?: string;
|
|
315
|
+
type: string;
|
|
316
|
+
internalType?: string;
|
|
317
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
318
|
+
indexed?: boolean;
|
|
319
|
+
}[];
|
|
320
|
+
outputs: {
|
|
321
|
+
name?: string;
|
|
322
|
+
type: string;
|
|
323
|
+
internalType?: string;
|
|
324
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
325
|
+
indexed?: boolean;
|
|
326
|
+
}[];
|
|
327
|
+
}>, z.ZodObject<{
|
|
328
|
+
/** Type identifier (always 'event') */
|
|
329
|
+
type: z.ZodLiteral<"event">;
|
|
330
|
+
/** Name of the event */
|
|
331
|
+
name: z.ZodString;
|
|
332
|
+
/** Array of event parameters */
|
|
333
|
+
inputs: z.ZodArray<z.ZodType<{
|
|
334
|
+
name?: string;
|
|
335
|
+
type: string;
|
|
336
|
+
internalType?: string;
|
|
337
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
338
|
+
indexed?: boolean;
|
|
339
|
+
}, z.ZodTypeDef, {
|
|
340
|
+
name?: string;
|
|
341
|
+
type: string;
|
|
342
|
+
internalType?: string;
|
|
343
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
344
|
+
indexed?: boolean;
|
|
345
|
+
}>, "many">;
|
|
346
|
+
/** Whether the event is anonymous */
|
|
347
|
+
anonymous: z.ZodOptional<z.ZodBoolean>;
|
|
348
|
+
}, "strip", z.ZodTypeAny, {
|
|
349
|
+
type: "event";
|
|
350
|
+
name: string;
|
|
351
|
+
inputs: {
|
|
352
|
+
name?: string;
|
|
353
|
+
type: string;
|
|
354
|
+
internalType?: string;
|
|
355
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
356
|
+
indexed?: boolean;
|
|
357
|
+
}[];
|
|
358
|
+
anonymous?: boolean | undefined;
|
|
359
|
+
}, {
|
|
360
|
+
type: "event";
|
|
361
|
+
name: string;
|
|
362
|
+
inputs: {
|
|
363
|
+
name?: string;
|
|
364
|
+
type: string;
|
|
365
|
+
internalType?: string;
|
|
366
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
367
|
+
indexed?: boolean;
|
|
368
|
+
}[];
|
|
369
|
+
anonymous?: boolean | undefined;
|
|
370
|
+
}>, z.ZodObject<{
|
|
371
|
+
/** Type identifier (always 'constructor') */
|
|
372
|
+
type: z.ZodLiteral<"constructor">;
|
|
373
|
+
/** Array of constructor parameters */
|
|
374
|
+
inputs: z.ZodArray<z.ZodType<{
|
|
375
|
+
name?: string;
|
|
376
|
+
type: string;
|
|
377
|
+
internalType?: string;
|
|
378
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
379
|
+
indexed?: boolean;
|
|
380
|
+
}, z.ZodTypeDef, {
|
|
381
|
+
name?: string;
|
|
382
|
+
type: string;
|
|
383
|
+
internalType?: string;
|
|
384
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
385
|
+
indexed?: boolean;
|
|
386
|
+
}>, "many">;
|
|
387
|
+
/** State mutability of the constructor */
|
|
388
|
+
stateMutability: z.ZodEnum<["nonpayable", "payable"]>;
|
|
389
|
+
}, "strip", z.ZodTypeAny, {
|
|
390
|
+
type: "constructor";
|
|
391
|
+
stateMutability: "nonpayable" | "payable";
|
|
392
|
+
inputs: {
|
|
393
|
+
name?: string;
|
|
394
|
+
type: string;
|
|
395
|
+
internalType?: string;
|
|
396
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
397
|
+
indexed?: boolean;
|
|
398
|
+
}[];
|
|
399
|
+
}, {
|
|
400
|
+
type: "constructor";
|
|
401
|
+
stateMutability: "nonpayable" | "payable";
|
|
402
|
+
inputs: {
|
|
403
|
+
name?: string;
|
|
404
|
+
type: string;
|
|
405
|
+
internalType?: string;
|
|
406
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
407
|
+
indexed?: boolean;
|
|
408
|
+
}[];
|
|
409
|
+
}>, z.ZodObject<{
|
|
410
|
+
/** Type identifier (always 'fallback') */
|
|
411
|
+
type: z.ZodLiteral<"fallback">;
|
|
412
|
+
/** State mutability of the fallback function */
|
|
413
|
+
stateMutability: z.ZodEnum<["nonpayable", "payable"]>;
|
|
414
|
+
}, "strip", z.ZodTypeAny, {
|
|
415
|
+
type: "fallback";
|
|
416
|
+
stateMutability: "nonpayable" | "payable";
|
|
417
|
+
}, {
|
|
418
|
+
type: "fallback";
|
|
419
|
+
stateMutability: "nonpayable" | "payable";
|
|
420
|
+
}>, z.ZodObject<{
|
|
421
|
+
/** Type identifier (always 'error') */
|
|
422
|
+
type: z.ZodLiteral<"error">;
|
|
423
|
+
/** Name of the error */
|
|
424
|
+
name: z.ZodString;
|
|
425
|
+
/** Array of error parameters */
|
|
426
|
+
inputs: z.ZodArray<z.ZodType<{
|
|
427
|
+
name?: string;
|
|
428
|
+
type: string;
|
|
429
|
+
internalType?: string;
|
|
430
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
431
|
+
indexed?: boolean;
|
|
432
|
+
}, z.ZodTypeDef, {
|
|
433
|
+
name?: string;
|
|
434
|
+
type: string;
|
|
435
|
+
internalType?: string;
|
|
436
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
437
|
+
indexed?: boolean;
|
|
438
|
+
}>, "many">;
|
|
439
|
+
}, "strip", z.ZodTypeAny, {
|
|
440
|
+
type: "error";
|
|
441
|
+
name: string;
|
|
442
|
+
inputs: {
|
|
443
|
+
name?: string;
|
|
444
|
+
type: string;
|
|
445
|
+
internalType?: string;
|
|
446
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
447
|
+
indexed?: boolean;
|
|
448
|
+
}[];
|
|
449
|
+
}, {
|
|
450
|
+
type: "error";
|
|
451
|
+
name: string;
|
|
452
|
+
inputs: {
|
|
453
|
+
name?: string;
|
|
454
|
+
type: string;
|
|
455
|
+
internalType?: string;
|
|
456
|
+
components?: Array<z.infer<typeof abiParameterSchema>>;
|
|
457
|
+
indexed?: boolean;
|
|
458
|
+
}[];
|
|
459
|
+
}>, z.ZodObject<{
|
|
460
|
+
/** Type identifier (always 'receive') */
|
|
461
|
+
type: z.ZodLiteral<"receive">;
|
|
462
|
+
/** State mutability of the receive function */
|
|
463
|
+
stateMutability: z.ZodLiteral<"payable">;
|
|
464
|
+
}, "strip", z.ZodTypeAny, {
|
|
465
|
+
type: "receive";
|
|
466
|
+
stateMutability: "payable";
|
|
467
|
+
}, {
|
|
468
|
+
type: "receive";
|
|
469
|
+
stateMutability: "payable";
|
|
470
|
+
}>]>, "many">;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Schema for validating function parameters, event parameters, and struct fields
|
|
4
|
+
* Uses z.lazy() to handle the circular dependency in the components property
|
|
5
|
+
*/
|
|
6
|
+
export const abiParameterSchema = z.object({
|
|
7
|
+
/** Name of the parameter (optional for some ABI types) */
|
|
8
|
+
name: z.string().optional(),
|
|
9
|
+
/** Solidity type of the parameter */
|
|
10
|
+
type: z.string(),
|
|
11
|
+
/** Internal type of the parameter (used for complex types) */
|
|
12
|
+
internalType: z.string().optional(),
|
|
13
|
+
/** Array of components for tuple types */
|
|
14
|
+
components: z.lazy(() => z.array(abiParameterSchema)).optional(),
|
|
15
|
+
/** Whether the parameter is indexed (for event parameters) */
|
|
16
|
+
indexed: z.boolean().optional(),
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Schema for validating the structure of a smart contract function
|
|
20
|
+
*/
|
|
21
|
+
export const abiFunctionSchema = z.object({
|
|
22
|
+
/** Type identifier (always 'function') */
|
|
23
|
+
type: z.literal("function"),
|
|
24
|
+
/** Name of the function */
|
|
25
|
+
name: z.string(),
|
|
26
|
+
/** State mutability of the function */
|
|
27
|
+
stateMutability: z.enum(["pure", "view", "nonpayable", "payable"]),
|
|
28
|
+
/** Array of input parameters */
|
|
29
|
+
inputs: z.array(abiParameterSchema),
|
|
30
|
+
/** Array of output parameters */
|
|
31
|
+
outputs: z.array(abiParameterSchema),
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Schema for validating the structure of a smart contract event
|
|
35
|
+
*/
|
|
36
|
+
export const abiEventSchema = z.object({
|
|
37
|
+
/** Type identifier (always 'event') */
|
|
38
|
+
type: z.literal("event"),
|
|
39
|
+
/** Name of the event */
|
|
40
|
+
name: z.string(),
|
|
41
|
+
/** Array of event parameters */
|
|
42
|
+
inputs: z.array(abiParameterSchema),
|
|
43
|
+
/** Whether the event is anonymous */
|
|
44
|
+
anonymous: z.boolean().optional(),
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Schema for validating the structure of a smart contract constructor
|
|
48
|
+
*/
|
|
49
|
+
export const abiConstructorSchema = z.object({
|
|
50
|
+
/** Type identifier (always 'constructor') */
|
|
51
|
+
type: z.literal("constructor"),
|
|
52
|
+
/** Array of constructor parameters */
|
|
53
|
+
inputs: z.array(abiParameterSchema),
|
|
54
|
+
/** State mutability of the constructor */
|
|
55
|
+
stateMutability: z.enum(["nonpayable", "payable"]),
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Schema for validating the structure of a smart contract fallback function
|
|
59
|
+
*/
|
|
60
|
+
export const abiFallbackSchema = z.object({
|
|
61
|
+
/** Type identifier (always 'fallback') */
|
|
62
|
+
type: z.literal("fallback"),
|
|
63
|
+
/** State mutability of the fallback function */
|
|
64
|
+
stateMutability: z.enum(["nonpayable", "payable"]),
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* Schema for validating an error
|
|
68
|
+
*/
|
|
69
|
+
export const abiErrorSchema = z.object({
|
|
70
|
+
/** Type identifier (always 'error') */
|
|
71
|
+
type: z.literal("error"),
|
|
72
|
+
/** Name of the error */
|
|
73
|
+
name: z.string(),
|
|
74
|
+
/** Array of error parameters */
|
|
75
|
+
inputs: z.array(abiParameterSchema),
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* Schema for validating the structure of a smart contract receive function
|
|
79
|
+
* This is a special function that is used to receive native tokens
|
|
80
|
+
*/
|
|
81
|
+
export const abiReceiveSchema = z.object({
|
|
82
|
+
/** Type identifier (always 'receive') */
|
|
83
|
+
type: z.literal("receive"),
|
|
84
|
+
/** State mutability of the receive function */
|
|
85
|
+
stateMutability: z.literal("payable"),
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* Schema for validating an Ethereum ABI
|
|
89
|
+
* Uses a discriminated union based on the 'type' property to validate different ABI entries
|
|
90
|
+
*/
|
|
91
|
+
export const ethereumAbiSchema = z.array(z.discriminatedUnion("type", [
|
|
92
|
+
abiFunctionSchema,
|
|
93
|
+
abiEventSchema,
|
|
94
|
+
abiConstructorSchema,
|
|
95
|
+
abiFallbackSchema,
|
|
96
|
+
abiErrorSchema,
|
|
97
|
+
abiReceiveSchema,
|
|
98
|
+
]));
|
|
99
|
+
//# sourceMappingURL=abi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.js","sourceRoot":"","sources":["../../src/validation/abi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,C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