git.delta.rocks / unique-network / refs/commits / 8298cf829479

difftreelog

feat Rewrite tuple to named structures for TokenPropertyPermission. fix: AbiCoder derive macro

Trubnikov Sergey2022-12-19parent: #ab6e845.patch.diff
in: master

23 files changed

modifiedcrates/evm-coder/procedural/src/abi_derive/derive_enum.rsdiffbeforeafterboth
--- a/crates/evm-coder/procedural/src/abi_derive/derive_enum.rs
+++ b/crates/evm-coder/procedural/src/abi_derive/derive_enum.rs
@@ -86,6 +86,21 @@
 	)
 }
 
+pub fn impl_enum_solidity_type<'a>(name: &syn::Ident) -> proc_macro2::TokenStream {
+	quote! {
+		#[cfg(feature = "stubgen")]
+		impl ::evm_coder::solidity::SolidityType for #name {
+			fn names(tc: &::evm_coder::solidity::TypeCollector) -> Vec<String> {
+				Vec::new()
+			}
+
+			fn len() -> usize {
+				1
+			}
+		}
+	}
+}
+
 pub fn impl_enum_solidity_type_name(name: &syn::Ident) -> proc_macro2::TokenStream {
 	quote!(
 		#[cfg(feature = "stubgen")]
modifiedcrates/evm-coder/procedural/src/abi_derive/mod.rsdiffbeforeafterboth
--- a/crates/evm-coder/procedural/src/abi_derive/mod.rs
+++ b/crates/evm-coder/procedural/src/abi_derive/mod.rs
@@ -86,6 +86,7 @@
 	let abi_type = impl_enum_abi_type(name, option_count);
 	let abi_read = impl_enum_abi_read(name);
 	let abi_write = impl_enum_abi_write(name);
+	let solidity_type = impl_enum_solidity_type(name);
 	let solidity_type_name = impl_enum_solidity_type_name(name);
 	let solidity_struct_collect = impl_enum_solidity_struct_collect(
 		name,
@@ -102,6 +103,7 @@
 		#abi_type
 		#abi_read
 		#abi_write
+		#solidity_type
 		#solidity_type_name
 		#solidity_struct_collect
 	})
modifiedcrates/evm-coder/src/abi/impls.rsdiffbeforeafterboth
before · crates/evm-coder/src/abi/impls.rs
1use crate::{2	custom_signature::SignatureUnit,3	execution::{Result, ResultWithPostInfo, WithPostDispatchInfo},4	make_signature, sealed,5	types::*,6};7use super::{traits::*, ABI_ALIGNMENT, AbiReader, AbiWriter};8use primitive_types::{U256, H160};910#[cfg(not(feature = "std"))]11use alloc::vec::Vec;1213macro_rules! impl_abi_type {14	($ty:ty, $name:ident, $dynamic:literal) => {15		impl sealed::CanBePlacedInVec for $ty {}1617		impl AbiType for $ty {18			const SIGNATURE: SignatureUnit = make_signature!(new fixed(stringify!($name)));19			const FIELDS_COUNT: usize = 1;2021			fn is_dynamic() -> bool {22				$dynamic23			}2425			fn size() -> usize {26				ABI_ALIGNMENT27			}28		}29	};30}3132macro_rules! impl_abi_readable {33	($ty:ty, $method:ident) => {34		impl AbiRead for $ty {35			fn abi_read(reader: &mut AbiReader) -> Result<$ty> {36				reader.$method()37			}38		}39	};40}4142macro_rules! impl_abi_writeable {43	($ty:ty, $method:ident) => {44		impl AbiWrite for $ty {45			fn abi_write(&self, writer: &mut AbiWriter) {46				writer.$method(&self)47			}48		}49	};50}5152macro_rules! impl_abi {53	($ty:ty, $method:ident, $dynamic:literal) => {54		impl_abi_type!($ty, $method, $dynamic);55		impl_abi_readable!($ty, $method);56		impl_abi_writeable!($ty, $method);57	};58}5960impl_abi!(bool, bool, false);61impl_abi!(u8, uint8, false);62impl_abi!(u32, uint32, false);63impl_abi!(u64, uint64, false);64impl_abi!(u128, uint128, false);65impl_abi!(U256, uint256, false);66impl_abi!(H160, address, false);67impl_abi!(string, string, true);6869impl_abi_writeable!(&str, string);7071impl_abi_type!(bytes, bytes, true);7273impl AbiRead for bytes {74	fn abi_read(reader: &mut AbiReader) -> Result<bytes> {75		Ok(bytes(reader.bytes()?))76	}77}7879impl AbiWrite for bytes {80	fn abi_write(&self, writer: &mut AbiWriter) {81		writer.bytes(self.0.as_slice())82	}83}8485impl_abi_type!(bytes4, bytes4, false);86impl AbiRead for bytes4 {87	fn abi_read(reader: &mut AbiReader) -> Result<bytes4> {88		reader.bytes4()89	}90}9192impl<T: AbiWrite> AbiWrite for &T {93	fn abi_write(&self, writer: &mut AbiWriter) {94		T::abi_write(self, writer);95	}96}9798impl<T: AbiType> AbiType for &T {99	const SIGNATURE: SignatureUnit = T::SIGNATURE;100	const FIELDS_COUNT: usize = T::FIELDS_COUNT;101102	fn is_dynamic() -> bool {103		T::is_dynamic()104	}105106	fn size() -> usize {107		T::size()108	}109}110111impl<T: AbiType + AbiRead + sealed::CanBePlacedInVec> AbiRead for Vec<T> {112	fn abi_read(reader: &mut AbiReader) -> Result<Vec<T>> {113		let mut sub = reader.subresult(None)?;114		let size = sub.uint32()? as usize;115		sub.subresult_offset = sub.offset;116		let is_dynamic = <T as AbiType>::is_dynamic();117		let mut out = Vec::with_capacity(size);118		for _ in 0..size {119			out.push(<T as AbiRead>::abi_read(&mut sub)?);120			if !is_dynamic {121				sub.bytes_read(<T as AbiType>::size());122			};123		}124		Ok(out)125	}126}127128impl<T: AbiType> AbiType for Vec<T> {129	const SIGNATURE: SignatureUnit = make_signature!(new nameof(T::SIGNATURE) fixed("[]"));130	const FIELDS_COUNT: usize = 1;131132	fn is_dynamic() -> bool {133		true134	}135136	fn size() -> usize {137		ABI_ALIGNMENT138	}139}140141impl<T: AbiWrite + AbiType> AbiWrite for Vec<T> {142	fn abi_write(&self, writer: &mut AbiWriter) {143		let is_dynamic = T::is_dynamic();144		let mut sub = if is_dynamic {145			AbiWriter::new_dynamic(is_dynamic)146		} else {147			AbiWriter::new()148		};149150		// Write items count151		(self.len() as u32).abi_write(&mut sub);152153		for item in self {154			item.abi_write(&mut sub);155		}156		writer.write_subresult(sub);157	}158}159160impl AbiWrite for () {161	fn abi_write(&self, _writer: &mut AbiWriter) {}162}163164/// This particular AbiWrite implementation should be split to another trait,165/// which only implements `to_result`, but due to lack of specialization feature166/// in stable Rust, we can't have blanket impl of this trait `for T where T: AbiWrite`,167/// so here we abusing default trait methods for it168impl<T: AbiWrite> AbiWrite for ResultWithPostInfo<T> {169	fn abi_write(&self, _writer: &mut AbiWriter) {170		debug_assert!(false, "shouldn't be called, see comment")171	}172	fn to_result(&self) -> ResultWithPostInfo<AbiWriter> {173		match self {174			Ok(v) => Ok(WithPostDispatchInfo {175				post_info: v.post_info.clone(),176				data: {177					let mut out = AbiWriter::new();178					v.data.abi_write(&mut out);179					out180				},181			}),182			Err(e) => Err(e.clone()),183		}184	}185}186187macro_rules! impl_tuples {188	($($ident:ident)+) => {189		impl<$($ident: AbiType,)+> AbiType for ($($ident,)+)190		where191        $(192            $ident: AbiType,193        )+194		{195            const SIGNATURE: SignatureUnit = make_signature!(196                new fixed("(")197                $(nameof(<$ident>::SIGNATURE) fixed(","))+198                shift_left(1)199                fixed(")")200            );201			const FIELDS_COUNT: usize = 0 $(+ {let _ = <$ident as AbiType>::FIELDS_COUNT; 1})+;202203			fn is_dynamic() -> bool {204				false205				$(206					|| <$ident>::is_dynamic()207				)*208			}209210			fn size() -> usize {211				0 $(+ <$ident>::size())+212			}213		}214215		impl<$($ident),+> sealed::CanBePlacedInVec for ($($ident,)+) {}216217		impl<$($ident),+> AbiRead for ($($ident,)+)218		where219			Self: AbiType,220			$($ident: AbiRead + AbiType,)+221		{222			fn abi_read(reader: &mut AbiReader) -> Result<($($ident,)+)> {223				let is_dynamic = <Self>::is_dynamic();224				let size = if !is_dynamic { Some(<Self>::size()) } else { None };225				let mut subresult = reader.subresult(size)?;226				Ok((227					$({228						let value = <$ident>::abi_read(&mut subresult)?;229						if !is_dynamic {subresult.bytes_read(<$ident as AbiType>::size())};230						value231					},)+232				))233			}234		}235236		#[allow(non_snake_case)]237		impl<$($ident),+> AbiWrite for ($($ident,)+)238		where239			$($ident: AbiWrite + AbiType,)+240		{241			fn abi_write(&self, writer: &mut AbiWriter) {242				let ($($ident,)+) = self;243				if <Self as AbiType>::is_dynamic() {244					let mut sub = AbiWriter::new();245					$($ident.abi_write(&mut sub);)+246					writer.write_subresult(sub);247				} else {248					$($ident.abi_write(writer);)+249				}250			}251		}252	};253}254255impl_tuples! {A}256impl_tuples! {A B}257impl_tuples! {A B C}258impl_tuples! {A B C D}259impl_tuples! {A B C D E}260impl_tuples! {A B C D E F}261impl_tuples! {A B C D E F G}262impl_tuples! {A B C D E F G H}263impl_tuples! {A B C D E F G H I}264impl_tuples! {A B C D E F G H I J}
after · crates/evm-coder/src/abi/impls.rs
1use crate::{2	custom_signature::SignatureUnit,3	execution::{Result, ResultWithPostInfo, WithPostDispatchInfo},4	make_signature, sealed,5	types::*,6};7use super::{traits::*, ABI_ALIGNMENT, AbiReader, AbiWriter};8use primitive_types::{U256, H160};910#[cfg(not(feature = "std"))]11use alloc::vec::Vec;1213macro_rules! impl_abi_type {14	($ty:ty, $name:ident, $dynamic:literal) => {15		impl sealed::CanBePlacedInVec for $ty {}1617		impl AbiType for $ty {18			const SIGNATURE: SignatureUnit = make_signature!(new fixed(stringify!($name)));19			const FIELDS_COUNT: usize = 1;2021			fn is_dynamic() -> bool {22				$dynamic23			}2425			fn size() -> usize {26				ABI_ALIGNMENT27			}28		}29	};30}3132macro_rules! impl_abi_readable {33	($ty:ty, $method:ident) => {34		impl AbiRead for $ty {35			fn abi_read(reader: &mut AbiReader) -> Result<$ty> {36				reader.$method()37			}38		}39	};40}4142macro_rules! impl_abi_writeable {43	($ty:ty, $method:ident) => {44		impl AbiWrite for $ty {45			fn abi_write(&self, writer: &mut AbiWriter) {46				writer.$method(&self)47			}48		}49	};50}5152macro_rules! impl_abi {53	($ty:ty, $method:ident, $dynamic:literal) => {54		impl_abi_type!($ty, $method, $dynamic);55		impl_abi_readable!($ty, $method);56		impl_abi_writeable!($ty, $method);57	};58}5960impl_abi!(bool, bool, false);61impl_abi!(u8, uint8, false);62impl_abi!(u32, uint32, false);63impl_abi!(u64, uint64, false);64impl_abi!(u128, uint128, false);65impl_abi!(U256, uint256, false);66impl_abi!(H160, address, false);67impl_abi!(string, string, true);6869impl_abi_writeable!(&str, string);7071impl_abi_type!(bytes, bytes, true);7273impl AbiRead for bytes {74	fn abi_read(reader: &mut AbiReader) -> Result<bytes> {75		Ok(bytes(reader.bytes()?))76	}77}7879impl AbiWrite for bytes {80	fn abi_write(&self, writer: &mut AbiWriter) {81		writer.bytes(self.0.as_slice())82	}83}8485impl_abi_type!(bytes4, bytes4, false);86impl AbiRead for bytes4 {87	fn abi_read(reader: &mut AbiReader) -> Result<bytes4> {88		reader.bytes4()89	}90}9192impl<T: AbiWrite> AbiWrite for &T {93	fn abi_write(&self, writer: &mut AbiWriter) {94		T::abi_write(self, writer);95	}96}9798impl<T: AbiType> AbiType for &T {99	const SIGNATURE: SignatureUnit = T::SIGNATURE;100	const FIELDS_COUNT: usize = T::FIELDS_COUNT;101102	fn is_dynamic() -> bool {103		T::is_dynamic()104	}105106	fn size() -> usize {107		T::size()108	}109}110111impl<T: AbiType + AbiRead + sealed::CanBePlacedInVec> AbiRead for Vec<T> {112	fn abi_read(reader: &mut AbiReader) -> Result<Vec<T>> {113		let mut sub = reader.subresult(None)?;114		let size = sub.uint32()? as usize;115		sub.subresult_offset = sub.offset;116		let is_dynamic = <T as AbiType>::is_dynamic();117		let mut out = Vec::with_capacity(size);118		for _ in 0..size {119			out.push(<T as AbiRead>::abi_read(&mut sub)?);120			if !is_dynamic {121				sub.bytes_read(<T as AbiType>::size());122			};123		}124		Ok(out)125	}126}127128impl<T: AbiType> AbiType for Vec<T> {129	const SIGNATURE: SignatureUnit = make_signature!(new nameof(T::SIGNATURE) fixed("[]"));130	const FIELDS_COUNT: usize = 1;131132	fn is_dynamic() -> bool {133		true134	}135136	fn size() -> usize {137		ABI_ALIGNMENT138	}139}140141impl<T: AbiWrite + AbiType> AbiWrite for Vec<T> {142	fn abi_write(&self, writer: &mut AbiWriter) {143		let is_dynamic = T::is_dynamic();144		let mut sub = if is_dynamic {145			AbiWriter::new_dynamic(is_dynamic)146		} else {147			AbiWriter::new()148		};149150		// Write items count151		(self.len() as u32).abi_write(&mut sub);152153		for item in self {154			item.abi_write(&mut sub);155		}156		writer.write_subresult(sub);157	}158}159160impl AbiWrite for () {161	fn abi_write(&self, _writer: &mut AbiWriter) {}162}163164/// This particular AbiWrite implementation should be split to another trait,165/// which only implements `to_result`, but due to lack of specialization feature166/// in stable Rust, we can't have blanket impl of this trait `for T where T: AbiWrite`,167/// so here we abusing default trait methods for it168impl<T: AbiWrite> AbiWrite for ResultWithPostInfo<T> {169	fn abi_write(&self, _writer: &mut AbiWriter) {170		debug_assert!(false, "shouldn't be called, see comment")171	}172	fn to_result(&self) -> ResultWithPostInfo<AbiWriter> {173		match self {174			Ok(v) => Ok(WithPostDispatchInfo {175				post_info: v.post_info.clone(),176				data: {177					let mut out = AbiWriter::new();178					v.data.abi_write(&mut out);179					out180				},181			}),182			Err(e) => Err(e.clone()),183		}184	}185}186187macro_rules! count {188    () => (0usize);189    ( $x:tt $($xs:tt)* ) => (1usize + count!($($xs)*));190}191192macro_rules! impl_tuples {193	($($ident:ident)+) => {194		impl<$($ident: AbiType,)+> AbiType for ($($ident,)+)195		where196        $(197            $ident: AbiType,198        )+199		{200            const SIGNATURE: SignatureUnit = make_signature!(201                new fixed("(")202                $(nameof(<$ident>::SIGNATURE) fixed(","))+203                shift_left(1)204                fixed(")")205            );206			const FIELDS_COUNT: usize = count!($($ident)*);207208			fn is_dynamic() -> bool {209				false210				$(211					|| <$ident>::is_dynamic()212				)*213			}214215			fn size() -> usize {216				0 $(+ <$ident>::size())+217			}218		}219220		impl<$($ident),+> sealed::CanBePlacedInVec for ($($ident,)+) {}221222		impl<$($ident),+> AbiRead for ($($ident,)+)223		where224			Self: AbiType,225			$($ident: AbiRead + AbiType,)+226		{227			fn abi_read(reader: &mut AbiReader) -> Result<($($ident,)+)> {228				let is_dynamic = <Self>::is_dynamic();229				let size = if !is_dynamic { Some(<Self>::size()) } else { None };230				let mut subresult = reader.subresult(size)?;231				Ok((232					$({233						let value = <$ident>::abi_read(&mut subresult)?;234						if !is_dynamic {subresult.bytes_read(<$ident as AbiType>::size())};235						value236					},)+237				))238			}239		}240241		#[allow(non_snake_case)]242		impl<$($ident),+> AbiWrite for ($($ident,)+)243		where244			$($ident: AbiWrite + AbiType,)+245		{246			fn abi_write(&self, writer: &mut AbiWriter) {247				let ($($ident,)+) = self;248				if <Self as AbiType>::is_dynamic() {249					let mut sub = AbiWriter::new();250					$($ident.abi_write(&mut sub);)+251					writer.write_subresult(sub);252				} else {253					$($ident.abi_write(writer);)+254				}255			}256		}257	};258}259260impl_tuples! {A}261impl_tuples! {A B}262impl_tuples! {A B C}263impl_tuples! {A B C D}264impl_tuples! {A B C D E}265impl_tuples! {A B C D E F}266impl_tuples! {A B C D E F G}267impl_tuples! {A B C D E F G H}268impl_tuples! {A B C D E F G H I}269impl_tuples! {A B C D E F G H I J}
modifiedcrates/evm-coder/src/solidity/impls.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/solidity/impls.rs
+++ b/crates/evm-coder/src/solidity/impls.rs
@@ -74,6 +74,16 @@
 	}
 }
 
