--- a/crates/evm-coder/procedural/src/abi_derive.rs +++ b/crates/evm-coder/procedural/src/abi_derive.rs @@ -90,7 +90,7 @@ &docs, ); - let tt = quote! { + Ok(quote! { #from #solidity_option #can_be_plcaed_in_vec @@ -99,14 +99,7 @@ #abi_write #solidity_type_name #solidity_struct_collect - }; - - println!( - "!!!!!!!!!!!!!!!!!!!!!!!!!\n{}\n!!!!!!!!!!!!!!!!!!!!!!!!!", - tt - ); - - Ok(tt) + }) } fn impl_solidity_option<'a>( @@ -134,16 +127,19 @@ name: &proc_macro2::Ident, enum_options: impl Iterator, ) -> proc_macro2::TokenStream { + let error_str = format!("Value not convertible into enum \"{name}\""); + let error_str = proc_macro2::Literal::string(&error_str); let enum_options = enum_options.enumerate().map(|(i, opt)| { let n = proc_macro2::Literal::u8_suffixed(i as u8); quote! {#n => Ok(#name::#opt),} }); + quote!( impl TryFrom for #name { type Error = &'static str; fn try_from(value: u8) -> ::core::result::Result { - const err: &'static str = "Not convertible"; + const err: &'static str = #error_str; match value { #(#enum_options)* _ => Err(err)