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.soldiffbeforeafterboth--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -18,7 +18,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.
// ///
@@ -167,26 +167,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/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.jsondiffbeforeafterboth1[2 {3 "anonymous": false,4 "inputs": [5 {6 "indexed": true,7 "internalType": "address",8 "name": "owner",9 "type": "address"10 },11 {12 "indexed": true,13 "internalType": "address",14 "name": "approved",15 "type": "address"16 },17 {18 "indexed": true,19 "internalType": "uint256",20 "name": "tokenId",21 "type": "uint256"22 }23 ],24 "name": "Approval",25 "type": "event"26 },27 {28 "anonymous": false,29 "inputs": [30 {31 "indexed": true,32 "internalType": "address",33 "name": "owner",34 "type": "address"35 },36 {37 "indexed": true,38 "internalType": "address",39 "name": "operator",40 "type": "address"41 },42 {43 "indexed": false,44 "internalType": "bool",45 "name": "approved",46 "type": "bool"47 }48 ],49 "name": "ApprovalForAll",50 "type": "event"51 },52 {53 "anonymous": false,54 "inputs": [],55 "name": "MintingFinished",56 "type": "event"57 },58 {59 "anonymous": false,60 "inputs": [61 {62 "indexed": true,63 "internalType": "address",64 "name": "from",65 "type": "address"66 },67 {68 "indexed": true,69 "internalType": "address",70 "name": "to",71 "type": "address"72 },73 {74 "indexed": true,75 "internalType": "uint256",76 "name": "tokenId",77 "type": "uint256"78 }79 ],80 "name": "Transfer",81 "type": "event"82 },83 {84 "inputs": [85 {86 "components": [87 { "internalType": "address", "name": "eth", "type": "address" },88 { "internalType": "uint256", "name": "sub", "type": "uint256" }89 ],90 "internalType": "struct EthCrossAccount",91 "name": "newAdmin",92 "type": "tuple"93 }94 ],95 "name": "addCollectionAdminCross",96 "outputs": [],97 "stateMutability": "nonpayable",98 "type": "function"99 },100 {101 "inputs": [102 {103 "components": [104 { "internalType": "address", "name": "eth", "type": "address" },105 { "internalType": "uint256", "name": "sub", "type": "uint256" }106 ],107 "internalType": "struct EthCrossAccount",108 "name": "user",109 "type": "tuple"110 }111 ],112 "name": "addToCollectionAllowListCross",113 "outputs": [],114 "stateMutability": "nonpayable",115 "type": "function"116 },117 {118 "inputs": [119 { "internalType": "address", "name": "user", "type": "address" }120 ],121 "name": "allowed",122 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],123 "stateMutability": "view",124 "type": "function"125 },126 {127 "inputs": [128 { "internalType": "address", "name": "approved", "type": "address" },129 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }130 ],131 "name": "approve",132 "outputs": [],133 "stateMutability": "nonpayable",134 "type": "function"135 },136 {137 "inputs": [138 {139 "components": [140 { "internalType": "address", "name": "eth", "type": "address" },141 { "internalType": "uint256", "name": "sub", "type": "uint256" }142 ],143 "internalType": "struct EthCrossAccount",144 "name": "approved",145 "type": "tuple"146 },147 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }148 ],149 "name": "approveCross",150 "outputs": [],151 "stateMutability": "nonpayable",152 "type": "function"153 },154 {155 "inputs": [156 { "internalType": "address", "name": "owner", "type": "address" }157 ],158 "name": "balanceOf",159 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],160 "stateMutability": "view",161 "type": "function"162 },163 {164 "inputs": [165 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }166 ],167 "name": "burn",168 "outputs": [],169 "stateMutability": "nonpayable",170 "type": "function"171 },172 {173 "inputs": [174 {175 "components": [176 { "internalType": "address", "name": "eth", "type": "address" },177 { "internalType": "uint256", "name": "sub", "type": "uint256" }178 ],179 "internalType": "struct EthCrossAccount",180 "name": "from",181 "type": "tuple"182 },183 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }184 ],185 "name": "burnFromCross",186 "outputs": [],187 "stateMutability": "nonpayable",188 "type": "function"189 },190 {191 "inputs": [192 {193 "components": [194 { "internalType": "address", "name": "eth", "type": "address" },195 { "internalType": "uint256", "name": "sub", "type": "uint256" }196 ],197 "internalType": "struct EthCrossAccount",198 "name": "newOwner",199 "type": "tuple"200 }201 ],202 "name": "changeCollectionOwnerCross",203 "outputs": [],204 "stateMutability": "nonpayable",205 "type": "function"206 },207 {208 "inputs": [],209 "name": "collectionAdmins",210 "outputs": [211 {212 "components": [213 { "internalType": "address", "name": "eth", "type": "address" },214 { "internalType": "uint256", "name": "sub", "type": "uint256" }215 ],216 "internalType": "struct EthCrossAccount[]",217 "name": "",218 "type": "tuple[]"219 }220 ],221 "stateMutability": "view",222 "type": "function"223 },224 {225 "inputs": [],226 "name": "collectionOwner",227 "outputs": [228 {229 "components": [230 { "internalType": "address", "name": "eth", "type": "address" },231 { "internalType": "uint256", "name": "sub", "type": "uint256" }232 ],233 "internalType": "struct EthCrossAccount",234 "name": "",235 "type": "tuple"236 }237 ],238 "stateMutability": "view",239 "type": "function"240 },241 {242 "inputs": [243 { "internalType": "string[]", "name": "keys", "type": "string[]" }244 ],245 "name": "collectionProperties",246 "outputs": [247 {248 "components": [249 { "internalType": "string", "name": "field_0", "type": "string" },250 { "internalType": "bytes", "name": "field_1", "type": "bytes" }251 ],252 "internalType": "struct Tuple23[]",253 "name": "",254 "type": "tuple[]"255 }256 ],257 "stateMutability": "view",258 "type": "function"259 },260 {261 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],262 "name": "collectionProperty",263 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],264 "stateMutability": "view",265 "type": "function"266 },267 {268 "inputs": [],269 "name": "collectionSponsor",270 "outputs": [271 {272 "components": [273 { "internalType": "address", "name": "field_0", "type": "address" },274 { "internalType": "uint256", "name": "field_1", "type": "uint256" }275 ],276 "internalType": "struct Tuple26",277 "name": "",278 "type": "tuple"279 }280 ],281 "stateMutability": "view",282 "type": "function"283 },284 {285 "inputs": [],286 "name": "confirmCollectionSponsorship",287 "outputs": [],288 "stateMutability": "nonpayable",289 "type": "function"290 },291 {292 "inputs": [],293 "name": "contractAddress",294 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],295 "stateMutability": "view",296 "type": "function"297 },298 {299 "inputs": [300 { "internalType": "string[]", "name": "keys", "type": "string[]" }301 ],302 "name": "deleteCollectionProperties",303 "outputs": [],304 "stateMutability": "nonpayable",305 "type": "function"306 },307 {308 "inputs": [309 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },310 { "internalType": "string[]", "name": "keys", "type": "string[]" }311 ],312 "name": "deleteProperties",313 "outputs": [],314 "stateMutability": "nonpayable",315 "type": "function"316 },317 {318 "inputs": [],319 "name": "finishMinting",320 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],321 "stateMutability": "nonpayable",322 "type": "function"323 },324 {325 "inputs": [326 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }327 ],328 "name": "getApproved",329 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],330 "stateMutability": "view",331 "type": "function"332 },333 {334 "inputs": [],335 "name": "hasCollectionPendingSponsor",336 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],337 "stateMutability": "view",338 "type": "function"339 },340 {341 "inputs": [342 { "internalType": "address", "name": "owner", "type": "address" },343 { "internalType": "address", "name": "operator", "type": "address" }344 ],345 "name": "isApprovedForAll",346 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],347 "stateMutability": "view",348 "type": "function"349 },350 {351 "inputs": [352 {353 "components": [354 { "internalType": "address", "name": "eth", "type": "address" },355 { "internalType": "uint256", "name": "sub", "type": "uint256" }356 ],357 "internalType": "struct EthCrossAccount",358 "name": "user",359 "type": "tuple"360 }361 ],362 "name": "isOwnerOrAdminCross",363 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],364 "stateMutability": "view",365 "type": "function"366 },367 {368 "inputs": [{ "internalType": "address", "name": "to", "type": "address" }],369 "name": "mint",370 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],371 "stateMutability": "nonpayable",372 "type": "function"373 },374 {375 "inputs": [376 { "internalType": "address", "name": "to", "type": "address" },377 { "internalType": "string", "name": "tokenUri", "type": "string" }378 ],379 "name": "mintWithTokenURI",380 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],381 "stateMutability": "nonpayable",382 "type": "function"383 },384 {385 "inputs": [],386 "name": "mintingFinished",387 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],388 "stateMutability": "view",389 "type": "function"390 },391 {392 "inputs": [],393 "name": "name",394 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],395 "stateMutability": "view",396 "type": "function"397 },398 {399 "inputs": [],400 "name": "nextTokenId",401 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],402 "stateMutability": "view",403 "type": "function"404 },405 {406 "inputs": [407 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }408 ],409 "name": "ownerOf",410 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],411 "stateMutability": "view",412 "type": "function"413 },414 {415 "inputs": [416 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },417 { "internalType": "string", "name": "key", "type": "string" }418 ],419 "name": "property",420 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],421 "stateMutability": "view",422 "type": "function"423 },424 {425 "inputs": [426 {427 "components": [428 { "internalType": "address", "name": "eth", "type": "address" },429 { "internalType": "uint256", "name": "sub", "type": "uint256" }430 ],431 "internalType": "struct EthCrossAccount",432 "name": "admin",433 "type": "tuple"434 }435 ],436 "name": "removeCollectionAdminCross",437 "outputs": [],438 "stateMutability": "nonpayable",439 "type": "function"440 },441 {442 "inputs": [],443 "name": "removeCollectionSponsor",444 "outputs": [],445 "stateMutability": "nonpayable",446 "type": "function"447 },448 {449 "inputs": [450 {451 "components": [452 { "internalType": "address", "name": "eth", "type": "address" },453 { "internalType": "uint256", "name": "sub", "type": "uint256" }454 ],455 "internalType": "struct EthCrossAccount",456 "name": "user",457 "type": "tuple"458 }459 ],460 "name": "removeFromCollectionAllowListCross",461 "outputs": [],462 "stateMutability": "nonpayable",463 "type": "function"464 },465 {466 "inputs": [467 { "internalType": "address", "name": "from", "type": "address" },468 { "internalType": "address", "name": "to", "type": "address" },469 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }470 ],471 "name": "safeTransferFrom",472 "outputs": [],473 "stateMutability": "nonpayable",474 "type": "function"475 },476 {477 "inputs": [478 { "internalType": "address", "name": "from", "type": "address" },479 { "internalType": "address", "name": "to", "type": "address" },480 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },481 { "internalType": "bytes", "name": "data", "type": "bytes" }482 ],483 "name": "safeTransferFrom",484 "outputs": [],485 "stateMutability": "nonpayable",486 "type": "function"487 },488 {489 "inputs": [490 { "internalType": "address", "name": "operator", "type": "address" },491 { "internalType": "bool", "name": "approved", "type": "bool" }492 ],493 "name": "setApprovalForAll",494 "outputs": [],495 "stateMutability": "nonpayable",496 "type": "function"497 },498 {499 "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],500 "name": "setCollectionAccess",501 "outputs": [],502 "stateMutability": "nonpayable",503 "type": "function"504 },505 {506 "inputs": [507 { "internalType": "string", "name": "limit", "type": "string" },508 { "internalType": "uint256", "name": "value", "type": "uint256" }509 ],510 "name": "setCollectionLimit",511 "outputs": [],512 "stateMutability": "nonpayable",513 "type": "function"514 },515 {516 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],517 "name": "setCollectionMintMode",518 "outputs": [],519 "stateMutability": "nonpayable",520 "type": "function"521 },522 {523 "inputs": [{ "internalType": "bool", "name": "enable", "type": "bool" }],524 "name": "setCollectionNesting",525 "outputs": [],526 "stateMutability": "nonpayable",527 "type": "function"528 },529 {530 "inputs": [531 { "internalType": "bool", "name": "enable", "type": "bool" },532 {533 "internalType": "address[]",534 "name": "collections",535 "type": "address[]"536 }537 ],538 "name": "setCollectionNesting",539 "outputs": [],540 "stateMutability": "nonpayable",541 "type": "function"542 },543 {544 "inputs": [545 {546 "components": [547 { "internalType": "string", "name": "key", "type": "string" },548 { "internalType": "bytes", "name": "value", "type": "bytes" }549 ],550 "internalType": "struct Property[]",551 "name": "properties",552 "type": "tuple[]"553 }554 ],555 "name": "setCollectionProperties",556 "outputs": [],557 "stateMutability": "nonpayable",558 "type": "function"559 },560 {561 "inputs": [562 {563 "components": [564 { "internalType": "address", "name": "eth", "type": "address" },565 { "internalType": "uint256", "name": "sub", "type": "uint256" }566 ],567 "internalType": "struct EthCrossAccount",568 "name": "sponsor",569 "type": "tuple"570 }571 ],572 "name": "setCollectionSponsorCross",573 "outputs": [],574 "stateMutability": "nonpayable",575 "type": "function"576 },577 {578 "inputs": [579 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },580 {581 "components": [582 { "internalType": "string", "name": "key", "type": "string" },583 { "internalType": "bytes", "name": "value", "type": "bytes" }584 ],585 "internalType": "struct Property[]",586 "name": "properties",587 "type": "tuple[]"588 }589 ],590 "name": "setProperties",591 "outputs": [],592 "stateMutability": "nonpayable",593 "type": "function"594 },595 {596 "inputs": [597 { "internalType": "string", "name": "key", "type": "string" },598 { "internalType": "bool", "name": "isMutable", "type": "bool" },599 { "internalType": "bool", "name": "collectionAdmin", "type": "bool" },600 { "internalType": "bool", "name": "tokenOwner", "type": "bool" }601 ],602 "name": "setTokenPropertyPermission",603 "outputs": [],604 "stateMutability": "nonpayable",605 "type": "function"606 },607 {608 "inputs": [609 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }610 ],611 "name": "supportsInterface",612 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],613 "stateMutability": "view",614 "type": "function"615 },616 {617 "inputs": [],618 "name": "symbol",619 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],620 "stateMutability": "view",621 "type": "function"622 },623 {624 "inputs": [625 { "internalType": "uint256", "name": "index", "type": "uint256" }626 ],627 "name": "tokenByIndex",628 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],629 "stateMutability": "view",630 "type": "function"631 },632 {633 "inputs": [634 { "internalType": "address", "name": "owner", "type": "address" },635 { "internalType": "uint256", "name": "index", "type": "uint256" }636 ],637 "name": "tokenOfOwnerByIndex",638 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],639 "stateMutability": "view",640 "type": "function"641 },642 {643 "inputs": [644 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }645 ],646 "name": "tokenURI",647 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],648 "stateMutability": "view",649 "type": "function"650 },651 {652 "inputs": [],653 "name": "totalSupply",654 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],655 "stateMutability": "view",656 "type": "function"657 },658 {659 "inputs": [660 { "internalType": "address", "name": "to", "type": "address" },661 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }662 ],663 "name": "transfer",664 "outputs": [],665 "stateMutability": "nonpayable",666 "type": "function"667 },668 {669 "inputs": [670 {671 "components": [672 { "internalType": "address", "name": "eth", "type": "address" },673 { "internalType": "uint256", "name": "sub", "type": "uint256" }674 ],675 "internalType": "struct EthCrossAccount",676 "name": "to",677 "type": "tuple"678 },679 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }680 ],681 "name": "transferCross",682 "outputs": [],683 "stateMutability": "nonpayable",684 "type": "function"685 },686 {687 "inputs": [688 { "internalType": "address", "name": "from", "type": "address" },689 { "internalType": "address", "name": "to", "type": "address" },690 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }691 ],692 "name": "transferFrom",693 "outputs": [],694 "stateMutability": "nonpayable",695 "type": "function"696 },697 {698 "inputs": [699 {700 "components": [701 { "internalType": "address", "name": "eth", "type": "address" },702 { "internalType": "uint256", "name": "sub", "type": "uint256" }703 ],704 "internalType": "struct EthCrossAccount",705 "name": "from",706 "type": "tuple"707 },708 {709 "components": [710 { "internalType": "address", "name": "eth", "type": "address" },711 { "internalType": "uint256", "name": "sub", "type": "uint256" }712 ],713 "internalType": "struct EthCrossAccount",714 "name": "to",715 "type": "tuple"716 },717 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }718 ],719 "name": "transferFromCross",720 "outputs": [],721 "stateMutability": "nonpayable",722 "type": "function"723 },724 {725 "inputs": [],726 "name": "uniqueCollectionType",727 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],728 "stateMutability": "view",729 "type": "function"730 }731]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}) => {