+impl<T: StructCollect + sealed::CanBePlacedInVec> StructCollect for Vec<T> {
+	fn name() -> String {
+		<T as StructCollect>::name() + "[]"
+	}
+
+	fn declaration() -> String {
+		unimplemented!("Vectors have not declarations.")
+	}
+}
+
 macro_rules! count {
     () => (0usize);
     ( $x:tt $($xs:tt)* ) => (1usize + count!($($xs)*));
@@ -131,60 +141,3 @@
 impl_tuples! {A B C D E F G H}
 impl_tuples! {A B C D E F G H I}
 impl_tuples! {A B C D E F G H I J}
-
-impl StructCollect for Property {
-	fn name() -> String {
-		"Property".into()
-	}
-
-	fn declaration() -> String {
-		use std::fmt::Write;
-
-		let mut str = String::new();
-		writeln!(str, "/// @dev Property struct").unwrap();
-		writeln!(str, "struct {} {{", Self::name()).unwrap();
-		writeln!(str, "\tstring key;").unwrap();
-		writeln!(str, "\tbytes value;").unwrap();
-		writeln!(str, "}}").unwrap();
-		str
-	}
-}
-
-impl SolidityTypeName for Property {
-	fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
-		write!(writer, "{}", tc.collect_struct::<Self>())
-	}
-
-	fn is_simple() -> bool {
-		false
-	}
-
-	fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
-		write!(writer, "{}(", tc.collect_struct::<Self>())?;
-		address::solidity_default(writer, tc)?;
-		write!(writer, ",")?;
-		uint256::solidity_default(writer, tc)?;
-		write!(writer, ")")
-	}
-}
-
-impl SolidityType for Property {
-	fn names(tc: &TypeCollector) -> Vec<string> {
-		let mut collected = Vec::with_capacity(Self::len());
-		{
-			let mut out = string::new();
-			string::solidity_name(&mut out, tc).expect("no fmt error");
-			collected.push(out);
-		}
-		{
-			let mut out = string::new();
-			bytes::solidity_name(&mut out, tc).expect("no fmt error");
-			collected.push(out);
-		}
-		collected
-	}
-
-	fn len() -> usize {
-		2
-	}
-}
modifiedcrates/evm-coder/src/solidity/mod.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/solidity/mod.rs
+++ b/crates/evm-coder/src/solidity/mod.rs
@@ -76,7 +76,8 @@
 		self.anonymous.borrow_mut().insert(names, id);
 		format!("Tuple{}", id)
 	}
