1#[derive(Debug, Clone, Default)]
2pub struct SelectorRegistry {
3 pub type_method_selectors:
9 std::collections::HashMap<String, std::collections::HashMap<String, Vec<[u8; 4]>>>,
10 pub interface_types: std::collections::HashSet<String>,
12}
13
14#[derive(Debug, Clone)]
15pub struct ContractMetadata {
16 pub name: String,
17 pub is_abstract: bool,
19 pub is_library: bool,
21 pub methods: Vec<FunctionMetadata>,
22 pub events: Vec<EventMetadata>,
23 pub uses_storage: bool,
24 pub state_variables: Vec<StateVariableMetadata>,
25 pub structs: Vec<StructMetadata>,
26 pub enums: Vec<EnumMetadata>,
27 pub contract_types: Vec<String>,
33 pub selector_registry: std::sync::Arc<SelectorRegistry>,
36 pub documentation: NatspecDoc,
38 pub has_using_for_star: bool,
40 pub has_using_function_list: bool,
42 pub using_for_libraries: Vec<String>,
44 pub has_type_definitions: bool,
46 pub type_aliases: std::collections::HashMap<String, String>,
49 pub flatten_warnings: Vec<String>,
51 pub super_method_map: std::collections::HashMap<String, String>,
54}
55
56#[derive(Debug, Clone)]
57pub struct FunctionMetadata {
58 pub name: String,
59 pub neo_name: String,
62 pub kind: FunctionKind,
63 pub parameters: Vec<ParameterMetadata>,
64 pub return_parameters: Vec<ParameterMetadata>,
65 pub state_mutability: StateMutability,
66 pub visibility: VisibilityKind,
67 pub offset: u32,
68 pub body: Option<Statement>,
69 pub selector: [u8; 4],
70 pub is_virtual: bool,
72 pub is_override: bool,
74 pub documentation: NatspecDoc,
76}
77
78#[derive(Debug, Clone, Copy, PartialEq, Eq)]
79pub enum FunctionKind {
80 Constructor,
81 Regular,
82}
83
84#[derive(Debug, Clone)]
85pub struct ParameterMetadata {
86 pub name: Option<String>,
87 pub ty: String,
88 pub neo_type: Option<NeoType>,
89 pub storage: Option<String>,
90}
91
92#[derive(Debug, Clone)]
93pub struct EventMetadata {
94 pub name: String,
95 pub normalized_name: String,
96 pub parameters: Vec<EventParameter>,
97}
98
99#[derive(Debug, Clone)]
100pub struct EventParameter {
101 pub name: Option<String>,
102 pub ty: String,
103 pub indexed: bool,
104}
105
106#[derive(Debug, Clone)]
107pub struct StateVariableMetadata {
108 pub name: Option<String>,
109 pub ty: String,
110 pub is_constant: bool,
111 pub is_immutable: bool,
112 pub visibility: Option<String>,
113 pub neo_type: Option<NeoType>,
114 pub has_initializer: bool,
115 pub initializer: Option<Expression>,
116}
117
118#[derive(Debug, Clone)]
119pub struct StructMetadata {
120 pub name: String,
121 pub fields: Vec<StructFieldMetadata>,
122}
123
124#[derive(Debug, Clone)]
125pub struct StructFieldMetadata {
126 pub name: String,
127 pub ty: String,
128}
129
130#[derive(Debug, Clone)]
131pub struct EnumMetadata {
132 pub name: String,
133 pub values: Vec<String>,
134}
135
136#[derive(Debug, Clone, Copy, PartialEq, Eq)]
137pub enum StateMutability {
138 Pure,
139 View,
140 NonPayable,
141 Payable,
142}
143
144impl StateMutability {
145 pub fn is_safe(self) -> bool {
146 matches!(self, StateMutability::Pure | StateMutability::View)
147 }
148}
149
150#[derive(Debug, Clone, Copy, PartialEq, Eq)]
151pub enum DiagnosticSeverity {
152 Warning,
153 Error,
154}
155
156#[derive(Debug, Clone)]
157pub struct Diagnostic {
158 pub severity: DiagnosticSeverity,
159 pub message: String,
160 pub code: Option<String>,
161 pub suggestion: Option<String>,
162}
163
164impl Diagnostic {
165 pub fn warning(message: impl Into<String>) -> Self {
167 Self {
168 severity: DiagnosticSeverity::Warning,
169 message: message.into(),
170 code: None,
171 suggestion: None,
172 }
173 }
174
175 pub fn error(message: impl Into<String>) -> Self {
177 Self {
178 severity: DiagnosticSeverity::Error,
179 message: message.into(),
180 code: None,
181 suggestion: None,
182 }
183 }
184
185 pub fn with_code(mut self, code: impl Into<String>) -> Self {
187 self.code = Some(code.into());
188 self
189 }
190
191 pub fn with_suggestion(mut self, suggestion: impl Into<String>) -> Self {
193 self.suggestion = Some(suggestion.into());
194 self
195 }
196}