huff_neo_utils/ast/
abi.rs1use crate::ast::span::AstSpan;
2use crate::token::Literal;
3use serde::{Deserialize, Serialize};
4
5#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord)]
7pub enum ArgumentLocation {
8 #[default]
10 Memory,
11 Storage,
13 Calldata,
15}
16
17#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord)]
19pub struct Argument {
20 pub arg_type: Option<String>,
22 pub arg_location: Option<ArgumentLocation>,
24 pub name: Option<String>,
26 pub indexed: bool,
28 pub span: AstSpan,
30}
31
32#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
34pub struct FunctionDefinition {
35 pub name: String,
37 pub signature: [u8; 4],
39 pub inputs: Vec<Argument>,
41 pub fn_type: FunctionType,
43 pub outputs: Vec<Argument>,
45 pub span: AstSpan,
47}
48
49#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
51#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
52#[cfg_attr(feature = "wasm", tsify(into_wasm_abi, from_wasm_abi))]
53pub enum FunctionType {
54 View,
56 Payable,
58 NonPayable,
60 Pure,
62}
63
64impl FunctionType {
65 pub fn interface_mutability(&self) -> &str {
68 match self {
69 FunctionType::View => " view",
70 FunctionType::Pure => " pure",
71 _ => "", }
73 }
74}
75
76#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord)]
78pub struct EventDefinition {
79 pub name: String,
81 pub parameters: Vec<Argument>,
83 pub span: AstSpan,
85 pub hash: Literal,
87}