difftreelog
refactor impl AbiType, AbiWrite, AbiRead via tuple
in: master
3 files changed
crates/evm-coder/procedural/src/abi_derive.rsdiffbeforeafterboth--- a/crates/evm-coder/procedural/src/abi_derive.rs
+++ b/crates/evm-coder/procedural/src/abi_derive.rs
@@ -1,3 +1,4 @@
+use proc_macro2::TokenStream;
use quote::quote;
pub(crate) fn impl_abi_macro(ast: &syn::DeriveInput) -> syn::Result<proc_macro2::TokenStream> {
@@ -30,15 +31,25 @@
return Err(syn::Error::new(name.span(), "Empty structs not supported"));
};
+ let tuple_type = tuple_type(field_types.clone());
+ let tuple_ref_type = tuple_ref_type(field_types.clone());
+ let tuple_data = tuple_data_as_ref(is_named_fields, field_names.clone());
+ let tuple_names = tuple_names(is_named_fields, field_names.clone());
+ let struct_from_tuple = struct_from_tuple(name, is_named_fields, field_names.clone());
+
let can_be_plcaed_in_vec = impl_can_be_placed_in_vec(name);
- let abi_type = impl_abi_type(name, field_types.clone());
+ let abi_type = impl_abi_type(name, tuple_type.clone());
let abi_read = impl_abi_read(
name,
- is_named_fields,
- field_names.clone(),
- field_types.clone(),
+ tuple_type.clone(),
+ tuple_names.clone(),
+ struct_from_tuple,
);
- let abi_write = impl_abi_write(name, is_named_fields, params_count, field_names.clone());
+ let abi_write = impl_abi_write(name, is_named_fields, tuple_ref_type, tuple_data);
+ println!(
+ "=========================\n{}\n=========================",
+ &abi_write
+ );
let solidity_type = impl_solidity_type(name, field_types.clone(), params_count);
let solidity_type_name = impl_solidity_type_name(name, field_types.clone(), params_count);
let solidity_struct_collect =
@@ -55,6 +66,73 @@
})
}
+fn tuple_type<'a>(
+ field_types: impl Iterator<Item = &'a syn::Type> + Clone,
+) -> proc_macro2::TokenStream {
+ let field_types = field_types.map(|ty| quote!(#ty,));
+ quote! {(#(#field_types)*)}
+}
+fn tuple_ref_type<'a>(
+ field_types: impl Iterator<Item = &'a syn::Type> + Clone,
+) -> proc_macro2::TokenStream {
+ let field_types = field_types.map(|ty| quote!(&#ty,));
+ quote! {(#(#field_types)*)}
+}
+fn tuple_data_as_ref(
+ is_named_fields: bool,
+ field_names: impl Iterator<Item = syn::Ident> + Clone,
+) -> proc_macro2::TokenStream {
+ let field_names = field_names.enumerate().map(|(i, field)| {
+ if is_named_fields {
+ quote!(&self.#field,)
+ } else {
+ let field = proc_macro2::Literal::usize_unsuffixed(i);
+ quote!(&self.#field,)
+ }
+ });
+ quote! {(#(#field_names)*)}
+}
+fn tuple_names(
+ is_named_fields: bool,
+ field_names: impl Iterator<Item = syn::Ident> + Clone,
+) -> proc_macro2::TokenStream {
+ let field_names = field_names.enumerate().map(|(i, field)| {
+ if is_named_fields {
+ quote!(#field,)
+ } else {
+ let field = proc_macro2::Ident::new(
+ format!("field{}", i).as_str(),
+ proc_macro2::Span::call_site(),
+ );
+ quote!(#field,)
+ }
+ });
+ quote! {(#(#field_names)*)}
+}
+fn struct_from_tuple(
+ name: &syn::Ident,
+ is_named_fields: bool,
+ field_names: impl Iterator<Item = syn::Ident> + Clone,
+) -> proc_macro2::TokenStream {
+ let field_names = field_names.enumerate().map(|(i, field)| {
+ if is_named_fields {
+ quote!(#field,)
+ } else {
+ let field = proc_macro2::Ident::new(
+ format!("field{}", i).as_str(),
+ proc_macro2::Span::call_site(),
+ );
+ quote!(#field,)
+ }
+ });
+
+ if is_named_fields {
+ quote! {#name {#(#field_names)*}}
+ } else {
+ quote! {#name (#(#field_names)*)}
+ }
+}
+
fn extract_docs(attrs: &Vec<syn::Attribute>) -> syn::Result<Vec<String>> {
attrs
.iter()
@@ -106,34 +184,16 @@
fn impl_abi_type<'a>(
name: &syn::Ident,
- field_types: impl Iterator<Item = &'a syn::Type> + Clone,
+ tuple_type: proc_macro2::TokenStream,
) -> proc_macro2::TokenStream {
- let mut params_signature = {
- let types = field_types.clone();
- quote!(
- #(nameof(<#types as ::evm_coder::abi::AbiType>::SIGNATURE) fixed(","))*
- )
- };
-
- params_signature.extend(quote!(shift_left(1)));
-
- let fields_for_dynamic = field_types.clone();
-
quote! {
impl ::evm_coder::abi::AbiType for #name {
- const SIGNATURE: ::evm_coder::custom_signature::SignatureUnit = ::evm_coder::make_signature!(
- new fixed("(")
- #params_signature
- fixed(")")
- );
+ const SIGNATURE: ::evm_coder::custom_signature::SignatureUnit = <#tuple_type as ::evm_coder::abi::AbiType>::SIGNATURE;
fn is_dynamic() -> bool {
- false
- #(
- || <#fields_for_dynamic as ::evm_coder::abi::AbiType>::is_dynamic()
- )*
+ <#tuple_type as ::evm_coder::abi::AbiType>::is_dynamic()
}
fn size() -> usize {
- 0 #(+ <#field_types as ::evm_coder::abi::AbiType>::size())*
+ <#tuple_type as ::evm_coder::abi::AbiType>::size()
}
}
}
@@ -141,36 +201,15 @@
fn impl_abi_read<'a>(
name: &syn::Ident,
- is_named_fields: bool,
- field_names: impl Iterator<Item = proc_macro2::Ident> + Clone,
- field_types: impl Iterator<Item = &'a syn::Type> + Clone,
+ tuple_type: proc_macro2::TokenStream,
+ tuple_names: proc_macro2::TokenStream,
+ struct_from_tuple: proc_macro2::TokenStream,
) -> proc_macro2::TokenStream {
- let field_names1 = field_names.clone();
-
- let struct_constructor = if is_named_fields {
- quote!(Ok(Self { #(#field_names1),* }))
- } else {
- quote!(Ok(Self ( #(#field_names1),* )))
- };
quote!(
impl ::evm_coder::abi::AbiRead for #name {
fn abi_read(reader: &mut ::evm_coder::abi::AbiReader) -> ::evm_coder::execution::Result<Self> {
- let is_dynamic = <Self as ::evm_coder::abi::AbiType>::is_dynamic();
- let size = if !is_dynamic {
- Some(<Self as ::evm_coder::abi::AbiType>::size())
- } else {
- None
- };
- let mut subresult = reader.subresult(size)?;
- #(
- let #field_names = {
- let value = <#field_types as ::evm_coder::abi::AbiRead>::abi_read(&mut subresult)?;
- if !is_dynamic {subresult.bytes_read(<#field_types as ::evm_coder::abi::AbiType>::size())};
- value
- };
- )*
-
- #struct_constructor
+ let #tuple_names = <#tuple_type as ::evm_coder::abi::AbiRead>::abi_read(reader)?;
+ Ok(#struct_from_tuple)
}
}
)
@@ -179,39 +218,13 @@
fn impl_abi_write<'a>(
name: &syn::Ident,
is_named_fields: bool,
- params_count: usize,
- field_names: impl Iterator<Item = proc_macro2::Ident> + Clone,
+ tuple_type: proc_macro2::TokenStream,
+ tuple_data: proc_macro2::TokenStream,
) -> proc_macro2::TokenStream {
- let abi_write = if is_named_fields {
- quote!(
- #(
- ::evm_coder::abi::AbiWrite::abi_write(&self.#field_names, sub);
- )*
- )
- } else {
- let field_names = (0..params_count)
- .into_iter()
- .map(proc_macro2::Literal::usize_unsuffixed);
- quote!(
- #(
- ::evm_coder::abi::AbiWrite::abi_write(&self.#field_names, sub);
- )*
- )
- };
quote!(
impl ::evm_coder::abi::AbiWrite for #name {
fn abi_write(&self, writer: &mut ::evm_coder::abi::AbiWriter) {
- if <Self as ::evm_coder::abi::AbiType>::is_dynamic() {
- let mut sub = ::evm_coder::abi::AbiWriter::new();
- {
- let sub = &mut sub;
- #abi_write
- }
- writer.write_subresult(sub);
- } else {
- let sub = writer;
- #abi_write
- }
+ <#tuple_type as ::evm_coder::abi::AbiWrite>::abi_write(&#tuple_data, writer)
}
}
)
crates/evm-coder/src/abi/impls.rsdiffbeforeafterboth1use crate::{2 custom_signature::SignatureUnit,3 execution::{Result, ResultWithPostInfo, WithPostDispatchInfo},4 make_signature, sealed,5 types::*,6};7use super::{traits::*, ABI_ALIGNMENT, AbiReader, AbiWriter};8use primitive_types::{U256, H160};910#[cfg(not(feature = "std"))]11use alloc::vec::Vec;1213macro_rules! impl_abi_type {14 ($ty:ty, $name:ident, $dynamic:literal) => {15 impl sealed::CanBePlacedInVec for $ty {}1617 impl AbiType for $ty {18 const SIGNATURE: SignatureUnit = make_signature!(new fixed(stringify!($name)));1920 fn is_dynamic() -> bool {21 $dynamic22 }2324 fn size() -> usize {25 ABI_ALIGNMENT26 }27 }28 };29}3031macro_rules! impl_abi_readable {32 ($ty:ty, $method:ident) => {33 impl AbiRead for $ty {34 fn abi_read(reader: &mut AbiReader) -> Result<$ty> {35 reader.$method()36 }37 }38 };39}4041macro_rules! impl_abi_writeable {42 ($ty:ty, $method:ident) => {43 impl AbiWrite for $ty {44 fn abi_write(&self, writer: &mut AbiWriter) {45 writer.$method(&self)46 }47 }48 };49}5051macro_rules! impl_abi {52 ($ty:ty, $method:ident, $dynamic:literal) => {53 impl_abi_type!($ty, $method, $dynamic);54 impl_abi_readable!($ty, $method);55 impl_abi_writeable!($ty, $method);56 };57}5859impl_abi!(bool, bool, false);60impl_abi!(u8, uint8, false);61impl_abi!(u32, uint32, false);62impl_abi!(u64, uint64, false);63impl_abi!(u128, uint128, false);64impl_abi!(U256, uint256, false);65impl_abi!(H160, address, false);66impl_abi!(string, string, true);6768impl_abi_writeable!(&str, string);6970impl_abi_type!(bytes, bytes, true);7172impl AbiRead for bytes {73 fn abi_read(reader: &mut AbiReader) -> Result<bytes> {74 Ok(bytes(reader.bytes()?))75 }76}7778impl AbiWrite for bytes {79 fn abi_write(&self, writer: &mut AbiWriter) {80 writer.bytes(self.0.as_slice())81 }82}8384impl_abi_type!(bytes4, bytes4, false);85impl AbiRead for bytes4 {86 fn abi_read(reader: &mut AbiReader) -> Result<bytes4> {87 reader.bytes4()88 }89}9091impl<T: AbiType + AbiRead + sealed::CanBePlacedInVec> AbiRead for Vec<T> {92 fn abi_read(reader: &mut AbiReader) -> Result<Vec<T>> {93 let mut sub = reader.subresult(None)?;94 let size = sub.uint32()? as usize;95 sub.subresult_offset = sub.offset;96 let is_dynamic = <T as AbiType>::is_dynamic();97 let mut out = Vec::with_capacity(size);98 for _ in 0..size {99 out.push(<T as AbiRead>::abi_read(&mut sub)?);100 if !is_dynamic {101 sub.bytes_read(<T as AbiType>::size());102 };103 }104 Ok(out)105 }106}107108impl<T: AbiType> AbiType for Vec<T> {109 const SIGNATURE: SignatureUnit = make_signature!(new nameof(T::SIGNATURE) fixed("[]"));110111 fn is_dynamic() -> bool {112 true113 }114115 fn size() -> usize {116 ABI_ALIGNMENT117 }118}119120impl sealed::CanBePlacedInVec for Property {}121122impl AbiType for Property {123 const SIGNATURE: SignatureUnit = make_signature!(new fixed("(string,bytes)"));124125 fn is_dynamic() -> bool {126 string::is_dynamic() || bytes::is_dynamic()127 }128129 fn size() -> usize {130 <string as AbiType>::size() + <bytes as AbiType>::size()131 }132}133134impl AbiRead for Property {135 fn abi_read(reader: &mut AbiReader) -> Result<Property> {136 let size = if !Property::is_dynamic() {137 Some(<Property as AbiType>::size())138 } else {139 None140 };141 let mut subresult = reader.subresult(size)?;142 let key = <string>::abi_read(&mut subresult)?;143 let value = <bytes>::abi_read(&mut subresult)?;144145 Ok(Property { key, value })146 }147}148149impl AbiWrite for Property {150 fn abi_write<'a>(&'a self, writer: &mut AbiWriter) {151 (self.key.clone(), self.value.clone()).abi_write(writer);152 }153}154155impl<T: AbiWrite + AbiType> AbiWrite for Vec<T> {156 fn abi_write(&self, writer: &mut AbiWriter) {157 let is_dynamic = T::is_dynamic();158 let mut sub = if is_dynamic {159 AbiWriter::new_dynamic(is_dynamic)160 } else {161 AbiWriter::new()162 };163164 // Write items count165 (self.len() as u32).abi_write(&mut sub);166167 for item in self {168 item.abi_write(&mut sub);169 }170 writer.write_subresult(sub);171 }172}173174impl AbiWrite for () {175 fn abi_write(&self, _writer: &mut AbiWriter) {}176}177178/// This particular AbiWrite implementation should be split to another trait,179/// which only implements `to_result`, but due to lack of specialization feature180/// in stable Rust, we can't have blanket impl of this trait `for T where T: AbiWrite`,181/// so here we abusing default trait methods for it182impl<T: AbiWrite> AbiWrite for ResultWithPostInfo<T> {183 fn abi_write(&self, _writer: &mut AbiWriter) {184 debug_assert!(false, "shouldn't be called, see comment")185 }186 fn to_result(&self) -> ResultWithPostInfo<AbiWriter> {187 match self {188 Ok(v) => Ok(WithPostDispatchInfo {189 post_info: v.post_info.clone(),190 data: {191 let mut out = AbiWriter::new();192 v.data.abi_write(&mut out);193 out194 },195 }),196 Err(e) => Err(e.clone()),197 }198 }199}200201macro_rules! impl_tuples {202 ($($ident:ident)+) => {203 impl<$($ident: AbiType,)+> AbiType for ($($ident,)+)204 where205 $(206 $ident: AbiType,207 )+208 {209 const SIGNATURE: SignatureUnit = make_signature!(210 new fixed("(")211 $(nameof(<$ident>::SIGNATURE) fixed(","))+212 shift_left(1)213 fixed(")")214 );215216 fn is_dynamic() -> bool {217 false218 $(219 || <$ident>::is_dynamic()220 )*221 }222223 fn size() -> usize {224 0 $(+ <$ident>::size())+225 }226 }227228 impl<$($ident),+> sealed::CanBePlacedInVec for ($($ident,)+) {}229230 impl<$($ident),+> AbiRead for ($($ident,)+)231 where232 Self: AbiType,233 $($ident: AbiRead + AbiType,)+234 {235 fn abi_read(reader: &mut AbiReader) -> Result<($($ident,)+)> {236 let is_dynamic = <Self>::is_dynamic();237 let size = if !is_dynamic { Some(<Self>::size()) } else { None };238 let mut subresult = reader.subresult(size)?;239 Ok((240 $({241 let value = <$ident>::abi_read(&mut subresult)?;242 if !is_dynamic {subresult.bytes_read(<$ident as AbiType>::size())};243 value244 },)+245 ))246 }247 }248249 #[allow(non_snake_case)]250 impl<$($ident),+> AbiWrite for ($($ident,)+)251 where252 $($ident: AbiWrite + AbiType,)+253 {254 fn abi_write(&self, writer: &mut AbiWriter) {255 let ($($ident,)+) = self;256 if <Self as AbiType>::is_dynamic() {257 let mut sub = AbiWriter::new();258 $($ident.abi_write(&mut sub);)+259 writer.write_subresult(sub);260 } else {261 $($ident.abi_write(writer);)+262 }263 }264 }265 };266}267268impl_tuples! {A}269impl_tuples! {A B}270impl_tuples! {A B C}271impl_tuples! {A B C D}272impl_tuples! {A B C D E}273impl_tuples! {A B C D E F}274impl_tuples! {A B C D E F G}275impl_tuples! {A B C D E F G H}276impl_tuples! {A B C D E F G H I}277impl_tuples! {A B C D E F G H I J}1use crate::{2 custom_signature::SignatureUnit,3 execution::{Result, ResultWithPostInfo, WithPostDispatchInfo},4 make_signature, sealed,5 types::*,6};7use super::{traits::*, ABI_ALIGNMENT, AbiReader, AbiWriter};8use primitive_types::{U256, H160};910#[cfg(not(feature = "std"))]11use alloc::vec::Vec;1213macro_rules! impl_abi_type {14 ($ty:ty, $name:ident, $dynamic:literal) => {15 impl sealed::CanBePlacedInVec for $ty {}1617 impl AbiType for $ty {18 const SIGNATURE: SignatureUnit = make_signature!(new fixed(stringify!($name)));1920 fn is_dynamic() -> bool {21 $dynamic22 }2324 fn size() -> usize {25 ABI_ALIGNMENT26 }27 }28 };29}3031macro_rules! impl_abi_readable {32 ($ty:ty, $method:ident) => {33 impl AbiRead for $ty {34 fn abi_read(reader: &mut AbiReader) -> Result<$ty> {35 reader.$method()36 }37 }38 };39}4041macro_rules! impl_abi_writeable {42 ($ty:ty, $method:ident) => {43 impl AbiWrite for $ty {44 fn abi_write(&self, writer: &mut AbiWriter) {45 writer.$method(&self)46 }47 }48 };49}5051macro_rules! impl_abi {52 ($ty:ty, $method:ident, $dynamic:literal) => {53 impl_abi_type!($ty, $method, $dynamic);54 impl_abi_readable!($ty, $method);55 impl_abi_writeable!($ty, $method);56 };57}5859impl_abi!(bool, bool, false);60impl_abi!(u8, uint8, false);61impl_abi!(u32, uint32, false);62impl_abi!(u64, uint64, false);63impl_abi!(u128, uint128, false);64impl_abi!(U256, uint256, false);65impl_abi!(H160, address, false);66impl_abi!(string, string, true);6768impl_abi_writeable!(&str, string);6970impl_abi_type!(bytes, bytes, true);7172impl AbiRead for bytes {73 fn abi_read(reader: &mut AbiReader) -> Result<bytes> {74 Ok(bytes(reader.bytes()?))75 }76}7778impl AbiWrite for bytes {79 fn abi_write(&self, writer: &mut AbiWriter) {80 writer.bytes(self.0.as_slice())81 }82}8384impl_abi_type!(bytes4, bytes4, false);85impl AbiRead for bytes4 {86 fn abi_read(reader: &mut AbiReader) -> Result<bytes4> {87 reader.bytes4()88 }89}9091impl<T: AbiWrite> AbiWrite for &T {92 fn abi_write(&self, writer: &mut AbiWriter) {93 T::abi_write(self, writer);94 }95}9697impl<T: AbiType> AbiType for &T {98 const SIGNATURE: SignatureUnit = T::SIGNATURE;99100 fn is_dynamic() -> bool {101 T::is_dynamic()102 }103104 fn size() -> usize {105 T::size()106 }107}108109impl<T: AbiType + AbiRead + sealed::CanBePlacedInVec> AbiRead for Vec<T> {110 fn abi_read(reader: &mut AbiReader) -> Result<Vec<T>> {111 let mut sub = reader.subresult(None)?;112 let size = sub.uint32()? as usize;113 sub.subresult_offset = sub.offset;114 let is_dynamic = <T as AbiType>::is_dynamic();115 let mut out = Vec::with_capacity(size);116 for _ in 0..size {117 out.push(<T as AbiRead>::abi_read(&mut sub)?);118 if !is_dynamic {119 sub.bytes_read(<T as AbiType>::size());120 };121 }122 Ok(out)123 }124}125126impl<T: AbiType> AbiType for Vec<T> {127 const SIGNATURE: SignatureUnit = make_signature!(new nameof(T::SIGNATURE) fixed("[]"));128129 fn is_dynamic() -> bool {130 true131 }132133 fn size() -> usize {134 ABI_ALIGNMENT135 }136}137138impl sealed::CanBePlacedInVec for Property {}139140impl AbiType for Property {141 const SIGNATURE: SignatureUnit = make_signature!(new fixed("(string,bytes)"));142143 fn is_dynamic() -> bool {144 string::is_dynamic() || bytes::is_dynamic()145 }146147 fn size() -> usize {148 <string as AbiType>::size() + <bytes as AbiType>::size()149 }150}151152impl AbiRead for Property {153 fn abi_read(reader: &mut AbiReader) -> Result<Property> {154 let size = if !Property::is_dynamic() {155 Some(<Property as AbiType>::size())156 } else {157 None158 };159 let mut subresult = reader.subresult(size)?;160 let key = <string>::abi_read(&mut subresult)?;161 let value = <bytes>::abi_read(&mut subresult)?;162163 Ok(Property { key, value })164 }165}166167impl AbiWrite for Property {168 fn abi_write<'a>(&'a self, writer: &mut AbiWriter) {169 (&self.key, &self.value).abi_write(writer);170 }171}172173impl<T: AbiWrite + AbiType> AbiWrite for Vec<T> {174 fn abi_write(&self, writer: &mut AbiWriter) {175 let is_dynamic = T::is_dynamic();176 let mut sub = if is_dynamic {177 AbiWriter::new_dynamic(is_dynamic)178 } else {179 AbiWriter::new()180 };181182 // Write items count183 (self.len() as u32).abi_write(&mut sub);184185 for item in self {186 item.abi_write(&mut sub);187 }188 writer.write_subresult(sub);189 }190}191192impl AbiWrite for () {193 fn abi_write(&self, _writer: &mut AbiWriter) {}194}195196/// This particular AbiWrite implementation should be split to another trait,197/// which only implements `to_result`, but due to lack of specialization feature198/// in stable Rust, we can't have blanket impl of this trait `for T where T: AbiWrite`,199/// so here we abusing default trait methods for it200impl<T: AbiWrite> AbiWrite for ResultWithPostInfo<T> {201 fn abi_write(&self, _writer: &mut AbiWriter) {202 debug_assert!(false, "shouldn't be called, see comment")203 }204 fn to_result(&self) -> ResultWithPostInfo<AbiWriter> {205 match self {206 Ok(v) => Ok(WithPostDispatchInfo {207 post_info: v.post_info.clone(),208 data: {209 let mut out = AbiWriter::new();210 v.data.abi_write(&mut out);211 out212 },213 }),214 Err(e) => Err(e.clone()),215 }216 }217}218219macro_rules! impl_tuples {220 ($($ident:ident)+) => {221 impl<$($ident: AbiType,)+> AbiType for ($($ident,)+)222 where223 $(224 $ident: AbiType,225 )+226 {227 const SIGNATURE: SignatureUnit = make_signature!(228 new fixed("(")229 $(nameof(<$ident>::SIGNATURE) fixed(","))+230 shift_left(1)231 fixed(")")232 );233234 fn is_dynamic() -> bool {235 false236 $(237 || <$ident>::is_dynamic()238 )*239 }240241 fn size() -> usize {242 0 $(+ <$ident>::size())+243 }244 }245246 impl<$($ident),+> sealed::CanBePlacedInVec for ($($ident,)+) {}247248 impl<$($ident),+> AbiRead for ($($ident,)+)249 where250 Self: AbiType,251 $($ident: AbiRead + AbiType,)+252 {253 fn abi_read(reader: &mut AbiReader) -> Result<($($ident,)+)> {254 let is_dynamic = <Self>::is_dynamic();255 let size = if !is_dynamic { Some(<Self>::size()) } else { None };256 let mut subresult = reader.subresult(size)?;257 Ok((258 $({259 let value = <$ident>::abi_read(&mut subresult)?;260 if !is_dynamic {subresult.bytes_read(<$ident as AbiType>::size())};261 value262 },)+263 ))264 }265 }266267 #[allow(non_snake_case)]268 impl<$($ident),+> AbiWrite for ($($ident,)+)269 where270 $($ident: AbiWrite + AbiType,)+271 {272 fn abi_write(&self, writer: &mut AbiWriter) {273 let ($($ident,)+) = self;274 if <Self as AbiType>::is_dynamic() {275 let mut sub = AbiWriter::new();276 $($ident.abi_write(&mut sub);)+277 writer.write_subresult(sub);278 } else {279 $($ident.abi_write(writer);)+280 }281 }282 }283 };284}285286impl_tuples! {A}287impl_tuples! {A B}288impl_tuples! {A B C}289impl_tuples! {A B C D}290impl_tuples! {A B C D E}291impl_tuples! {A B C D E F}292impl_tuples! {A B C D E F G}293impl_tuples! {A B C D E F G H}294impl_tuples! {A B C D E F G H I}295impl_tuples! {A B C D E F G H I J}crates/evm-coder/src/abi/traits.rsdiffbeforeafterboth--- a/crates/evm-coder/src/abi/traits.rs
+++ b/crates/evm-coder/src/abi/traits.rs
@@ -43,9 +43,3 @@
Ok(writer.into())
}
}
-
-impl<T: AbiWrite> AbiWrite for &T {
- fn abi_write(&self, writer: &mut AbiWriter) {
- T::abi_write(self, writer);
- }
-}