sb_starknet_abigen_parser/
cairo_function.rs1use starknet::core::types::contract::{AbiNamedMember, AbiOutput, StateMutability};
2
3use super::abi_types::AbiTypeAny;
4
5#[derive(Debug, Clone)]
6pub struct CairoFunction {
7 pub name: String,
8 pub state_mutability: StateMutability,
9 pub inputs: Vec<(String, AbiTypeAny)>,
10 pub output: Option<AbiTypeAny>,
14}
15
16impl CairoFunction {
17 pub fn new(
19 abi_name: &str,
20 state_mutability: StateMutability,
21 inputs: &[AbiNamedMember],
22 outputs: &Vec<AbiOutput>,
23 ) -> CairoFunction {
24 let name = abi_name.to_string();
25
26 let output = if !outputs.is_empty() {
27 Some(AbiTypeAny::from_string(&outputs[0].r#type))
30 } else {
31 None
32 };
33
34 let inputs = inputs
35 .iter()
36 .map(|i| (i.name.clone(), AbiTypeAny::from_string(&i.r#type)))
37 .collect();
38
39 CairoFunction {
40 name,
41 state_mutability,
42 inputs,
43 output,
44 }
45 }
46}