difftreelog
refactor merge sealed::CanBePlacedInVec traits
in: master
7 files changed
crates/evm-coder/procedural/src/abi_derive.rsdiffbeforeafterboth414142fn impl_can_be_placed_in_vec(ident: &syn::Ident) -> proc_macro2::TokenStream {42fn impl_can_be_placed_in_vec(ident: &syn::Ident) -> proc_macro2::TokenStream {43 quote! {43 quote! {44 impl ::evm_coder::abi::sealed::CanBePlacedInVec for #ident {}44 impl ::evm_coder::sealed::CanBePlacedInVec for #ident {}45 }45 }46}46}4747crates/evm-coder/src/abi/impls.rsdiffbeforeafterboth1use crate::{1use crate::{2 custom_signature::SignatureUnit,2 execution::{Result, ResultWithPostInfo, WithPostDispatchInfo},3 execution::{Result, ResultWithPostInfo, WithPostDispatchInfo},4 make_signature, sealed,3 types::*,5 types::*,4 make_signature,5 custom_signature::SignatureUnit,6};6};7use super::{traits::*, ABI_ALIGNMENT, AbiReader, AbiWriter};7use super::{traits::*, ABI_ALIGNMENT, AbiReader, AbiWriter};8use primitive_types::{U256, H160};8use primitive_types::{U256, H160};crates/evm-coder/src/abi/traits.rsdiffbeforeafterboth22 fn size() -> usize;22 fn size() -> usize;23}23}2425/// Sealed traits.26pub mod sealed {27 /// Not all types can be placed in vec, i.e `Vec<u8>` is restricted, `bytes` should be used instead28 pub trait CanBePlacedInVec {}29}302431/// [`AbiReader`] implements reading of many types.25/// [`AbiReader`] implements reading of many types.32pub trait AbiRead {26pub trait AbiRead {crates/evm-coder/src/lib.rsdiffbeforeafterboth112#[cfg(feature = "stubgen")]112#[cfg(feature = "stubgen")]113pub mod solidity;113pub mod solidity;114115/// Sealed traits.116pub mod sealed {117 /// Not every type should be directly placed in vec.118 /// Vec encoding is not memory efficient, as every item will be padded119 /// to 32 bytes.120 /// Instead you should use specialized types (`bytes` in case of `Vec<u8>`)121 pub trait CanBePlacedInVec {}122}114123115/// Solidity type definitions (aliases from solidity name to rust type)124/// Solidity type definitions (aliases from solidity name to rust type)116/// To be used in [`solidity_interface`] definitions, to make sure there is no125/// To be used in [`solidity_interface`] definitions, to make sure there is nocrates/evm-coder/src/solidity/impls.rsdiffbeforeafterboth1use super::{TypeCollector, SolidityTypeName, SolidityTupleType, sealed};1use super::{TypeCollector, SolidityTypeName, SolidityTupleType};2use crate::types::*;2use crate::{sealed, types::*};3use core::fmt;3use core::fmt;45impl sealed::CanBePlacedInVec for uint256 {}6impl sealed::CanBePlacedInVec for string {}7impl sealed::CanBePlacedInVec for address {}849macro_rules! solidity_type_name {5macro_rules! solidity_type_name {10 ($($ty:ty => $name:literal $simple:literal = $default:literal),* $(,)?) => {6 ($($ty:ty => $name:literal $simple:literal = $default:literal),* $(,)?) => {747075macro_rules! impl_tuples {71macro_rules! impl_tuples {76 ($($ident:ident)+) => {72 ($($ident:ident)+) => {77 impl<$($ident),+> sealed::CanBePlacedInVec for ($($ident,)+) {}78 impl<$($ident: SolidityTypeName + 'static),+> SolidityTupleType for ($($ident,)+) {73 impl<$($ident: SolidityTypeName + 'static),+> SolidityTupleType for ($($ident,)+) {79 fn names(tc: &TypeCollector) -> Vec<string> {74 fn names(tc: &TypeCollector) -> Vec<string> {80 let mut collected = Vec::with_capacity(Self::len());75 let mut collected = Vec::with_capacity(Self::len());crates/evm-coder/src/solidity/traits.rsdiffbeforeafterboth1use super::TypeCollector;1use super::TypeCollector;2use core::fmt;2use core::fmt;34pub mod sealed {5 /// Not every type should be directly placed in vec.6 /// Vec encoding is not memory efficient, as every item will be padded7 /// to 32 bytes.8 /// Instead you should use specialized types (`bytes` in case of `Vec<u8>`)9 pub trait CanBePlacedInVec {}10}11312pub trait StructCollect: 'static {4pub trait StructCollect: 'static {13 /// Structure name.5 /// Structure name.pallets/common/src/eth.rsdiffbeforeafterboth155 }155 }156}156}157158#[cfg(feature = "stubgen")]159impl ::evm_coder::solidity::sealed::CanBePlacedInVec for EthCrossAccount {}160157161#[cfg(feature = "stubgen")]158#[cfg(feature = "stubgen")]162impl ::evm_coder::solidity::SolidityTupleType for EthCrossAccount {159impl ::evm_coder::solidity::SolidityTupleType for EthCrossAccount {