-	pub fn collect_struct<T: StructCollect>(&self) -> String {
+	pub fn collect_struct<T: StructCollect + SolidityType>(&self) -> String {
+		let _names = T::names(self);
 		self.collect(<T as StructCollect>::declaration());
 		<T as StructCollect>::name()
 	}
modifiedcrates/evm-coder/tests/abi_derive_generation.rsdiffbeforeafterboth
--- a/crates/evm-coder/tests/abi_derive_generation.rs
+++ b/crates/evm-coder/tests/abi_derive_generation.rs
@@ -100,6 +100,15 @@
 	}
 
 	#[test]
+	#[cfg(feature = "stubgen")]
+	fn struct_collect_vec() {
+		assert_eq!(
+			<Vec<u8> as ::evm_coder::solidity::StructCollect>::name(),
+			"uint8[]"
+		);
+	}
+
+	#[test]
 	fn impl_abi_type_signature() {
 		assert_eq!(
 			<TypeStruct1SimpleParam as evm_coder::abi::AbiType>::SIGNATURE
modifiedpallets/common/src/eth.rsdiffbeforeafterboth
--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -16,6 +16,7 @@
 
 //! The module contains a number of functions for converting and checking ethereum identifiers.
 
+use sp_std::{vec, vec::Vec};
 use evm_coder::{
 	AbiCoder,
 	types::{uint256, address},
@@ -183,3 +184,102 @@
 	/// Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]
 	CollectionAdmin,
 }
+
+/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
+#[derive(Debug, Default, AbiCoder)]
+pub struct PropertyPermission {
+	/// TokenPermission field.
+	code: EthTokenPermissions,
+	/// TokenPermission value.
+	value: bool,
+}
+
+impl PropertyPermission {
+	pub fn into_vec(pp: up_data_structs::PropertyPermission) -> Vec<Self> {
+		vec![
+			PropertyPermission {
+				code: EthTokenPermissions::Mutable,
+				value: pp.mutable,
+			},
+			PropertyPermission {
+				code: EthTokenPermissions::TokenOwner,
+				value: pp.token_owner,
+			},
+			PropertyPermission {
+				code: EthTokenPermissions::CollectionAdmin,
+				value: pp.collection_admin,
+			},
+		]
+	}
+
+	pub fn from_vec(permission: Vec<Self>) -> up_data_structs::PropertyPermission {
+		let mut token_permission = up_data_structs::PropertyPermission::default();
+
+		for PropertyPermission { code, value } in permission {
+			match code {
+				EthTokenPermissions::Mutable => token_permission.mutable = value,
+				EthTokenPermissions::TokenOwner => token_permission.token_owner = value,
+				EthTokenPermissions::CollectionAdmin => token_permission.collection_admin = value,
+			}
+		}
+		token_permission
+	}
+}
+
+/// Ethereum representation of Token Property Permissions.
+#[derive(Debug, Default, AbiCoder)]
+pub struct TokenPropertyPermission {
+	/// Token property key.
+	key: evm_coder::types::string,
+	/// Token property permissions.
+	permissions: Vec<PropertyPermission>,
+}
+
+impl
+	From<(
+		up_data_structs::PropertyKey,
+		up_data_structs::PropertyPermission,
+	)> for TokenPropertyPermission
+{
+	fn from(
+		value: (
+			up_data_structs::PropertyKey,
+			up_data_structs::PropertyPermission,
+		),
+	) -> Self {
+		let (key, permission) = value;
+		let key = evm_coder::types::string::from_utf8(key.into_inner())
+			.expect("Stored key must be valid");
+		let permissions = PropertyPermission::into_vec(permission);
+		Self { key, permissions }
+	}
+}
+
+impl TokenPropertyPermission {
+	pub fn into_property_key_permissions(
+		permissions: Vec<TokenPropertyPermission>,
+	) -> evm_coder::execution::Result<Vec<up_data_structs::PropertyKeyPermission>> {
+		let mut perms = Vec::new();
+
+		for TokenPropertyPermission { key, permissions } in permissions {
+			if permissions.len() > <EthTokenPermissions as evm_coder::abi::AbiType>::FIELDS_COUNT {
+				return Err(alloc::format!(
+					"Actual number of fields {} for {}, which exceeds the maximum value of {}",
+					permissions.len(),
+					stringify!(EthTokenPermissions),
+					<EthTokenPermissions as evm_coder::abi::AbiType>::FIELDS_COUNT
+				)
+				.as_str()
+				.into());
+			}
+
+			let token_permission = PropertyPermission::from_vec(permissions);
+
+			perms.push(up_data_structs::PropertyKeyPermission {
+				key: key.into_bytes().try_into().map_err(|_| "too long key")?,
+				permission: token_permission,
+			});
+		}
+		Ok(perms)
+	}
+}
modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -470,9 +470,12 @@
 	uint256 sub;
 }
 
+/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
 enum CollectionPermissions {
-	CollectionAdmin,
-	TokenOwner
+	/// @dev Owner of token can nest tokens under it.
+	TokenOwner,
+	/// @dev Admin of token collection can nest tokens under token.
+	CollectionAdmin
 }
 
 /// @dev anonymous struct
@@ -516,9 +519,11 @@
 	uint256 field_2;
 }
 
