difftreelog
refactor CanBePlacedInVec
in: master
2 files changed
crates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth--- a/crates/evm-coder/procedural/src/solidity_interface.rs
+++ b/crates/evm-coder/procedural/src/solidity_interface.rs
@@ -21,9 +21,8 @@
// https://doc.rust-lang.org/reference/procedural-macros.html
use proc_macro2::TokenStream;
-use quote::{quote, ToTokens, format_ident};
+use quote::{quote, format_ident};
use inflector::cases;
-use std::fmt::Write;
use syn::{
Expr, FnArg, GenericArgument, Generics, Ident, ImplItem, ImplItemMethod, ItemImpl, Lit, Meta,
MetaNameValue, PatType, PathArguments, ReturnType, Type,
@@ -33,8 +32,8 @@
};
use crate::{
- fn_selector_str, parse_ident_from_pat, parse_ident_from_path, parse_path, parse_path_segment,
- parse_result_ok, pascal_ident_to_call, pascal_ident_to_snake_call, snake_ident_to_pascal,
+ parse_ident_from_pat, parse_ident_from_path, parse_path, parse_path_segment, parse_result_ok,
+ pascal_ident_to_call, pascal_ident_to_snake_call, snake_ident_to_pascal,
snake_ident_to_screaming,
};
crates/evm-coder/src/abi.rsdiffbeforeafterboth352352353macro_rules! impl_abi_readable {353macro_rules! impl_abi_readable {354 ($ty:ty, $method:ident, $dynamic:literal) => {354 ($ty:ty, $method:ident, $dynamic:literal) => {355 impl sealed::CanBePlacedInVec for $ty {}356355 impl TypeHelper for $ty {357 impl TypeHelper for $ty {356 fn is_dynamic() -> bool {358 fn is_dynamic() -> bool {370}373}371374372impl_abi_readable!(bool, bool, false);375impl_abi_readable!(bool, bool, false);373impl_abi_readable!(uint8, uint8, false);374impl_abi_readable!(uint32, uint32, false);376impl_abi_readable!(uint32, uint32, false);375impl_abi_readable!(uint64, uint64, false);377impl_abi_readable!(uint64, uint64, false);376impl_abi_readable!(uint128, uint128, false);378impl_abi_readable!(uint128, uint128, false);379impl_abi_readable!(address, address, false);381impl_abi_readable!(address, address, false);380impl_abi_readable!(string, string, true);382impl_abi_readable!(string, string, true);383384impl TypeHelper for uint8 {385 fn is_dynamic() -> bool {386 false387 }388 fn size() -> usize {389 ABI_ALIGNMENT390 }391}392impl AbiRead for uint8 {393 fn abi_read(reader: &mut AbiReader) -> Result<uint8> {394 reader.uint8()395 }396}381397382impl TypeHelper for bytes {398impl TypeHelper for bytes {383 fn is_dynamic() -> bool {399 fn is_dynamic() -> bool {398 pub trait CanBePlacedInVec {}414 pub trait CanBePlacedInVec {}399}415}400401impl sealed::CanBePlacedInVec for U256 {}402impl sealed::CanBePlacedInVec for string {}403impl sealed::CanBePlacedInVec for H160 {}404impl sealed::CanBePlacedInVec for EthCrossAccount {}405416406impl<R: AbiRead + sealed::CanBePlacedInVec> AbiRead for Vec<R> {417impl<R: AbiRead + sealed::CanBePlacedInVec> AbiRead for Vec<R> {407 fn abi_read(reader: &mut AbiReader) -> Result<Vec<R>> {418 fn abi_read(reader: &mut AbiReader) -> Result<Vec<R>> {420 make_signature!(new nameof(R) fixed("[]"));431 make_signature!(new nameof(R) fixed("[]"));421}432}433434impl sealed::CanBePlacedInVec for EthCrossAccount {}422435423impl TypeHelper for EthCrossAccount {436impl TypeHelper for EthCrossAccount {424 fn is_dynamic() -> bool {437 fn is_dynamic() -> bool {