pub fn new<S: AsRef<str>>(contract_name: &str, abi_source: S) -> Result<Self, Error> {
        let source = Source::parse(abi_source).unwrap();
        let mut parsed_abi: JsonABI = serde_json::from_str(&source.get().unwrap())?;

        // Filter out outputs with empty returns. These are
        // generated by forc's json abi as `"name": ""` and `"type": "()"`
        for f in &mut parsed_abi {
            let index = f
                .outputs
                .iter()
                .position(|p| p.name.is_empty() && p.type_field == "()");

            match index {
                Some(i) => f.outputs.remove(i),
                None => continue,
            };
        }

        Ok(Self {
            custom_structs: Abigen::get_custom_types(&parsed_abi, &CustomType::Struct),
            custom_enums: Abigen::get_custom_types(&parsed_abi, &CustomType::Enum),
            abi: parsed_abi,
            contract_name: ident(contract_name),
            abi_parser: ABIParser::new(),
            rustfmt: true,
            no_std: false,
        })
    }
/// Creates a new contract with the given ABI JSON source.
Creates a new contract with the given ABI JSON source.
Creates a new contract with the given ABI JSON source .
pub fn new<S: AsRef<str>>(contract_name: &str, abi_source: S) -> Result<Self, Error> {
        let source = Source::parse(abi_source).unwrap();
        let mut parsed_abi: JsonABI = serde_json::from_str(&source.get().unwrap())?;
        // Filter out outputs with empty returns. These are
        // generated by forc's json abi as `"name": ""` and `"type": "()"`
        for f in &mut parsed_abi {
            let index = f
                .outputs
                .iter()
                .position(|p| p.name.is_empty() && p.type_field == "()");
            match index {
                Some(i) => f.outputs.remove(i),
                None => continue,
            };
        }
        Ok(Self {
            custom_structs: Abigen::get_custom_types(&parsed_abi, &CustomType::Struct),
            custom_enums: Abigen::get_custom_types(&parsed_abi, &CustomType::Enum),
            abi: parsed_abi,
            contract_name: ident(contract_name),
            abi_parser: ABIParser::new(),
            rustfmt: true,
            no_std: false,
        })
    }
pub fn new < S : AsRef < str > > ( contract_name : & str , abi_source : S ) -> Result < Self , Error > { let source = Source :: parse ( abi_source ) . unwrap ( ) ; let mut parsed_abi : JsonABI = serde_json :: from_str ( & source . get ( ) . unwrap ( ) ) ? ; // Filter out outputs with empty returns. These are // generated by forc's json abi as `"name": ""` and `"type": "()"` for f in & mut parsed_abi { let index = f . outputs . iter ( ) . position ( | p | p . name . is_empty ( ) && p . type_field == " " ) ; match index { Some ( i ) => f . outputs . remove ( i ) , None => continue , } ; } Ok ( Self { custom_structs : Abigen :: get_custom_types ( & parsed_abi , & CustomType :: Struct ) , custom_enums : Abigen :: get_custom_types ( & parsed_abi , & CustomType :: Enum ) , abi : parsed_abi , contract_name : ident ( contract_name ) , abi_parser : ABIParser :: new ( ) , rustfmt : true , no_std : false , } ) }
Creates a new contract with the given ABI JSON source.
Creates a new contract with the given ABI JSON source .
contract_name
&str
abi_source
S