difftreelog
refactor abi module
in: master
17 files changed
crates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth328 }328 }329}329}330330331trait AbiType {331trait AbiTypeHelper {332 fn plain(&self) -> syn::Result<&Ident>;332 fn plain(&self) -> syn::Result<&Ident>;333 fn is_value(&self) -> bool;333 fn is_value(&self) -> bool;334 fn is_caller(&self) -> bool;334 fn is_caller(&self) -> bool;335 fn is_special(&self) -> bool;335 fn is_special(&self) -> bool;336}336}337337338impl AbiType for Type {338impl AbiTypeHelper for Type {339 fn plain(&self) -> syn::Result<&Ident> {339 fn plain(&self) -> syn::Result<&Ident> {340 let path = parse_path(self)?;340 let path = parse_path(self)?;341 let segment = parse_path_segment(path)?;341 let segment = parse_path_segment(path)?;crates/evm-coder/src/abi.rsdiffbeforeafterbothno changes
crates/evm-coder/src/abi/impls.rsdiffbeforeafterbothno changes
crates/evm-coder/src/abi/mod.rsdiffbeforeafterbothno changes
crates/evm-coder/src/abi/test.rsdiffbeforeafterbothno changes
crates/evm-coder/src/abi/traits.rsdiffbeforeafterbothno changes
crates/evm-coder/src/lib.rsdiffbeforeafterboth121 use alloc::{vec::Vec};121 use alloc::{vec::Vec};122 use pallet_evm::account::CrossAccountId;122 use pallet_evm::account::CrossAccountId;123 use primitive_types::{U256, H160, H256};123 use primitive_types::{U256, H160, H256};124 use core::str::from_utf8;125126 use crate::custom_signature::SignatureUnit;127128 pub trait Signature {129 const SIGNATURE: SignatureUnit;130131 fn as_str() -> &'static str {132 from_utf8(&Self::SIGNATURE.data[..Self::SIGNATURE.len]).expect("bad utf-8")133 }134 }135136 impl Signature for bool {137 const SIGNATURE: SignatureUnit = make_signature!(new fixed("bool"));138 }139140 macro_rules! define_simple_type {141 (type $ident:ident = $ty:ty) => {142 pub type $ident = $ty;143 impl Signature for $ty {144 const SIGNATURE: SignatureUnit = make_signature!(new fixed(stringify!($ident)));145 }146 };147 }148124149 define_simple_type!(type address = H160);125 pub type address = H160;150151 define_simple_type!(type uint8 = u8);126 pub type uint8 = u8;152 define_simple_type!(type uint16 = u16);127 pub type uint16 = u16;153 define_simple_type!(type uint32 = u32);128 pub type uint32 = u32;154 define_simple_type!(type uint64 = u64);129 pub type uint64 = u64;155 define_simple_type!(type uint128 = u128);130 pub type uint128 = u128;156 define_simple_type!(type uint256 = U256);131 pub type uint256 = U256;157 define_simple_type!(type bytes4 = [u8; 4]);132 pub type bytes4 = [u8; 4];158159 define_simple_type!(type topic = H256);133 pub type topic = H256;160134161 #[cfg(not(feature = "std"))]135 #[cfg(not(feature = "std"))]162 define_simple_type!(type string = ::alloc::string::String);136 pub type string = ::alloc::string::String;163 #[cfg(feature = "std")]137 #[cfg(feature = "std")]164 define_simple_type!(type string = ::std::string::String);138 pub type string = ::std::string::String;165139166 #[derive(Default, Debug, PartialEq)]140 #[derive(Default, Debug, PartialEq)]167 pub struct bytes(pub Vec<u8>);141 pub struct bytes(pub Vec<u8>);168 impl Signature for bytes {169 const SIGNATURE: SignatureUnit = make_signature!(new fixed("bytes"));170 }171142172 /// Solidity doesn't have `void` type, however we have special implementation143 /// Solidity doesn't have `void` type, however we have special implementation173 /// for empty tuple return type144 /// for empty tuple return type259 }230 }260 }231 }261262 impl Signature for EthCrossAccount {263 const SIGNATURE: SignatureUnit = make_signature!(new fixed("(address,uint256)"));264 }265232266 /// Convert `CrossAccountId` to `uint256`.233 /// Convert `CrossAccountId` to `uint256`.267 pub fn convert_cross_account_to_uint256<T: pallet_evm::account::Config>(234 pub fn convert_cross_account_to_uint256<T: pallet_evm::account::Config>(crates/evm-coder/tests/random.rsdiffbeforeafterboth17#![allow(dead_code)] // This test only checks that macros is not panicking17#![allow(dead_code)] // This test only checks that macros is not panicking181819use evm_coder::{ToLog, execution::Result, solidity_interface, types::*, solidity, weight};19use evm_coder::{20use evm_coder::{types::Signature};20 abi::AbiType, ToLog, execution::Result, solidity_interface, types::*, solidity, weight,21};212222pub struct Impls;23pub struct Impls;crates/evm-coder/tests/solidity_generation.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617use evm_coder::{execution::Result, generate_stubgen, solidity_interface, types::*};17use evm_coder::{abi::AbiType, execution::Result, generate_stubgen, solidity_interface, types::*};18use evm_coder::{types::Signature};191820pub struct ERC20;19pub struct ERC20;2120pallets/common/src/erc.rsdiffbeforeafterboth17//! This module contains the implementation of pallet methods for evm.17//! This module contains the implementation of pallet methods for evm.181819use evm_coder::{19use evm_coder::{20 abi::AbiType,20 solidity_interface, solidity, ToLog,21 solidity_interface, solidity, ToLog,21 types::*,22 types::*,22 execution::{Result, Error},23 execution::{Result, Error},pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth19extern crate alloc;19extern crate alloc;20use core::marker::PhantomData;20use core::marker::PhantomData;21use evm_coder::{21use evm_coder::{22 abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*, ToLog,22 abi::{AbiWriter, AbiType},23 execution::Result,24 generate_stubgen, solidity_interface,25 types::*,pallets/fungible/src/erc.rsdiffbeforeafterboth20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};21use core::convert::TryInto;21use core::convert::TryInto;22use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};22use evm_coder::{23 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight,24};23use up_data_structs::CollectionMode;25use up_data_structs::CollectionMode;24use pallet_common::erc::{CommonEvmHandler, PrecompileResult};26use pallet_common::erc::{CommonEvmHandler, PrecompileResult};pallets/nonfungible/src/erc.rsdiffbeforeafterboth25 convert::TryInto,25 convert::TryInto,26};26};27use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};27use evm_coder::{28 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*,29 weight,30};28use frame_support::BoundedVec;31use frame_support::BoundedVec;29use up_data_structs::{32use up_data_structs::{pallets/refungible/src/erc.rsdiffbeforeafterboth26 convert::TryInto,26 convert::TryInto,27};27};28use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};28use evm_coder::{29 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*,30 weight,31};29use frame_support::{BoundedBTreeMap, BoundedVec};32use frame_support::{BoundedBTreeMap, BoundedVec};30use pallet_common::{33use pallet_common::{pallets/refungible/src/erc_token.rsdiffbeforeafterboth30 ops::Deref,30 ops::Deref,31};31};32use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};32use evm_coder::{33 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight,34};33use pallet_common::{35use pallet_common::{34 CommonWeightInfo,36 CommonWeightInfo,pallets/unique/Cargo.tomldiffbeforeafterbothno syntactic changes
pallets/unique/src/eth/mod.rsdiffbeforeafterboth19use core::marker::PhantomData;19use core::marker::PhantomData;20use ethereum as _;20use ethereum as _;21use evm_coder::{execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};21use evm_coder::{22 abi::AbiType, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight,23};22use frame_support::traits::Get;24use frame_support::traits::Get;23use crate::Pallet;25use crate::Pallet;242625use pallet_common::{27use pallet_common::{26 CollectionById,28 CollectionById,27 dispatch::CollectionDispatch,29 dispatch::CollectionDispatch,28 erc::{static_property::key, CollectionHelpersEvents},30 erc::{CollectionHelpersEvents, static_property::key},29 Pallet as PalletCommon,31 Pallet as PalletCommon,30};32};31use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};33use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};