--- a/crates/evm-coder/src/abi/impls.rs +++ b/crates/evm-coder/src/abi/impls.rs @@ -138,42 +138,6 @@ } } -impl sealed::CanBePlacedInVec for Property {} - -impl AbiType for Property { - const SIGNATURE: SignatureUnit = make_signature!(new fixed("(string,bytes)")); - const FIELDS_COUNT: usize = 2; - - fn is_dynamic() -> bool { - string::is_dynamic() || bytes::is_dynamic() - } - - fn size() -> usize { - ::size() + ::size() - } -} - -impl AbiRead for Property { - fn abi_read(reader: &mut AbiReader) -> Result { - let size = if !Property::is_dynamic() { - Some(::size()) - } else { - None - }; - let mut subresult = reader.subresult(size)?; - let key = ::abi_read(&mut subresult)?; - let value = ::abi_read(&mut subresult)?; - - Ok(Property { key, value }) - } -} - -impl AbiWrite for Property { - fn abi_write(&self, writer: &mut AbiWriter) { - (&self.key, &self.value).abi_write(writer); - } -} - impl AbiWrite for Vec { fn abi_write(&self, writer: &mut AbiWriter) { let is_dynamic = T::is_dynamic(); --- a/crates/evm-coder/src/lib.rs +++ b/crates/evm-coder/src/lib.rs @@ -196,12 +196,6 @@ self.len() == 0 } } - - #[derive(Debug, Default)] - pub struct Property { - pub key: string, - pub value: bytes, - } } /// Parseable EVM call, this trait should be implemented with [`solidity_interface`] macro --- a/pallets/common/src/erc.rs +++ b/pallets/common/src/erc.rs @@ -21,7 +21,6 @@ abi::AbiType, solidity_interface, solidity, ToLog, types::*, - types::Property as PropertyStruct, execution::{Result, Error}, weight, }; @@ -36,7 +35,7 @@ use crate::{ Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf, eth::{ - EthCrossAccount, CollectionPermissions as EvmPermissions, + Property as PropertyStruct, EthCrossAccount, CollectionPermissions as EvmPermissions, CollectionLimits as EvmCollectionLimits, }, weights::WeightInfo, --- a/pallets/common/src/eth.rs +++ b/pallets/common/src/eth.rs @@ -116,6 +116,15 @@ } } +/// Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue). +#[derive(Debug, Default, AbiCoder)] +pub struct Property { + /// Property key. + pub key: evm_coder::types::string, + /// Property value. + pub value: evm_coder::types::bytes, +} + /// [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM. #[derive(Debug, Default, Clone, Copy, AbiCoder)] #[repr(u8)] --- a/pallets/nonfungible/src/erc.rs +++ b/pallets/nonfungible/src/erc.rs @@ -26,7 +26,7 @@ }; use evm_coder::{ abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, - types::Property as PropertyStruct, weight, + weight, }; use frame_support::BoundedVec; use up_data_structs::{ @@ -38,7 +38,7 @@ use pallet_common::{ CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations, erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key}, - eth::{EthCrossAccount, EthTokenPermissions}, + eth::{Property as PropertyStruct, EthCrossAccount, EthTokenPermissions}, }; use pallet_evm::{account::CrossAccountId, PrecompileHandle}; use pallet_evm_coder_substrate::call; @@ -97,17 +97,15 @@ permissions: Vec<(string, Vec<(EthTokenPermissions, bool)>)>, ) -> Result<()> { let caller = T::CrossAccountId::from_eth(caller); - const PERMISSIONS_FIELDS_COUNT: usize = 3; - let mut perms = Vec::new(); for (key, pp) in permissions { - if pp.len() > PERMISSIONS_FIELDS_COUNT { + if pp.len() > EthTokenPermissions::FIELDS_COUNT { return Err(alloc::format!( "Actual number of fields {} for {}, which exceeds the maximum value of {}", pp.len(), stringify!(EthTokenPermissions), - PERMISSIONS_FIELDS_COUNT + EthTokenPermissions::FIELDS_COUNT ) .as_str() .into()); --- a/pallets/refungible/src/erc.rs +++ b/pallets/refungible/src/erc.rs @@ -27,13 +27,13 @@ }; use evm_coder::{ abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, - types::Property as PropertyStruct, weight, + weight, }; use frame_support::{BoundedBTreeMap, BoundedVec}; use pallet_common::{ CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations, erc::{CommonEvmHandler, CollectionCall, static_property::key}, - eth::{EthCrossAccount, EthTokenPermissions}, + eth::{Property as PropertyStruct, EthCrossAccount, EthTokenPermissions}, Error as CommonError, }; use pallet_evm::{account::CrossAccountId, PrecompileHandle};