difftreelog
feature/setCollectionLimit Behavior of the `setCollectionLimit` method. Removed method overload: single signature `(string, uint256)` is used for both cases.
in: master
22 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5831,7 +5831,7 @@
[[package]]
name = "pallet-common"
-version = "0.1.10"
+version = "0.1.11"
dependencies = [
"ethereum",
"evm-coder",
pallets/common/CHANGELOG.mddiffbeforeafterboth--- a/pallets/common/CHANGELOG.md
+++ b/pallets/common/CHANGELOG.md
@@ -2,10 +2,22 @@
All notable changes to this project will be documented in this file.
+<!-- bureaucrate goes here -->
+
+## [0.1.11] - 2022-11-16
+
+### Changed
+
+- Behavior of the `setCollectionLimit` method.
+ Removed method overload: single signature `(string, uint256)`
+ is used for both cases.
+
## [0.1.10] - 2022-11-02
+
### Changed
- - Use named structure `EthCrossAccount` in eth functions.
+- Use named structure `EthCrossAccount` in eth functions.
+
## [0.1.9] - 2022-10-13
## Added
@@ -34,8 +46,6 @@
### Added
- New Ethereum API methods: changeOwner, changeOwner(Substrate) and verifyOwnerOrAdmin(Substrate).
-
-<!-- bureaucrate goes here -->
## [v0.1.5] 2022-08-16
pallets/common/Cargo.tomldiffbeforeafterboth--- a/pallets/common/Cargo.toml
+++ b/pallets/common/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pallet-common"
-version = "0.1.10"
+version = "0.1.11"
license = "GPLv3"
edition = "2021"
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -303,11 +303,29 @@
/// "tokenLimit",
/// "sponsorTransferTimeout",
/// "sponsorApproveTimeout"
+ /// "ownerCanTransfer",
+ /// "ownerCanDestroy",
+ /// "transfersEnabled"
/// @param value Value of the limit.
#[solidity(rename_selector = "setCollectionLimit")]
- fn set_int_limit(&mut self, caller: caller, limit: string, value: uint32) -> Result<void> {
+ fn set_int_limit(&mut self, caller: caller, limit: string, value: uint256) -> Result<void> {
self.consume_store_reads_and_writes(1, 1)?;
+ let value = value
+ .try_into()
+ .map_err(|_| Error::Revert(format!("can't convert value to u32 \"{}\"", value)))?;
+
+ let convert_value_to_bool = || match value {
+ 0 => Ok(false),
+ 1 => Ok(true),
+ _ => {
+ return Err(Error::Revert(format!(
+ "can't convert value to boolean \"{}\"",
+ value
+ )))
+ }
+ };
+
check_is_owner_or_admin(caller, self)?;
let mut limits = self.limits.clone();
@@ -330,48 +348,16 @@
"sponsorApproveTimeout" => {
limits.sponsor_approve_timeout = Some(value);
}
- _ => {
- return Err(Error::Revert(format!(
- "unknown integer limit \"{}\"",
- limit
- )))
- }
- }
- self.limits = <Pallet<T>>::clamp_limits(self.mode.clone(), &self.limits, limits)
- .map_err(dispatch_to_evm::<T>)?;
- save(self)
- }
-
- /// Set limits for the collection.
- /// @dev Throws error if limit not found.
- /// @param limit Name of the limit. Valid names:
- /// "ownerCanTransfer",
- /// "ownerCanDestroy",
- /// "transfersEnabled"
- /// @param value Value of the limit.
- #[solidity(rename_selector = "setCollectionLimit")]
- fn set_bool_limit(&mut self, caller: caller, limit: string, value: bool) -> Result<void> {
- self.consume_store_reads_and_writes(1, 1)?;
-
- check_is_owner_or_admin(caller, self)?;
- let mut limits = self.limits.clone();
-
- match limit.as_str() {
"ownerCanTransfer" => {
- limits.owner_can_transfer = Some(value);
+ limits.owner_can_transfer = Some(convert_value_to_bool()?);
}
"ownerCanDestroy" => {
- limits.owner_can_destroy = Some(value);
+ limits.owner_can_destroy = Some(convert_value_to_bool()?);
}
"transfersEnabled" => {
- limits.transfers_enabled = Some(value);
- }
- _ => {
- return Err(Error::Revert(format!(
- "unknown boolean limit \"{}\"",
- limit
- )))
+ limits.transfers_enabled = Some(convert_value_to_bool()?);
}
+ _ => return Err(Error::Revert(format!("unknown limit \"{}\"", limit))),
}
self.limits = <Pallet<T>>::clamp_limits(self.mode.clone(), &self.limits, limits)
.map_err(dispatch_to_evm::<T>)?;
pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56/// @dev common stubs holder7contract Dummy {8 uint8 dummy;9 string stub_error = "this contract is implemented in native";10}1112contract ERC165 is Dummy {13 function supportsInterface(bytes4 interfaceID) external view returns (bool) {14 require(false, stub_error);15 interfaceID;16 return true;17 }18}1920/// @title A contract that allows you to work with collections.21/// @dev the ERC-165 identifier for this interface is 0x8b91d19222contract Collection is Dummy, ERC165 {23 // /// Set collection property.24 // ///25 // /// @param key Property key.26 // /// @param value Propery value.27 // /// @dev EVM selector for this function is: 0x2f073f66,28 // /// or in textual repr: setCollectionProperty(string,bytes)29 // function setCollectionProperty(string memory key, bytes memory value) public {30 // require(false, stub_error);31 // key;32 // value;33 // dummy = 0;34 // }3536 /// Set collection properties.37 ///38 /// @param properties Vector of properties key/value pair.39 /// @dev EVM selector for this function is: 0x50b26b2a,40 /// or in textual repr: setCollectionProperties((string,bytes)[])41 function setCollectionProperties(Property[] memory properties) public {42 require(false, stub_error);43 properties;44 dummy = 0;45 }4647 // /// Delete collection property.48 // ///49 // /// @param key Property key.50 // /// @dev EVM selector for this function is: 0x7b7debce,51 // /// or in textual repr: deleteCollectionProperty(string)52 // function deleteCollectionProperty(string memory key) public {53 // require(false, stub_error);54 // key;55 // dummy = 0;56 // }5758 /// Delete collection properties.59 ///60 /// @param keys Properties keys.61 /// @dev EVM selector for this function is: 0xee206ee3,62 /// or in textual repr: deleteCollectionProperties(string[])63 function deleteCollectionProperties(string[] memory keys) public {64 require(false, stub_error);65 keys;66 dummy = 0;67 }6869 /// Get collection property.70 ///71 /// @dev Throws error if key not found.72 ///73 /// @param key Property key.74 /// @return bytes The property corresponding to the key.75 /// @dev EVM selector for this function is: 0xcf24fd6d,76 /// or in textual repr: collectionProperty(string)77 function collectionProperty(string memory key) public view returns (bytes memory) {78 require(false, stub_error);79 key;80 dummy;81 return hex"";82 }8384 /// Get collection properties.85 ///86 /// @param keys Properties keys. Empty keys for all propertyes.87 /// @return Vector of properties key/value pairs.88 /// @dev EVM selector for this function is: 0x285fb8e6,89 /// or in textual repr: collectionProperties(string[])90 function collectionProperties(string[] memory keys) public view returns (Tuple16[] memory) {91 require(false, stub_error);92 keys;93 dummy;94 return new Tuple16[](0);95 }9697 // /// Set the sponsor of the collection.98 // ///99 // /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.100 // ///101 // /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.102 // /// @dev EVM selector for this function is: 0x7623402e,103 // /// or in textual repr: setCollectionSponsor(address)104 // function setCollectionSponsor(address sponsor) public {105 // require(false, stub_error);106 // sponsor;107 // dummy = 0;108 // }109110 /// Set the sponsor of the collection.111 ///112 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.113 ///114 /// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.115 /// @dev EVM selector for this function is: 0x84a1d5a8,116 /// or in textual repr: setCollectionSponsorCross((address,uint256))117 function setCollectionSponsorCross(EthCrossAccount memory sponsor) public {118 require(false, stub_error);119 sponsor;120 dummy = 0;121 }122123 /// Whether there is a pending sponsor.124 /// @dev EVM selector for this function is: 0x058ac185,125 /// or in textual repr: hasCollectionPendingSponsor()126 function hasCollectionPendingSponsor() public view returns (bool) {127 require(false, stub_error);128 dummy;129 return false;130 }131132 /// Collection sponsorship confirmation.133 ///134 /// @dev After setting the sponsor for the collection, it must be confirmed with this function.135 /// @dev EVM selector for this function is: 0x3c50e97a,136 /// or in textual repr: confirmCollectionSponsorship()137 function confirmCollectionSponsorship() public {138 require(false, stub_error);139 dummy = 0;140 }141142 /// Remove collection sponsor.143 /// @dev EVM selector for this function is: 0x6e0326a3,144 /// or in textual repr: removeCollectionSponsor()145 function removeCollectionSponsor() public {146 require(false, stub_error);147 dummy = 0;148 }149150 /// Get current sponsor.151 ///152 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.153 /// @dev EVM selector for this function is: 0x6ec0a9f1,154 /// or in textual repr: collectionSponsor()155 function collectionSponsor() public view returns (Tuple8 memory) {156 require(false, stub_error);157 dummy;158 return Tuple8(0x0000000000000000000000000000000000000000, 0);159 }160161 /// Set limits for the collection.162 /// @dev Throws error if limit not found.163 /// @param limit Name of the limit. Valid names:164 /// "accountTokenOwnershipLimit",165 /// "sponsoredDataSize",166 /// "sponsoredDataRateLimit",167 /// "tokenLimit",168 /// "sponsorTransferTimeout",169 /// "sponsorApproveTimeout"170 /// "ownerCanTransfer",171 /// "ownerCanDestroy",172 /// "transfersEnabled"173 /// @param value Value of the limit.174 /// @dev EVM selector for this function is: 0x4ad890a8,175 /// or in textual repr: setCollectionLimit(string,uint256)176 function setCollectionLimit(string memory limit, uint256 value) public {177 require(false, stub_error);178 limit;179 value;180 dummy = 0;181 }182183 /// Get contract address.184 /// @dev EVM selector for this function is: 0xf6b4dfb4,185 /// or in textual repr: contractAddress()186 function contractAddress() public view returns (address) {187 require(false, stub_error);188 dummy;189 return 0x0000000000000000000000000000000000000000;190 }191192 /// Add collection admin.193 /// @param newAdmin Cross account administrator address.194 /// @dev EVM selector for this function is: 0x859aa7d6,195 /// or in textual repr: addCollectionAdminCross((address,uint256))196 function addCollectionAdminCross(EthCrossAccount memory newAdmin) public {197 require(false, stub_error);198 newAdmin;199 dummy = 0;200 }201202 /// Remove collection admin.203 /// @param admin Cross account administrator address.204 /// @dev EVM selector for this function is: 0x6c0cd173,205 /// or in textual repr: removeCollectionAdminCross((address,uint256))206 function removeCollectionAdminCross(EthCrossAccount memory admin) public {207 require(false, stub_error);208 admin;209 dummy = 0;210 }211212 // /// Add collection admin.213 // /// @param newAdmin Address of the added administrator.214 // /// @dev EVM selector for this function is: 0x92e462c7,215 // /// or in textual repr: addCollectionAdmin(address)216 // function addCollectionAdmin(address newAdmin) public {217 // require(false, stub_error);218 // newAdmin;219 // dummy = 0;220 // }221222 // /// Remove collection admin.223 // ///224 // /// @param admin Address of the removed administrator.225 // /// @dev EVM selector for this function is: 0xfafd7b42,226 // /// or in textual repr: removeCollectionAdmin(address)227 // function removeCollectionAdmin(address admin) public {228 // require(false, stub_error);229 // admin;230 // dummy = 0;231 // }232233 /// Toggle accessibility of collection nesting.234 ///235 /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'236 /// @dev EVM selector for this function is: 0x112d4586,237 /// or in textual repr: setCollectionNesting(bool)238 function setCollectionNesting(bool enable) public {239 require(false, stub_error);240 enable;241 dummy = 0;242 }243244 /// Toggle accessibility of collection nesting.245 ///246 /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'247 /// @param collections Addresses of collections that will be available for nesting.248 /// @dev EVM selector for this function is: 0x64872396,249 /// or in textual repr: setCollectionNesting(bool,address[])250 function setCollectionNesting(bool enable, address[] memory collections) public {251 require(false, stub_error);252 enable;253 collections;254 dummy = 0;255 }256257 /// Set the collection access method.258 /// @param mode Access mode259 /// 0 for Normal260 /// 1 for AllowList261 /// @dev EVM selector for this function is: 0x41835d4c,262 /// or in textual repr: setCollectionAccess(uint8)263 function setCollectionAccess(uint8 mode) public {264 require(false, stub_error);265 mode;266 dummy = 0;267 }268269 /// Checks that user allowed to operate with collection.270 ///271 /// @param user User address to check.272 /// @dev EVM selector for this function is: 0xd63a8e11,273 /// or in textual repr: allowed(address)274 function allowed(address user) public view returns (bool) {275 require(false, stub_error);276 user;277 dummy;278 return false;279 }280281 // /// Add the user to the allowed list.282 // ///283 // /// @param user Address of a trusted user.284 // /// @dev EVM selector for this function is: 0x67844fe6,285 // /// or in textual repr: addToCollectionAllowList(address)286 // function addToCollectionAllowList(address user) public {287 // require(false, stub_error);288 // user;289 // dummy = 0;290 // }291292 /// Add user to allowed list.293 ///294 /// @param user User cross account address.295 /// @dev EVM selector for this function is: 0xa0184a3a,296 /// or in textual repr: addToCollectionAllowListCross((address,uint256))297 function addToCollectionAllowListCross(EthCrossAccount memory user) public {298 require(false, stub_error);299 user;300 dummy = 0;301 }302303 // /// Remove the user from the allowed list.304 // ///305 // /// @param user Address of a removed user.306 // /// @dev EVM selector for this function is: 0x85c51acb,307 // /// or in textual repr: removeFromCollectionAllowList(address)308 // function removeFromCollectionAllowList(address user) public {309 // require(false, stub_error);310 // user;311 // dummy = 0;312 // }313314 /// Remove user from allowed list.315 ///316 /// @param user User cross account address.317 /// @dev EVM selector for this function is: 0x09ba452a,318 /// or in textual repr: removeFromCollectionAllowListCross((address,uint256))319 function removeFromCollectionAllowListCross(EthCrossAccount memory user) public {320 require(false, stub_error);321 user;322 dummy = 0;323 }324325 /// Switch permission for minting.326 ///327 /// @param mode Enable if "true".328 /// @dev EVM selector for this function is: 0x00018e84,329 /// or in textual repr: setCollectionMintMode(bool)330 function setCollectionMintMode(bool mode) public {331 require(false, stub_error);332 mode;333 dummy = 0;334 }335336 // /// Check that account is the owner or admin of the collection337 // ///338 // /// @param user account to verify339 // /// @return "true" if account is the owner or admin340 // /// @dev EVM selector for this function is: 0x9811b0c7,341 // /// or in textual repr: isOwnerOrAdmin(address)342 // function isOwnerOrAdmin(address user) public view returns (bool) {343 // require(false, stub_error);344 // user;345 // dummy;346 // return false;347 // }348349 /// Check that account is the owner or admin of the collection350 ///351 /// @param user User cross account to verify352 /// @return "true" if account is the owner or admin353 /// @dev EVM selector for this function is: 0x3e75a905,354 /// or in textual repr: isOwnerOrAdminCross((address,uint256))355 function isOwnerOrAdminCross(EthCrossAccount memory user) public view returns (bool) {356 require(false, stub_error);357 user;358 dummy;359 return false;360 }361362 /// Returns collection type363 ///364 /// @return `Fungible` or `NFT` or `ReFungible`365 /// @dev EVM selector for this function is: 0xd34b55b8,366 /// or in textual repr: uniqueCollectionType()367 function uniqueCollectionType() public view returns (string memory) {368 require(false, stub_error);369 dummy;370 return "";371 }372373 /// Get collection owner.374 ///375 /// @return Tuble with sponsor address and his substrate mirror.376 /// If address is canonical then substrate mirror is zero and vice versa.377 /// @dev EVM selector for this function is: 0xdf727d3b,378 /// or in textual repr: collectionOwner()379 function collectionOwner() public view returns (EthCrossAccount memory) {380 require(false, stub_error);381 dummy;382 return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);383 }384385 // /// Changes collection owner to another account386 // ///387 // /// @dev Owner can be changed only by current owner388 // /// @param newOwner new owner account389 // /// @dev EVM selector for this function is: 0x4f53e226,390 // /// or in textual repr: changeCollectionOwner(address)391 // function changeCollectionOwner(address newOwner) public {392 // require(false, stub_error);393 // newOwner;394 // dummy = 0;395 // }396397 /// Get collection administrators398 ///399 /// @return Vector of tuples with admins address and his substrate mirror.400 /// If address is canonical then substrate mirror is zero and vice versa.401 /// @dev EVM selector for this function is: 0x5813216b,402 /// or in textual repr: collectionAdmins()403 function collectionAdmins() public view returns (EthCrossAccount[] memory) {404 require(false, stub_error);405 dummy;406 return new EthCrossAccount[](0);407 }408409 /// Changes collection owner to another account410 ///411 /// @dev Owner can be changed only by current owner412 /// @param newOwner new owner cross account413 /// @dev EVM selector for this function is: 0x6496c497,414 /// or in textual repr: changeCollectionOwnerCross((address,uint256))415 function changeCollectionOwnerCross(EthCrossAccount memory newOwner) public {416 require(false, stub_error);417 newOwner;418 dummy = 0;419 }420}421422/// @dev Cross account struct423struct EthCrossAccount {424 address eth;425 uint256 sub;426}427428/// @dev anonymous struct429struct Tuple16 {430 string field_0;431 bytes field_1;432}433434/// @dev Property struct435struct Property {436 string key;437 bytes value;438}439440/// @dev the ERC-165 identifier for this interface is 0x29f4dcd9441contract ERC20UniqueExtensions is Dummy, ERC165 {442 /// @dev EVM selector for this function is: 0x0ecd0ab0,443 /// or in textual repr: approveCross((address,uint256),uint256)444 function approveCross(EthCrossAccount memory spender, uint256 amount) public returns (bool) {445 require(false, stub_error);446 spender;447 amount;448 dummy = 0;449 return false;450 }451452 // /// Burn tokens from account453 // /// @dev Function that burns an `amount` of the tokens of a given account,454 // /// deducting from the sender's allowance for said account.455 // /// @param from The account whose tokens will be burnt.456 // /// @param amount The amount that will be burnt.457 // /// @dev EVM selector for this function is: 0x79cc6790,458 // /// or in textual repr: burnFrom(address,uint256)459 // function burnFrom(address from, uint256 amount) public returns (bool) {460 // require(false, stub_error);461 // from;462 // amount;463 // dummy = 0;464 // return false;465 // }466467 /// Burn tokens from account468 /// @dev Function that burns an `amount` of the tokens of a given account,469 /// deducting from the sender's allowance for said account.470 /// @param from The account whose tokens will be burnt.471 /// @param amount The amount that will be burnt.472 /// @dev EVM selector for this function is: 0xbb2f5a58,473 /// or in textual repr: burnFromCross((address,uint256),uint256)474 function burnFromCross(EthCrossAccount memory from, uint256 amount) public returns (bool) {475 require(false, stub_error);476 from;477 amount;478 dummy = 0;479 return false;480 }481482 /// Mint tokens for multiple accounts.483 /// @param amounts array of pairs of account address and amount484 /// @dev EVM selector for this function is: 0x1acf2d55,485 /// or in textual repr: mintBulk((address,uint256)[])486 function mintBulk(Tuple8[] memory amounts) public returns (bool) {487 require(false, stub_error);488 amounts;489 dummy = 0;490 return false;491 }492493 /// @dev EVM selector for this function is: 0x2ada85ff,494 /// or in textual repr: transferCross((address,uint256),uint256)495 function transferCross(EthCrossAccount memory to, uint256 amount) public returns (bool) {496 require(false, stub_error);497 to;498 amount;499 dummy = 0;500 return false;501 }502503 /// @dev EVM selector for this function is: 0xd5cf430b,504 /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)505 function transferFromCross(506 EthCrossAccount memory from,507 EthCrossAccount memory to,508 uint256 amount509 ) public returns (bool) {510 require(false, stub_error);511 from;512 to;513 amount;514 dummy = 0;515 return false;516 }517}518519/// @dev anonymous struct520struct Tuple8 {521 address field_0;522 uint256 field_1;523}524525/// @dev the ERC-165 identifier for this interface is 0x40c10f19526contract ERC20Mintable is Dummy, ERC165 {527 /// Mint tokens for `to` account.528 /// @param to account that will receive minted tokens529 /// @param amount amount of tokens to mint530 /// @dev EVM selector for this function is: 0x40c10f19,531 /// or in textual repr: mint(address,uint256)532 function mint(address to, uint256 amount) public returns (bool) {533 require(false, stub_error);534 to;535 amount;536 dummy = 0;537 return false;538 }539}540541/// @dev inlined interface542contract ERC20Events {543 event Transfer(address indexed from, address indexed to, uint256 value);544 event Approval(address indexed owner, address indexed spender, uint256 value);545}546547/// @dev the ERC-165 identifier for this interface is 0x942e8b22548contract ERC20 is Dummy, ERC165, ERC20Events {549 /// @dev EVM selector for this function is: 0x06fdde03,550 /// or in textual repr: name()551 function name() public view returns (string memory) {552 require(false, stub_error);553 dummy;554 return "";555 }556557 /// @dev EVM selector for this function is: 0x95d89b41,558 /// or in textual repr: symbol()559 function symbol() public view returns (string memory) {560 require(false, stub_error);561 dummy;562 return "";563 }564565 /// @dev EVM selector for this function is: 0x18160ddd,566 /// or in textual repr: totalSupply()567 function totalSupply() public view returns (uint256) {568 require(false, stub_error);569 dummy;570 return 0;571 }572573 /// @dev EVM selector for this function is: 0x313ce567,574 /// or in textual repr: decimals()575 function decimals() public view returns (uint8) {576 require(false, stub_error);577 dummy;578 return 0;579 }580581 /// @dev EVM selector for this function is: 0x70a08231,582 /// or in textual repr: balanceOf(address)583 function balanceOf(address owner) public view returns (uint256) {584 require(false, stub_error);585 owner;586 dummy;587 return 0;588 }589590 /// @dev EVM selector for this function is: 0xa9059cbb,591 /// or in textual repr: transfer(address,uint256)592 function transfer(address to, uint256 amount) public returns (bool) {593 require(false, stub_error);594 to;595 amount;596 dummy = 0;597 return false;598 }599600 /// @dev EVM selector for this function is: 0x23b872dd,601 /// or in textual repr: transferFrom(address,address,uint256)602 function transferFrom(603 address from,604 address to,605 uint256 amount606 ) public returns (bool) {607 require(false, stub_error);608 from;609 to;610 amount;611 dummy = 0;612 return false;613 }614615 /// @dev EVM selector for this function is: 0x095ea7b3,616 /// or in textual repr: approve(address,uint256)617 function approve(address spender, uint256 amount) public returns (bool) {618 require(false, stub_error);619 spender;620 amount;621 dummy = 0;622 return false;623 }624625 /// @dev EVM selector for this function is: 0xdd62ed3e,626 /// or in textual repr: allowance(address,address)627 function allowance(address owner, address spender) public view returns (uint256) {628 require(false, stub_error);629 owner;630 spender;631 dummy;632 return 0;633 }634}635636contract UniqueFungible is Dummy, ERC165, ERC20, ERC20Mintable, ERC20UniqueExtensions, Collection {}pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -119,7 +119,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x324a7f5b
+/// @dev the ERC-165 identifier for this interface is 0x8b91d192
contract Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -268,26 +268,13 @@
/// "tokenLimit",
/// "sponsorTransferTimeout",
/// "sponsorApproveTimeout"
- /// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x6a3841db,
- /// or in textual repr: setCollectionLimit(string,uint32)
- function setCollectionLimit(string memory limit, uint32 value) public {
- require(false, stub_error);
- limit;
- value;
- dummy = 0;
- }
-
- /// Set limits for the collection.
- /// @dev Throws error if limit not found.
- /// @param limit Name of the limit. Valid names:
- /// "ownerCanTransfer",
+ /// "ownerCanTransfer",
/// "ownerCanDestroy",
/// "transfersEnabled"
/// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x993b7fba,
- /// or in textual repr: setCollectionLimit(string,bool)
- function setCollectionLimit(string memory limit, bool value) public {
+ /// @dev EVM selector for this function is: 0x4ad890a8,
+ /// or in textual repr: setCollectionLimit(string,uint256)
+ function setCollectionLimit(string memory limit, uint256 value) public {
require(false, stub_error);
limit;
value;
pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -119,7 +119,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x324a7f5b
+/// @dev the ERC-165 identifier for this interface is 0x8b91d192
contract Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -268,26 +268,13 @@
/// "tokenLimit",
/// "sponsorTransferTimeout",
/// "sponsorApproveTimeout"
- /// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x6a3841db,
- /// or in textual repr: setCollectionLimit(string,uint32)
- function setCollectionLimit(string memory limit, uint32 value) public {
- require(false, stub_error);
- limit;
- value;
- dummy = 0;
- }
-
- /// Set limits for the collection.
- /// @dev Throws error if limit not found.
- /// @param limit Name of the limit. Valid names:
- /// "ownerCanTransfer",
+ /// "ownerCanTransfer",
/// "ownerCanDestroy",
/// "transfersEnabled"
/// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x993b7fba,
- /// or in textual repr: setCollectionLimit(string,bool)
- function setCollectionLimit(string memory limit, bool value) public {
+ /// @dev EVM selector for this function is: 0x4ad890a8,
+ /// or in textual repr: setCollectionLimit(string,uint256)
+ function setCollectionLimit(string memory limit, uint256 value) public {
require(false, stub_error);
limit;
value;
pallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterbothbinary blob — no preview
pallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterbothbinary blob — no preview
tests/src/eth/abi/fungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/fungible.json
+++ b/tests/src/eth/abi/fungible.json
@@ -390,17 +390,7 @@
{
"inputs": [
{ "internalType": "string", "name": "limit", "type": "string" },
- { "internalType": "uint32", "name": "value", "type": "uint32" }
- ],
- "name": "setCollectionLimit",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [
- { "internalType": "string", "name": "limit", "type": "string" },
- { "internalType": "bool", "name": "value", "type": "bool" }
+ { "internalType": "uint256", "name": "value", "type": "uint256" }
],
"name": "setCollectionLimit",
"outputs": [],
tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -505,17 +505,7 @@
{
"inputs": [
{ "internalType": "string", "name": "limit", "type": "string" },
- { "internalType": "uint32", "name": "value", "type": "uint32" }
- ],
- "name": "setCollectionLimit",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [
- { "internalType": "string", "name": "limit", "type": "string" },
- { "internalType": "bool", "name": "value", "type": "bool" }
+ { "internalType": "uint256", "name": "value", "type": "uint256" }
],
"name": "setCollectionLimit",
"outputs": [],
tests/src/eth/abi/reFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -487,17 +487,7 @@
{
"inputs": [
{ "internalType": "string", "name": "limit", "type": "string" },
- { "internalType": "uint32", "name": "value", "type": "uint32" }
- ],
- "name": "setCollectionLimit",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [
- { "internalType": "string", "name": "limit", "type": "string" },
- { "internalType": "bool", "name": "value", "type": "bool" }
+ { "internalType": "uint256", "name": "value", "type": "uint256" }
],
"name": "setCollectionLimit",
"outputs": [],
tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -13,7 +13,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x324a7f5b
+/// @dev the ERC-165 identifier for this interface is 0x8b91d192
interface Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -113,21 +113,13 @@
/// "tokenLimit",
/// "sponsorTransferTimeout",
/// "sponsorApproveTimeout"
- /// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x6a3841db,
- /// or in textual repr: setCollectionLimit(string,uint32)
- function setCollectionLimit(string memory limit, uint32 value) external;
-
- /// Set limits for the collection.
- /// @dev Throws error if limit not found.
- /// @param limit Name of the limit. Valid names:
- /// "ownerCanTransfer",
+ /// "ownerCanTransfer",
/// "ownerCanDestroy",
/// "transfersEnabled"
/// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x993b7fba,
- /// or in textual repr: setCollectionLimit(string,bool)
- function setCollectionLimit(string memory limit, bool value) external;
+ /// @dev EVM selector for this function is: 0x4ad890a8,
+ /// or in textual repr: setCollectionLimit(string,uint256)
+ function setCollectionLimit(string memory limit, uint256 value) external;
/// Get contract address.
/// @dev EVM selector for this function is: 0xf6b4dfb4,
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -80,7 +80,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x324a7f5b
+/// @dev the ERC-165 identifier for this interface is 0x8b91d192
interface Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -180,21 +180,13 @@
/// "tokenLimit",
/// "sponsorTransferTimeout",
/// "sponsorApproveTimeout"
- /// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x6a3841db,
- /// or in textual repr: setCollectionLimit(string,uint32)
- function setCollectionLimit(string memory limit, uint32 value) external;
-
- /// Set limits for the collection.
- /// @dev Throws error if limit not found.
- /// @param limit Name of the limit. Valid names:
- /// "ownerCanTransfer",
+ /// "ownerCanTransfer",
/// "ownerCanDestroy",
/// "transfersEnabled"
/// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x993b7fba,
- /// or in textual repr: setCollectionLimit(string,bool)
- function setCollectionLimit(string memory limit, bool value) external;
+ /// @dev EVM selector for this function is: 0x4ad890a8,
+ /// or in textual repr: setCollectionLimit(string,uint256)
+ function setCollectionLimit(string memory limit, uint256 value) external;
/// Get contract address.
/// @dev EVM selector for this function is: 0xf6b4dfb4,
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -80,7 +80,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x324a7f5b
+/// @dev the ERC-165 identifier for this interface is 0x8b91d192
interface Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -180,21 +180,13 @@
/// "tokenLimit",
/// "sponsorTransferTimeout",
/// "sponsorApproveTimeout"
- /// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x6a3841db,
- /// or in textual repr: setCollectionLimit(string,uint32)
- function setCollectionLimit(string memory limit, uint32 value) external;
-
- /// Set limits for the collection.
- /// @dev Throws error if limit not found.
- /// @param limit Name of the limit. Valid names:
- /// "ownerCanTransfer",
+ /// "ownerCanTransfer",
/// "ownerCanDestroy",
/// "transfersEnabled"
/// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x993b7fba,
- /// or in textual repr: setCollectionLimit(string,bool)
- function setCollectionLimit(string memory limit, bool value) external;
+ /// @dev EVM selector for this function is: 0x4ad890a8,
+ /// or in textual repr: setCollectionLimit(string,uint256)
+ function setCollectionLimit(string memory limit, uint256 value) external;
/// Get contract address.
/// @dev EVM selector for this function is: 0xf6b4dfb4,
tests/src/eth/createFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createFTCollection.test.ts
+++ b/tests/src/eth/createFTCollection.test.ts
@@ -85,32 +85,44 @@
tokenLimit: 1000000,
sponsorTransferTimeout: 6,
sponsorApproveTimeout: 6,
+ ownerCanTransfer: 0,
+ ownerCanDestroy: 0,
+ transfersEnabled: 0,
+ };
+
+ const expectedLimits = {
+ accountTokenOwnershipLimit: 1000,
+ sponsoredDataSize: 1024,
+ sponsoredDataRateLimit: 30,
+ tokenLimit: 1000000,
+ sponsorTransferTimeout: 6,
+ sponsorApproveTimeout: 6,
ownerCanTransfer: false,
ownerCanDestroy: false,
transfersEnabled: false,
};
-
+
const collection = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
- await collection.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
- await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();
- await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
- await collection.methods['setCollectionLimit(string,uint32)']('tokenLimit', limits.tokenLimit).send();
- await collection.methods['setCollectionLimit(string,uint32)']('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
- await collection.methods['setCollectionLimit(string,uint32)']('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
- await collection.methods['setCollectionLimit(string,bool)']('ownerCanTransfer', limits.ownerCanTransfer).send();
- await collection.methods['setCollectionLimit(string,bool)']('ownerCanDestroy', limits.ownerCanDestroy).send();
- await collection.methods['setCollectionLimit(string,bool)']('transfersEnabled', limits.transfersEnabled).send();
+ await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
+ await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();
+ await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
+ await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();
+ await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
+ await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
+ await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();
+ await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();
+ await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();
const data = (await helper.rft.getData(collectionId))!;
- expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(limits.accountTokenOwnershipLimit);
- expect(data.raw.limits.sponsoredDataSize).to.be.eq(limits.sponsoredDataSize);
- expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(limits.sponsoredDataRateLimit);
- expect(data.raw.limits.tokenLimit).to.be.eq(limits.tokenLimit);
- expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(limits.sponsorTransferTimeout);
- expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(limits.sponsorApproveTimeout);
- expect(data.raw.limits.ownerCanTransfer).to.be.eq(limits.ownerCanTransfer);
- expect(data.raw.limits.ownerCanDestroy).to.be.eq(limits.ownerCanDestroy);
- expect(data.raw.limits.transfersEnabled).to.be.eq(limits.transfersEnabled);
+ expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
+ expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
+ expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
+ expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
+ expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
+ expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
+ expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
+ expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
+ expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
});
itEth('Collection address exist', async ({helper}) => {
@@ -257,11 +269,28 @@
});
itEth('(!negative test!) Set limits', async ({helper}) => {
+
+ const invalidLimits = {
+ accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
+ transfersEnabled: 3,
+ };
+
const owner = await helper.eth.createAccountWithBalance(donor);
const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'ISNI');
const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
await expect(collectionEvm.methods
- .setCollectionLimit('badLimit', 'true')
- .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');
+ .setCollectionLimit('badLimit', '1')
+ .call()).to.be.rejectedWith('unknown limit "badLimit"');
+
+ await expect(collectionEvm.methods
+ .setCollectionLimit(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)
+ .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
+
+ await expect(collectionEvm.methods
+ .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)
+ .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
});
+
+
+
});
tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createNFTCollection.test.ts
+++ b/tests/src/eth/createNFTCollection.test.ts
@@ -124,32 +124,44 @@
tokenLimit: 1000000,
sponsorTransferTimeout: 6,
sponsorApproveTimeout: 6,
+ ownerCanTransfer: 0,
+ ownerCanDestroy: 0,
+ transfersEnabled: 0,
+ };
+
+ const expectedLimits = {
+ accountTokenOwnershipLimit: 1000,
+ sponsoredDataSize: 1024,
+ sponsoredDataRateLimit: 30,
+ tokenLimit: 1000000,
+ sponsorTransferTimeout: 6,
+ sponsorApproveTimeout: 6,
ownerCanTransfer: false,
ownerCanDestroy: false,
transfersEnabled: false,
};
const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
- await collection.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
- await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();
- await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
- await collection.methods['setCollectionLimit(string,uint32)']('tokenLimit', limits.tokenLimit).send();
- await collection.methods['setCollectionLimit(string,uint32)']('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
- await collection.methods['setCollectionLimit(string,uint32)']('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
- await collection.methods['setCollectionLimit(string,bool)']('ownerCanTransfer', limits.ownerCanTransfer).send();
- await collection.methods['setCollectionLimit(string,bool)']('ownerCanDestroy', limits.ownerCanDestroy).send();
- await collection.methods['setCollectionLimit(string,bool)']('transfersEnabled', limits.transfersEnabled).send();
+ await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
+ await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();
+ await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
+ await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();
+ await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
+ await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
+ await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();
+ await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();
+ await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();
- const data = (await helper.nft.getData(collectionId))!;
- expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(limits.accountTokenOwnershipLimit);
- expect(data.raw.limits.sponsoredDataSize).to.be.eq(limits.sponsoredDataSize);
- expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(limits.sponsoredDataRateLimit);
- expect(data.raw.limits.tokenLimit).to.be.eq(limits.tokenLimit);
- expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(limits.sponsorTransferTimeout);
- expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(limits.sponsorApproveTimeout);
- expect(data.raw.limits.ownerCanTransfer).to.be.eq(limits.ownerCanTransfer);
- expect(data.raw.limits.ownerCanDestroy).to.be.eq(limits.ownerCanDestroy);
- expect(data.raw.limits.transfersEnabled).to.be.eq(limits.transfersEnabled);
+ const data = (await helper.rft.getData(collectionId))!;
+ expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
+ expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
+ expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
+ expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
+ expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
+ expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
+ expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
+ expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
+ expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
});
itEth('Collection address exist', async ({helper}) => {
@@ -270,12 +282,22 @@
});
itEth('(!negative test!) Set limits', async ({helper}) => {
+ const invalidLimits = {
+ accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
+ transfersEnabled: 3,
+ };
+
const owner = await helper.eth.createAccountWithBalance(donor);
const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');
const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
+
+ await expect(collectionEvm.methods
+ .setCollectionLimit(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)
+ .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
+
await expect(collectionEvm.methods
- .setCollectionLimit('badLimit', 'true')
- .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');
+ .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)
+ .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
});
itEth('destroyCollection', async ({helper}) => {
tests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -159,32 +159,44 @@
tokenLimit: 1000000,
sponsorTransferTimeout: 6,
sponsorApproveTimeout: 6,
+ ownerCanTransfer: 0,
+ ownerCanDestroy: 0,
+ transfersEnabled: 0,
+ };
+
+ const expectedLimits = {
+ accountTokenOwnershipLimit: 1000,
+ sponsoredDataSize: 1024,
+ sponsoredDataRateLimit: 30,
+ tokenLimit: 1000000,
+ sponsorTransferTimeout: 6,
+ sponsorApproveTimeout: 6,
ownerCanTransfer: false,
ownerCanDestroy: false,
transfersEnabled: false,
};
-
+
const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
- await collection.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
- await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();
- await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
- await collection.methods['setCollectionLimit(string,uint32)']('tokenLimit', limits.tokenLimit).send();
- await collection.methods['setCollectionLimit(string,uint32)']('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
- await collection.methods['setCollectionLimit(string,uint32)']('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
- await collection.methods['setCollectionLimit(string,bool)']('ownerCanTransfer', limits.ownerCanTransfer).send();
- await collection.methods['setCollectionLimit(string,bool)']('ownerCanDestroy', limits.ownerCanDestroy).send();
- await collection.methods['setCollectionLimit(string,bool)']('transfersEnabled', limits.transfersEnabled).send();
+ await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
+ await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();
+ await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
+ await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();
+ await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
+ await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
+ await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();
+ await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();
+ await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();
const data = (await helper.rft.getData(collectionId))!;
- expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(limits.accountTokenOwnershipLimit);
- expect(data.raw.limits.sponsoredDataSize).to.be.eq(limits.sponsoredDataSize);
- expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(limits.sponsoredDataRateLimit);
- expect(data.raw.limits.tokenLimit).to.be.eq(limits.tokenLimit);
- expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(limits.sponsorTransferTimeout);
- expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(limits.sponsorApproveTimeout);
- expect(data.raw.limits.ownerCanTransfer).to.be.eq(limits.ownerCanTransfer);
- expect(data.raw.limits.ownerCanDestroy).to.be.eq(limits.ownerCanDestroy);
- expect(data.raw.limits.transfersEnabled).to.be.eq(limits.transfersEnabled);
+ expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
+ expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
+ expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
+ expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
+ expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
+ expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
+ expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
+ expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
+ expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
});
itEth('Collection address exist', async ({helper}) => {
@@ -305,12 +317,22 @@
});
itEth('(!negative test!) Set limits', async ({helper}) => {
+ const invalidLimits = {
+ accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
+ transfersEnabled: 3,
+ };
+
const owner = await helper.eth.createAccountWithBalance(donor);
const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'ISNI');
const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
+
+ await expect(collectionEvm.methods
+ .setCollectionLimit(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)
+ .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
+
await expect(collectionEvm.methods
- .setCollectionLimit('badLimit', 'true')
- .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');
+ .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)
+ .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
});
itEth('destroyCollection', async ({helper}) => {