diff --git a/crates/abi/src/builder.rs b/crates/abi/src/builder.rs index 6ba24ba074..45f6f274c4 100644 --- a/crates/abi/src/builder.rs +++ b/crates/abi/src/builder.rs @@ -1,6 +1,6 @@ use crate::elements::{ Component, Contract, Event, EventField, FuncInput, FuncOutput, FuncType, Function, JsonAbi, - ModuleAbis, + ModuleAbis, StateMutability, }; use crate::AbiError; use fe_analyzer::namespace::items::{ContractId, FunctionId, ModuleId}; @@ -97,6 +97,7 @@ fn function_def(db: &dyn AnalyzerDb, name: &str, fn_id: FunctionId, typ: FuncTyp typ, inputs, outputs, + state_mutability: StateMutability::Payable, } } diff --git a/crates/abi/src/elements.rs b/crates/abi/src/elements.rs index ef8b1e8f10..81d6ab6dfb 100644 --- a/crates/abi/src/elements.rs +++ b/crates/abi/src/elements.rs @@ -173,6 +173,7 @@ pub struct EventField { /// A function interface. #[derive(Serialize, Debug, PartialEq, Clone)] +#[serde(rename_all = "camelCase")] pub struct Function { /// The function's name. pub name: String, @@ -183,6 +184,8 @@ pub struct Function { pub inputs: Vec, /// All function outputs. pub outputs: Vec, + /// Mutability of the function + pub state_mutability: StateMutability, } /// Component of an ABI tuple. @@ -250,7 +253,6 @@ pub enum FuncType { } /// The mutability of a public function. -#[allow(dead_code)] #[derive(Serialize, Debug, PartialEq, Clone)] #[serde(rename_all = "lowercase")] pub enum StateMutability { @@ -262,7 +264,9 @@ pub enum StateMutability { #[cfg(test)] mod tests { - use crate::elements::{Contract, Event, EventField, FuncInput, FuncOutput, FuncType, Function}; + use crate::elements::{ + Contract, Event, EventField, FuncInput, FuncOutput, FuncType, Function, StateMutability, + }; #[test] fn contract_json() { @@ -291,6 +295,7 @@ mod tests { typ: "uint256".to_string(), components: vec![], }], + state_mutability: StateMutability::Payable, }], }; @@ -313,7 +318,8 @@ mod tests { "name":"function_name", "type":"function", "inputs":[{"name":"input_name","type":"address"}], - "outputs":[{"name":"output_name","type":"uint256"}] + "outputs":[{"name":"output_name","type":"uint256"}], + "stateMutability":"payable" } ]"# .split_whitespace()