1234567891011121314151617use evm_coder::{solidity_interface, types::*, execution::Result};18pub use pallet_evm::{PrecompileOutput, PrecompileResult, account::CrossAccountId};19use pallet_evm_coder_substrate::dispatch_to_evm;20use sp_core::{H160, U256};21use sp_std::vec::Vec;22use up_data_structs::Property;2324use crate::{Pallet, CollectionHandle, Config};25262728pub trait CommonEvmHandler {29 const CODE: &'static [u8];3031 fn call(self, source: &H160, input: &[u8], value: U256) -> Option<PrecompileResult>;32}3334#[solidity_interface(name = "CollectionProperties")]35impl<T: Config> CollectionHandle<T> {36 fn set_property(&mut self, caller: caller, key: string, value: string) -> Result<()> {37 <Pallet<T>>::set_collection_property(38 self,39 &T::CrossAccountId::from_eth(caller),40 Property {41 key: <Vec<u8>>::from(key)42 .try_into()43 .map_err(|_| "key too large")?,44 value: <Vec<u8>>::from(value)45 .try_into()46 .map_err(|_| "value too large")?,47 },48 )49 .map_err(dispatch_to_evm::<T>)?;50 Ok(())51 }5253 fn delete_property(&mut self, caller: caller, key: string) -> Result<()> {54 self.set_property(caller, key, string::new())55 }56}