-/// @dev Property struct
+/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
 struct Property {
+	/// @dev Property key.
 	string key;
+	/// @dev Property value.
 	bytes value;
 }
 
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -38,7 +38,7 @@
 use pallet_common::{
 	CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,
 	erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},
-	eth::{Property as PropertyStruct, EthCrossAccount, EthTokenPermissions},
+	eth::{Property as PropertyStruct, EthCrossAccount},
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::call;
@@ -94,40 +94,12 @@
 	fn set_token_property_permissions(
 		&mut self,
 		caller: caller,
-		permissions: Vec<(string, Vec<(EthTokenPermissions, bool)>)>,
+		permissions: Vec<pallet_common::eth::TokenPropertyPermission>,
 	) -> Result<()> {
 		let caller = T::CrossAccountId::from_eth(caller);
-		let mut perms = Vec::new();
-
-		for (key, pp) in permissions {
-			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),
-					EthTokenPermissions::FIELDS_COUNT
-				)
-				.as_str()
-				.into());
-			}
-
-			let mut token_permission = PropertyPermission::default();
-
-			for (perm, value) in pp {
-				match perm {
-					EthTokenPermissions::Mutable => token_permission.mutable = value,
-					EthTokenPermissions::TokenOwner => token_permission.token_owner = value,
-					EthTokenPermissions::CollectionAdmin => {
-						token_permission.collection_admin = value
-					}
-				}
-			}
-
-			perms.push(PropertyKeyPermission {
-				key: key.into_bytes().try_into().map_err(|_| "too long key")?,
-				permission: token_permission,
-			});
-		}
+		let perms = pallet_common::eth::TokenPropertyPermission::into_property_key_permissions(
+			permissions,
+		)?;
 
 		<Pallet<T>>::set_token_property_permissions(self, &caller, perms)
 			.map_err(dispatch_to_evm::<T>)
