--- a/crates/evm-coder/procedural/src/solidity_interface.rs +++ b/crates/evm-coder/procedural/src/solidity_interface.rs @@ -734,8 +734,14 @@ const #screaming_name_signature: ::evm_coder::custom_signature::FunctionSignature = #custom_signature; #[doc = #selector_str] const #screaming_name: ::evm_coder::types::bytes4 = { + let mut data = [0_u8; Self::#screaming_name_signature.unit.len]; + let mut pos = 0; + while pos < Self::#screaming_name_signature.unit.len { + data[pos] = Self::#screaming_name_signature.unit.data[pos]; + pos += 1; + } let a = ::evm_coder::sha3_const::Keccak256::new() - .update_with_size(&Self::#screaming_name_signature.data, Self::#screaming_name_signature.len) + .update(&data) .finalize(); [a[0], a[1], a[2], a[3]] }; @@ -953,9 +959,9 @@ cs } ); - // println!("!!!!! {}", custom_signature); let is_payable = self.has_value_args; - let out = quote! { + + quote! { SolidityFunction { docs: &[#(#docs),*], selector_str: #selector_str, @@ -972,9 +978,7 @@ ), result: >::default(), } - }; - // println!("@@@ {}", out); - out + } } } --- a/crates/evm-coder/src/custom_signature.rs +++ b/crates/evm-coder/src/custom_signature.rs @@ -13,9 +13,7 @@ #[derive(Debug)] pub struct FunctionSignature { - pub data: [u8; SIGNATURE_SIZE_LIMIT], - pub len: usize, - + pub unit: SignatureUnit, preferences: SignaturePreferences, } @@ -30,8 +28,10 @@ crate::make_signature!(@copy(delimiter.data, dst, delimiter.len, dst_offset)); } FunctionSignature { - data: dst, - len: dst_offset, + unit: SignatureUnit { + data: dst, + len: dst_offset, + }, preferences, } } @@ -40,22 +40,24 @@ signature: FunctionSignature, param: SignatureUnit, ) -> FunctionSignature { - let mut dst = signature.data; - let mut dst_offset = signature.len; + let mut dst = signature.unit.data; + let mut dst_offset = signature.unit.len; crate::make_signature!(@copy(param.data, dst, param.len, dst_offset)); if let Some(ref delimiter) = signature.preferences.param_delimiter { crate::make_signature!(@copy(delimiter.data, dst, delimiter.len, dst_offset)); } FunctionSignature { - data: dst, - len: dst_offset, + unit: SignatureUnit { + data: dst, + len: dst_offset, + }, ..signature } } pub const fn done(signature: FunctionSignature, owerride: bool) -> FunctionSignature { - let mut dst = signature.data; - let mut dst_offset = signature.len - if owerride { 1 } else { 0 }; + let mut dst = signature.unit.data; + let mut dst_offset = signature.unit.len - if owerride { 1 } else { 0 }; if let Some(ref delimiter) = signature.preferences.close_delimiter { crate::make_signature!(@copy(delimiter.data, dst, delimiter.len, dst_offset)); } @@ -63,14 +65,16 @@ crate::make_signature!(@copy(name.data, dst, name.len, dst_offset)); } FunctionSignature { - data: dst, - len: dst_offset, + unit: SignatureUnit { + data: dst, + len: dst_offset, + }, ..signature } } pub fn as_str(&self) -> &str { - from_utf8(&self.data[..self.len]).expect("bad utf-8") + from_utf8(&self.unit.data[..self.unit.len]).expect("bad utf-8") } } @@ -335,11 +339,11 @@ (::SIGNATURE), (>::SIGNATURE), ); - const NAME: [u8; SIG.len] = { - let mut name: [u8; SIG.len] = [0; SIG.len]; + const NAME: [u8; SIG.unit.len] = { + let mut name: [u8; SIG.unit.len] = [0; SIG.unit.len]; let mut i = 0; - while i < SIG.len { - name[i] = SIG.data[i]; + while i < SIG.unit.len { + name[i] = SIG.unit.data[i]; i += 1; } name