neo_devpack_solidity/solidity/
solidity_metadata.rs1#[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,
18 pub is_interface: bool,
20 pub is_library: bool,
22 pub methods: Vec<FunctionMetadata>,
23 pub events: Vec<EventMetadata>,
24 pub errors: Vec<ErrorMetadata>,
28 pub uses_storage: bool,
29 pub state_variables: Vec<StateVariableMetadata>,
30 pub structs: Vec<StructMetadata>,
31 pub enums: Vec<EnumMetadata>,
32 pub contract_types: Vec<String>,
38 pub selector_registry: std::sync::Arc<SelectorRegistry>,
41 pub documentation: NatspecDoc,
43 pub has_using_for_star: bool,
45 pub has_using_function_list: bool,
47 pub using_for_libraries: Vec<String>,
49 pub using_directives: Vec<UsingDirectiveMetadata>,
51 pub has_type_definitions: bool,
53 pub type_aliases: std::collections::HashMap<String, String>,
56 pub flatten_warnings: Vec<String>,
58 pub super_method_map: std::collections::HashMap<String, String>,
61}
62
63#[derive(Debug, Clone)]
64pub struct UsingDirectiveMetadata {
65 pub target_type: Option<String>,
67 pub function_names: Option<Vec<String>>,
72}
73
74#[derive(Debug, Clone)]
75pub struct FunctionMetadata {
76 pub name: String,
77 pub neo_name: String,
80 pub kind: FunctionKind,
81 pub parameters: Vec<ParameterMetadata>,
82 pub return_parameters: Vec<ParameterMetadata>,
83 pub state_mutability: StateMutability,
84 pub visibility: VisibilityKind,
85 pub offset: u32,
86 pub body: Option<Statement>,
87 pub selector: [u8; 4],
88 pub is_virtual: bool,
90 pub is_override: bool,
92 pub documentation: NatspecDoc,
94 pub had_modifier_epilogue: bool,
100}
101
102#[derive(Debug, Clone, Copy, PartialEq, Eq)]
103pub enum FunctionKind {
104 Constructor,
105 Regular,
106}
107
108#[derive(Debug, Clone)]
109pub struct ParameterMetadata {
110 pub name: Option<String>,
111 pub ty: String,
112 pub neo_type: Option<NeoType>,
113 pub storage: Option<String>,
114}
115
116#[derive(Debug, Clone)]
117pub struct EventMetadata {
118 pub name: String,
119 pub normalized_name: String,
120 pub parameters: Vec<EventParameter>,
121 pub anonymous: bool,
125}
126
127#[derive(Debug, Clone)]
128pub struct EventParameter {
129 pub name: Option<String>,
130 pub ty: String,
131 pub indexed: bool,
132 pub neo_type: Option<NeoType>,
133}
134
135#[derive(Debug, Clone)]
137pub struct ErrorMetadata {
138 pub name: String,
139 pub parameters: Vec<ErrorParameterMetadata>,
141}
142
143#[derive(Debug, Clone)]
145pub struct ErrorParameterMetadata {
146 pub name: Option<String>,
147 pub ty: String,
150}
151
152#[derive(Debug, Clone)]
153pub struct StateVariableMetadata {
154 pub name: Option<String>,
155 pub ty: String,
156 pub is_constant: bool,
157 pub is_immutable: bool,
158 pub visibility: Option<String>,
159 pub neo_type: Option<NeoType>,
160 pub has_initializer: bool,
161 pub initializer: Option<Expression>,
162}
163
164#[derive(Debug, Clone)]
165pub struct StructMetadata {
166 pub name: String,
167 pub fields: Vec<StructFieldMetadata>,
168}
169
170#[derive(Debug, Clone)]
171pub struct StructFieldMetadata {
172 pub name: String,
173 pub ty: String,
174}
175
176#[derive(Debug, Clone)]
177pub struct EnumMetadata {
178 pub name: String,
179 pub values: Vec<String>,
180}
181
182#[derive(Debug, Clone, Copy, PartialEq, Eq)]
183pub enum StateMutability {
184 Pure,
185 View,
186 NonPayable,
187 Payable,
188}
189
190impl StateMutability {
191 pub fn is_safe(self) -> bool {
192 matches!(self, StateMutability::Pure | StateMutability::View)
193 }
194}
195
196#[derive(Debug, Clone, Copy, PartialEq, Eq)]
197pub enum DiagnosticSeverity {
198 Warning,
199 Error,
200}
201
202#[derive(Debug, Clone)]
203pub struct Diagnostic {
204 pub severity: DiagnosticSeverity,
205 pub message: String,
206 pub code: Option<String>,
207 pub suggestion: Option<String>,
208}
209
210impl Diagnostic {
211 pub fn warning(message: impl Into<String>) -> Self {
213 Self {
214 severity: DiagnosticSeverity::Warning,
215 message: message.into(),
216 code: None,
217 suggestion: None,
218 }
219 }
220
221 pub fn error(message: impl Into<String>) -> Self {
223 Self {
224 severity: DiagnosticSeverity::Error,
225 message: message.into(),
226 code: None,
227 suggestion: None,
228 }
229 }
230
231 pub fn with_code(mut self, code: impl Into<String>) -> Self {
233 self.code = Some(code.into());
234 self
235 }
236
237 pub fn with_suggestion(mut self, suggestion: impl Into<String>) -> Self {
239 self.suggestion = Some(suggestion.into());
240 self
241 }
242}