difftreelog
refactor merge sealed::CanBePlacedInVec traits
in: master
7 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
@@ -41,7 +41,7 @@
fn impl_can_be_placed_in_vec(ident: &syn::Ident) -> proc_macro2::TokenStream {
quote! {
- impl ::evm_coder::abi::sealed::CanBePlacedInVec for #ident {}
+ impl ::evm_coder::sealed::CanBePlacedInVec for #ident {}
}
}
crates/evm-coder/src/abi/impls.rsdiffbeforeafterboth--- a/crates/evm-coder/src/abi/impls.rs
+++ b/crates/evm-coder/src/abi/impls.rs
@@ -1,8 +1,8 @@
use crate::{
+ custom_signature::SignatureUnit,
execution::{Result, ResultWithPostInfo, WithPostDispatchInfo},
+ make_signature, sealed,
types::*,
- make_signature,
- custom_signature::SignatureUnit,
};
use super::{traits::*, ABI_ALIGNMENT, AbiReader, AbiWriter};
use primitive_types::{U256, H160};
crates/evm-coder/src/abi/traits.rsdiffbeforeafterboth--- a/crates/evm-coder/src/abi/traits.rs
+++ b/crates/evm-coder/src/abi/traits.rs
@@ -22,12 +22,6 @@
fn size() -> usize;
}
-/// Sealed traits.
-pub mod sealed {
- /// Not all types can be placed in vec, i.e `Vec<u8>` is restricted, `bytes` should be used instead
- pub trait CanBePlacedInVec {}
-}
-
/// [`AbiReader`] implements reading of many types.
pub trait AbiRead {
/// Read item from current position, advanding decoder
crates/evm-coder/src/lib.rsdiffbeforeafterboth--- a/crates/evm-coder/src/lib.rs
+++ b/crates/evm-coder/src/lib.rs
@@ -112,6 +112,15 @@
#[cfg(feature = "stubgen")]
pub mod solidity;
+/// Sealed traits.
+pub mod sealed {
+ /// Not every type should be directly placed in vec.
+ /// Vec encoding is not memory efficient, as every item will be padded
+ /// to 32 bytes.
+ /// Instead you should use specialized types (`bytes` in case of `Vec<u8>`)
+ pub trait CanBePlacedInVec {}
+}
+
/// Solidity type definitions (aliases from solidity name to rust type)
/// To be used in [`solidity_interface`] definitions, to make sure there is no
/// type conflict between Rust code and generated definitions
crates/evm-coder/src/solidity/impls.rsdiffbeforeafterboth--- a/crates/evm-coder/src/solidity/impls.rs
+++ b/crates/evm-coder/src/solidity/impls.rs
@@ -1,11 +1,7 @@
-use super::{TypeCollector, SolidityTypeName, SolidityTupleType, sealed};
-use crate::types::*;
+use super::{TypeCollector, SolidityTypeName, SolidityTupleType};
+use crate::{sealed, types::*};
use core::fmt;
-impl sealed::CanBePlacedInVec for uint256 {}
-impl sealed::CanBePlacedInVec for string {}
-impl sealed::CanBePlacedInVec for address {}
-
macro_rules! solidity_type_name {
($($ty:ty => $name:literal $simple:literal = $default:literal),* $(,)?) => {
$(
@@ -74,7 +70,6 @@
macro_rules! impl_tuples {
($($ident:ident)+) => {
- impl<$($ident),+> sealed::CanBePlacedInVec for ($($ident,)+) {}
impl<$($ident: SolidityTypeName + 'static),+> SolidityTupleType for ($($ident,)+) {
fn names(tc: &TypeCollector) -> Vec<string> {
let mut collected = Vec::with_capacity(Self::len());
crates/evm-coder/src/solidity/traits.rsdiffbeforeafterboth1use super::TypeCollector;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}1112pub trait StructCollect: 'static {13 /// Structure name.14 fn name() -> String;15 /// Structure declaration.16 fn declaration() -> String;17}1819pub trait SolidityTypeName: 'static {20 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;21 /// "simple" types are stored inline, no `memory` modifier should be used in solidity22 fn is_simple() -> bool;23 fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;24 /// Specialization25 fn is_void() -> bool {26 false27 }28}2930pub trait SolidityTupleType {31 fn names(tc: &TypeCollector) -> Vec<String>;32 fn len() -> usize;33}3435pub trait SolidityArguments {36 fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;37 fn solidity_get(&self, prefix: &str, writer: &mut impl fmt::Write) -> fmt::Result;38 fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;39 fn is_empty(&self) -> bool {40 self.len() == 041 }42 fn len(&self) -> usize;43}4445pub trait SolidityFunctions {46 fn solidity_name(47 &self,48 is_impl: bool,49 writer: &mut impl fmt::Write,50 tc: &TypeCollector,51 ) -> fmt::Result;52}1use super::TypeCollector;2use core::fmt;34pub trait StructCollect: 'static {5 /// Structure name.6 fn name() -> String;7 /// Structure declaration.8 fn declaration() -> String;9}1011pub trait SolidityTypeName: 'static {12 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;13 /// "simple" types are stored inline, no `memory` modifier should be used in solidity14 fn is_simple() -> bool;15 fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;16 /// Specialization17 fn is_void() -> bool {18 false19 }20}2122pub trait SolidityTupleType {23 fn names(tc: &TypeCollector) -> Vec<String>;24 fn len() -> usize;25}2627pub trait SolidityArguments {28 fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;29 fn solidity_get(&self, prefix: &str, writer: &mut impl fmt::Write) -> fmt::Result;30 fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;31 fn is_empty(&self) -> bool {32 self.len() == 033 }34 fn len(&self) -> usize;35}3637pub trait SolidityFunctions {38 fn solidity_name(39 &self,40 is_impl: bool,41 writer: &mut impl fmt::Write,42 tc: &TypeCollector,43 ) -> fmt::Result;44}pallets/common/src/eth.rsdiffbeforeafterboth--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -156,9 +156,6 @@
}
#[cfg(feature = "stubgen")]
-impl ::evm_coder::solidity::sealed::CanBePlacedInVec for EthCrossAccount {}
-
-#[cfg(feature = "stubgen")]
impl ::evm_coder::solidity::SolidityTupleType for EthCrossAccount {
fn names(tc: &::evm_coder::solidity::TypeCollector) -> Vec<String> {
let mut collected =