forked from software-mansion/starknet.py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshape.py
108 lines (71 loc) · 2.02 KB
/
shape.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
from __future__ import annotations
from typing import List, Literal, Optional, TypedDict, Union
STRUCT_ENTRY = "struct"
EVENT_ENTRY = "event"
FUNCTION_ENTRY = "function"
ENUM_ENTRY = "enum"
CONSTRUCTOR_ENTRY = "constructor"
L1_HANDLER_ENTRY = "l1_handler"
IMPL_ENTRY = "impl"
INTERFACE_ENTRY = "interface"
KEY_KIND = "key"
DATA_KIND = "data"
NESTED_KIND = "nested"
class TypeDict(TypedDict):
type: str
class TypedParameterDict(TypeDict):
name: str
class StructDict(TypedDict):
type: Literal["struct"]
name: str
members: List[TypedParameterDict]
class FunctionBaseDict(TypedDict):
name: str
inputs: List[TypedParameterDict]
outputs: List[TypeDict]
state_mutability: Optional[Literal["external", "view"]]
class FunctionDict(FunctionBaseDict):
type: Literal["function"]
class ConstructorDict(TypedDict):
type: Literal["constructor"]
name: str
inputs: List[TypedParameterDict]
class L1HandlerDict(FunctionBaseDict):
type: Literal["l1_handler"]
class EventBaseDict(TypedDict):
type: Literal["event"]
name: str
class EventStructMemberDict(TypedParameterDict):
kind: Literal["data", "key"]
class EventStructDict(EventBaseDict):
kind: Literal["struct"]
members: List[EventStructMemberDict]
class EventEnumVariantDict(TypedParameterDict):
kind: Literal["nested"]
class EventEnumDict(EventBaseDict):
kind: Literal["enum"]
variants: List[EventEnumVariantDict]
EventDict = Union[EventStructDict, EventEnumDict]
class EnumDict(TypedDict):
type: Literal["enum"]
name: str
variants: List[TypedParameterDict]
class ImplDict(TypedDict):
type: Literal["impl"]
name: str
interface_name: str
class InterfaceDict(TypedDict):
type: Literal["interface"]
name: str
items: List[FunctionDict] # for now only functions can be defined here
AbiDictEntry = Union[
StructDict,
FunctionDict,
EventDict,
EnumDict,
ConstructorDict,
L1HandlerDict,
ImplDict,
InterfaceDict,
]
AbiDictList = List[AbiDictEntry]