@@ -136,19 +108,11 @@
 	/// @notice Get permissions for token properties.
 	fn token_property_permissions(
 		&self,
-	) -> Result<Vec<(string, Vec<(EthTokenPermissions, bool)>)>> {
+	) -> Result<Vec<pallet_common::eth::TokenPropertyPermission>> {
 		let perms = <Pallet<T>>::token_property_permission(self.id);
 		Ok(perms
 			.into_iter()
-			.map(|(key, pp)| {
-				let key = string::from_utf8(key.into_inner()).expect("Stored key must be valid");
-				let pp = vec![
-					(EthTokenPermissions::Mutable, pp.mutable),
-					(EthTokenPermissions::TokenOwner, pp.token_owner),
-					(EthTokenPermissions::CollectionAdmin, pp.collection_admin),
-				];
-				(key, pp)
-			})
+			.map(pallet_common::eth::TokenPropertyPermission::from)
 			.collect())
 	}
 
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -42,7 +42,7 @@
 	/// @param permissions Permissions for keys.
 	/// @dev EVM selector for this function is: 0xbd92983a,
 	///  or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])
-	function setTokenPropertyPermissions(Tuple61[] memory permissions) public {
+	function setTokenPropertyPermissions(TokenPropertyPermission[] memory permissions) public {
 		require(false, stub_error);
 		permissions;
 		dummy = 0;
@@ -51,10 +51,10 @@
 	/// @notice Get permissions for token properties.
 	/// @dev EVM selector for this function is: 0xf23d7790,
 	///  or in textual repr: tokenPropertyPermissions()
-	function tokenPropertyPermissions() public view returns (Tuple61[] memory) {
+	function tokenPropertyPermissions() public view returns (TokenPropertyPermission[] memory) {
 		require(false, stub_error);
 		dummy;
-		return new Tuple61[](0);
+		return new TokenPropertyPermission[](0);
 	}
 
 	// /// @notice Set token property value.
@@ -127,12 +127,30 @@
 	}
 }
 
-/// @dev Property struct
+/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
 struct Property {
+	/// @dev Property key.
 	string key;
+	/// @dev Property value.
 	bytes value;
 }
 
+/// @dev Ethereum representation of Token Property Permissions.
+struct TokenPropertyPermission {
+	/// @dev Token property key.
+	string key;
+	/// @dev Token property permissions.
+	PropertyPermission[] permissions;
+}
+
+/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
+struct PropertyPermission {
+	/// @dev TokenPermission field.
+	EthTokenPermissions code;
+	/// @dev TokenPermission value.
+	bool value;
+}
+
 /// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
 enum EthTokenPermissions {
 	/// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
@@ -141,18 +159,6 @@
 	TokenOwner,
 	/// @dev Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]
 	CollectionAdmin
-}
-
-/// @dev anonymous struct
-struct Tuple61 {
-	string field_0;
-	Tuple59[] field_1;
-}
-
-/// @dev anonymous struct
-struct Tuple59 {
-	EthTokenPermissions field_0;
-	bool field_1;
 }
 
 /// @title A contract that allows you to work with collections.
@@ -608,9 +614,12 @@
 	uint256 sub;
 }
 
