difftreelog
feat Rewrite tuple to named structures for TokenPropertyPermission. fix: AbiCoder derive macro
in: master
23 files changed
crates/evm-coder/procedural/src/abi_derive/derive_enum.rsdiffbeforeafterboth86 )86 )87}87}8889pub fn impl_enum_solidity_type<'a>(name: &syn::Ident) -> proc_macro2::TokenStream {90 quote! {91 #[cfg(feature = "stubgen")]92 impl ::evm_coder::solidity::SolidityType for #name {93 fn names(tc: &::evm_coder::solidity::TypeCollector) -> Vec<String> {94 Vec::new()95 }9697 fn len() -> usize {98 199 }100 }101 }102}8810389pub fn impl_enum_solidity_type_name(name: &syn::Ident) -> proc_macro2::TokenStream {104pub fn impl_enum_solidity_type_name(name: &syn::Ident) -> proc_macro2::TokenStream {90 quote!(105 quote!(crates/evm-coder/procedural/src/abi_derive/mod.rsdiffbeforeafterboth86 let abi_type = impl_enum_abi_type(name, option_count);86 let abi_type = impl_enum_abi_type(name, option_count);87 let abi_read = impl_enum_abi_read(name);87 let abi_read = impl_enum_abi_read(name);88 let abi_write = impl_enum_abi_write(name);88 let abi_write = impl_enum_abi_write(name);89 let solidity_type = impl_enum_solidity_type(name);89 let solidity_type_name = impl_enum_solidity_type_name(name);90 let solidity_type_name = impl_enum_solidity_type_name(name);90 let solidity_struct_collect = impl_enum_solidity_struct_collect(91 let solidity_struct_collect = impl_enum_solidity_struct_collect(91 name,92 name,102 #abi_type103 #abi_type103 #abi_read104 #abi_read104 #abi_write105 #abi_write106 #solidity_type105 #solidity_type_name107 #solidity_type_name106 #solidity_struct_collect108 #solidity_struct_collect107 })109 })crates/evm-coder/src/abi/impls.rsdiffbeforeafterboth184 }184 }185}185}186187macro_rules! count {188 () => (0usize);189 ( $x:tt $($xs:tt)* ) => (1usize + count!($($xs)*));190}186191187macro_rules! impl_tuples {192macro_rules! impl_tuples {188 ($($ident:ident)+) => {193 ($($ident:ident)+) => {198 shift_left(1)203 shift_left(1)199 fixed(")")204 fixed(")")200 );205 );201 const FIELDS_COUNT: usize = 0 $(+ {let _ = <$ident as AbiType>::FIELDS_COUNT; 1})+;206 const FIELDS_COUNT: usize = count!($($ident)*);202207203 fn is_dynamic() -> bool {208 fn is_dynamic() -> bool {204 false209 falsecrates/evm-coder/src/solidity/impls.rsdiffbeforeafterboth74 }74 }75}75}7677impl<T: StructCollect + sealed::CanBePlacedInVec> StructCollect for Vec<T> {78 fn name() -> String {79 <T as StructCollect>::name() + "[]"80 }8182 fn declaration() -> String {83 unimplemented!("Vectors have not declarations.")84 }85}768677macro_rules! count {87macro_rules! count {78 () => (0usize);88 () => (0usize);132impl_tuples! {A B C D E F G H I}142impl_tuples! {A B C D E F G H I}133impl_tuples! {A B C D E F G H I J}143impl_tuples! {A B C D E F G H I J}134135impl StructCollect for Property {136 fn name() -> String {137 "Property".into()138 }139140 fn declaration() -> String {141 use std::fmt::Write;142143 let mut str = String::new();144 writeln!(str, "/// @dev Property struct").unwrap();145 writeln!(str, "struct {} {{", Self::name()).unwrap();146 writeln!(str, "\tstring key;").unwrap();147 writeln!(str, "\tbytes value;").unwrap();148 writeln!(str, "}}").unwrap();149 str150 }151}152153impl SolidityTypeName for Property {154 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {155 write!(writer, "{}", tc.collect_struct::<Self>())156 }157158 fn is_simple() -> bool {159 false160 }161162 fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {163 write!(writer, "{}(", tc.collect_struct::<Self>())?;164 address::solidity_default(writer, tc)?;165 write!(writer, ",")?;166 uint256::solidity_default(writer, tc)?;167 write!(writer, ")")168 }169}170171impl SolidityType for Property {172 fn names(tc: &TypeCollector) -> Vec<string> {173 let mut collected = Vec::with_capacity(Self::len());174 {175 let mut out = string::new();176 string::solidity_name(&mut out, tc).expect("no fmt error");177 collected.push(out);178 }179 {180 let mut out = string::new();181 bytes::solidity_name(&mut out, tc).expect("no fmt error");182 collected.push(out);183 }184 collected185 }186187 fn len() -> usize {188 2189 }190}191144crates/evm-coder/src/solidity/mod.rsdiffbeforeafterboth76 self.anonymous.borrow_mut().insert(names, id);76 self.anonymous.borrow_mut().insert(names, id);77 format!("Tuple{}", id)77 format!("Tuple{}", id)78 }78 }79 pub fn collect_struct<T: StructCollect>(&self) -> String {79 pub fn collect_struct<T: StructCollect + SolidityType>(&self) -> String {80 let _names = T::names(self);80 self.collect(<T as StructCollect>::declaration());81 self.collect(<T as StructCollect>::declaration());81 <T as StructCollect>::name()82 <T as StructCollect>::name()82 }83 }crates/evm-coder/tests/abi_derive_generation.rsdiffbeforeafterboth99 );99 );100 }100 }101102 #[test]103 #[cfg(feature = "stubgen")]104 fn struct_collect_vec() {105 assert_eq!(106 <Vec<u8> as ::evm_coder::solidity::StructCollect>::name(),107 "uint8[]"108 );109 }101110102 #[test]111 #[test]103 fn impl_abi_type_signature() {112 fn impl_abi_type_signature() {pallets/common/src/eth.rsdiffbeforeafterboth161617//! The module contains a number of functions for converting and checking ethereum identifiers.17//! The module contains a number of functions for converting and checking ethereum identifiers.181819use sp_std::{vec, vec::Vec};19use evm_coder::{20use evm_coder::{20 AbiCoder,21 AbiCoder,21 types::{uint256, address},22 types::{uint256, address},184 CollectionAdmin,185 CollectionAdmin,185}186}187188/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.189#[derive(Debug, Default, AbiCoder)]190pub struct PropertyPermission {191 /// TokenPermission field.192 code: EthTokenPermissions,193 /// TokenPermission value.194 value: bool,195}196197impl PropertyPermission {198 pub fn into_vec(pp: up_data_structs::PropertyPermission) -> Vec<Self> {199 vec![200 PropertyPermission {201 code: EthTokenPermissions::Mutable,202 value: pp.mutable,203 },204 PropertyPermission {205 code: EthTokenPermissions::TokenOwner,206 value: pp.token_owner,207 },208 PropertyPermission {209 code: EthTokenPermissions::CollectionAdmin,210 value: pp.collection_admin,211 },212 ]213 }214215 pub fn from_vec(permission: Vec<Self>) -> up_data_structs::PropertyPermission {216 let mut token_permission = up_data_structs::PropertyPermission::default();217218 for PropertyPermission { code, value } in permission {219 match code {220 EthTokenPermissions::Mutable => token_permission.mutable = value,221 EthTokenPermissions::TokenOwner => token_permission.token_owner = value,222 EthTokenPermissions::CollectionAdmin => token_permission.collection_admin = value,223 }224 }225 token_permission226 }227}228229/// Ethereum representation of Token Property Permissions.230#[derive(Debug, Default, AbiCoder)]231pub struct TokenPropertyPermission {232 /// Token property key.233 key: evm_coder::types::string,234 /// Token property permissions.235 permissions: Vec<PropertyPermission>,236}237238impl239 From<(240 up_data_structs::PropertyKey,241 up_data_structs::PropertyPermission,242 )> for TokenPropertyPermission243{244 fn from(245 value: (246 up_data_structs::PropertyKey,247 up_data_structs::PropertyPermission,248 ),249 ) -> Self {250 let (key, permission) = value;251 let key = evm_coder::types::string::from_utf8(key.into_inner())252 .expect("Stored key must be valid");253 let permissions = PropertyPermission::into_vec(permission);254 Self { key, permissions }255 }256}257258impl TokenPropertyPermission {259 pub fn into_property_key_permissions(260 permissions: Vec<TokenPropertyPermission>,261 ) -> evm_coder::execution::Result<Vec<up_data_structs::PropertyKeyPermission>> {262 let mut perms = Vec::new();263264 for TokenPropertyPermission { key, permissions } in permissions {265 if permissions.len() > <EthTokenPermissions as evm_coder::abi::AbiType>::FIELDS_COUNT {266 return Err(alloc::format!(267 "Actual number of fields {} for {}, which exceeds the maximum value of {}",268 permissions.len(),269 stringify!(EthTokenPermissions),270 <EthTokenPermissions as evm_coder::abi::AbiType>::FIELDS_COUNT271 )272 .as_str()273 .into());274 }275276 let token_permission = PropertyPermission::from_vec(permissions);277278 perms.push(up_data_structs::PropertyKeyPermission {279 key: key.into_bytes().try_into().map_err(|_| "too long key")?,280 permission: token_permission,281 });282 }283 Ok(perms)284 }285}186286pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth470 uint256 sub;470 uint256 sub;471}471}472472473/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.473enum CollectionPermissions {474enum CollectionPermissions {474 CollectionAdmin,475 /// @dev Owner of token can nest tokens under it.475 TokenOwner476 TokenOwner,477 /// @dev Admin of token collection can nest tokens under token.478 CollectionAdmin476}479}477480478/// @dev anonymous struct481/// @dev anonymous struct516 uint256 field_2;519 uint256 field_2;517}520}518521519/// @dev Property struct522/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).520struct Property {523struct Property {524 /// @dev Property key.521 string key;525 string key;526 /// @dev Property value.522 bytes value;527 bytes value;523}528}524529pallets/nonfungible/src/erc.rsdiffbeforeafterboth38use pallet_common::{38use pallet_common::{39 CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,39 CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,40 erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},40 erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},41 eth::{Property as PropertyStruct, EthCrossAccount, EthTokenPermissions},41 eth::{Property as PropertyStruct, EthCrossAccount},42};42};43use pallet_evm::{account::CrossAccountId, PrecompileHandle};43use pallet_evm::{account::CrossAccountId, PrecompileHandle};44use pallet_evm_coder_substrate::call;44use pallet_evm_coder_substrate::call;94 fn set_token_property_permissions(94 fn set_token_property_permissions(95 &mut self,95 &mut self,96 caller: caller,96 caller: caller,97 permissions: Vec<(string, Vec<(EthTokenPermissions, bool)>)>,97 permissions: Vec<pallet_common::eth::TokenPropertyPermission>,98 ) -> Result<()> {98 ) -> Result<()> {99 let caller = T::CrossAccountId::from_eth(caller);99 let caller = T::CrossAccountId::from_eth(caller);100 let mut perms = Vec::new();101102 for (key, pp) in permissions {103 if pp.len() > EthTokenPermissions::FIELDS_COUNT {104 return Err(alloc::format!(105 "Actual number of fields {} for {}, which exceeds the maximum value of {}",106 pp.len(),107 stringify!(EthTokenPermissions),108 EthTokenPermissions::FIELDS_COUNT109 )110 .as_str()111 .into());112 }113114 let mut token_permission = PropertyPermission::default();100 let perms = pallet_common::eth::TokenPropertyPermission::into_property_key_permissions(115101 permissions,116 for (perm, value) in pp {117 match perm {118 EthTokenPermissions::Mutable => token_permission.mutable = value,119 EthTokenPermissions::TokenOwner => token_permission.token_owner = value,120 EthTokenPermissions::CollectionAdmin => {121 token_permission.collection_admin = value122 }123 }124 }125126 perms.push(PropertyKeyPermission {127 key: key.into_bytes().try_into().map_err(|_| "too long key")?,102 )?;128 permission: token_permission,129 });130 }131103132 <Pallet<T>>::set_token_property_permissions(self, &caller, perms)104 <Pallet<T>>::set_token_property_permissions(self, &caller, perms)133 .map_err(dispatch_to_evm::<T>)105 .map_err(dispatch_to_evm::<T>)136 /// @notice Get permissions for token properties.108 /// @notice Get permissions for token properties.137 fn token_property_permissions(109 fn token_property_permissions(138 &self,110 &self,139 ) -> Result<Vec<(string, Vec<(EthTokenPermissions, bool)>)>> {111 ) -> Result<Vec<pallet_common::eth::TokenPropertyPermission>> {140 let perms = <Pallet<T>>::token_property_permission(self.id);112 let perms = <Pallet<T>>::token_property_permission(self.id);141 Ok(perms113 Ok(perms142 .into_iter()114 .into_iter()143 .map(|(key, pp)| {115 .map(pallet_common::eth::TokenPropertyPermission::from)144 let key = string::from_utf8(key.into_inner()).expect("Stored key must be valid");145 let pp = vec![146 (EthTokenPermissions::Mutable, pp.mutable),147 (EthTokenPermissions::TokenOwner, pp.token_owner),148 (EthTokenPermissions::CollectionAdmin, pp.collection_admin),149 ];150 (key, pp)151 })152 .collect())116 .collect())153 }117 }154118pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth42 /// @param permissions Permissions for keys.42 /// @param permissions Permissions for keys.43 /// @dev EVM selector for this function is: 0xbd92983a,43 /// @dev EVM selector for this function is: 0xbd92983a,44 /// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])44 /// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])45 function setTokenPropertyPermissions(Tuple61[] memory permissions) public {45 function setTokenPropertyPermissions(TokenPropertyPermission[] memory permissions) public {46 require(false, stub_error);46 require(false, stub_error);47 permissions;47 permissions;48 dummy = 0;48 dummy = 0;51 /// @notice Get permissions for token properties.51 /// @notice Get permissions for token properties.52 /// @dev EVM selector for this function is: 0xf23d7790,52 /// @dev EVM selector for this function is: 0xf23d7790,53 /// or in textual repr: tokenPropertyPermissions()53 /// or in textual repr: tokenPropertyPermissions()54 function tokenPropertyPermissions() public view returns (Tuple61[] memory) {54 function tokenPropertyPermissions() public view returns (TokenPropertyPermission[] memory) {55 require(false, stub_error);55 require(false, stub_error);56 dummy;56 dummy;57 return new Tuple61[](0);57 return new TokenPropertyPermission[](0);58 }58 }595960 // /// @notice Set token property value.60 // /// @notice Set token property value.127 }127 }128}128}129129130/// @dev Property struct130/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).131struct Property {131struct Property {132 /// @dev Property key.132 string key;133 string key;134 /// @dev Property value.133 bytes value;135 bytes value;134}136}137138/// @dev Ethereum representation of Token Property Permissions.139struct TokenPropertyPermission {140 /// @dev Token property key.141 string key;142 /// @dev Token property permissions.143 PropertyPermission[] permissions;144}145146/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.147struct PropertyPermission {148 /// @dev TokenPermission field.149 EthTokenPermissions code;150 /// @dev TokenPermission value.151 bool value;152}135153136/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.154/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.137enum EthTokenPermissions {155enum EthTokenPermissions {143 CollectionAdmin161 CollectionAdmin144}162}145146/// @dev anonymous struct147struct Tuple61 {148 string field_0;149 Tuple59[] field_1;150}151152/// @dev anonymous struct153struct Tuple59 {154 EthTokenPermissions field_0;155 bool field_1;156}157163158/// @title A contract that allows you to work with collections.164/// @title A contract that allows you to work with collections.159/// @dev the ERC-165 identifier for this interface is 0x81172a75165/// @dev the ERC-165 identifier for this interface is 0x81172a75608 uint256 sub;614 uint256 sub;609}615}610616617/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.611enum CollectionPermissions {618enum CollectionPermissions {612 CollectionAdmin,619 /// @dev Owner of token can nest tokens under it.613 TokenOwner620 TokenOwner,621 /// @dev Admin of token collection can nest tokens under token.622 CollectionAdmin614}623}615624616/// @dev anonymous struct625/// @dev anonymous structpallets/refungible/src/erc.rsdiffbeforeafterboth33use pallet_common::{33use pallet_common::{34 CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,34 CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,35 erc::{CommonEvmHandler, CollectionCall, static_property::key},35 erc::{CommonEvmHandler, CollectionCall, static_property::key},36 eth::{Property as PropertyStruct, EthCrossAccount, EthTokenPermissions},36 eth::{Property as PropertyStruct, EthCrossAccount},37 Error as CommonError,37 Error as CommonError,38};38};39use pallet_evm::{account::CrossAccountId, PrecompileHandle};39use pallet_evm::{account::CrossAccountId, PrecompileHandle};97 fn set_token_property_permissions(97 fn set_token_property_permissions(98 &mut self,98 &mut self,99 caller: caller,99 caller: caller,100 permissions: Vec<(string, Vec<(EthTokenPermissions, bool)>)>,100 permissions: Vec<pallet_common::eth::TokenPropertyPermission>,101 ) -> Result<()> {101 ) -> Result<()> {102 let caller = T::CrossAccountId::from_eth(caller);102 let caller = T::CrossAccountId::from_eth(caller);103 const PERMISSIONS_FIELDS_COUNT: usize = 3;104105 let mut perms = Vec::new();106107 for (key, pp) in permissions {108 if pp.len() > PERMISSIONS_FIELDS_COUNT {109 return Err(alloc::format!(110 "Actual number of fields {} for {}, which exceeds the maximum value of {}",111 pp.len(),112 stringify!(EthTokenPermissions),113 PERMISSIONS_FIELDS_COUNT114 )115 .as_str()116 .into());117 }118119 let mut token_permission = PropertyPermission {103 let perms = pallet_common::eth::TokenPropertyPermission::into_property_key_permissions(120 mutable: false,104 permissions,121 collection_admin: false,122 token_owner: false,123 };124125 for (perm, value) in pp {126 match perm {127 EthTokenPermissions::Mutable => token_permission.mutable = value,128 EthTokenPermissions::TokenOwner => token_permission.token_owner = value,129 EthTokenPermissions::CollectionAdmin => {130 token_permission.collection_admin = value131 }132 }133 }134135 perms.push(PropertyKeyPermission {136 key: key.into_bytes().try_into().map_err(|_| "too long key")?,105 )?;137 permission: token_permission,138 });139 }140106141 <Pallet<T>>::set_token_property_permissions(self, &caller, perms)107 <Pallet<T>>::set_token_property_permissions(self, &caller, perms)142 .map_err(dispatch_to_evm::<T>)108 .map_err(dispatch_to_evm::<T>)145 /// @notice Get permissions for token properties.111 /// @notice Get permissions for token properties.146 fn token_property_permissions(112 fn token_property_permissions(147 &self,113 &self,148 ) -> Result<Vec<(string, Vec<(EthTokenPermissions, bool)>)>> {114 ) -> Result<Vec<pallet_common::eth::TokenPropertyPermission>> {149 let perms = <Pallet<T>>::token_property_permission(self.id);115 let perms = <Pallet<T>>::token_property_permission(self.id);150 Ok(perms116 Ok(perms151 .into_iter()117 .into_iter()152 .map(|(key, pp)| {118 .map(pallet_common::eth::TokenPropertyPermission::from)153 let key = string::from_utf8(key.into_inner()).expect("Stored key must be valid");154 let pp = vec![155 (EthTokenPermissions::Mutable, pp.mutable),156 (EthTokenPermissions::TokenOwner, pp.token_owner),157 (EthTokenPermissions::CollectionAdmin, pp.collection_admin),158 ];159 (key, pp)160 })161 .collect())119 .collect())162 }120 }163121pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth42 /// @param permissions Permissions for keys.42 /// @param permissions Permissions for keys.43 /// @dev EVM selector for this function is: 0xbd92983a,43 /// @dev EVM selector for this function is: 0xbd92983a,44 /// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])44 /// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])45 function setTokenPropertyPermissions(Tuple60[] memory permissions) public {45 function setTokenPropertyPermissions(TokenPropertyPermission[] memory permissions) public {46 require(false, stub_error);46 require(false, stub_error);47 permissions;47 permissions;48 dummy = 0;48 dummy = 0;51 /// @notice Get permissions for token properties.51 /// @notice Get permissions for token properties.52 /// @dev EVM selector for this function is: 0xf23d7790,52 /// @dev EVM selector for this function is: 0xf23d7790,53 /// or in textual repr: tokenPropertyPermissions()53 /// or in textual repr: tokenPropertyPermissions()54 function tokenPropertyPermissions() public view returns (Tuple60[] memory) {54 function tokenPropertyPermissions() public view returns (TokenPropertyPermission[] memory) {55 require(false, stub_error);55 require(false, stub_error);56 dummy;56 dummy;57 return new Tuple60[](0);57 return new TokenPropertyPermission[](0);58 }58 }595960 // /// @notice Set token property value.60 // /// @notice Set token property value.127 }127 }128}128}129129130/// @dev Property struct130/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).131struct Property {131struct Property {132 /// @dev Property key.132 string key;133 string key;134 /// @dev Property value.133 bytes value;135 bytes value;134}136}137138/// @dev Ethereum representation of Token Property Permissions.139struct TokenPropertyPermission {140 /// @dev Token property key.141 string key;142 /// @dev Token property permissions.143 PropertyPermission[] permissions;144}145146/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.147struct PropertyPermission {148 /// @dev TokenPermission field.149 EthTokenPermissions code;150 /// @dev TokenPermission value.151 bool value;152}135153136/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.154/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.137enum EthTokenPermissions {155enum EthTokenPermissions {143 CollectionAdmin161 CollectionAdmin144}162}145146/// @dev anonymous struct147struct Tuple60 {148 string field_0;149 Tuple58[] field_1;150}151152/// @dev anonymous struct153struct Tuple58 {154 EthTokenPermissions field_0;155 bool field_1;156}157163158/// @title A contract that allows you to work with collections.164/// @title A contract that allows you to work with collections.159/// @dev the ERC-165 identifier for this interface is 0x81172a75165/// @dev the ERC-165 identifier for this interface is 0x81172a75608 uint256 sub;614 uint256 sub;609}615}610616617/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.611enum CollectionPermissions {618enum CollectionPermissions {612 CollectionAdmin,619 /// @dev Owner of token can nest tokens under it.613 TokenOwner620 TokenOwner,621 /// @dev Admin of token collection can nest tokens under token.622 CollectionAdmin614}623}615624616/// @dev anonymous struct625/// @dev anonymous structpallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterbothbinary blob — no preview
pallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterbothbinary blob — no preview
tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth752 "inputs": [752 "inputs": [753 {753 {754 "components": [754 "components": [755 { "internalType": "string", "name": "field_0", "type": "string" },755 { "internalType": "string", "name": "key", "type": "string" },756 {756 {757 "components": [757 "components": [758 {758 {759 "internalType": "enum EthTokenPermissions",759 "internalType": "enum EthTokenPermissions",760 "name": "field_0",760 "name": "code",761 "type": "uint8"761 "type": "uint8"762 },762 },763 { "internalType": "bool", "name": "field_1", "type": "bool" }763 { "internalType": "bool", "name": "value", "type": "bool" }764 ],764 ],765 "internalType": "struct Tuple59[]",765 "internalType": "struct PropertyPermission[]",766 "name": "field_1",766 "name": "permissions",767 "type": "tuple[]"767 "type": "tuple[]"768 }768 }769 ],769 ],770 "internalType": "struct Tuple61[]",770 "internalType": "struct TokenPropertyPermission[]",771 "name": "permissions",771 "name": "permissions",772 "type": "tuple[]"772 "type": "tuple[]"773 }773 }818 "outputs": [818 "outputs": [819 {819 {820 "components": [820 "components": [821 { "internalType": "string", "name": "field_0", "type": "string" },821 { "internalType": "string", "name": "key", "type": "string" },822 {822 {823 "components": [823 "components": [824 {824 {825 "internalType": "enum EthTokenPermissions",825 "internalType": "enum EthTokenPermissions",826 "name": "field_0",826 "name": "code",827 "type": "uint8"827 "type": "uint8"828 },828 },829 { "internalType": "bool", "name": "field_1", "type": "bool" }829 { "internalType": "bool", "name": "value", "type": "bool" }830 ],830 ],831 "internalType": "struct Tuple59[]",831 "internalType": "struct PropertyPermission[]",832 "name": "field_1",832 "name": "permissions",833 "type": "tuple[]"833 "type": "tuple[]"834 }834 }835 ],835 ],836 "internalType": "struct Tuple61[]",836 "internalType": "struct TokenPropertyPermission[]",837 "name": "",837 "name": "",838 "type": "tuple[]"838 "type": "tuple[]"839 }839 }tests/src/eth/abi/reFungible.jsondiffbeforeafterboth734 "inputs": [734 "inputs": [735 {735 {736 "components": [736 "components": [737 { "internalType": "string", "name": "field_0", "type": "string" },737 { "internalType": "string", "name": "key", "type": "string" },738 {738 {739 "components": [739 "components": [740 {740 {741 "internalType": "enum EthTokenPermissions",741 "internalType": "enum EthTokenPermissions",742 "name": "field_0",742 "name": "code",743 "type": "uint8"743 "type": "uint8"744 },744 },745 { "internalType": "bool", "name": "field_1", "type": "bool" }745 { "internalType": "bool", "name": "value", "type": "bool" }746 ],746 ],747 "internalType": "struct Tuple58[]",747 "internalType": "struct PropertyPermission[]",748 "name": "field_1",748 "name": "permissions",749 "type": "tuple[]"749 "type": "tuple[]"750 }750 }751 ],751 ],752 "internalType": "struct Tuple60[]",752 "internalType": "struct TokenPropertyPermission[]",753 "name": "permissions",753 "name": "permissions",754 "type": "tuple[]"754 "type": "tuple[]"755 }755 }809 "outputs": [809 "outputs": [810 {810 {811 "components": [811 "components": [812 { "internalType": "string", "name": "field_0", "type": "string" },812 { "internalType": "string", "name": "key", "type": "string" },813 {813 {814 "components": [814 "components": [815 {815 {816 "internalType": "enum EthTokenPermissions",816 "internalType": "enum EthTokenPermissions",817 "name": "field_0",817 "name": "code",818 "type": "uint8"818 "type": "uint8"819 },819 },820 { "internalType": "bool", "name": "field_1", "type": "bool" }820 { "internalType": "bool", "name": "value", "type": "bool" }821 ],821 ],822 "internalType": "struct Tuple58[]",822 "internalType": "struct PropertyPermission[]",823 "name": "field_1",823 "name": "permissions",824 "type": "tuple[]"824 "type": "tuple[]"825 }825 }826 ],826 ],827 "internalType": "struct Tuple60[]",827 "internalType": "struct TokenPropertyPermission[]",828 "name": "",828 "name": "",829 "type": "tuple[]"829 "type": "tuple[]"830 }830 }tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth316 bool field_1;316 bool field_1;317}317}318318319/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.319enum CollectionPermissions {320enum CollectionPermissions {320 CollectionAdmin,321 /// @dev Owner of token can nest tokens under it.321 TokenOwner322 TokenOwner,323 /// @dev Admin of token collection can nest tokens under token.324 CollectionAdmin322}325}323326324/// @dev anonymous struct327/// @dev anonymous struct356 uint256 field_2;359 uint256 field_2;357}360}358361359/// @dev Property struct362/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).360struct Property {363struct Property {364 /// @dev Property key.361 string key;365 string key;366 /// @dev Property value.362 bytes value;367 bytes value;363}368}364369tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth30 /// @param permissions Permissions for keys.30 /// @param permissions Permissions for keys.31 /// @dev EVM selector for this function is: 0xbd92983a,31 /// @dev EVM selector for this function is: 0xbd92983a,32 /// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])32 /// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])33 function setTokenPropertyPermissions(Tuple53[] memory permissions) external;33 function setTokenPropertyPermissions(TokenPropertyPermission[] memory permissions) external;343435 /// @notice Get permissions for token properties.35 /// @notice Get permissions for token properties.36 /// @dev EVM selector for this function is: 0xf23d7790,36 /// @dev EVM selector for this function is: 0xf23d7790,37 /// or in textual repr: tokenPropertyPermissions()37 /// or in textual repr: tokenPropertyPermissions()38 function tokenPropertyPermissions() external view returns (Tuple53[] memory);38 function tokenPropertyPermissions() external view returns (TokenPropertyPermission[] memory);393940 // /// @notice Set token property value.40 // /// @notice Set token property value.41 // /// @dev Throws error if `msg.sender` has no permission to edit the property.41 // /// @dev Throws error if `msg.sender` has no permission to edit the property.80 function property(uint256 tokenId, string memory key) external view returns (bytes memory);80 function property(uint256 tokenId, string memory key) external view returns (bytes memory);81}81}828283/// @dev Property struct83/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).84struct Property {84struct Property {85 /// @dev Property key.85 string key;86 string key;87 /// @dev Property value.86 bytes value;88 bytes value;87}89}9091/// @dev Ethereum representation of Token Property Permissions.92struct TokenPropertyPermission {93 /// @dev Token property key.94 string key;95 /// @dev Token property permissions.96 PropertyPermission[] permissions;97}9899/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.100struct PropertyPermission {101 /// @dev TokenPermission field.102 EthTokenPermissions code;103 /// @dev TokenPermission value.104 bool value;105}8810689/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.107/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.90enum EthTokenPermissions {108enum EthTokenPermissions {96 CollectionAdmin114 CollectionAdmin97}115}9899/// @dev anonymous struct100struct Tuple53 {101 string field_0;102 Tuple51[] field_1;103}104105/// @dev anonymous struct106struct Tuple51 {107 EthTokenPermissions field_0;108 bool field_1;109}110116111/// @title A contract that allows you to work with collections.117/// @title A contract that allows you to work with collections.112/// @dev the ERC-165 identifier for this interface is 0x81172a75118/// @dev the ERC-165 identifier for this interface is 0x81172a75412 bool field_1;418 bool field_1;413}419}414420421/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.415enum CollectionPermissions {422enum CollectionPermissions {416 CollectionAdmin,423 /// @dev Owner of token can nest tokens under it.417 TokenOwner424 TokenOwner,425 /// @dev Admin of token collection can nest tokens under token.426 CollectionAdmin418}427}419428420/// @dev anonymous struct429/// @dev anonymous structtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth30 /// @param permissions Permissions for keys.30 /// @param permissions Permissions for keys.31 /// @dev EVM selector for this function is: 0xbd92983a,31 /// @dev EVM selector for this function is: 0xbd92983a,32 /// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])32 /// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])33 function setTokenPropertyPermissions(Tuple52[] memory permissions) external;33 function setTokenPropertyPermissions(TokenPropertyPermission[] memory permissions) external;343435 /// @notice Get permissions for token properties.35 /// @notice Get permissions for token properties.36 /// @dev EVM selector for this function is: 0xf23d7790,36 /// @dev EVM selector for this function is: 0xf23d7790,37 /// or in textual repr: tokenPropertyPermissions()37 /// or in textual repr: tokenPropertyPermissions()38 function tokenPropertyPermissions() external view returns (Tuple52[] memory);38 function tokenPropertyPermissions() external view returns (TokenPropertyPermission[] memory);393940 // /// @notice Set token property value.40 // /// @notice Set token property value.41 // /// @dev Throws error if `msg.sender` has no permission to edit the property.41 // /// @dev Throws error if `msg.sender` has no permission to edit the property.80 function property(uint256 tokenId, string memory key) external view returns (bytes memory);80 function property(uint256 tokenId, string memory key) external view returns (bytes memory);81}81}828283/// @dev Property struct83/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).84struct Property {84struct Property {85 /// @dev Property key.85 string key;86 string key;87 /// @dev Property value.86 bytes value;88 bytes value;87}89}9091/// @dev Ethereum representation of Token Property Permissions.92struct TokenPropertyPermission {93 /// @dev Token property key.94 string key;95 /// @dev Token property permissions.96 PropertyPermission[] permissions;97}9899/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.100struct PropertyPermission {101 /// @dev TokenPermission field.102 EthTokenPermissions code;103 /// @dev TokenPermission value.104 bool value;105}8810689/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.107/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.90enum EthTokenPermissions {108enum EthTokenPermissions {96 CollectionAdmin114 CollectionAdmin97}115}9899/// @dev anonymous struct100struct Tuple52 {101 string field_0;102 Tuple50[] field_1;103}104105/// @dev anonymous struct106struct Tuple50 {107 EthTokenPermissions field_0;108 bool field_1;109}110116111/// @title A contract that allows you to work with collections.117/// @title A contract that allows you to work with collections.112/// @dev the ERC-165 identifier for this interface is 0x81172a75118/// @dev the ERC-165 identifier for this interface is 0x81172a75412 bool field_1;418 bool field_1;413}419}414420421/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.415enum CollectionPermissions {422enum CollectionPermissions {416 CollectionAdmin,423 /// @dev Owner of token can nest tokens under it.417 TokenOwner424 TokenOwner,425 /// @dev Admin of token collection can nest tokens under token.426 CollectionAdmin418}427}419428420/// @dev anonymous struct429/// @dev anonymous struct