starknet_abigen_parser_stopgap/
cairo_function.rsuse starknet::core::types::contract::{AbiNamedMember, AbiOutput, StateMutability};
use super::abi_types::AbiTypeAny;
#[derive(Debug, Clone)]
pub struct CairoFunction {
pub name: String,
pub state_mutability: StateMutability,
pub inputs: Vec<(String, AbiTypeAny)>,
pub output: Option<AbiTypeAny>,
}
impl CairoFunction {
pub fn new(
abi_name: &str,
state_mutability: StateMutability,
inputs: &[AbiNamedMember],
outputs: &Vec<AbiOutput>,
) -> CairoFunction {
let name = abi_name.to_string();
let output = if !outputs.is_empty() {
Some(AbiTypeAny::from_string(&outputs[0].r#type))
} else {
None
};
let inputs = inputs
.iter()
.map(|i| (i.name.clone(), AbiTypeAny::from_string(&i.r#type)))
.collect();
CairoFunction {
name,
state_mutability,
inputs,
output,
}
}
}