+/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
 enum CollectionPermissions {
-	CollectionAdmin,
-	TokenOwner
+	/// @dev Owner of token can nest tokens under it.
+	TokenOwner,
+	/// @dev Admin of token collection can nest tokens under token.
+	CollectionAdmin
 }
 
 /// @dev anonymous struct
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -33,7 +33,7 @@
 use pallet_common::{
 	CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,
 	erc::{CommonEvmHandler, CollectionCall, static_property::key},
-	eth::{Property as PropertyStruct, EthCrossAccount, EthTokenPermissions},
+	eth::{Property as PropertyStruct, EthCrossAccount},
 	Error as CommonError,
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
@@ -97,47 +97,13 @@
 	fn set_token_property_permissions(
 		&mut self,
 		caller: caller,
-		permissions: Vec<(string, Vec<(EthTokenPermissions, bool)>)>,
+		permissions: Vec<pallet_common::eth::TokenPropertyPermission>,
 	) -> 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 {
-				return Err(alloc::format!(
-					"Actual number of fields {} for {}, which exceeds the maximum value of {}",
-					pp.len(),
-					stringify!(EthTokenPermissions),
-					PERMISSIONS_FIELDS_COUNT
-				)
-				.as_str()
-				.into());
-			}
-
-			let mut token_permission = PropertyPermission {
-				mutable: false,
-				collection_admin: false,
-				token_owner: false,
-			};
+		let perms = pallet_common::eth::TokenPropertyPermission::into_property_key_permissions(
+			permissions,
+		)?;
 
-			for (perm, value) in pp {
-				match perm {
-					EthTokenPermissions::Mutable => token_permission.mutable = value,
-					EthTokenPermissions::TokenOwner => token_permission.token_owner = value,
-					EthTokenPermissions::CollectionAdmin => {
-						token_permission.collection_admin = value
-					}
-				}
-			}
-
-			perms.push(PropertyKeyPermission {
-				key: key.into_bytes().try_into().map_err(|_| "too long key")?,
-				permission: token_permission,
-			});
-		}
-
 		<Pallet<T>>::set_token_property_permissions(self, &caller, perms)
 			.map_err(dispatch_to_evm::<T>)
 	}
@@ -145,19 +111,11 @@
 	/// @notice Get permissions for token properties.
 	fn token_property_permissions(
 		&self,
-	) -> Result<Vec<(string, Vec<(EthTokenPermissions, bool)>)>> {
+	) -> Result<Vec<pallet_common::eth::TokenPropertyPermission>> {
 		let perms = <Pallet<T>>::token_property_permission(self.id);
 		Ok(perms
 			.into_iter()
-			.map(|(key, pp)| {
-				let key = string::from_utf8(key.into_inner()).expect("Stored key must be valid");
-				let pp = vec![
-					(EthTokenPermissions::Mutable, pp.mutable),
-					(EthTokenPermissions::TokenOwner, pp.token_owner),
-					(EthTokenPermissions::CollectionAdmin, pp.collection_admin),
-				];
-				(key, pp)
-			})
+			.map(pallet_common::eth::TokenPropertyPermission::from)
 			.collect())
 	}
 
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -42,7 +42,7 @@
 	/// @param permissions Permissions for keys.
 	/// @dev EVM selector for this function is: 0xbd92983a,
 	///  or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])
