difftreelog
feat Rewrite tuple to named structures for CollectionLimits.
in: master
21 files changed
pallets/common/src/erc.rsdiffbeforeafterboth36 Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,36 Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,37 eth::{37 eth::{38 Property as PropertyStruct, EthCrossAccount, CollectionPermissions as EvmPermissions,38 Property as PropertyStruct, EthCrossAccount, CollectionPermissions as EvmPermissions,39 CollectionLimits as EvmCollectionLimits,39 CollectionLimitField as EvmCollectionLimits, self,40 },40 },41 weights::WeightInfo,41 weights::WeightInfo,42};42};299299300 /// Get current collection limits.300 /// Get current collection limits.301 ///301 ///302 /// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:302 /// @return Array of collection limits303 /// "accountTokenOwnershipLimit",304 /// "sponsoredDataSize",305 /// "sponsoredDataRateLimit",306 /// "tokenLimit",307 /// "sponsorTransferTimeout",308 /// "sponsorApproveTimeout"309 /// "ownerCanTransfer",310 /// "ownerCanDestroy",311 /// "transfersEnabled"312 /// Return `false` if a limit not set.313 fn collection_limits(&self) -> Result<Vec<(EvmCollectionLimits, bool, uint256)>> {303 fn collection_limits(&self) -> Result<Vec<eth::CollectionLimit>> {314 let convert_value_limit = |limit: EvmCollectionLimits,315 value: Option<u32>|316 -> (EvmCollectionLimits, bool, uint256) {317 value318 .map(|v| (limit, true, v.into()))319 .unwrap_or((limit, false, Default::default()))320 };321322 let convert_bool_limit = |limit: EvmCollectionLimits,323 value: Option<bool>|324 -> (EvmCollectionLimits, bool, uint256) {325 value326 .map(|v| {327 (328 limit,329 true,330 if v {331 uint256::from(1)332 } else {333 Default::default()334 },335 )336 })337 .unwrap_or((limit, false, Default::default()))338 };339340 let limits = &self.collection.limits;304 let limits = &self.collection.limits;341305342 Ok(vec![306 Ok(vec![343 convert_value_limit(307 eth::CollectionLimit::from_opt_int(344 EvmCollectionLimits::AccountTokenOwnership,308 EvmCollectionLimits::AccountTokenOwnership,345 limits.account_token_ownership_limit,309 limits.account_token_ownership_limit,346 ),310 ),347 convert_value_limit(311 eth::CollectionLimit::from_opt_int(348 EvmCollectionLimits::SponsoredDataSize,312 EvmCollectionLimits::SponsoredDataSize,349 limits.sponsored_data_size,313 limits.sponsored_data_size,350 ),314 ),351 limits315 limits352 .sponsored_data_rate_limit316 .sponsored_data_rate_limit353 .and_then(|limit| {317 .and_then(|limit| {354 if let SponsoringRateLimit::Blocks(blocks) = limit {318 if let SponsoringRateLimit::Blocks(blocks) = limit {355 Some((319 Some(eth::CollectionLimit::from_int(356 EvmCollectionLimits::SponsoredDataRateLimit,320 EvmCollectionLimits::SponsoredDataRateLimit,357 true,358 blocks.into(),321 blocks,359 ))322 ))360 } else {323 } else {361 None324 None362 }325 }363 })326 })364 .unwrap_or((327 .unwrap_or(eth::CollectionLimit::from_int(365 EvmCollectionLimits::SponsoredDataRateLimit,328 EvmCollectionLimits::SponsoredDataRateLimit,366 false,367 Default::default(),329 Default::default(),368 )),330 )),369 convert_value_limit(EvmCollectionLimits::TokenLimit, limits.token_limit),331 eth::CollectionLimit::from_opt_int(EvmCollectionLimits::TokenLimit, limits.token_limit),370 convert_value_limit(332 eth::CollectionLimit::from_opt_int(371 EvmCollectionLimits::SponsorTransferTimeout,333 EvmCollectionLimits::SponsorTransferTimeout,372 limits.sponsor_transfer_timeout,334 limits.sponsor_transfer_timeout,373 ),335 ),374 convert_value_limit(336 eth::CollectionLimit::from_opt_int(375 EvmCollectionLimits::SponsorApproveTimeout,337 EvmCollectionLimits::SponsorApproveTimeout,376 limits.sponsor_approve_timeout,338 limits.sponsor_approve_timeout,377 ),339 ),378 convert_bool_limit(340 eth::CollectionLimit::from_opt_bool(379 EvmCollectionLimits::OwnerCanTransfer,341 EvmCollectionLimits::OwnerCanTransfer,380 limits.owner_can_transfer,342 limits.owner_can_transfer,381 ),343 ),382 convert_bool_limit(344 eth::CollectionLimit::from_opt_bool(383 EvmCollectionLimits::OwnerCanDestroy,345 EvmCollectionLimits::OwnerCanDestroy,384 limits.owner_can_destroy,346 limits.owner_can_destroy,385 ),347 ),386 convert_bool_limit(348 eth::CollectionLimit::from_opt_bool(387 EvmCollectionLimits::TransferEnabled,349 EvmCollectionLimits::TransferEnabled,388 limits.transfers_enabled,350 limits.transfers_enabled,389 ),351 ),392354393 /// Set limits for the collection.355 /// Set limits for the collection.394 /// @dev Throws error if limit not found.356 /// @dev Throws error if limit not found.395 /// @param limit Name of the limit. Valid names:396 /// "accountTokenOwnershipLimit",397 /// "sponsoredDataSize",398 /// "sponsoredDataRateLimit",399 /// "tokenLimit",400 /// "sponsorTransferTimeout",401 /// "sponsorApproveTimeout"402 /// "ownerCanTransfer",403 /// "ownerCanDestroy",404 /// "transfersEnabled"405 /// @param status enable\disable limit. Works only with `true`.406 /// @param value Value of the limit.357 /// @param limit Some limit.407 #[solidity(rename_selector = "setCollectionLimit")]358 #[solidity(rename_selector = "setCollectionLimit")]408 fn set_collection_limit(359 fn set_collection_limit(409 &mut self,360 &mut self,410 caller: caller,361 caller: caller,411 limit: EvmCollectionLimits,362 limit: eth::CollectionLimit,412 status: bool,413 value: uint256,414 ) -> Result<void> {363 ) -> Result<void> {415 self.consume_store_reads_and_writes(1, 1)?;364 self.consume_store_reads_and_writes(1, 1)?;416417 if !status {418 return Err(Error::Revert("user can't disable limits".into()));419 }420421 let value = value422 .try_into()423 .map_err(|_| Error::Revert(format!("can't convert value to u32 \"{}\"", value)))?;424425 let convert_value_to_bool = || match value {426 0 => Ok(false),427 1 => Ok(true),428 _ => {429 return Err(Error::Revert(format!(430 "can't convert value to boolean \"{}\"",431 value432 )))433 }434 };435436 let mut limits = self.limits.clone();437438 match limit {439 EvmCollectionLimits::AccountTokenOwnership => {440 limits.account_token_ownership_limit = Some(value);441 }442 EvmCollectionLimits::SponsoredDataSize => {443 limits.sponsored_data_size = Some(value);444 }445 EvmCollectionLimits::SponsoredDataRateLimit => {446 limits.sponsored_data_rate_limit = Some(SponsoringRateLimit::Blocks(value));447 }448 EvmCollectionLimits::TokenLimit => {449 limits.token_limit = Some(value);450 }451 EvmCollectionLimits::SponsorTransferTimeout => {452 limits.sponsor_transfer_timeout = Some(value);453 }454 EvmCollectionLimits::SponsorApproveTimeout => {455 limits.sponsor_approve_timeout = Some(value);456 }457 EvmCollectionLimits::OwnerCanTransfer => {458 limits.owner_can_transfer = Some(convert_value_to_bool()?);459 }460 EvmCollectionLimits::OwnerCanDestroy => {461 limits.owner_can_destroy = Some(convert_value_to_bool()?);462 }463 EvmCollectionLimits::TransferEnabled => {464 limits.transfers_enabled = Some(convert_value_to_bool()?);465 }466 _ => return Err(Error::Revert(format!("unknown limit \"{:?}\"", limit))),467 }468365469 let caller = T::CrossAccountId::from_eth(caller);366 let caller = T::CrossAccountId::from_eth(caller);470 <Pallet<T>>::update_limits(&caller, self, limits).map_err(dispatch_to_evm::<T>)367 <Pallet<T>>::update_limits(&caller, self, limit.try_into()?).map_err(dispatch_to_evm::<T>)471 }368 }472369473 /// Get contract address.370 /// Get contract address.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 alloc::format;19use sp_std::{vec, vec::Vec};20use sp_std::{vec, vec::Vec};20use evm_coder::{21use evm_coder::{21 AbiCoder,22 AbiCoder,129/// [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.130/// [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.130#[derive(Debug, Default, Clone, Copy, AbiCoder)]131#[derive(Debug, Default, Clone, Copy, AbiCoder)]131#[repr(u8)]132#[repr(u8)]132pub enum CollectionLimits {133pub enum CollectionLimitField {133 /// How many tokens can a user have on one account.134 /// How many tokens can a user have on one account.134 #[default]135 #[default]135 AccountTokenOwnership,136 AccountTokenOwnership,159 TransferEnabled,160 TransferEnabled,160}161}162163#[derive(Debug, Default, AbiCoder)]164pub struct CollectionLimit {165 field: CollectionLimitField,166 status: bool,167 value: uint256,168}169170impl CollectionLimit {171 pub fn from_int(field: CollectionLimitField, value: u32) -> Self {172 Self {173 field,174 status: true,175 value: value.into(),176 }177 }178179 pub fn from_opt_int(field: CollectionLimitField, value: Option<u32>) -> Self {180 value181 .map(|v| Self {182 field,183 status: true,184 value: v.into(),185 })186 .unwrap_or(Self {187 field,188 status: false,189 value: Default::default(),190 })191 }192193 pub fn from_opt_bool(field: CollectionLimitField, value: Option<bool>) -> Self {194 value195 .map(|v| Self {196 field,197 status: true,198 value: if v {199 uint256::from(1)200 } else {201 Default::default()202 },203 })204 .unwrap_or(Self {205 field,206 status: false,207 value: Default::default(),208 })209 }210}211212impl TryInto<up_data_structs::CollectionLimits> for CollectionLimit {213 type Error = evm_coder::execution::Error;214215 fn try_into(self) -> Result<up_data_structs::CollectionLimits, Self::Error> {216 if !self.status {217 return Err(Self::Error::Revert("user can't disable limits".into()));218 }219220 let value = self.value.try_into().map_err(|error| {221 Self::Error::Revert(format!(222 "can't convert value to u32 \"{}\" because: \"{error}\"",223 self.value224 ))225 })?;226227 let convert_value_to_bool = || match value {228 0 => Ok(false),229 1 => Ok(true),230 _ => {231 return Err(Self::Error::Revert(format!(232 "can't convert value to boolean \"{value}\""233 )))234 }235 };236237 let mut limits = up_data_structs::CollectionLimits::default();238 match self.field {239 CollectionLimitField::AccountTokenOwnership => {240 limits.account_token_ownership_limit = Some(value);241 }242 CollectionLimitField::SponsoredDataSize => {243 limits.sponsored_data_size = Some(value);244 }245 CollectionLimitField::SponsoredDataRateLimit => {246 limits.sponsored_data_rate_limit =247 Some(up_data_structs::SponsoringRateLimit::Blocks(value));248 }249 CollectionLimitField::TokenLimit => {250 limits.token_limit = Some(value);251 }252 CollectionLimitField::SponsorTransferTimeout => {253 limits.sponsor_transfer_timeout = Some(value);254 }255 CollectionLimitField::SponsorApproveTimeout => {256 limits.sponsor_approve_timeout = Some(value);257 }258 CollectionLimitField::OwnerCanTransfer => {259 limits.owner_can_transfer = Some(convert_value_to_bool()?);260 }261 CollectionLimitField::OwnerCanDestroy => {262 limits.owner_can_destroy = Some(convert_value_to_bool()?);263 }264 CollectionLimitField::TransferEnabled => {265 limits.transfers_enabled = Some(convert_value_to_bool()?);266 }267 };268 Ok(limits)269 }270}271161/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.272/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.162#[derive(Default, Debug, Clone, Copy, AbiCoder)]273#[derive(Default, Debug, Clone, Copy, AbiCoder)]173/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.284/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.174#[derive(AbiCoder, Copy, Clone, Default, Debug)]285#[derive(AbiCoder, Copy, Clone, Default, Debug)]175#[repr(u8)]286#[repr(u8)]176pub enum EthTokenPermissions {287pub enum TokenPermissionField {177 /// Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]288 /// Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]178 #[default]289 #[default]179 Mutable,290 Mutable,189#[derive(Debug, Default, AbiCoder)]300#[derive(Debug, Default, AbiCoder)]190pub struct PropertyPermission {301pub struct PropertyPermission {191 /// TokenPermission field.302 /// TokenPermission field.192 code: EthTokenPermissions,303 code: TokenPermissionField,193 /// TokenPermission value.304 /// TokenPermission value.194 value: bool,305 value: bool,195}306}198 pub fn into_vec(pp: up_data_structs::PropertyPermission) -> Vec<Self> {309 pub fn into_vec(pp: up_data_structs::PropertyPermission) -> Vec<Self> {199 vec![310 vec![200 PropertyPermission {311 PropertyPermission {201 code: EthTokenPermissions::Mutable,312 code: TokenPermissionField::Mutable,202 value: pp.mutable,313 value: pp.mutable,203 },314 },204 PropertyPermission {315 PropertyPermission {205 code: EthTokenPermissions::TokenOwner,316 code: TokenPermissionField::TokenOwner,206 value: pp.token_owner,317 value: pp.token_owner,207 },318 },208 PropertyPermission {319 PropertyPermission {209 code: EthTokenPermissions::CollectionAdmin,320 code: TokenPermissionField::CollectionAdmin,210 value: pp.collection_admin,321 value: pp.collection_admin,211 },322 },212 ]323 ]217328218 for PropertyPermission { code, value } in permission {329 for PropertyPermission { code, value } in permission {219 match code {330 match code {220 EthTokenPermissions::Mutable => token_permission.mutable = value,331 TokenPermissionField::Mutable => token_permission.mutable = value,221 EthTokenPermissions::TokenOwner => token_permission.token_owner = value,332 TokenPermissionField::TokenOwner => token_permission.token_owner = value,222 EthTokenPermissions::CollectionAdmin => token_permission.collection_admin = value,333 TokenPermissionField::CollectionAdmin => token_permission.collection_admin = value,223 }334 }224 }335 }225 token_permission336 token_permission262 let mut perms = Vec::new();373 let mut perms = Vec::new();263374264 for TokenPropertyPermission { key, permissions } in permissions {375 for TokenPropertyPermission { key, permissions } in permissions {265 if permissions.len() > <EthTokenPermissions as evm_coder::abi::AbiType>::FIELDS_COUNT {376 if permissions.len() > <TokenPermissionField as evm_coder::abi::AbiType>::FIELDS_COUNT {266 return Err(alloc::format!(377 return Err(alloc::format!(267 "Actual number of fields {} for {}, which exceeds the maximum value of {}",378 "Actual number of fields {} for {}, which exceeds the maximum value of {}",268 permissions.len(),379 permissions.len(),269 stringify!(EthTokenPermissions),380 stringify!(EthTokenPermissions),270 <EthTokenPermissions as evm_coder::abi::AbiType>::FIELDS_COUNT381 <TokenPermissionField as evm_coder::abi::AbiType>::FIELDS_COUNT271 )382 )272 .as_str()383 .as_str()273 .into());384 .into());pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth18}18}191920/// @title A contract that allows you to work with collections.20/// @title A contract that allows you to work with collections.21/// @dev the ERC-165 identifier for this interface is 0x81172a7521/// @dev the ERC-165 identifier for this interface is 0x2320144222contract Collection is Dummy, ERC165 {22contract Collection is Dummy, ERC165 {23 // /// Set collection property.23 // /// Set collection property.24 // ///24 // ///160160161 /// Get current collection limits.161 /// Get current collection limits.162 ///162 ///163 /// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:163 /// @return Array of collection limits164 /// "accountTokenOwnershipLimit",165 /// "sponsoredDataSize",166 /// "sponsoredDataRateLimit",167 /// "tokenLimit",168 /// "sponsorTransferTimeout",169 /// "sponsorApproveTimeout"170 /// "ownerCanTransfer",171 /// "ownerCanDestroy",172 /// "transfersEnabled"173 /// Return `false` if a limit not set.174 /// @dev EVM selector for this function is: 0xf63bc572,164 /// @dev EVM selector for this function is: 0xf63bc572,175 /// or in textual repr: collectionLimits()165 /// or in textual repr: collectionLimits()176 function collectionLimits() public view returns (Tuple23[] memory) {166 function collectionLimits() public view returns (CollectionLimit[] memory) {177 require(false, stub_error);167 require(false, stub_error);178 dummy;168 dummy;179 return new Tuple23[](0);169 return new CollectionLimit[](0);180 }170 }181171182 /// Set limits for the collection.172 /// Set limits for the collection.183 /// @dev Throws error if limit not found.173 /// @dev Throws error if limit not found.184 /// @param limit Name of the limit. Valid names:185 /// "accountTokenOwnershipLimit",186 /// "sponsoredDataSize",187 /// "sponsoredDataRateLimit",188 /// "tokenLimit",189 /// "sponsorTransferTimeout",190 /// "sponsorApproveTimeout"191 /// "ownerCanTransfer",192 /// "ownerCanDestroy",193 /// "transfersEnabled"194 /// @param status enable\disable limit. Works only with `true`.195 /// @param value Value of the limit.174 /// @param limit Some limit.196 /// @dev EVM selector for this function is: 0x88150bd0,175 /// @dev EVM selector for this function is: 0x2a2235e7,197 /// or in textual repr: setCollectionLimit(uint8,bool,uint256)176 /// or in textual repr: setCollectionLimit((uint8,bool,uint256))198 function setCollectionLimit(177 function setCollectionLimit(CollectionLimit memory limit) public {199 CollectionLimits limit,200 bool status,201 uint256 value202 ) public {203 require(false, stub_error);178 require(false, stub_error);204 limit;179 limit;205 status;206 value;207 dummy = 0;180 dummy = 0;208 }181 }209182284 /// Returns nesting for a collection257 /// Returns nesting for a collection285 /// @dev EVM selector for this function is: 0x22d25bfe,258 /// @dev EVM selector for this function is: 0x22d25bfe,286 /// or in textual repr: collectionNestingRestrictedCollectionIds()259 /// or in textual repr: collectionNestingRestrictedCollectionIds()287 function collectionNestingRestrictedCollectionIds() public view returns (Tuple29 memory) {260 function collectionNestingRestrictedCollectionIds() public view returns (Tuple30 memory) {288 require(false, stub_error);261 require(false, stub_error);289 dummy;262 dummy;290 return Tuple29(false, new uint256[](0));263 return Tuple30(false, new uint256[](0));291 }264 }292265293 /// Returns permissions for a collection266 /// Returns permissions for a collection294 /// @dev EVM selector for this function is: 0x5b2eaf4b,267 /// @dev EVM selector for this function is: 0x5b2eaf4b,295 /// or in textual repr: collectionNestingPermissions()268 /// or in textual repr: collectionNestingPermissions()296 function collectionNestingPermissions() public view returns (Tuple32[] memory) {269 function collectionNestingPermissions() public view returns (Tuple33[] memory) {297 require(false, stub_error);270 require(false, stub_error);298 dummy;271 dummy;299 return new Tuple32[](0);272 return new Tuple33[](0);300 }273 }301274302 /// Set the collection access method.275 /// Set the collection access method.479}452}480453481/// @dev anonymous struct454/// @dev anonymous struct482struct Tuple32 {455struct Tuple33 {483 CollectionPermissions field_0;456 CollectionPermissions field_0;484 bool field_1;457 bool field_1;485}458}486459487/// @dev anonymous struct460/// @dev anonymous struct488struct Tuple29 {461struct Tuple30 {489 bool field_0;462 bool field_0;490 uint256[] field_1;463 uint256[] field_1;491}464}465466struct CollectionLimit {467 CollectionLimitField field;468 bool status;469 uint256 value;470}492471493/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.472/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.494enum CollectionLimits {473enum CollectionLimitField {495 /// @dev How many tokens can a user have on one account.474 /// @dev How many tokens can a user have on one account.496 AccountTokenOwnership,475 AccountTokenOwnership,497 /// @dev How many bytes of data are available for sponsorship.476 /// @dev How many bytes of data are available for sponsorship.512 TransferEnabled491 TransferEnabled513}492}514515/// @dev anonymous struct516struct Tuple23 {517 CollectionLimits field_0;518 bool field_1;519 uint256 field_2;520}521493522/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).494/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).523struct Property {495struct Property {pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth146/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.146/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.147struct PropertyPermission {147struct PropertyPermission {148 /// @dev TokenPermission field.148 /// @dev TokenPermission field.149 EthTokenPermissions code;149 TokenPermissionField code;150 /// @dev TokenPermission value.150 /// @dev TokenPermission value.151 bool value;151 bool value;152}152}153153154/// @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.155enum EthTokenPermissions {155enum TokenPermissionField {156 /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]156 /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]157 Mutable,157 Mutable,158 /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]158 /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]162}162}163163164/// @title A contract that allows you to work with collections.164/// @title A contract that allows you to work with collections.165/// @dev the ERC-165 identifier for this interface is 0x81172a75165/// @dev the ERC-165 identifier for this interface is 0x23201442166contract Collection is Dummy, ERC165 {166contract Collection is Dummy, ERC165 {167 // /// Set collection property.167 // /// Set collection property.168 // ///168 // ///304304305 /// Get current collection limits.305 /// Get current collection limits.306 ///306 ///307 /// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:307 /// @return Array of collection limits308 /// "accountTokenOwnershipLimit",309 /// "sponsoredDataSize",310 /// "sponsoredDataRateLimit",311 /// "tokenLimit",312 /// "sponsorTransferTimeout",313 /// "sponsorApproveTimeout"314 /// "ownerCanTransfer",315 /// "ownerCanDestroy",316 /// "transfersEnabled"317 /// Return `false` if a limit not set.318 /// @dev EVM selector for this function is: 0xf63bc572,308 /// @dev EVM selector for this function is: 0xf63bc572,319 /// or in textual repr: collectionLimits()309 /// or in textual repr: collectionLimits()320 function collectionLimits() public view returns (Tuple35[] memory) {310 function collectionLimits() public view returns (CollectionLimit[] memory) {321 require(false, stub_error);311 require(false, stub_error);322 dummy;312 dummy;323 return new Tuple35[](0);313 return new CollectionLimit[](0);324 }314 }325315326 /// Set limits for the collection.316 /// Set limits for the collection.327 /// @dev Throws error if limit not found.317 /// @dev Throws error if limit not found.328 /// @param limit Name of the limit. Valid names:329 /// "accountTokenOwnershipLimit",330 /// "sponsoredDataSize",331 /// "sponsoredDataRateLimit",332 /// "tokenLimit",333 /// "sponsorTransferTimeout",334 /// "sponsorApproveTimeout"335 /// "ownerCanTransfer",336 /// "ownerCanDestroy",337 /// "transfersEnabled"338 /// @param status enable\disable limit. Works only with `true`.339 /// @param value Value of the limit.318 /// @param limit Some limit.340 /// @dev EVM selector for this function is: 0x88150bd0,319 /// @dev EVM selector for this function is: 0x2a2235e7,341 /// or in textual repr: setCollectionLimit(uint8,bool,uint256)320 /// or in textual repr: setCollectionLimit((uint8,bool,uint256))342 function setCollectionLimit(321 function setCollectionLimit(CollectionLimit memory limit) public {343 CollectionLimits limit,344 bool status,345 uint256 value346 ) public {347 require(false, stub_error);322 require(false, stub_error);348 limit;323 limit;349 status;350 value;351 dummy = 0;324 dummy = 0;352 }325 }353326428 /// Returns nesting for a collection401 /// Returns nesting for a collection429 /// @dev EVM selector for this function is: 0x22d25bfe,402 /// @dev EVM selector for this function is: 0x22d25bfe,430 /// or in textual repr: collectionNestingRestrictedCollectionIds()403 /// or in textual repr: collectionNestingRestrictedCollectionIds()431 function collectionNestingRestrictedCollectionIds() public view returns (Tuple41 memory) {404 function collectionNestingRestrictedCollectionIds() public view returns (Tuple42 memory) {432 require(false, stub_error);405 require(false, stub_error);433 dummy;406 dummy;434 return Tuple41(false, new uint256[](0));407 return Tuple42(false, new uint256[](0));435 }408 }436409437 /// Returns permissions for a collection410 /// Returns permissions for a collection438 /// @dev EVM selector for this function is: 0x5b2eaf4b,411 /// @dev EVM selector for this function is: 0x5b2eaf4b,439 /// or in textual repr: collectionNestingPermissions()412 /// or in textual repr: collectionNestingPermissions()440 function collectionNestingPermissions() public view returns (Tuple44[] memory) {413 function collectionNestingPermissions() public view returns (Tuple45[] memory) {441 require(false, stub_error);414 require(false, stub_error);442 dummy;415 dummy;443 return new Tuple44[](0);416 return new Tuple45[](0);444 }417 }445418446 /// Set the collection access method.419 /// Set the collection access method.623}596}624597625/// @dev anonymous struct598/// @dev anonymous struct626struct Tuple44 {599struct Tuple45 {627 CollectionPermissions field_0;600 CollectionPermissions field_0;628 bool field_1;601 bool field_1;629}602}630603631/// @dev anonymous struct604/// @dev anonymous struct632struct Tuple41 {605struct Tuple42 {633 bool field_0;606 bool field_0;634 uint256[] field_1;607 uint256[] field_1;635}608}609610struct CollectionLimit {611 CollectionLimitField field;612 bool status;613 uint256 value;614}636615637/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.616/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.638enum CollectionLimits {617enum CollectionLimitField {639 /// @dev How many tokens can a user have on one account.618 /// @dev How many tokens can a user have on one account.640 AccountTokenOwnership,619 AccountTokenOwnership,641 /// @dev How many bytes of data are available for sponsorship.620 /// @dev How many bytes of data are available for sponsorship.656 TransferEnabled635 TransferEnabled657}636}658659/// @dev anonymous struct660struct Tuple35 {661 CollectionLimits field_0;662 bool field_1;663 uint256 field_2;664}665637666/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension638/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension667/// @dev See https://eips.ethereum.org/EIPS/eip-721639/// @dev See https://eips.ethereum.org/EIPS/eip-721pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth146/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.146/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.147struct PropertyPermission {147struct PropertyPermission {148 /// @dev TokenPermission field.148 /// @dev TokenPermission field.149 EthTokenPermissions code;149 TokenPermissionField code;150 /// @dev TokenPermission value.150 /// @dev TokenPermission value.151 bool value;151 bool value;152}152}153153154/// @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.155enum EthTokenPermissions {155enum TokenPermissionField {156 /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]156 /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]157 Mutable,157 Mutable,158 /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]158 /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]162}162}163163164/// @title A contract that allows you to work with collections.164/// @title A contract that allows you to work with collections.165/// @dev the ERC-165 identifier for this interface is 0x81172a75165/// @dev the ERC-165 identifier for this interface is 0x23201442166contract Collection is Dummy, ERC165 {166contract Collection is Dummy, ERC165 {167 // /// Set collection property.167 // /// Set collection property.168 // ///168 // ///304304305 /// Get current collection limits.305 /// Get current collection limits.306 ///306 ///307 /// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:307 /// @return Array of collection limits308 /// "accountTokenOwnershipLimit",309 /// "sponsoredDataSize",310 /// "sponsoredDataRateLimit",311 /// "tokenLimit",312 /// "sponsorTransferTimeout",313 /// "sponsorApproveTimeout"314 /// "ownerCanTransfer",315 /// "ownerCanDestroy",316 /// "transfersEnabled"317 /// Return `false` if a limit not set.318 /// @dev EVM selector for this function is: 0xf63bc572,308 /// @dev EVM selector for this function is: 0xf63bc572,319 /// or in textual repr: collectionLimits()309 /// or in textual repr: collectionLimits()320 function collectionLimits() public view returns (Tuple34[] memory) {310 function collectionLimits() public view returns (CollectionLimit[] memory) {321 require(false, stub_error);311 require(false, stub_error);322 dummy;312 dummy;323 return new Tuple34[](0);313 return new CollectionLimit[](0);324 }314 }325315326 /// Set limits for the collection.316 /// Set limits for the collection.327 /// @dev Throws error if limit not found.317 /// @dev Throws error if limit not found.328 /// @param limit Name of the limit. Valid names:329 /// "accountTokenOwnershipLimit",330 /// "sponsoredDataSize",331 /// "sponsoredDataRateLimit",332 /// "tokenLimit",333 /// "sponsorTransferTimeout",334 /// "sponsorApproveTimeout"335 /// "ownerCanTransfer",336 /// "ownerCanDestroy",337 /// "transfersEnabled"338 /// @param status enable\disable limit. Works only with `true`.339 /// @param value Value of the limit.318 /// @param limit Some limit.340 /// @dev EVM selector for this function is: 0x88150bd0,319 /// @dev EVM selector for this function is: 0x2a2235e7,341 /// or in textual repr: setCollectionLimit(uint8,bool,uint256)320 /// or in textual repr: setCollectionLimit((uint8,bool,uint256))342 function setCollectionLimit(321 function setCollectionLimit(CollectionLimit memory limit) public {343 CollectionLimits limit,344 bool status,345 uint256 value346 ) public {347 require(false, stub_error);322 require(false, stub_error);348 limit;323 limit;349 status;350 value;351 dummy = 0;324 dummy = 0;352 }325 }353326428 /// Returns nesting for a collection401 /// Returns nesting for a collection429 /// @dev EVM selector for this function is: 0x22d25bfe,402 /// @dev EVM selector for this function is: 0x22d25bfe,430 /// or in textual repr: collectionNestingRestrictedCollectionIds()403 /// or in textual repr: collectionNestingRestrictedCollectionIds()431 function collectionNestingRestrictedCollectionIds() public view returns (Tuple40 memory) {404 function collectionNestingRestrictedCollectionIds() public view returns (Tuple41 memory) {432 require(false, stub_error);405 require(false, stub_error);433 dummy;406 dummy;434 return Tuple40(false, new uint256[](0));407 return Tuple41(false, new uint256[](0));435 }408 }436409437 /// Returns permissions for a collection410 /// Returns permissions for a collection438 /// @dev EVM selector for this function is: 0x5b2eaf4b,411 /// @dev EVM selector for this function is: 0x5b2eaf4b,439 /// or in textual repr: collectionNestingPermissions()412 /// or in textual repr: collectionNestingPermissions()440 function collectionNestingPermissions() public view returns (Tuple43[] memory) {413 function collectionNestingPermissions() public view returns (Tuple44[] memory) {441 require(false, stub_error);414 require(false, stub_error);442 dummy;415 dummy;443 return new Tuple43[](0);416 return new Tuple44[](0);444 }417 }445418446 /// Set the collection access method.419 /// Set the collection access method.623}596}624597625/// @dev anonymous struct598/// @dev anonymous struct626struct Tuple43 {599struct Tuple44 {627 CollectionPermissions field_0;600 CollectionPermissions field_0;628 bool field_1;601 bool field_1;629}602}630603631/// @dev anonymous struct604/// @dev anonymous struct632struct Tuple40 {605struct Tuple41 {633 bool field_0;606 bool field_0;634 uint256[] field_1;607 uint256[] field_1;635}608}609610struct CollectionLimit {611 CollectionLimitField field;612 bool status;613 uint256 value;614}636615637/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.616/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.638enum CollectionLimits {617enum CollectionLimitField {639 /// @dev How many tokens can a user have on one account.618 /// @dev How many tokens can a user have on one account.640 AccountTokenOwnership,619 AccountTokenOwnership,641 /// @dev How many bytes of data are available for sponsorship.620 /// @dev How many bytes of data are available for sponsorship.656 TransferEnabled635 TransferEnabled657}636}658659/// @dev anonymous struct660struct Tuple34 {661 CollectionLimits field_0;662 bool field_1;663 uint256 field_2;664}665637666/// @dev the ERC-165 identifier for this interface is 0x5b5e139f638/// @dev the ERC-165 identifier for this interface is 0x5b5e139f667contract ERC721Metadata is Dummy, ERC165 {639contract ERC721Metadata is Dummy, ERC165 {tests/src/eth/abi/fungible.jsondiffbeforeafterboth213 {213 {214 "components": [214 "components": [215 {215 {216 "internalType": "enum CollectionLimits",216 "internalType": "enum CollectionLimitField",217 "name": "field_0",217 "name": "field",218 "type": "uint8"218 "type": "uint8"219 },219 },220 { "internalType": "bool", "name": "field_1", "type": "bool" },220 { "internalType": "bool", "name": "status", "type": "bool" },221 { "internalType": "uint256", "name": "field_2", "type": "uint256" }221 { "internalType": "uint256", "name": "value", "type": "uint256" }222 ],222 ],223 "internalType": "struct Tuple23[]",223 "internalType": "struct CollectionLimit[]",224 "name": "",224 "name": "",225 "type": "tuple[]"225 "type": "tuple[]"226 }226 }241 },241 },242 { "internalType": "bool", "name": "field_1", "type": "bool" }242 { "internalType": "bool", "name": "field_1", "type": "bool" }243 ],243 ],244 "internalType": "struct Tuple32[]",244 "internalType": "struct Tuple33[]",245 "name": "",245 "name": "",246 "type": "tuple[]"246 "type": "tuple[]"247 }247 }262 "type": "uint256[]"262 "type": "uint256[]"263 }263 }264 ],264 ],265 "internalType": "struct Tuple29",265 "internalType": "struct Tuple30",266 "name": "",266 "name": "",267 "type": "tuple"267 "type": "tuple"268 }268 }492 "type": "function"492 "type": "function"493 },493 },494 {494 {495 "inputs": [495 "inputs": [496 {497 "components": [496 {498 {497 "internalType": "enum CollectionLimits",499 "internalType": "enum CollectionLimitField",498 "name": "limit",500 "name": "field",499 "type": "uint8"501 "type": "uint8"500 },502 },501 { "internalType": "bool", "name": "status", "type": "bool" },503 { "internalType": "bool", "name": "status", "type": "bool" },502 { "internalType": "uint256", "name": "value", "type": "uint256" }504 { "internalType": "uint256", "name": "value", "type": "uint256" }505 ],506 "internalType": "struct CollectionLimit",507 "name": "limit",508 "type": "tuple"509 }503 ],510 ],504 "name": "setCollectionLimit",511 "name": "setCollectionLimit",505 "outputs": [],512 "outputs": [],506 "stateMutability": "nonpayable",513 "stateMutability": "nonpayable",tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth243 {243 {244 "components": [244 "components": [245 {245 {246 "internalType": "enum CollectionLimits",246 "internalType": "enum CollectionLimitField",247 "name": "field_0",247 "name": "field",248 "type": "uint8"248 "type": "uint8"249 },249 },250 { "internalType": "bool", "name": "field_1", "type": "bool" },250 { "internalType": "bool", "name": "status", "type": "bool" },251 { "internalType": "uint256", "name": "field_2", "type": "uint256" }251 { "internalType": "uint256", "name": "value", "type": "uint256" }252 ],252 ],253 "internalType": "struct Tuple35[]",253 "internalType": "struct CollectionLimit[]",254 "name": "",254 "name": "",255 "type": "tuple[]"255 "type": "tuple[]"256 }256 }271 },271 },272 { "internalType": "bool", "name": "field_1", "type": "bool" }272 { "internalType": "bool", "name": "field_1", "type": "bool" }273 ],273 ],274 "internalType": "struct Tuple44[]",274 "internalType": "struct Tuple45[]",275 "name": "",275 "name": "",276 "type": "tuple[]"276 "type": "tuple[]"277 }277 }292 "type": "uint256[]"292 "type": "uint256[]"293 }293 }294 ],294 ],295 "internalType": "struct Tuple41",295 "internalType": "struct Tuple42",296 "name": "",296 "name": "",297 "type": "tuple"297 "type": "tuple"298 }298 }654 "type": "function"654 "type": "function"655 },655 },656 {656 {657 "inputs": [657 "inputs": [658 {659 "components": [658 {660 {659 "internalType": "enum CollectionLimits",661 "internalType": "enum CollectionLimitField",660 "name": "limit",662 "name": "field",661 "type": "uint8"663 "type": "uint8"662 },664 },663 { "internalType": "bool", "name": "status", "type": "bool" },665 { "internalType": "bool", "name": "status", "type": "bool" },664 { "internalType": "uint256", "name": "value", "type": "uint256" }666 { "internalType": "uint256", "name": "value", "type": "uint256" }667 ],668 "internalType": "struct CollectionLimit",669 "name": "limit",670 "type": "tuple"671 }665 ],672 ],666 "name": "setCollectionLimit",673 "name": "setCollectionLimit",667 "outputs": [],674 "outputs": [],668 "stateMutability": "nonpayable",675 "stateMutability": "nonpayable",756 {763 {757 "components": [764 "components": [758 {765 {759 "internalType": "enum EthTokenPermissions",766 "internalType": "enum TokenPermissionField",760 "name": "code",767 "name": "code",761 "type": "uint8"768 "type": "uint8"762 },769 },822 {829 {823 "components": [830 "components": [824 {831 {825 "internalType": "enum EthTokenPermissions",832 "internalType": "enum TokenPermissionField",826 "name": "code",833 "name": "code",827 "type": "uint8"834 "type": "uint8"828 },835 },tests/src/eth/abi/reFungible.jsondiffbeforeafterboth225 {225 {226 "components": [226 "components": [227 {227 {228 "internalType": "enum CollectionLimits",228 "internalType": "enum CollectionLimitField",229 "name": "field_0",229 "name": "field",230 "type": "uint8"230 "type": "uint8"231 },231 },232 { "internalType": "bool", "name": "field_1", "type": "bool" },232 { "internalType": "bool", "name": "status", "type": "bool" },233 { "internalType": "uint256", "name": "field_2", "type": "uint256" }233 { "internalType": "uint256", "name": "value", "type": "uint256" }234 ],234 ],235 "internalType": "struct Tuple34[]",235 "internalType": "struct CollectionLimit[]",236 "name": "",236 "name": "",237 "type": "tuple[]"237 "type": "tuple[]"238 }238 }253 },253 },254 { "internalType": "bool", "name": "field_1", "type": "bool" }254 { "internalType": "bool", "name": "field_1", "type": "bool" }255 ],255 ],256 "internalType": "struct Tuple43[]",256 "internalType": "struct Tuple44[]",257 "name": "",257 "name": "",258 "type": "tuple[]"258 "type": "tuple[]"259 }259 }274 "type": "uint256[]"274 "type": "uint256[]"275 }275 }276 ],276 ],277 "internalType": "struct Tuple40",277 "internalType": "struct Tuple41",278 "name": "",278 "name": "",279 "type": "tuple"279 "type": "tuple"280 }280 }636 "type": "function"636 "type": "function"637 },637 },638 {638 {639 "inputs": [639 "inputs": [640 {641 "components": [640 {642 {641 "internalType": "enum CollectionLimits",643 "internalType": "enum CollectionLimitField",642 "name": "limit",644 "name": "field",643 "type": "uint8"645 "type": "uint8"644 },646 },645 { "internalType": "bool", "name": "status", "type": "bool" },647 { "internalType": "bool", "name": "status", "type": "bool" },646 { "internalType": "uint256", "name": "value", "type": "uint256" }648 { "internalType": "uint256", "name": "value", "type": "uint256" }649 ],650 "internalType": "struct CollectionLimit",651 "name": "limit",652 "type": "tuple"653 }647 ],654 ],648 "name": "setCollectionLimit",655 "name": "setCollectionLimit",649 "outputs": [],656 "outputs": [],650 "stateMutability": "nonpayable",657 "stateMutability": "nonpayable",738 {745 {739 "components": [746 "components": [740 {747 {741 "internalType": "enum EthTokenPermissions",748 "internalType": "enum TokenPermissionField",742 "name": "code",749 "name": "code",743 "type": "uint8"750 "type": "uint8"744 },751 },813 {820 {814 "components": [821 "components": [815 {822 {816 "internalType": "enum EthTokenPermissions",823 "internalType": "enum TokenPermissionField",817 "name": "code",824 "name": "code",818 "type": "uint8"825 "type": "uint8"819 },826 },tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth13}13}141415/// @title A contract that allows you to work with collections.15/// @title A contract that allows you to work with collections.16/// @dev the ERC-165 identifier for this interface is 0x81172a7516/// @dev the ERC-165 identifier for this interface is 0x2320144217interface Collection is Dummy, ERC165 {17interface Collection is Dummy, ERC165 {18 // /// Set collection property.18 // /// Set collection property.19 // ///19 // ///106106107 /// Get current collection limits.107 /// Get current collection limits.108 ///108 ///109 /// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:109 /// @return Array of collection limits110 /// "accountTokenOwnershipLimit",111 /// "sponsoredDataSize",112 /// "sponsoredDataRateLimit",113 /// "tokenLimit",114 /// "sponsorTransferTimeout",115 /// "sponsorApproveTimeout"116 /// "ownerCanTransfer",117 /// "ownerCanDestroy",118 /// "transfersEnabled"119 /// Return `false` if a limit not set.120 /// @dev EVM selector for this function is: 0xf63bc572,110 /// @dev EVM selector for this function is: 0xf63bc572,121 /// or in textual repr: collectionLimits()111 /// or in textual repr: collectionLimits()122 function collectionLimits() external view returns (Tuple21[] memory);112 function collectionLimits() external view returns (CollectionLimit[] memory);123113124 /// Set limits for the collection.114 /// Set limits for the collection.125 /// @dev Throws error if limit not found.115 /// @dev Throws error if limit not found.126 /// @param limit Name of the limit. Valid names:127 /// "accountTokenOwnershipLimit",128 /// "sponsoredDataSize",129 /// "sponsoredDataRateLimit",130 /// "tokenLimit",131 /// "sponsorTransferTimeout",132 /// "sponsorApproveTimeout"133 /// "ownerCanTransfer",134 /// "ownerCanDestroy",135 /// "transfersEnabled"136 /// @param status enable\disable limit. Works only with `true`.137 /// @param value Value of the limit.116 /// @param limit Some limit.138 /// @dev EVM selector for this function is: 0x88150bd0,117 /// @dev EVM selector for this function is: 0x2a2235e7,139 /// or in textual repr: setCollectionLimit(uint8,bool,uint256)118 /// or in textual repr: setCollectionLimit((uint8,bool,uint256))140 function setCollectionLimit(119 function setCollectionLimit(CollectionLimit memory limit) external;141 CollectionLimits limit,142 bool status,143 uint256 value144 ) external;145120146 /// Get contract address.121 /// Get contract address.330 uint256[] field_1;305 uint256[] field_1;331}306}307308struct CollectionLimit {309 CollectionLimitField field;310 bool status;311 uint256 value;312}332313333/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.314/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.334enum CollectionLimits {315enum CollectionLimitField {335 /// @dev How many tokens can a user have on one account.316 /// @dev How many tokens can a user have on one account.336 AccountTokenOwnership,317 AccountTokenOwnership,337 /// @dev How many bytes of data are available for sponsorship.318 /// @dev How many bytes of data are available for sponsorship.352 TransferEnabled333 TransferEnabled353}334}354355/// @dev anonymous struct356struct Tuple21 {357 CollectionLimits field_0;358 bool field_1;359 uint256 field_2;360}361335362/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).336/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).363struct Property {337struct Property {tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth99/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.99/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.100struct PropertyPermission {100struct PropertyPermission {101 /// @dev TokenPermission field.101 /// @dev TokenPermission field.102 EthTokenPermissions code;102 TokenPermissionField code;103 /// @dev TokenPermission value.103 /// @dev TokenPermission value.104 bool value;104 bool value;105}105}106106107/// @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.108enum EthTokenPermissions {108enum TokenPermissionField {109 /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]109 /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]110 Mutable,110 Mutable,111 /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]111 /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]115}115}116116117/// @title A contract that allows you to work with collections.117/// @title A contract that allows you to work with collections.118/// @dev the ERC-165 identifier for this interface is 0x81172a75118/// @dev the ERC-165 identifier for this interface is 0x23201442119interface Collection is Dummy, ERC165 {119interface Collection is Dummy, ERC165 {120 // /// Set collection property.120 // /// Set collection property.121 // ///121 // ///208208209 /// Get current collection limits.209 /// Get current collection limits.210 ///210 ///211 /// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:211 /// @return Array of collection limits212 /// "accountTokenOwnershipLimit",213 /// "sponsoredDataSize",214 /// "sponsoredDataRateLimit",215 /// "tokenLimit",216 /// "sponsorTransferTimeout",217 /// "sponsorApproveTimeout"218 /// "ownerCanTransfer",219 /// "ownerCanDestroy",220 /// "transfersEnabled"221 /// Return `false` if a limit not set.222 /// @dev EVM selector for this function is: 0xf63bc572,212 /// @dev EVM selector for this function is: 0xf63bc572,223 /// or in textual repr: collectionLimits()213 /// or in textual repr: collectionLimits()224 function collectionLimits() external view returns (Tuple31[] memory);214 function collectionLimits() external view returns (CollectionLimit[] memory);225215226 /// Set limits for the collection.216 /// Set limits for the collection.227 /// @dev Throws error if limit not found.217 /// @dev Throws error if limit not found.228 /// @param limit Name of the limit. Valid names:229 /// "accountTokenOwnershipLimit",230 /// "sponsoredDataSize",231 /// "sponsoredDataRateLimit",232 /// "tokenLimit",233 /// "sponsorTransferTimeout",234 /// "sponsorApproveTimeout"235 /// "ownerCanTransfer",236 /// "ownerCanDestroy",237 /// "transfersEnabled"238 /// @param status enable\disable limit. Works only with `true`.239 /// @param value Value of the limit.218 /// @param limit Some limit.240 /// @dev EVM selector for this function is: 0x88150bd0,219 /// @dev EVM selector for this function is: 0x2a2235e7,241 /// or in textual repr: setCollectionLimit(uint8,bool,uint256)220 /// or in textual repr: setCollectionLimit((uint8,bool,uint256))242 function setCollectionLimit(221 function setCollectionLimit(CollectionLimit memory limit) external;243 CollectionLimits limit,244 bool status,245 uint256 value246 ) external;247222248 /// Get contract address.223 /// Get contract address.432 uint256[] field_1;407 uint256[] field_1;433}408}409410struct CollectionLimit {411 CollectionLimitField field;412 bool status;413 uint256 value;414}434415435/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.416/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.436enum CollectionLimits {417enum CollectionLimitField {437 /// @dev How many tokens can a user have on one account.418 /// @dev How many tokens can a user have on one account.438 AccountTokenOwnership,419 AccountTokenOwnership,439 /// @dev How many bytes of data are available for sponsorship.420 /// @dev How many bytes of data are available for sponsorship.454 TransferEnabled435 TransferEnabled455}436}456457/// @dev anonymous struct458struct Tuple31 {459 CollectionLimits field_0;460 bool field_1;461 uint256 field_2;462}463437464/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension438/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension465/// @dev See https://eips.ethereum.org/EIPS/eip-721439/// @dev See https://eips.ethereum.org/EIPS/eip-721tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth99/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.99/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.100struct PropertyPermission {100struct PropertyPermission {101 /// @dev TokenPermission field.101 /// @dev TokenPermission field.102 EthTokenPermissions code;102 TokenPermissionField code;103 /// @dev TokenPermission value.103 /// @dev TokenPermission value.104 bool value;104 bool value;105}105}106106107/// @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.108enum EthTokenPermissions {108enum TokenPermissionField {109 /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]109 /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]110 Mutable,110 Mutable,111 /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]111 /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]115}115}116116117/// @title A contract that allows you to work with collections.117/// @title A contract that allows you to work with collections.118/// @dev the ERC-165 identifier for this interface is 0x81172a75118/// @dev the ERC-165 identifier for this interface is 0x23201442119interface Collection is Dummy, ERC165 {119interface Collection is Dummy, ERC165 {120 // /// Set collection property.120 // /// Set collection property.121 // ///121 // ///208208209 /// Get current collection limits.209 /// Get current collection limits.210 ///210 ///211 /// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:211 /// @return Array of collection limits212 /// "accountTokenOwnershipLimit",213 /// "sponsoredDataSize",214 /// "sponsoredDataRateLimit",215 /// "tokenLimit",216 /// "sponsorTransferTimeout",217 /// "sponsorApproveTimeout"218 /// "ownerCanTransfer",219 /// "ownerCanDestroy",220 /// "transfersEnabled"221 /// Return `false` if a limit not set.222 /// @dev EVM selector for this function is: 0xf63bc572,212 /// @dev EVM selector for this function is: 0xf63bc572,223 /// or in textual repr: collectionLimits()213 /// or in textual repr: collectionLimits()224 function collectionLimits() external view returns (Tuple30[] memory);214 function collectionLimits() external view returns (CollectionLimit[] memory);225215226 /// Set limits for the collection.216 /// Set limits for the collection.227 /// @dev Throws error if limit not found.217 /// @dev Throws error if limit not found.228 /// @param limit Name of the limit. Valid names:229 /// "accountTokenOwnershipLimit",230 /// "sponsoredDataSize",231 /// "sponsoredDataRateLimit",232 /// "tokenLimit",233 /// "sponsorTransferTimeout",234 /// "sponsorApproveTimeout"235 /// "ownerCanTransfer",236 /// "ownerCanDestroy",237 /// "transfersEnabled"238 /// @param status enable\disable limit. Works only with `true`.239 /// @param value Value of the limit.218 /// @param limit Some limit.240 /// @dev EVM selector for this function is: 0x88150bd0,219 /// @dev EVM selector for this function is: 0x2a2235e7,241 /// or in textual repr: setCollectionLimit(uint8,bool,uint256)220 /// or in textual repr: setCollectionLimit((uint8,bool,uint256))242 function setCollectionLimit(221 function setCollectionLimit(CollectionLimit memory limit) external;243 CollectionLimits limit,244 bool status,245 uint256 value246 ) external;247222248 /// Get contract address.223 /// Get contract address.432 uint256[] field_1;407 uint256[] field_1;433}408}409410struct CollectionLimit {411 CollectionLimitField field;412 bool status;413 uint256 value;414}434415435/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.416/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.436enum CollectionLimits {417enum CollectionLimitField {437 /// @dev How many tokens can a user have on one account.418 /// @dev How many tokens can a user have on one account.438 AccountTokenOwnership,419 AccountTokenOwnership,439 /// @dev How many bytes of data are available for sponsorship.420 /// @dev How many bytes of data are available for sponsorship.454 TransferEnabled435 TransferEnabled455}436}456457/// @dev anonymous struct458struct Tuple30 {459 CollectionLimits field_0;460 bool field_1;461 uint256 field_2;462}463437464/// @dev the ERC-165 identifier for this interface is 0x5b5e139f438/// @dev the ERC-165 identifier for this interface is 0x5b5e139f465interface ERC721Metadata is Dummy, ERC165 {439interface ERC721Metadata is Dummy, ERC165 {tests/src/eth/collectionLimits.test.tsdiffbeforeafterboth1import {IKeyringPair} from '@polkadot/types/types';1import {IKeyringPair} from '@polkadot/types/types';2import {Pallets} from '../util';2import {Pallets} from '../util';3import {expect, itEth, usingEthPlaygrounds} from './util';3import {expect, itEth, usingEthPlaygrounds} from './util';4import {CollectionLimits} from './util/playgrounds/types';4import {CollectionLimitField} from './util/playgrounds/types';55667describe('Can set collection limits', () => {7describe('Can set collection limits', () => {46 };46 };47 47 48 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);48 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);49 await collectionEvm.methods.setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();49 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: limits.accountTokenOwnershipLimit}).send();50 await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();50 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsoredDataSize, status: true, value: limits.sponsoredDataSize}).send();51 await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();51 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsoredDataRateLimit, status: true, value: limits.sponsoredDataRateLimit}).send();52 await collectionEvm.methods.setCollectionLimit(CollectionLimits.TokenLimit, true, limits.tokenLimit).send();52 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.TokenLimit, status: true, value: limits.tokenLimit}).send();53 await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsorTransferTimeout, true, limits.sponsorTransferTimeout).send();53 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsorTransferTimeout, status: true, value: limits.sponsorTransferTimeout}).send();54 await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsorApproveTimeout, true, limits.sponsorApproveTimeout).send();54 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsorApproveTimeout, status: true, value: limits.sponsorApproveTimeout}).send();55 await collectionEvm.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, limits.ownerCanTransfer).send();55 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.OwnerCanTransfer, status: true, value: limits.ownerCanTransfer}).send();56 await collectionEvm.methods.setCollectionLimit(CollectionLimits.OwnerCanDestroy, true, limits.ownerCanDestroy).send();56 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.OwnerCanDestroy, status: true, value: limits.ownerCanDestroy}).send();57 await collectionEvm.methods.setCollectionLimit(CollectionLimits.TransferEnabled, true, limits.transfersEnabled).send();57 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.TransferEnabled, status: true, value: limits.transfersEnabled}).send();58 58 59 // Check limits from sub:59 // Check limits from sub:60 const data = (await helper.rft.getData(collectionId))!;60 const data = (await helper.rft.getData(collectionId))!;63 // Check limits from eth:63 // Check limits from eth:64 const limitsEvm = await collectionEvm.methods.collectionLimits().call({from: owner});64 const limitsEvm = await collectionEvm.methods.collectionLimits().call({from: owner});65 expect(limitsEvm).to.have.length(9);65 expect(limitsEvm).to.have.length(9);66 expect(limitsEvm[0]).to.deep.eq([CollectionLimits.AccountTokenOwnership.toString(), true, limits.accountTokenOwnershipLimit.toString()]);66 expect(limitsEvm[0]).to.deep.eq([CollectionLimitField.AccountTokenOwnership.toString(), true, limits.accountTokenOwnershipLimit.toString()]);67 expect(limitsEvm[1]).to.deep.eq([CollectionLimits.SponsoredDataSize.toString(), true, limits.sponsoredDataSize.toString()]);67 expect(limitsEvm[1]).to.deep.eq([CollectionLimitField.SponsoredDataSize.toString(), true, limits.sponsoredDataSize.toString()]);68 expect(limitsEvm[2]).to.deep.eq([CollectionLimits.SponsoredDataRateLimit.toString(), true, limits.sponsoredDataRateLimit.toString()]);68 expect(limitsEvm[2]).to.deep.eq([CollectionLimitField.SponsoredDataRateLimit.toString(), true, limits.sponsoredDataRateLimit.toString()]);69 expect(limitsEvm[3]).to.deep.eq([CollectionLimits.TokenLimit.toString(), true, limits.tokenLimit.toString()]);69 expect(limitsEvm[3]).to.deep.eq([CollectionLimitField.TokenLimit.toString(), true, limits.tokenLimit.toString()]);70 expect(limitsEvm[4]).to.deep.eq([CollectionLimits.SponsorTransferTimeout.toString(), true, limits.sponsorTransferTimeout.toString()]);70 expect(limitsEvm[4]).to.deep.eq([CollectionLimitField.SponsorTransferTimeout.toString(), true, limits.sponsorTransferTimeout.toString()]);71 expect(limitsEvm[5]).to.deep.eq([CollectionLimits.SponsorApproveTimeout.toString(), true, limits.sponsorApproveTimeout.toString()]);71 expect(limitsEvm[5]).to.deep.eq([CollectionLimitField.SponsorApproveTimeout.toString(), true, limits.sponsorApproveTimeout.toString()]);72 expect(limitsEvm[6]).to.deep.eq([CollectionLimits.OwnerCanTransfer.toString(), true, limits.ownerCanTransfer.toString()]);72 expect(limitsEvm[6]).to.deep.eq([CollectionLimitField.OwnerCanTransfer.toString(), true, limits.ownerCanTransfer.toString()]);73 expect(limitsEvm[7]).to.deep.eq([CollectionLimits.OwnerCanDestroy.toString(), true, limits.ownerCanDestroy.toString()]);73 expect(limitsEvm[7]).to.deep.eq([CollectionLimitField.OwnerCanDestroy.toString(), true, limits.ownerCanDestroy.toString()]);74 expect(limitsEvm[8]).to.deep.eq([CollectionLimits.TransferEnabled.toString(), true, limits.transfersEnabled.toString()]);74 expect(limitsEvm[8]).to.deep.eq([CollectionLimitField.TransferEnabled.toString(), true, limits.transfersEnabled.toString()]);75 }));75 }));76});76});7777101101102 // Cannot set non-existing limit102 // Cannot set non-existing limit103 await expect(collectionEvm.methods103 await expect(collectionEvm.methods104 .setCollectionLimit(9, true, 1)104 .setCollectionLimit({field: 9, status: true, value: 1})105 .call()).to.be.rejectedWith('Returned error: VM Exception while processing transaction: revert Value not convertible into enum "CollectionLimits"'); 105 .call()).to.be.rejectedWith('Value not convertible into enum "CollectionLimitField"'); 106 106 107 // Cannot disable limits107 // Cannot disable limits108 await expect(collectionEvm.methods108 await expect(collectionEvm.methods109 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, false, 200)109 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: false, value: 200})110 .call()).to.be.rejectedWith('Returned error: VM Exception while processing transaction: revert user can\'t disable limits');110 .call()).to.be.rejectedWith('user can\'t disable limits');111111112 await expect(collectionEvm.methods112 await expect(collectionEvm.methods113 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, invalidLimits.accountTokenOwnershipLimit)113 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: invalidLimits.accountTokenOwnershipLimit})114 .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);114 .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);115 115 116 await expect(collectionEvm.methods116 await expect(collectionEvm.methods117 .setCollectionLimit(CollectionLimits.TransferEnabled, true, 3)117 .setCollectionLimit({field: CollectionLimitField.TransferEnabled, status: true, value: 3})118 .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);118 .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);119119120 expect(() => collectionEvm.methods120 expect(() => collectionEvm.methods121 .setCollectionLimit(CollectionLimits.SponsoredDataSize, true, -1).send()).to.throw('value out-of-bounds');121 .setCollectionLimit({field: CollectionLimitField.SponsoredDataSize, status: true, value: -1}).send()).to.throw('value out-of-bounds');122 }));122 }));123123124 [124 [133133134 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);134 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);135 await expect(collectionEvm.methods135 await expect(collectionEvm.methods136 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)136 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})137 .call({from: nonOwner}))137 .call({from: nonOwner}))138 .to.be.rejectedWith('NoPermission');138 .to.be.rejectedWith('NoPermission');139139140 await expect(collectionEvm.methods140 await expect(collectionEvm.methods141 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)141 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})142 .send({from: nonOwner}))142 .send({from: nonOwner}))143 .to.be.rejected;143 .to.be.rejected;144 }));144 }));tests/src/eth/createFTCollection.test.tsdiffbeforeafterboth18import {evmToAddress} from '@polkadot/util-crypto';18import {evmToAddress} from '@polkadot/util-crypto';19import {Pallets, requirePalletsOrSkip} from '../util';19import {Pallets, requirePalletsOrSkip} from '../util';20import {expect, itEth, usingEthPlaygrounds} from './util';20import {expect, itEth, usingEthPlaygrounds} from './util';21import { CollectionLimits } from './util/playgrounds/types';21import {CollectionLimitField} from './util/playgrounds/types';222223const DECIMALS = 18;23const DECIMALS = 18;2424197 }197 }198 {198 {199 await expect(peasantCollection.methods199 await expect(peasantCollection.methods200 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)200 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})201 .call()).to.be.rejectedWith(EXPECTED_ERROR);201 .call()).to.be.rejectedWith(EXPECTED_ERROR);202 }202 }203 });203 });222 }222 }223 {223 {224 await expect(peasantCollection.methods224 await expect(peasantCollection.methods225 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)225 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})226 .call()).to.be.rejectedWith(EXPECTED_ERROR);226 .call()).to.be.rejectedWith(EXPECTED_ERROR);227 }227 }228 }); 228 }); tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth17import {evmToAddress} from '@polkadot/util-crypto';17import {evmToAddress} from '@polkadot/util-crypto';18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import {expect, itEth, usingEthPlaygrounds} from './util';19import {expect, itEth, usingEthPlaygrounds} from './util';20import { CollectionLimits } from './util/playgrounds/types';20import {CollectionLimitField} from './util/playgrounds/types';2121222223describe('Create NFT collection from EVM', () => {23describe('Create NFT collection from EVM', () => {208 }208 }209 {209 {210 await expect(malfeasantCollection.methods210 await expect(malfeasantCollection.methods211 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)211 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})212 .call()).to.be.rejectedWith(EXPECTED_ERROR);212 .call()).to.be.rejectedWith(EXPECTED_ERROR);213 }213 }214 });214 });233 }233 }234 {234 {235 await expect(malfeasantCollection.methods235 await expect(malfeasantCollection.methods236 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)236 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})237 .call()).to.be.rejectedWith(EXPECTED_ERROR);237 .call()).to.be.rejectedWith(EXPECTED_ERROR);238 }238 }239 });239 });tests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import {Pallets, requirePalletsOrSkip} from '../util';19import {Pallets, requirePalletsOrSkip} from '../util';20import {expect, itEth, usingEthPlaygrounds} from './util';20import {expect, itEth, usingEthPlaygrounds} from './util';21import {CollectionLimits} from './util/playgrounds/types';21import {CollectionLimitField} from './util/playgrounds/types';2222232324describe('Create RFT collection from EVM', () => {24describe('Create RFT collection from EVM', () => {240 }240 }241 {241 {242 await expect(peasantCollection.methods242 await expect(peasantCollection.methods243 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)243 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})244 .call()).to.be.rejectedWith(EXPECTED_ERROR);244 .call()).to.be.rejectedWith(EXPECTED_ERROR);245 }245 }246 });246 });265 }265 }266 {266 {267 await expect(peasantCollection.methods267 await expect(peasantCollection.methods268 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)268 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})269 .call()).to.be.rejectedWith(EXPECTED_ERROR);269 .call()).to.be.rejectedWith(EXPECTED_ERROR);270 }270 }271 });271 });tests/src/eth/events.test.tsdiffbeforeafterboth19import {EthUniqueHelper, itEth, usingEthPlaygrounds} from './util';19import {EthUniqueHelper, itEth, usingEthPlaygrounds} from './util';20import {IEvent, TCollectionMode} from '../util/playgrounds/types';20import {IEvent, TCollectionMode} from '../util/playgrounds/types';21import {Pallets, requirePalletsOrSkip} from '../util';21import {Pallets, requirePalletsOrSkip} from '../util';22import {CollectionLimits, EthTokenPermissions, NormalizedEvent} from './util/playgrounds/types';22import {CollectionLimitField, TokenPermissionField, NormalizedEvent} from './util/playgrounds/types';232324let donor: IKeyringPair;24let donor: IKeyringPair;25 25 121 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['PropertyPermissionSet']}]);121 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['PropertyPermissionSet']}]);122 await collection.methods.setTokenPropertyPermissions([122 await collection.methods.setTokenPropertyPermissions([123 ['A', [123 ['A', [124 [EthTokenPermissions.Mutable, true], 124 [TokenPermissionField.Mutable, true], 125 [EthTokenPermissions.TokenOwner, true], 125 [TokenPermissionField.TokenOwner, true], 126 [EthTokenPermissions.CollectionAdmin, true]],126 [TokenPermissionField.CollectionAdmin, true]],127 ],127 ],128 ]).send({from: owner});128 ]).send({from: owner});129 await helper.wait.newBlocks(1);129 await helper.wait.newBlocks(1);233 });233 });234 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionLimitSet']}]);234 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionLimitSet']}]);235 {235 {236 await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, 0).send({from: owner});236 await collection.methods.setCollectionLimit({field: CollectionLimitField.OwnerCanTransfer, status: true, value: 0}).send({from: owner});237 await helper.wait.newBlocks(1);237 await helper.wait.newBlocks(1);238 expect(ethEvents).to.containSubset([238 expect(ethEvents).to.containSubset([239 {239 {379 const tokenId = result.events.Transfer.returnValues.tokenId;379 const tokenId = result.events.Transfer.returnValues.tokenId;380 await collection.methods.setTokenPropertyPermissions([380 await collection.methods.setTokenPropertyPermissions([381 ['A', [381 ['A', [382 [EthTokenPermissions.Mutable, true], 382 [TokenPermissionField.Mutable, true], 383 [EthTokenPermissions.TokenOwner, true], 383 [TokenPermissionField.TokenOwner, true], 384 [EthTokenPermissions.CollectionAdmin, true]],384 [TokenPermissionField.CollectionAdmin, true]],385 ],385 ],386 ]).send({from: owner});386 ]).send({from: owner});387387tests/src/eth/tokenProperties.test.tsdiffbeforeafterboth20import {ITokenPropertyPermission} from '../util/playgrounds/types';20import {ITokenPropertyPermission} from '../util/playgrounds/types';21import {Pallets} from '../util';21import {Pallets} from '../util';22import {UniqueNFTCollection, UniqueNFToken, UniqueRFTCollection} from '../util/playgrounds/unique';22import {UniqueNFTCollection, UniqueNFToken, UniqueRFTCollection} from '../util/playgrounds/unique';23import {EthTokenPermissions} from './util/playgrounds/types';23import {TokenPermissionField} from './util/playgrounds/types';242425describe('EVM token properties', () => {25describe('EVM token properties', () => {26 let donor: IKeyringPair;26 let donor: IKeyringPair;474748 await collection.methods.setTokenPropertyPermissions([48 await collection.methods.setTokenPropertyPermissions([49 ['testKey', [49 ['testKey', [50 [EthTokenPermissions.Mutable, mutable], 50 [TokenPermissionField.Mutable, mutable], 51 [EthTokenPermissions.TokenOwner, tokenOwner], 51 [TokenPermissionField.TokenOwner, tokenOwner], 52 [EthTokenPermissions.CollectionAdmin, collectionAdmin]],52 [TokenPermissionField.CollectionAdmin, collectionAdmin]],53 ],53 ],54 ]).send({from: caller.eth});54 ]).send({from: caller.eth});55 55 606061 expect(await collection.methods.tokenPropertyPermissions().call({from: caller.eth})).to.be.like([61 expect(await collection.methods.tokenPropertyPermissions().call({from: caller.eth})).to.be.like([62 ['testKey', [62 ['testKey', [63 [EthTokenPermissions.Mutable.toString(), mutable], 63 [TokenPermissionField.Mutable.toString(), mutable], 64 [EthTokenPermissions.TokenOwner.toString(), tokenOwner], 64 [TokenPermissionField.TokenOwner.toString(), tokenOwner], 65 [EthTokenPermissions.CollectionAdmin.toString(), collectionAdmin]],65 [TokenPermissionField.CollectionAdmin.toString(), collectionAdmin]],66 ],66 ],67 ]);67 ]);68 }68 }808081 await collection.methods.setTokenPropertyPermissions([81 await collection.methods.setTokenPropertyPermissions([82 ['testKey_0', [82 ['testKey_0', [83 [EthTokenPermissions.Mutable, true], 83 [TokenPermissionField.Mutable, true], 84 [EthTokenPermissions.TokenOwner, true], 84 [TokenPermissionField.TokenOwner, true], 85 [EthTokenPermissions.CollectionAdmin, true]],85 [TokenPermissionField.CollectionAdmin, true]],86 ],86 ],87 ['testKey_1', [87 ['testKey_1', [88 [EthTokenPermissions.Mutable, true], 88 [TokenPermissionField.Mutable, true], 89 [EthTokenPermissions.TokenOwner, false], 89 [TokenPermissionField.TokenOwner, false], 90 [EthTokenPermissions.CollectionAdmin, true]],90 [TokenPermissionField.CollectionAdmin, true]],91 ],91 ],92 ['testKey_2', [92 ['testKey_2', [93 [EthTokenPermissions.Mutable, false], 93 [TokenPermissionField.Mutable, false], 94 [EthTokenPermissions.TokenOwner, true], 94 [TokenPermissionField.TokenOwner, true], 95 [EthTokenPermissions.CollectionAdmin, false]],95 [TokenPermissionField.CollectionAdmin, false]],96 ],96 ],97 ]).send({from: owner});97 ]).send({from: owner});98 98 113113114 expect(await collection.methods.tokenPropertyPermissions().call({from: owner})).to.be.like([114 expect(await collection.methods.tokenPropertyPermissions().call({from: owner})).to.be.like([115 ['testKey_0', [115 ['testKey_0', [116 [EthTokenPermissions.Mutable.toString(), true], 116 [TokenPermissionField.Mutable.toString(), true], 117 [EthTokenPermissions.TokenOwner.toString(), true], 117 [TokenPermissionField.TokenOwner.toString(), true], 118 [EthTokenPermissions.CollectionAdmin.toString(), true]],118 [TokenPermissionField.CollectionAdmin.toString(), true]],119 ],119 ],120 ['testKey_1', [120 ['testKey_1', [121 [EthTokenPermissions.Mutable.toString(), true], 121 [TokenPermissionField.Mutable.toString(), true], 122 [EthTokenPermissions.TokenOwner.toString(), false], 122 [TokenPermissionField.TokenOwner.toString(), false], 123 [EthTokenPermissions.CollectionAdmin.toString(), true]],123 [TokenPermissionField.CollectionAdmin.toString(), true]],124 ],124 ],125 ['testKey_2', [125 ['testKey_2', [126 [EthTokenPermissions.Mutable.toString(), false], 126 [TokenPermissionField.Mutable.toString(), false], 127 [EthTokenPermissions.TokenOwner.toString(), true], 127 [TokenPermissionField.TokenOwner.toString(), true], 128 [EthTokenPermissions.CollectionAdmin.toString(), false]],128 [TokenPermissionField.CollectionAdmin.toString(), false]],129 ],129 ],130 ]);130 ]);131 }));131 }));144144145 await collection.methods.setTokenPropertyPermissions([145 await collection.methods.setTokenPropertyPermissions([146 ['testKey_0', [146 ['testKey_0', [147 [EthTokenPermissions.Mutable, true], 147 [TokenPermissionField.Mutable, true], 148 [EthTokenPermissions.TokenOwner, true], 148 [TokenPermissionField.TokenOwner, true], 149 [EthTokenPermissions.CollectionAdmin, true]],149 [TokenPermissionField.CollectionAdmin, true]],150 ],150 ],151 ['testKey_1', [151 ['testKey_1', [152 [EthTokenPermissions.Mutable, true], 152 [TokenPermissionField.Mutable, true], 153 [EthTokenPermissions.TokenOwner, false], 153 [TokenPermissionField.TokenOwner, false], 154 [EthTokenPermissions.CollectionAdmin, true]],154 [TokenPermissionField.CollectionAdmin, true]],155 ],155 ],156 ['testKey_2', [156 ['testKey_2', [157 [EthTokenPermissions.Mutable, false], 157 [TokenPermissionField.Mutable, false], 158 [EthTokenPermissions.TokenOwner, true], 158 [TokenPermissionField.TokenOwner, true], 159 [EthTokenPermissions.CollectionAdmin, false]],159 [TokenPermissionField.CollectionAdmin, false]],160 ],160 ],161 ]).send({from: caller.eth});161 ]).send({from: caller.eth});162 162 177177178 expect(await collection.methods.tokenPropertyPermissions().call({from: caller.eth})).to.be.like([178 expect(await collection.methods.tokenPropertyPermissions().call({from: caller.eth})).to.be.like([179 ['testKey_0', [179 ['testKey_0', [180 [EthTokenPermissions.Mutable.toString(), true], 180 [TokenPermissionField.Mutable.toString(), true], 181 [EthTokenPermissions.TokenOwner.toString(), true], 181 [TokenPermissionField.TokenOwner.toString(), true], 182 [EthTokenPermissions.CollectionAdmin.toString(), true]],182 [TokenPermissionField.CollectionAdmin.toString(), true]],183 ],183 ],184 ['testKey_1', [184 ['testKey_1', [185 [EthTokenPermissions.Mutable.toString(), true], 185 [TokenPermissionField.Mutable.toString(), true], 186 [EthTokenPermissions.TokenOwner.toString(), false], 186 [TokenPermissionField.TokenOwner.toString(), false], 187 [EthTokenPermissions.CollectionAdmin.toString(), true]],187 [TokenPermissionField.CollectionAdmin.toString(), true]],188 ],188 ],189 ['testKey_2', [189 ['testKey_2', [190 [EthTokenPermissions.Mutable.toString(), false], 190 [TokenPermissionField.Mutable.toString(), false], 191 [EthTokenPermissions.TokenOwner.toString(), true], 191 [TokenPermissionField.TokenOwner.toString(), true], 192 [EthTokenPermissions.CollectionAdmin.toString(), false]],192 [TokenPermissionField.CollectionAdmin.toString(), false]],193 ],193 ],194 ]);194 ]);195 195 460 460 461 await expect(collection.methods.setTokenPropertyPermissions([461 await expect(collection.methods.setTokenPropertyPermissions([462 ['testKey_0', [462 ['testKey_0', [463 [EthTokenPermissions.Mutable, true], 463 [TokenPermissionField.Mutable, true], 464 [EthTokenPermissions.TokenOwner, true], 464 [TokenPermissionField.TokenOwner, true], 465 [EthTokenPermissions.CollectionAdmin, true]],465 [TokenPermissionField.CollectionAdmin, true]],466 ],466 ],467 ]).call({from: caller})).to.be.rejectedWith('NoPermission'); 467 ]).call({from: caller})).to.be.rejectedWith('NoPermission'); 468 }));468 }));480 await expect(collection.methods.setTokenPropertyPermissions([480 await expect(collection.methods.setTokenPropertyPermissions([481 // "Space" is invalid character481 // "Space" is invalid character482 ['testKey 0', [482 ['testKey 0', [483 [EthTokenPermissions.Mutable, true], 483 [TokenPermissionField.Mutable, true], 484 [EthTokenPermissions.TokenOwner, true], 484 [TokenPermissionField.TokenOwner, true], 485 [EthTokenPermissions.CollectionAdmin, true]],485 [TokenPermissionField.CollectionAdmin, true]],486 ],486 ],487 ]).call({from: owner})).to.be.rejectedWith('InvalidCharacterInPropertyKey'); 487 ]).call({from: owner})).to.be.rejectedWith('InvalidCharacterInPropertyKey'); 488 }));488 }));tests/src/eth/util/playgrounds/types.tsdiffbeforeafterboth202021export type EthProperty = string[];21export type EthProperty = string[];222223export enum EthTokenPermissions {23export enum TokenPermissionField {24 Mutable,24 Mutable,25 TokenOwner,25 TokenOwner,26 CollectionAdmin26 CollectionAdmin27}27}28export enum CollectionLimits {28export enum CollectionLimitField {29 AccountTokenOwnership,29 AccountTokenOwnership,30 SponsoredDataSize,30 SponsoredDataSize,31 SponsoredDataRateLimit,31 SponsoredDataRateLimit,37 TransferEnabled37 TransferEnabled38}38}3940export interface EthCollectionLimit {41 field: CollectionLimitField,42 status: boolean,43 value: bigint,44}3945