difftreelog
feat add evm OptionUint type
in: master
19 files changed
pallets/common/src/eth.rsdiffbeforeafterboth66 T::CrossAccountId::from_sub(account_id)66 T::CrossAccountId::from_sub(account_id)67}67}6869/// Ethereum representation of Optional value with uint256.70#[derive(Debug, Default, AbiCoder)]71pub struct OptionUint {72 status: bool,73 value: uint256,74}7576impl From<u32> for OptionUint {77 fn from(value: u32) -> Self {78 Self {79 status: true,80 value: uint256::from(value),81 }82 }83}8485impl From<Option<u32>> for OptionUint {86 fn from(value: Option<u32>) -> Self {87 match value {88 Some(value) => Self {89 status: true,90 value: value.into(),91 },92 None => Self {93 status: false,94 value: Default::default(),95 },96 }97 }98}99100impl From<Option<bool>> for OptionUint {101 fn from(value: Option<bool>) -> Self {102 match value {103 Some(value) => Self {104 status: true,105 value: if value {106 uint256::from(1)107 } else {108 Default::default()109 },110 },111 None => Self {112 status: false,113 value: Default::default(),114 },115 }116 }117}6811869/// Cross account struct119/// Cross account struct70#[derive(Debug, Default, AbiCoder)]120#[derive(Debug, Default, AbiCoder)]164#[derive(Debug, Default, AbiCoder)]214#[derive(Debug, Default, AbiCoder)]165pub struct CollectionLimit {215pub struct CollectionLimit {166 field: CollectionLimitField,216 field: CollectionLimitField,167 status: bool,168 value: uint256,217 value: OptionUint,169}218}170219171impl CollectionLimit {220impl CollectionLimit {172 /// Make [`CollectionLimit`] from [`CollectionLimitField`] and int value.221 /// Make [`CollectionLimit`] from [`CollectionLimitField`] and int value.173 pub fn from_int(field: CollectionLimitField, value: u32) -> Self {222 pub fn from_int(field: CollectionLimitField, value: u32) -> Self {174 Self {223 Self {175 field,224 field,176 status: true,177 value: value.into(),225 value: value.into(),178 }226 }179 }227 }180228181 /// Make [`CollectionLimit`] from [`CollectionLimitField`] and optional int value.229 /// Make [`CollectionLimit`] from [`CollectionLimitField`] and optional int value.182 pub fn from_opt_int(field: CollectionLimitField, value: Option<u32>) -> Self {230 pub fn from_opt_int(field: CollectionLimitField, value: Option<u32>) -> Self {183 value184 .map(|v| Self {231 Self {185 field,232 field,186 status: true,187 value: v.into(),233 value: value.into(),188 })234 }189 .unwrap_or(Self {190 field,191 status: false,192 value: Default::default(),193 })194 }235 }195236196 /// Make [`CollectionLimit`] from [`CollectionLimitField`] and bool value.237 /// Make [`CollectionLimit`] from [`CollectionLimitField`] and bool value.197 pub fn from_opt_bool(field: CollectionLimitField, value: Option<bool>) -> Self {238 pub fn from_opt_bool(field: CollectionLimitField, value: Option<bool>) -> Self {198 value199 .map(|v| Self {200 field,201 status: true,202 value: if v {203 uint256::from(1)204 } else {205 Default::default()206 },207 })208 .unwrap_or(Self {239 Self {209 field,240 field,210 status: false,211 value: Default::default(),241 value: value.into(),212 })242 }213 }243 }214}244}215245216impl TryInto<up_data_structs::CollectionLimits> for CollectionLimit {246impl TryInto<up_data_structs::CollectionLimits> for CollectionLimit {217 type Error = evm_coder::execution::Error;247 type Error = evm_coder::execution::Error;218248219 fn try_into(self) -> Result<up_data_structs::CollectionLimits, Self::Error> {249 fn try_into(self) -> Result<up_data_structs::CollectionLimits, Self::Error> {220 if !self.status {250 if !self.value.status {221 return Err(Self::Error::Revert("user can't disable limits".into()));251 return Err(Self::Error::Revert("user can't disable limits".into()));222 }252 }223253224 let value = self.value.try_into().map_err(|error| {254 let value = self.value.value.try_into().map_err(|error| {225 Self::Error::Revert(format!(255 Self::Error::Revert(format!(226 "can't convert value to u32 \"{}\" because: \"{error}\"",256 "can't convert value to u32 \"{}\" because: \"{error}\"",227 self.value257 self.value.value228 ))258 ))229 })?;259 })?;230260pallets/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 0x2320144221/// @dev the ERC-165 identifier for this interface is 0x2a14cfd122contract Collection is Dummy, ERC165 {22contract Collection is Dummy, ERC165 {23 // /// Set collection property.23 // /// Set collection property.24 // ///24 // ///172 /// Set limits for the collection.172 /// Set limits for the collection.173 /// @dev Throws error if limit not found.173 /// @dev Throws error if limit not found.174 /// @param limit Some limit.174 /// @param limit Some limit.175 /// @dev EVM selector for this function is: 0x2a2235e7,175 /// @dev EVM selector for this function is: 0x2316ee74,176 /// or in textual repr: setCollectionLimit((uint8,bool,uint256))176 /// or in textual repr: setCollectionLimit((uint8,(bool,uint256)))177 function setCollectionLimit(CollectionLimit memory limit) public {177 function setCollectionLimit(CollectionLimit memory limit) public {178 require(false, stub_error);178 require(false, stub_error);179 limit;179 limit;257 /// Returns nesting for a collection257 /// Returns nesting for a collection258 /// @dev EVM selector for this function is: 0x22d25bfe,258 /// @dev EVM selector for this function is: 0x22d25bfe,259 /// or in textual repr: collectionNestingRestrictedCollectionIds()259 /// or in textual repr: collectionNestingRestrictedCollectionIds()260 function collectionNestingRestrictedCollectionIds() public view returns (Tuple30 memory) {260 function collectionNestingRestrictedCollectionIds() public view returns (Tuple33 memory) {261 require(false, stub_error);261 require(false, stub_error);262 dummy;262 dummy;263 return Tuple30(false, new uint256[](0));263 return Tuple33(false, new uint256[](0));264 }264 }265265266 /// Returns permissions for a collection266 /// Returns permissions for a collection267 /// @dev EVM selector for this function is: 0x5b2eaf4b,267 /// @dev EVM selector for this function is: 0x5b2eaf4b,268 /// or in textual repr: collectionNestingPermissions()268 /// or in textual repr: collectionNestingPermissions()269 function collectionNestingPermissions() public view returns (Tuple33[] memory) {269 function collectionNestingPermissions() public view returns (Tuple36[] memory) {270 require(false, stub_error);270 require(false, stub_error);271 dummy;271 dummy;272 return new Tuple33[](0);272 return new Tuple36[](0);273 }273 }274274275 /// Set the collection access method.275 /// Set the collection access method.452}452}453453454/// @dev anonymous struct454/// @dev anonymous struct455struct Tuple33 {455struct Tuple36 {456 CollectionPermissions field_0;456 CollectionPermissions field_0;457 bool field_1;457 bool field_1;458}458}459459460/// @dev anonymous struct460/// @dev anonymous struct461struct Tuple30 {461struct Tuple33 {462 bool field_0;462 bool field_0;463 uint256[] field_1;463 uint256[] field_1;464}464}465465466/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.466/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.467struct CollectionLimit {467struct CollectionLimit {468 CollectionLimitField field;468 CollectionLimitField field;469 OptionUint value;470}471472struct OptionUint {469 bool status;473 bool status;470 uint256 value;474 uint256 value;471}475}pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth162}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 0x23201442165/// @dev the ERC-165 identifier for this interface is 0x2a14cfd1166contract Collection is Dummy, ERC165 {166contract Collection is Dummy, ERC165 {167 // /// Set collection property.167 // /// Set collection property.168 // ///168 // ///316 /// Set limits for the collection.316 /// Set limits for the collection.317 /// @dev Throws error if limit not found.317 /// @dev Throws error if limit not found.318 /// @param limit Some limit.318 /// @param limit Some limit.319 /// @dev EVM selector for this function is: 0x2a2235e7,319 /// @dev EVM selector for this function is: 0x2316ee74,320 /// or in textual repr: setCollectionLimit((uint8,bool,uint256))320 /// or in textual repr: setCollectionLimit((uint8,(bool,uint256)))321 function setCollectionLimit(CollectionLimit memory limit) public {321 function setCollectionLimit(CollectionLimit memory limit) public {322 require(false, stub_error);322 require(false, stub_error);323 limit;323 limit;401 /// Returns nesting for a collection401 /// Returns nesting for a collection402 /// @dev EVM selector for this function is: 0x22d25bfe,402 /// @dev EVM selector for this function is: 0x22d25bfe,403 /// or in textual repr: collectionNestingRestrictedCollectionIds()403 /// or in textual repr: collectionNestingRestrictedCollectionIds()404 function collectionNestingRestrictedCollectionIds() public view returns (Tuple42 memory) {404 function collectionNestingRestrictedCollectionIds() public view returns (Tuple45 memory) {405 require(false, stub_error);405 require(false, stub_error);406 dummy;406 dummy;407 return Tuple42(false, new uint256[](0));407 return Tuple45(false, new uint256[](0));408 }408 }409409410 /// Returns permissions for a collection410 /// Returns permissions for a collection411 /// @dev EVM selector for this function is: 0x5b2eaf4b,411 /// @dev EVM selector for this function is: 0x5b2eaf4b,412 /// or in textual repr: collectionNestingPermissions()412 /// or in textual repr: collectionNestingPermissions()413 function collectionNestingPermissions() public view returns (Tuple45[] memory) {413 function collectionNestingPermissions() public view returns (Tuple48[] memory) {414 require(false, stub_error);414 require(false, stub_error);415 dummy;415 dummy;416 return new Tuple45[](0);416 return new Tuple48[](0);417 }417 }418418419 /// Set the collection access method.419 /// Set the collection access method.596}596}597597598/// @dev anonymous struct598/// @dev anonymous struct599struct Tuple45 {599struct Tuple48 {600 CollectionPermissions field_0;600 CollectionPermissions field_0;601 bool field_1;601 bool field_1;602}602}603603604/// @dev anonymous struct604/// @dev anonymous struct605struct Tuple42 {605struct Tuple45 {606 bool field_0;606 bool field_0;607 uint256[] field_1;607 uint256[] field_1;608}608}609609610/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.610/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.611struct CollectionLimit {611struct CollectionLimit {612 CollectionLimitField field;612 CollectionLimitField field;613 OptionUint value;614}615616struct OptionUint {613 bool status;617 bool status;614 uint256 value;618 uint256 value;615}619}pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth162}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 0x23201442165/// @dev the ERC-165 identifier for this interface is 0x2a14cfd1166contract Collection is Dummy, ERC165 {166contract Collection is Dummy, ERC165 {167 // /// Set collection property.167 // /// Set collection property.168 // ///168 // ///316 /// Set limits for the collection.316 /// Set limits for the collection.317 /// @dev Throws error if limit not found.317 /// @dev Throws error if limit not found.318 /// @param limit Some limit.318 /// @param limit Some limit.319 /// @dev EVM selector for this function is: 0x2a2235e7,319 /// @dev EVM selector for this function is: 0x2316ee74,320 /// or in textual repr: setCollectionLimit((uint8,bool,uint256))320 /// or in textual repr: setCollectionLimit((uint8,(bool,uint256)))321 function setCollectionLimit(CollectionLimit memory limit) public {321 function setCollectionLimit(CollectionLimit memory limit) public {322 require(false, stub_error);322 require(false, stub_error);323 limit;323 limit;401 /// Returns nesting for a collection401 /// Returns nesting for a collection402 /// @dev EVM selector for this function is: 0x22d25bfe,402 /// @dev EVM selector for this function is: 0x22d25bfe,403 /// or in textual repr: collectionNestingRestrictedCollectionIds()403 /// or in textual repr: collectionNestingRestrictedCollectionIds()404 function collectionNestingRestrictedCollectionIds() public view returns (Tuple41 memory) {404 function collectionNestingRestrictedCollectionIds() public view returns (Tuple44 memory) {405 require(false, stub_error);405 require(false, stub_error);406 dummy;406 dummy;407 return Tuple41(false, new uint256[](0));407 return Tuple44(false, new uint256[](0));408 }408 }409409410 /// Returns permissions for a collection410 /// Returns permissions for a collection411 /// @dev EVM selector for this function is: 0x5b2eaf4b,411 /// @dev EVM selector for this function is: 0x5b2eaf4b,412 /// or in textual repr: collectionNestingPermissions()412 /// or in textual repr: collectionNestingPermissions()413 function collectionNestingPermissions() public view returns (Tuple44[] memory) {413 function collectionNestingPermissions() public view returns (Tuple47[] memory) {414 require(false, stub_error);414 require(false, stub_error);415 dummy;415 dummy;416 return new Tuple44[](0);416 return new Tuple47[](0);417 }417 }418418419 /// Set the collection access method.419 /// Set the collection access method.596}596}597597598/// @dev anonymous struct598/// @dev anonymous struct599struct Tuple44 {599struct Tuple47 {600 CollectionPermissions field_0;600 CollectionPermissions field_0;601 bool field_1;601 bool field_1;602}602}603603604/// @dev anonymous struct604/// @dev anonymous struct605struct Tuple41 {605struct Tuple44 {606 bool field_0;606 bool field_0;607 uint256[] field_1;607 uint256[] field_1;608}608}609609610/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.610/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.611struct CollectionLimit {611struct CollectionLimit {612 CollectionLimitField field;612 CollectionLimitField field;613 OptionUint value;614}615616struct OptionUint {613 bool status;617 bool status;614 uint256 value;618 uint256 value;615}619}tests/src/eth/abi/fungible.jsondiffbeforeafterboth217 "name": "field",217 "name": "field",218 "type": "uint8"218 "type": "uint8"219 },219 },220 {221 "components": [220 { "internalType": "bool", "name": "status", "type": "bool" },222 { "internalType": "bool", "name": "status", "type": "bool" },221 { "internalType": "uint256", "name": "value", "type": "uint256" }223 { "internalType": "uint256", "name": "value", "type": "uint256" }224 ],225 "internalType": "struct OptionUint",226 "name": "value",227 "type": "tuple"228 }222 ],229 ],223 "internalType": "struct CollectionLimit[]",230 "internalType": "struct CollectionLimit[]",224 "name": "",231 "name": "",241 },248 },242 { "internalType": "bool", "name": "field_1", "type": "bool" }249 { "internalType": "bool", "name": "field_1", "type": "bool" }243 ],250 ],244 "internalType": "struct Tuple33[]",251 "internalType": "struct Tuple36[]",245 "name": "",252 "name": "",246 "type": "tuple[]"253 "type": "tuple[]"247 }254 }262 "type": "uint256[]"269 "type": "uint256[]"263 }270 }264 ],271 ],265 "internalType": "struct Tuple30",272 "internalType": "struct Tuple33",266 "name": "",273 "name": "",267 "type": "tuple"274 "type": "tuple"268 }275 }500 "name": "field",507 "name": "field",501 "type": "uint8"508 "type": "uint8"502 },509 },510 {511 "components": [503 { "internalType": "bool", "name": "status", "type": "bool" },512 { "internalType": "bool", "name": "status", "type": "bool" },504 { "internalType": "uint256", "name": "value", "type": "uint256" }513 { "internalType": "uint256", "name": "value", "type": "uint256" }514 ],515 "internalType": "struct OptionUint",516 "name": "value",517 "type": "tuple"518 }505 ],519 ],506 "internalType": "struct CollectionLimit",520 "internalType": "struct CollectionLimit",507 "name": "limit",521 "name": "limit",tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth247 "name": "field",247 "name": "field",248 "type": "uint8"248 "type": "uint8"249 },249 },250 {251 "components": [250 { "internalType": "bool", "name": "status", "type": "bool" },252 { "internalType": "bool", "name": "status", "type": "bool" },251 { "internalType": "uint256", "name": "value", "type": "uint256" }253 { "internalType": "uint256", "name": "value", "type": "uint256" }254 ],255 "internalType": "struct OptionUint",256 "name": "value",257 "type": "tuple"258 }252 ],259 ],253 "internalType": "struct CollectionLimit[]",260 "internalType": "struct CollectionLimit[]",254 "name": "",261 "name": "",271 },278 },272 { "internalType": "bool", "name": "field_1", "type": "bool" }279 { "internalType": "bool", "name": "field_1", "type": "bool" }273 ],280 ],274 "internalType": "struct Tuple45[]",281 "internalType": "struct Tuple48[]",275 "name": "",282 "name": "",276 "type": "tuple[]"283 "type": "tuple[]"277 }284 }292 "type": "uint256[]"299 "type": "uint256[]"293 }300 }294 ],301 ],295 "internalType": "struct Tuple42",302 "internalType": "struct Tuple45",296 "name": "",303 "name": "",297 "type": "tuple"304 "type": "tuple"298 }305 }662 "name": "field",669 "name": "field",663 "type": "uint8"670 "type": "uint8"664 },671 },672 {673 "components": [665 { "internalType": "bool", "name": "status", "type": "bool" },674 { "internalType": "bool", "name": "status", "type": "bool" },666 { "internalType": "uint256", "name": "value", "type": "uint256" }675 { "internalType": "uint256", "name": "value", "type": "uint256" }676 ],677 "internalType": "struct OptionUint",678 "name": "value",679 "type": "tuple"680 }667 ],681 ],668 "internalType": "struct CollectionLimit",682 "internalType": "struct CollectionLimit",669 "name": "limit",683 "name": "limit",tests/src/eth/abi/reFungible.jsondiffbeforeafterboth229 "name": "field",229 "name": "field",230 "type": "uint8"230 "type": "uint8"231 },231 },232 {233 "components": [232 { "internalType": "bool", "name": "status", "type": "bool" },234 { "internalType": "bool", "name": "status", "type": "bool" },233 { "internalType": "uint256", "name": "value", "type": "uint256" }235 { "internalType": "uint256", "name": "value", "type": "uint256" }236 ],237 "internalType": "struct OptionUint",238 "name": "value",239 "type": "tuple"240 }234 ],241 ],235 "internalType": "struct CollectionLimit[]",242 "internalType": "struct CollectionLimit[]",236 "name": "",243 "name": "",253 },260 },254 { "internalType": "bool", "name": "field_1", "type": "bool" }261 { "internalType": "bool", "name": "field_1", "type": "bool" }255 ],262 ],256 "internalType": "struct Tuple44[]",263 "internalType": "struct Tuple47[]",257 "name": "",264 "name": "",258 "type": "tuple[]"265 "type": "tuple[]"259 }266 }274 "type": "uint256[]"281 "type": "uint256[]"275 }282 }276 ],283 ],277 "internalType": "struct Tuple41",284 "internalType": "struct Tuple44",278 "name": "",285 "name": "",279 "type": "tuple"286 "type": "tuple"280 }287 }644 "name": "field",651 "name": "field",645 "type": "uint8"652 "type": "uint8"646 },653 },654 {655 "components": [647 { "internalType": "bool", "name": "status", "type": "bool" },656 { "internalType": "bool", "name": "status", "type": "bool" },648 { "internalType": "uint256", "name": "value", "type": "uint256" }657 { "internalType": "uint256", "name": "value", "type": "uint256" }658 ],659 "internalType": "struct OptionUint",660 "name": "value",661 "type": "tuple"662 }649 ],663 ],650 "internalType": "struct CollectionLimit",664 "internalType": "struct CollectionLimit",651 "name": "limit",665 "name": "limit",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 0x2320144216/// @dev the ERC-165 identifier for this interface is 0x2a14cfd117interface Collection is Dummy, ERC165 {17interface Collection is Dummy, ERC165 {18 // /// Set collection property.18 // /// Set collection property.19 // ///19 // ///114 /// Set limits for the collection.114 /// Set limits for the collection.115 /// @dev Throws error if limit not found.115 /// @dev Throws error if limit not found.116 /// @param limit Some limit.116 /// @param limit Some limit.117 /// @dev EVM selector for this function is: 0x2a2235e7,117 /// @dev EVM selector for this function is: 0x2316ee74,118 /// or in textual repr: setCollectionLimit((uint8,bool,uint256))118 /// or in textual repr: setCollectionLimit((uint8,(bool,uint256)))119 function setCollectionLimit(CollectionLimit memory limit) external;119 function setCollectionLimit(CollectionLimit memory limit) external;120120121 /// Get contract address.121 /// Get contract address.166 /// Returns nesting for a collection166 /// Returns nesting for a collection167 /// @dev EVM selector for this function is: 0x22d25bfe,167 /// @dev EVM selector for this function is: 0x22d25bfe,168 /// or in textual repr: collectionNestingRestrictedCollectionIds()168 /// or in textual repr: collectionNestingRestrictedCollectionIds()169 function collectionNestingRestrictedCollectionIds() external view returns (Tuple26 memory);169 function collectionNestingRestrictedCollectionIds() external view returns (Tuple28 memory);170170171 /// Returns permissions for a collection171 /// Returns permissions for a collection172 /// @dev EVM selector for this function is: 0x5b2eaf4b,172 /// @dev EVM selector for this function is: 0x5b2eaf4b,173 /// or in textual repr: collectionNestingPermissions()173 /// or in textual repr: collectionNestingPermissions()174 function collectionNestingPermissions() external view returns (Tuple29[] memory);174 function collectionNestingPermissions() external view returns (Tuple31[] memory);175175176 /// Set the collection access method.176 /// Set the collection access method.177 /// @param mode Access mode177 /// @param mode Access mode286}286}287287288/// @dev anonymous struct288/// @dev anonymous struct289struct Tuple29 {289struct Tuple31 {290 CollectionPermissions field_0;290 CollectionPermissions field_0;291 bool field_1;291 bool field_1;292}292}300}300}301301302/// @dev anonymous struct302/// @dev anonymous struct303struct Tuple26 {303struct Tuple28 {304 bool field_0;304 bool field_0;305 uint256[] field_1;305 uint256[] field_1;306}306}307307308/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.308/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.309struct CollectionLimit {309struct CollectionLimit {310 CollectionLimitField field;310 CollectionLimitField field;311 OptionUint value;312}313314struct OptionUint {311 bool status;315 bool status;312 uint256 value;316 uint256 value;313}317}tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth115}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 0x23201442118/// @dev the ERC-165 identifier for this interface is 0x2a14cfd1119interface Collection is Dummy, ERC165 {119interface Collection is Dummy, ERC165 {120 // /// Set collection property.120 // /// Set collection property.121 // ///121 // ///216 /// Set limits for the collection.216 /// Set limits for the collection.217 /// @dev Throws error if limit not found.217 /// @dev Throws error if limit not found.218 /// @param limit Some limit.218 /// @param limit Some limit.219 /// @dev EVM selector for this function is: 0x2a2235e7,219 /// @dev EVM selector for this function is: 0x2316ee74,220 /// or in textual repr: setCollectionLimit((uint8,bool,uint256))220 /// or in textual repr: setCollectionLimit((uint8,(bool,uint256)))221 function setCollectionLimit(CollectionLimit memory limit) external;221 function setCollectionLimit(CollectionLimit memory limit) external;222222223 /// Get contract address.223 /// Get contract address.268 /// Returns nesting for a collection268 /// Returns nesting for a collection269 /// @dev EVM selector for this function is: 0x22d25bfe,269 /// @dev EVM selector for this function is: 0x22d25bfe,270 /// or in textual repr: collectionNestingRestrictedCollectionIds()270 /// or in textual repr: collectionNestingRestrictedCollectionIds()271 function collectionNestingRestrictedCollectionIds() external view returns (Tuple36 memory);271 function collectionNestingRestrictedCollectionIds() external view returns (Tuple38 memory);272272273 /// Returns permissions for a collection273 /// Returns permissions for a collection274 /// @dev EVM selector for this function is: 0x5b2eaf4b,274 /// @dev EVM selector for this function is: 0x5b2eaf4b,275 /// or in textual repr: collectionNestingPermissions()275 /// or in textual repr: collectionNestingPermissions()276 function collectionNestingPermissions() external view returns (Tuple39[] memory);276 function collectionNestingPermissions() external view returns (Tuple41[] memory);277277278 /// Set the collection access method.278 /// Set the collection access method.279 /// @param mode Access mode279 /// @param mode Access mode388}388}389389390/// @dev anonymous struct390/// @dev anonymous struct391struct Tuple39 {391struct Tuple41 {392 CollectionPermissions field_0;392 CollectionPermissions field_0;393 bool field_1;393 bool field_1;394}394}402}402}403403404/// @dev anonymous struct404/// @dev anonymous struct405struct Tuple36 {405struct Tuple38 {406 bool field_0;406 bool field_0;407 uint256[] field_1;407 uint256[] field_1;408}408}409409410/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.410/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.411struct CollectionLimit {411struct CollectionLimit {412 CollectionLimitField field;412 CollectionLimitField field;413 OptionUint value;414}415416struct OptionUint {413 bool status;417 bool status;414 uint256 value;418 uint256 value;415}419}tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth115}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 0x23201442118/// @dev the ERC-165 identifier for this interface is 0x2a14cfd1119interface Collection is Dummy, ERC165 {119interface Collection is Dummy, ERC165 {120 // /// Set collection property.120 // /// Set collection property.121 // ///121 // ///216 /// Set limits for the collection.216 /// Set limits for the collection.217 /// @dev Throws error if limit not found.217 /// @dev Throws error if limit not found.218 /// @param limit Some limit.218 /// @param limit Some limit.219 /// @dev EVM selector for this function is: 0x2a2235e7,219 /// @dev EVM selector for this function is: 0x2316ee74,220 /// or in textual repr: setCollectionLimit((uint8,bool,uint256))220 /// or in textual repr: setCollectionLimit((uint8,(bool,uint256)))221 function setCollectionLimit(CollectionLimit memory limit) external;221 function setCollectionLimit(CollectionLimit memory limit) external;222222223 /// Get contract address.223 /// Get contract address.268 /// Returns nesting for a collection268 /// Returns nesting for a collection269 /// @dev EVM selector for this function is: 0x22d25bfe,269 /// @dev EVM selector for this function is: 0x22d25bfe,270 /// or in textual repr: collectionNestingRestrictedCollectionIds()270 /// or in textual repr: collectionNestingRestrictedCollectionIds()271 function collectionNestingRestrictedCollectionIds() external view returns (Tuple35 memory);271 function collectionNestingRestrictedCollectionIds() external view returns (Tuple37 memory);272272273 /// Returns permissions for a collection273 /// Returns permissions for a collection274 /// @dev EVM selector for this function is: 0x5b2eaf4b,274 /// @dev EVM selector for this function is: 0x5b2eaf4b,275 /// or in textual repr: collectionNestingPermissions()275 /// or in textual repr: collectionNestingPermissions()276 function collectionNestingPermissions() external view returns (Tuple38[] memory);276 function collectionNestingPermissions() external view returns (Tuple40[] memory);277277278 /// Set the collection access method.278 /// Set the collection access method.279 /// @param mode Access mode279 /// @param mode Access mode388}388}389389390/// @dev anonymous struct390/// @dev anonymous struct391struct Tuple38 {391struct Tuple40 {392 CollectionPermissions field_0;392 CollectionPermissions field_0;393 bool field_1;393 bool field_1;394}394}402}402}403403404/// @dev anonymous struct404/// @dev anonymous struct405struct Tuple35 {405struct Tuple37 {406 bool field_0;406 bool field_0;407 uint256[] field_1;407 uint256[] field_1;408}408}409409410/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.410/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.411struct CollectionLimit {411struct CollectionLimit {412 CollectionLimitField field;412 CollectionLimitField field;413 OptionUint value;414}415416struct OptionUint {413 bool status;417 bool status;414 uint256 value;418 uint256 value;415}419}tests/src/eth/collectionLimits.test.tsdiffbeforeafterboth46 };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({field: CollectionLimitField.AccountTokenOwnership, status: true, value: limits.accountTokenOwnershipLimit}).send();49 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {status: true, value: limits.accountTokenOwnershipLimit}}).send();50 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsoredDataSize, status: true, value: limits.sponsoredDataSize}).send();50 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsoredDataSize, value: {status: true, value: limits.sponsoredDataSize}}).send();51 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsoredDataRateLimit, status: true, value: limits.sponsoredDataRateLimit}).send();51 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsoredDataRateLimit, value: {status: true, value: limits.sponsoredDataRateLimit}}).send();52 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.TokenLimit, status: true, value: limits.tokenLimit}).send();52 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.TokenLimit, value: {status: true, value: limits.tokenLimit}}).send();53 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsorTransferTimeout, status: true, value: limits.sponsorTransferTimeout}).send();53 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsorTransferTimeout, value: {status: true, value: limits.sponsorTransferTimeout}}).send();54 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsorApproveTimeout, status: true, value: limits.sponsorApproveTimeout}).send();54 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsorApproveTimeout, value: {status: true, value: limits.sponsorApproveTimeout}}).send();55 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.OwnerCanTransfer, status: true, value: limits.ownerCanTransfer}).send();55 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.OwnerCanTransfer, value: {status: true, value: limits.ownerCanTransfer}}).send();56 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.OwnerCanDestroy, status: true, value: limits.ownerCanDestroy}).send();56 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.OwnerCanDestroy, value: {status: true, value: limits.ownerCanDestroy}}).send();57 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.TransferEnabled, status: true, value: limits.transfersEnabled}).send();57 await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.TransferEnabled, value: {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([CollectionLimitField.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([CollectionLimitField.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([CollectionLimitField.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([CollectionLimitField.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([CollectionLimitField.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([CollectionLimitField.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([CollectionLimitField.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([CollectionLimitField.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([CollectionLimitField.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({field: 9, status: true, value: 1})104 .setCollectionLimit({field: 9, value: {status: true, value: 1}})105 .call()).to.be.rejectedWith('Value not convertible into enum "CollectionLimitField"'); 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({field: CollectionLimitField.AccountTokenOwnership, status: false, value: 200})109 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {status: false, value: 200}})110 .call()).to.be.rejectedWith('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({field: CollectionLimitField.AccountTokenOwnership, status: true, value: invalidLimits.accountTokenOwnershipLimit})113 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {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({field: CollectionLimitField.TransferEnabled, status: true, value: 3})117 .setCollectionLimit({field: CollectionLimitField.TransferEnabled, value: {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({field: CollectionLimitField.SponsoredDataSize, status: true, value: -1}).send()).to.throw('value out-of-bounds');121 .setCollectionLimit({field: CollectionLimitField.SponsoredDataSize, value: {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({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})136 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {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({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})141 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {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.tsdiffbeforeafterboth197 }197 }198 {198 {199 await expect(peasantCollection.methods199 await expect(peasantCollection.methods200 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})200 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {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({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})225 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {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.tsdiffbeforeafterboth208 }208 }209 {209 {210 await expect(malfeasantCollection.methods210 await expect(malfeasantCollection.methods211 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})211 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {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({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})236 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {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.tsdiffbeforeafterboth240 }240 }241 {241 {242 await expect(peasantCollection.methods242 await expect(peasantCollection.methods243 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})243 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {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({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})268 .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {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.tsdiffbeforeafterboth233 });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({field: CollectionLimitField.OwnerCanTransfer, status: true, value: 0}).send({from: owner});236 await collection.methods.setCollectionLimit({field: CollectionLimitField.OwnerCanTransfer, value: {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 {tests/src/eth/util/playgrounds/types.tsdiffbeforeafterboth14 args: { [key: string]: string }14 args: { [key: string]: string }15};15};1617export interface OptionUint {18 status: boolean,19 value: bigint,20}2116export interface TEthCrossAccount {22export interface TEthCrossAccount {17 readonly eth: string,23 readonly eth: string,404641export interface CollectionLimit {47export interface CollectionLimit {42 field: CollectionLimitField,48 field: CollectionLimitField,43 status: boolean,44 value: bigint | number,49 value: OptionUint,45}50}4651