pub(crate) fn struct_declaration(cx: &Context, abi_name: &proc_macro2::Ident) -> TokenStream {
    let name = &cx.contract_name;
    let abi = &cx.abi_str;

    let abi_parse = if !cx.human_readable {
        quote! {
            pub static #abi_name: ethers_contract::Lazy<ethers_core::abi::Abi> = ethers_contract::Lazy::new(|| serde_json::from_str(#abi)
                                              .expect("invalid abi"));
        }
    } else {
        quote! {
            pub static #abi_name: ethers_contract::Lazy<ethers_core::abi::Abi> = ethers_contract::Lazy::new(|| ethers::core::abi::parse_abi_str(#abi)
                                                .expect("invalid abi"));
        }
    };

    quote! {
        // Inline ABI declaration
        #abi_parse

        // Struct declaration
        #[derive(Clone)]
        pub struct #name<M>(ethers_contract::Contract<M>);


        // Deref to the inner contract in order to access more specific functions functions
        impl<M> std::ops::Deref for #name<M> {
            type Target = ethers_contract::Contract<M>;

            fn deref(&self) -> &Self::Target { &self.0 }
        }

        impl<M: ethers_providers::Middleware> std::fmt::Debug for #name<M> {
            fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
                f.debug_tuple(stringify!(#name))
                    .field(&self.address())
                    .finish()
            }
        }
    }
}
/// Generates the static `Abi` constants and the contract struct
Generates the static `Abi` constants and the contract struct
Generates the static ` Abi ` constants and the contract struct
pub(crate) fn struct_declaration(cx: &Context, abi_name: &proc_macro2::Ident) -> TokenStream {
    let name = &cx.contract_name;
    let abi = &cx.abi_str;
    let abi_parse = if !cx.human_readable {
        quote! {
            pub static #abi_name: ethers_contract::Lazy<ethers_core::abi::Abi> = ethers_contract::Lazy::new(|| serde_json::from_str(#abi)
                                              .expect("invalid abi"));
        }
    } else {
        quote! {
            pub static #abi_name: ethers_contract::Lazy<ethers_core::abi::Abi> = ethers_contract::Lazy::new(|| ethers::core::abi::parse_abi_str(#abi)
                                                .expect("invalid abi"));
        }
    };
    quote! {
        // Inline ABI declaration
        #abi_parse
        // Struct declaration
        #[derive(Clone)]
        pub struct #name<M>(ethers_contract::Contract<M>);
        // Deref to the inner contract in order to access more specific functions functions
        impl<M> std::ops::Deref for #name<M> {
            type Target = ethers_contract::Contract<M>;
            fn deref(&self) -> &Self::Target { &self.0 }
        }
        impl<M: ethers_providers::Middleware> std::fmt::Debug for #name<M> {
            fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
                f.debug_tuple(stringify!(#name))
                    .field(&self.address())
                    .finish()
            }
        }
    }
}
pub ( crate ) fn struct_declaration ( cx : & Context , abi_name : & proc_macro2 :: Ident ) -> TokenStream { let name = & cx . contract_name ; let abi = & cx . abi_str ; let abi_parse = if ! cx . human_readable { quote ! { pub static abi_name ethers_contract Lazy ethers_core abi Abi ethers_contract Lazy new ( serde_json from_str ( abi ) expect ( " " ) ) } } else { quote ! { pub static abi_name ethers_contract Lazy ethers_core abi Abi ethers_contract Lazy new ( ethers core abi parse_abi_str ( abi ) expect ( " " ) ) } } ; quote ! { // Inline ABI declaration abi_parse // Struct declaration [ derive ( Clone ) ] pub struct name M ( ethers_contract Contract M ) // Deref to the inner contract in order to access more specific functions functions impl M std ops Deref for name M { type Target ethers_contract Contract M fn deref ( self ) Self Target { self 0 } } impl M ethers_providers Middleware std fmt Debug for name M { fn fmt ( self f mut std fmt Formatter ) std fmt Result { f debug_tuple ( stringify ( name ) ) field ( self address ( ) ) finish ( ) } } } }
Generates the static `Abi` constants and the contract struct
Generates the static ` Abi ` constants and the contract struct
cx
&Context
abi_name
&proc_macro2::Ident