forked from OKEAMAH/mesc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.py
More file actions
131 lines (108 loc) · 3.12 KB
/
types.py
File metadata and controls
131 lines (108 loc) · 3.12 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
from __future__ import annotations
import typing
if typing.TYPE_CHECKING:
from typing_extensions import Any, MutableMapping, TypedDict, Literal
mesc_env_vars = [
'MESC_MODE',
'MESC_PATH',
'MESC_ENV',
'MESC_ENDPOINT_METADATA',
'MESC_GLOBAL_METADATA',
'MESC_ENDPOINTS',
'MESC_NETWORK_NAMES',
'MESC_DEFAULT_ENDPOINT',
'MESC_NETWORK_DEFAULTS',
'MESC_PROFILES',
]
if typing.TYPE_CHECKING:
class Endpoint(TypedDict):
name: str
url: str
chain_id: str | None
endpoint_metadata: MutableMapping[str, Any]
class Profile(TypedDict):
name: str
default_endpoint: str | None
network_defaults: MutableMapping[str, str]
profile_metadata: MutableMapping[str, Any]
use_mesc: bool
class RpcConfig(TypedDict):
mesc_version: str
default_endpoint: str | None
endpoints: MutableMapping[str, Endpoint]
network_defaults: MutableMapping[str, str]
network_names: MutableMapping[str, str]
profiles: MutableMapping[str, Profile]
global_metadata: MutableMapping[str, Any]
endpoint_types: dict[str, type | tuple[type, ...]] = {
'name': str,
'url': str,
'chain_id': (str, type(None)),
'endpoint_metadata': dict,
}
profile_types: dict[str, type | tuple[type, ...]] = {
'name': str,
'default_endpoint': (str, type(None)),
'network_defaults': dict,
'profile_metadata': dict,
'use_mesc': bool,
}
rpc_config_types: dict[str, type | tuple[type, ...]] = {
'mesc_version': str,
'default_endpoint': (str, type(None)),
'endpoints': dict,
'network_defaults': dict,
'network_names': dict,
'profiles': dict,
'global_metadata': dict,
}
#
# # query types
#
if typing.TYPE_CHECKING:
class EndpointQuery(TypedDict):
query_type: Literal[
'default_endpoint',
'endpoint_by_name',
'endpoint_by_network',
'user_input',
]
fields: (
DefaultEndpointQuery
| EndpointNameQuery
| EndpointNetworkQuery
| UserInputQuery
)
class DefaultEndpointQuery(TypedDict):
profile: str | None
class EndpointNameQuery(TypedDict):
name: str
class EndpointNetworkQuery(TypedDict):
profile: str | None
chain_id: str | int
class UserInputQuery(TypedDict):
profile: str | None
user_input: str
class MultiEndpointQuery(TypedDict, total=False):
name_contains: str | None
url_contains: str | None
chain_id: str | int | None
class GlobalMetadataQuery(TypedDict, total=False):
profile: str | None
class MescQuery(TypedDict):
query_type: Literal[
'default_endpoint',
'endpoint_by_name',
'endpoint_by_network',
'user_input',
'multi_endpoint',
'global_metadata',
]
fields: (
DefaultEndpointQuery
| EndpointNameQuery
| EndpointNetworkQuery
| UserInputQuery
| MultiEndpointQuery
| GlobalMetadataQuery
)