-	function setTokenPropertyPermissions(Tuple60[] memory permissions) public {
+	function setTokenPropertyPermissions(TokenPropertyPermission[] memory permissions) public {
 		require(false, stub_error);
 		permissions;
 		dummy = 0;
@@ -51,10 +51,10 @@
 	/// @notice Get permissions for token properties.
 	/// @dev EVM selector for this function is: 0xf23d7790,
 	///  or in textual repr: tokenPropertyPermissions()
-	function tokenPropertyPermissions() public view returns (Tuple60[] memory) {
+	function tokenPropertyPermissions() public view returns (TokenPropertyPermission[] memory) {
 		require(false, stub_error);
 		dummy;
-		return new Tuple60[](0);
+		return new TokenPropertyPermission[](0);
 	}
 
 	// /// @notice Set token property value.
@@ -127,12 +127,30 @@
 	}
 }
 
-/// @dev Property struct
+/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
 struct Property {
+	/// @dev Property key.
 	string key;
+	/// @dev Property value.
 	bytes value;
 }
 
+/// @dev Ethereum representation of Token Property Permissions.
+struct TokenPropertyPermission {
+	/// @dev Token property key.
+	string key;
+	/// @dev Token property permissions.
+	PropertyPermission[] permissions;
+}
+
+/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
+struct PropertyPermission {
+	/// @dev TokenPermission field.
+	EthTokenPermissions code;
+	/// @dev TokenPermission value.
+	bool value;
+}
+
 /// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
 enum EthTokenPermissions {
 	/// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
@@ -141,18 +159,6 @@
 	TokenOwner,
 	/// @dev Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]
 	CollectionAdmin
-}
-
-/// @dev anonymous struct
-struct Tuple60 {
-	string field_0;
-	Tuple58[] field_1;
-}
-
-/// @dev anonymous struct
-struct Tuple58 {
-	EthTokenPermissions field_0;
-	bool field_1;
 }
 
 /// @title A contract that allows you to work with collections.
@@ -608,9 +614,12 @@
 	uint256 sub;
 }
 
+/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
 enum CollectionPermissions {
-	CollectionAdmin,
-	TokenOwner
+	/// @dev Owner of token can nest tokens under it.
+	TokenOwner,
+	/// @dev Admin of token collection can nest tokens under token.
+	CollectionAdmin
 }
 
 /// @dev anonymous struct
modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedtests/src/eth/abi/nonFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -752,22 +752,22 @@
     "inputs": [
       {
         "components": [
-          { "internalType": "string", "name": "field_0", "type": "string" },
+          { "internalType": "string", "name": "key", "type": "string" },
           {
             "components": [
               {
                 "internalType": "enum EthTokenPermissions",
-                "name": "field_0",
+                "name": "code",
                 "type": "uint8"
               },
-              { "internalType": "bool", "name": "field_1", "type": "bool" }
+              { "internalType": "bool", "name": "value", "type": "bool" }
             ],
-            "internalType": "struct Tuple59[]",
-            "name": "field_1",
+            "internalType": "struct PropertyPermission[]",
+            "name": "permissions",
             "type": "tuple[]"
           }
         ],
-        "internalType": "struct Tuple61[]",
+        "internalType": "struct TokenPropertyPermission[]",
         "name": "permissions",
         "type": "tuple[]"
       }
@@ -818,22 +818,22 @@
     "outputs": [
       {
         "components": [
-          { "internalType": "string", "name": "field_0", "type": "string" },
+          { "internalType": "string", "name": "key", "type": "string" },
           {
             "components": [
               {
                 "internalType": "enum EthTokenPermissions",
-                "name": "field_0",
+                "name": "code",
                 "type": "uint8"
               },
-              { "internalType": "bool", "name": "field_1", "type": "bool" }
+              { "internalType": "bool", "name": "value", "type": "bool" }
             ],
-            "internalType": "struct Tuple59[]",
-            "name": "field_1",
+            "internalType": "struct PropertyPermission[]",
+            "name": "permissions",
             "type": "tuple[]"
           }
         ],
-        "internalType": "struct Tuple61[]",
+        "internalType": "struct TokenPropertyPermission[]",
         "name": "",
         "type": "tuple[]"
       }
modifiedtests/src/eth/abi/reFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -734,22 +734,22 @@
     "inputs": [
       {
         "components": [
-          { "internalType": "string", "name": "field_0", "type": "string" },
+          { "internalType": "string", "name": "key", "type": "string" },
           {
             "components": [
               {
                 "internalType": "enum EthTokenPermissions",
-                "name": "field_0",
+                "name": "code",
                 "type": "uint8"
               },
-              { "internalType": "bool", "name": "field_1", "type": "bool" }
+              { "internalType": "bool", "name": "value", "type": "bool" }
             ],
-            "internalType": "struct Tuple58[]",
-            "name": "field_1",
+            "internalType": "struct PropertyPermission[]",
+            "name": "permissions",
             "type": "tuple[]"
           }
         ],
-        "internalType": "struct Tuple60[]",
+        "internalType": "struct TokenPropertyPermission[]",
         "name": "permissions",
         "type": "tuple[]"
       }
@@ -809,22 +809,22 @@
     "outputs": [
       {
         "components": [
-          { "internalType": "string", "name": "field_0", "type": "string" },
+          { "internalType": "string", "name": "key", "type": "string" },
           {
             "components": [
               {
                 "internalType": "enum EthTokenPermissions",
-                "name": "field_0",
+                "name": "code",
                 "type": "uint8"
               },
-              { "internalType": "bool", "name": "field_1", "type": "bool" }
+              { "internalType": "bool", "name": "value", "type": "bool" }
             ],
-            "internalType": "struct Tuple58[]",
-            "name": "field_1",
+            "internalType": "struct PropertyPermission[]",
+            "name": "permissions",
             "type": "tuple[]"
           }
         ],
-        "internalType": "struct Tuple60[]",
+        "internalType": "struct TokenPropertyPermission[]",
         "name": "",
         "type": "tuple[]"
       }
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -316,9 +316,12 @@
 	bool field_1;
 }
 
+/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
 enum CollectionPermissions {
-	CollectionAdmin,
-	TokenOwner
+	/// @dev Owner of token can nest tokens under it.
+	TokenOwner,
+	/// @dev Admin of token collection can nest tokens under token.
+	CollectionAdmin
 }
 
 /// @dev anonymous struct
@@ -356,9 +359,11 @@
 	uint256 field_2;
 }
 
-/// @dev Property struct
+/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
 struct Property {
+	/// @dev Property key.
 	string key;
+	/// @dev Property value.
 	bytes value;
 }
 
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -30,12 +30,12 @@
 	/// @param permissions Permissions for keys.
 	/// @dev EVM selector for this function is: 0xbd92983a,
 	///  or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])
-	function setTokenPropertyPermissions(Tuple53[] memory permissions) external;
+	function setTokenPropertyPermissions(TokenPropertyPermission[] memory permissions) external;
 
 	/// @notice Get permissions for token properties.
 	/// @dev EVM selector for this function is: 0xf23d7790,
 	///  or in textual repr: tokenPropertyPermissions()
-	function tokenPropertyPermissions() external view returns (Tuple53[] memory);
+	function tokenPropertyPermissions() external view returns (TokenPropertyPermission[] memory);
 
 	// /// @notice Set token property value.
 	// /// @dev Throws error if `msg.sender` has no permission to edit the property.
@@ -80,12 +80,30 @@
 	function property(uint256 tokenId, string memory key) external view returns (bytes memory);
 }
 
-/// @dev Property struct
+/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
 struct Property {
+	/// @dev Property key.
 	string key;
+	/// @dev Property value.
 	bytes value;
 }
 
+/// @dev Ethereum representation of Token Property Permissions.
+struct TokenPropertyPermission {
+	/// @dev Token property key.
+	string key;
+	/// @dev Token property permissions.
+	PropertyPermission[] permissions;
+}
+
+/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
+struct PropertyPermission {
+	/// @dev TokenPermission field.
+	EthTokenPermissions code;
+	/// @dev TokenPermission value.
+	bool value;
+}
+
 /// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
 enum EthTokenPermissions {
 	/// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
@@ -96,18 +114,6 @@
 	CollectionAdmin
 }
 
-/// @dev anonymous struct
-struct Tuple53 {
-	string field_0;
-	Tuple51[] field_1;
-}
-
-/// @dev anonymous struct
-struct Tuple51 {
-	EthTokenPermissions field_0;
-	bool field_1;
-}
-
 /// @title A contract that allows you to work with collections.
 /// @dev the ERC-165 identifier for this interface is 0x81172a75
 interface Collection is Dummy, ERC165 {
@@ -412,9 +418,12 @@
 	bool field_1;
 }
 
+/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
 enum CollectionPermissions {
-	CollectionAdmin,
-	TokenOwner
+	/// @dev Owner of token can nest tokens under it.
+	TokenOwner,
+	/// @dev Admin of token collection can nest tokens under token.
+	CollectionAdmin
 }
 
 /// @dev anonymous struct
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -30,12 +30,12 @@
 	/// @param permissions Permissions for keys.
 	/// @dev EVM selector for this function is: 0xbd92983a,
 	///  or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])
-	function setTokenPropertyPermissions(Tuple52[] memory permissions) external;
+	function setTokenPropertyPermissions(TokenPropertyPermission[] memory permissions) external;
 
 	/// @notice Get permissions for token properties.
 	/// @dev EVM selector for this function is: 0xf23d7790,
 	///  or in textual repr: tokenPropertyPermissions()
-	function tokenPropertyPermissions() external view returns (Tuple52[] memory);
+	function tokenPropertyPermissions() external view returns (TokenPropertyPermission[] memory);
 
 	// /// @notice Set token property value.
 	// /// @dev Throws error if `msg.sender` has no permission to edit the property.
@@ -80,12 +80,30 @@
 	function property(uint256 tokenId, string memory key) external view returns (bytes memory);
 }
 
-/// @dev Property struct
+/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
 struct Property {
+	/// @dev Property key.
 	string key;
+	/// @dev Property value.
 	bytes value;
 }
 
+/// @dev Ethereum representation of Token Property Permissions.
+struct TokenPropertyPermission {
+	/// @dev Token property key.
+	string key;
+	/// @dev Token property permissions.
+	PropertyPermission[] permissions;
+}
+
+/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
+struct PropertyPermission {
+	/// @dev TokenPermission field.
+	EthTokenPermissions code;
+	/// @dev TokenPermission value.
+	bool value;
+}
+
 /// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
 enum EthTokenPermissions {
 	/// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
@@ -96,18 +114,6 @@
 	CollectionAdmin
 }
 
-/// @dev anonymous struct
-struct Tuple52 {
-	string field_0;
-	Tuple50[] field_1;
-}
-
-/// @dev anonymous struct
-struct Tuple50 {
-	EthTokenPermissions field_0;
-	bool field_1;
-}
-
 /// @title A contract that allows you to work with collections.
 /// @dev the ERC-165 identifier for this interface is 0x81172a75
 interface Collection is Dummy, ERC165 {
@@ -412,9 +418,12 @@
 	bool field_1;
 }
 
+/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
 enum CollectionPermissions {
-	CollectionAdmin,
-	TokenOwner
+	/// @dev Owner of token can nest tokens under it.
+	TokenOwner,
+	/// @dev Admin of token collection can nest tokens under token.
+	CollectionAdmin
 }
 
 /// @dev anonymous struct