git.delta.rocks / unique-network / refs/commits / 2e0d1a668d33

difftreelog

feature/setCollectionLimit Behavior of the `setCollectionLimit` method. Removed method overload: single signature `(string, uint256)` is used for both cases.

PraetorP2022-11-16parent: #78a9ca0.patch.diff
in: master

22 files changed

modifiedCargo.lockdiffbeforeafterboth
58315831
5832[[package]]5832[[package]]
5833name = "pallet-common"5833name = "pallet-common"
5834version = "0.1.10"5834version = "0.1.11"
5835dependencies = [5835dependencies = [
5836 "ethereum",5836 "ethereum",
5837 "evm-coder",5837 "evm-coder",
modifiedpallets/common/CHANGELOG.mddiffbeforeafterboth
22
3All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.
44
5<!-- bureaucrate goes here -->
6
7## [0.1.11] - 2022-11-16
8
9### Changed
10
11- Behavior of the `setCollectionLimit` method.
12 Removed method overload: single signature `(string, uint256)`
13 is used for both cases.
14
5## [0.1.10] - 2022-11-0215## [0.1.10] - 2022-11-02
16
6### Changed17### Changed
7 - Use named structure `EthCrossAccount` in eth functions.
818
19- Use named structure `EthCrossAccount` in eth functions.
20
9## [0.1.9] - 2022-10-1321## [0.1.9] - 2022-10-13
1022
11## Added23## Added
34### Added46### Added
3547
36- New Ethereum API methods: changeOwner, changeOwner(Substrate) and verifyOwnerOrAdmin(Substrate).48- New Ethereum API methods: changeOwner, changeOwner(Substrate) and verifyOwnerOrAdmin(Substrate).
37
38<!-- bureaucrate goes here -->
3949
40## [v0.1.5] 2022-08-1650## [v0.1.5] 2022-08-16
4151
modifiedpallets/common/Cargo.tomldiffbeforeafterboth
1[package]1[package]
2name = "pallet-common"2name = "pallet-common"
3version = "0.1.10"3version = "0.1.11"
4license = "GPLv3"4license = "GPLv3"
5edition = "2021"5edition = "2021"
66
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
303 /// "tokenLimit",303 /// "tokenLimit",
304 /// "sponsorTransferTimeout",304 /// "sponsorTransferTimeout",
305 /// "sponsorApproveTimeout"305 /// "sponsorApproveTimeout"
306 /// "ownerCanTransfer",
307 /// "ownerCanDestroy",
308 /// "transfersEnabled"
306 /// @param value Value of the limit.309 /// @param value Value of the limit.
307 #[solidity(rename_selector = "setCollectionLimit")]310 #[solidity(rename_selector = "setCollectionLimit")]
308 fn set_int_limit(&mut self, caller: caller, limit: string, value: uint32) -> Result<void> {311 fn set_int_limit(&mut self, caller: caller, limit: string, value: uint256) -> Result<void> {
309 self.consume_store_reads_and_writes(1, 1)?;312 self.consume_store_reads_and_writes(1, 1)?;
313
314 let value = value
315 .try_into()
316 .map_err(|_| Error::Revert(format!("can't convert value to u32 \"{}\"", value)))?;
317
318 let convert_value_to_bool = || match value {
319 0 => Ok(false),
320 1 => Ok(true),
321 _ => {
322 return Err(Error::Revert(format!(
323 "can't convert value to boolean \"{}\"",
324 value
325 )))
326 }
327 };
310328
311 check_is_owner_or_admin(caller, self)?;329 check_is_owner_or_admin(caller, self)?;
312 let mut limits = self.limits.clone();330 let mut limits = self.limits.clone();
330 "sponsorApproveTimeout" => {348 "sponsorApproveTimeout" => {
331 limits.sponsor_approve_timeout = Some(value);349 limits.sponsor_approve_timeout = Some(value);
332 }350 }
351 "ownerCanTransfer" => {
352 limits.owner_can_transfer = Some(convert_value_to_bool()?);
353 }
354 "ownerCanDestroy" => {
355 limits.owner_can_destroy = Some(convert_value_to_bool()?);
356 }
357 "transfersEnabled" => {
358 limits.transfers_enabled = Some(convert_value_to_bool()?);
359 }
333 _ => {360 _ => return Err(Error::Revert(format!("unknown limit \"{}\"", limit))),
334 return Err(Error::Revert(format!(
335 "unknown integer limit \"{}\"",
336 limit
337 )))
338 }
339 }361 }
340 self.limits = <Pallet<T>>::clamp_limits(self.mode.clone(), &self.limits, limits)362 self.limits = <Pallet<T>>::clamp_limits(self.mode.clone(), &self.limits, limits)
341 .map_err(dispatch_to_evm::<T>)?;363 .map_err(dispatch_to_evm::<T>)?;
342 save(self)364 save(self)
343 }365 }
344
345 /// Set limits for the collection.
346 /// @dev Throws error if limit not found.
347 /// @param limit Name of the limit. Valid names:
348 /// "ownerCanTransfer",
349 /// "ownerCanDestroy",
350 /// "transfersEnabled"
351 /// @param value Value of the limit.
352 #[solidity(rename_selector = "setCollectionLimit")]
353 fn set_bool_limit(&mut self, caller: caller, limit: string, value: bool) -> Result<void> {
354 self.consume_store_reads_and_writes(1, 1)?;
355
356 check_is_owner_or_admin(caller, self)?;
357 let mut limits = self.limits.clone();
358
359 match limit.as_str() {
360 "ownerCanTransfer" => {
361 limits.owner_can_transfer = Some(value);
362 }
363 "ownerCanDestroy" => {
364 limits.owner_can_destroy = Some(value);
365 }
366 "transfersEnabled" => {
367 limits.transfers_enabled = Some(value);
368 }
369 _ => {
370 return Err(Error::Revert(format!(
371 "unknown boolean limit \"{}\"",
372 limit
373 )))
374 }
375 }
376 self.limits = <Pallet<T>>::clamp_limits(self.mode.clone(), &self.limits, limits)
377 .map_err(dispatch_to_evm::<T>)?;
378 save(self)
379 }
380366
381 /// Get contract address.367 /// Get contract address.
382 fn contract_address(&self) -> Result<address> {368 fn contract_address(&self) -> Result<address> {
modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
18}18}
1919
20/// @title A contract that allows you to work with collections.20/// @title A contract that allows you to work with collections.
21/// @dev the ERC-165 identifier for this interface is 0x324a7f5b21/// @dev the ERC-165 identifier for this interface is 0x8b91d192
22contract Collection is Dummy, ERC165 {22contract Collection is Dummy, ERC165 {
23 // /// Set collection property.23 // /// Set collection property.
24 // ///24 // ///
167 /// "tokenLimit",167 /// "tokenLimit",
168 /// "sponsorTransferTimeout",168 /// "sponsorTransferTimeout",
169 /// "sponsorApproveTimeout"169 /// "sponsorApproveTimeout"
170 /// @param value Value of the limit.
171 /// @dev EVM selector for this function is: 0x6a3841db,
172 /// or in textual repr: setCollectionLimit(string,uint32)
173 function setCollectionLimit(string memory limit, uint32 value) public {
174 require(false, stub_error);
175 limit;
176 value;
177 dummy = 0;
178 }
179
180 /// Set limits for the collection.
181 /// @dev Throws error if limit not found.
182 /// @param limit Name of the limit. Valid names:
183 /// "ownerCanTransfer",170 /// "ownerCanTransfer",
184 /// "ownerCanDestroy",171 /// "ownerCanDestroy",
185 /// "transfersEnabled"172 /// "transfersEnabled"
186 /// @param value Value of the limit.173 /// @param value Value of the limit.
187 /// @dev EVM selector for this function is: 0x993b7fba,174 /// @dev EVM selector for this function is: 0x4ad890a8,
188 /// or in textual repr: setCollectionLimit(string,bool)175 /// or in textual repr: setCollectionLimit(string,uint256)
189 function setCollectionLimit(string memory limit, bool value) public {176 function setCollectionLimit(string memory limit, uint256 value) public {
190 require(false, stub_error);177 require(false, stub_error);
191 limit;178 limit;
192 value;179 value;
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
119}119}
120120
121/// @title A contract that allows you to work with collections.121/// @title A contract that allows you to work with collections.
122/// @dev the ERC-165 identifier for this interface is 0x324a7f5b122/// @dev the ERC-165 identifier for this interface is 0x8b91d192
123contract Collection is Dummy, ERC165 {123contract Collection is Dummy, ERC165 {
124 // /// Set collection property.124 // /// Set collection property.
125 // ///125 // ///
268 /// "tokenLimit",268 /// "tokenLimit",
269 /// "sponsorTransferTimeout",269 /// "sponsorTransferTimeout",
270 /// "sponsorApproveTimeout"270 /// "sponsorApproveTimeout"
271 /// @param value Value of the limit.
272 /// @dev EVM selector for this function is: 0x6a3841db,
273 /// or in textual repr: setCollectionLimit(string,uint32)
274 function setCollectionLimit(string memory limit, uint32 value) public {
275 require(false, stub_error);
276 limit;
277 value;
278 dummy = 0;
279 }
280
281 /// Set limits for the collection.
282 /// @dev Throws error if limit not found.
283 /// @param limit Name of the limit. Valid names:
284 /// "ownerCanTransfer",271 /// "ownerCanTransfer",
285 /// "ownerCanDestroy",272 /// "ownerCanDestroy",
286 /// "transfersEnabled"273 /// "transfersEnabled"
287 /// @param value Value of the limit.274 /// @param value Value of the limit.
288 /// @dev EVM selector for this function is: 0x993b7fba,275 /// @dev EVM selector for this function is: 0x4ad890a8,
289 /// or in textual repr: setCollectionLimit(string,bool)276 /// or in textual repr: setCollectionLimit(string,uint256)
290 function setCollectionLimit(string memory limit, bool value) public {277 function setCollectionLimit(string memory limit, uint256 value) public {
291 require(false, stub_error);278 require(false, stub_error);
292 limit;279 limit;
293 value;280 value;
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
119}119}
120120
121/// @title A contract that allows you to work with collections.121/// @title A contract that allows you to work with collections.
122/// @dev the ERC-165 identifier for this interface is 0x324a7f5b122/// @dev the ERC-165 identifier for this interface is 0x8b91d192
123contract Collection is Dummy, ERC165 {123contract Collection is Dummy, ERC165 {
124 // /// Set collection property.124 // /// Set collection property.
125 // ///125 // ///
268 /// "tokenLimit",268 /// "tokenLimit",
269 /// "sponsorTransferTimeout",269 /// "sponsorTransferTimeout",
270 /// "sponsorApproveTimeout"270 /// "sponsorApproveTimeout"
271 /// @param value Value of the limit.
272 /// @dev EVM selector for this function is: 0x6a3841db,
273 /// or in textual repr: setCollectionLimit(string,uint32)
274 function setCollectionLimit(string memory limit, uint32 value) public {
275 require(false, stub_error);
276 limit;
277 value;
278 dummy = 0;
279 }
280
281 /// Set limits for the collection.
282 /// @dev Throws error if limit not found.
283 /// @param limit Name of the limit. Valid names:
284 /// "ownerCanTransfer",271 /// "ownerCanTransfer",
285 /// "ownerCanDestroy",272 /// "ownerCanDestroy",
286 /// "transfersEnabled"273 /// "transfersEnabled"
287 /// @param value Value of the limit.274 /// @param value Value of the limit.
288 /// @dev EVM selector for this function is: 0x993b7fba,275 /// @dev EVM selector for this function is: 0x4ad890a8,
289 /// or in textual repr: setCollectionLimit(string,bool)276 /// or in textual repr: setCollectionLimit(string,uint256)
290 function setCollectionLimit(string memory limit, bool value) public {277 function setCollectionLimit(string memory limit, uint256 value) public {
291 require(false, stub_error);278 require(false, stub_error);
292 limit;279 limit;
293 value;280 value;
modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedtests/src/eth/abi/fungible.jsondiffbeforeafterboth
390 {390 {
391 "inputs": [391 "inputs": [
392 { "internalType": "string", "name": "limit", "type": "string" },392 { "internalType": "string", "name": "limit", "type": "string" },
393 { "internalType": "uint32", "name": "value", "type": "uint32" }393 { "internalType": "uint256", "name": "value", "type": "uint256" }
394 ],394 ],
395 "name": "setCollectionLimit",395 "name": "setCollectionLimit",
396 "outputs": [],396 "outputs": [],
397 "stateMutability": "nonpayable",397 "stateMutability": "nonpayable",
398 "type": "function"398 "type": "function"
399 },399 },
400 {
401 "inputs": [
402 { "internalType": "string", "name": "limit", "type": "string" },
403 { "internalType": "bool", "name": "value", "type": "bool" }
404 ],
405 "name": "setCollectionLimit",
406 "outputs": [],
407 "stateMutability": "nonpayable",
408 "type": "function"
409 },
410 {400 {
411 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],401 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],
412 "name": "setCollectionMintMode",402 "name": "setCollectionMintMode",
modifiedtests/src/eth/abi/nonFungible.jsondiffbeforeafterboth
505 {505 {
506 "inputs": [506 "inputs": [
507 { "internalType": "string", "name": "limit", "type": "string" },507 { "internalType": "string", "name": "limit", "type": "string" },
508 { "internalType": "uint32", "name": "value", "type": "uint32" }508 { "internalType": "uint256", "name": "value", "type": "uint256" }
509 ],509 ],
510 "name": "setCollectionLimit",510 "name": "setCollectionLimit",
511 "outputs": [],511 "outputs": [],
512 "stateMutability": "nonpayable",512 "stateMutability": "nonpayable",
513 "type": "function"513 "type": "function"
514 },514 },
515 {
516 "inputs": [
517 { "internalType": "string", "name": "limit", "type": "string" },
518 { "internalType": "bool", "name": "value", "type": "bool" }
519 ],
520 "name": "setCollectionLimit",
521 "outputs": [],
522 "stateMutability": "nonpayable",
523 "type": "function"
524 },
525 {515 {
526 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],516 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],
527 "name": "setCollectionMintMode",517 "name": "setCollectionMintMode",
modifiedtests/src/eth/abi/reFungible.jsondiffbeforeafterboth
487 {487 {
488 "inputs": [488 "inputs": [
489 { "internalType": "string", "name": "limit", "type": "string" },489 { "internalType": "string", "name": "limit", "type": "string" },
490 { "internalType": "uint32", "name": "value", "type": "uint32" }490 { "internalType": "uint256", "name": "value", "type": "uint256" }
491 ],491 ],
492 "name": "setCollectionLimit",492 "name": "setCollectionLimit",
493 "outputs": [],493 "outputs": [],
494 "stateMutability": "nonpayable",494 "stateMutability": "nonpayable",
495 "type": "function"495 "type": "function"
496 },496 },
497 {
498 "inputs": [
499 { "internalType": "string", "name": "limit", "type": "string" },
500 { "internalType": "bool", "name": "value", "type": "bool" }
501 ],
502 "name": "setCollectionLimit",
503 "outputs": [],
504 "stateMutability": "nonpayable",
505 "type": "function"
506 },
507 {497 {
508 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],498 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],
509 "name": "setCollectionMintMode",499 "name": "setCollectionMintMode",
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
13}13}
1414
15/// @title A contract that allows you to work with collections.15/// @title A contract that allows you to work with collections.
16/// @dev the ERC-165 identifier for this interface is 0x324a7f5b16/// @dev the ERC-165 identifier for this interface is 0x8b91d192
17interface Collection is Dummy, ERC165 {17interface Collection is Dummy, ERC165 {
18 // /// Set collection property.18 // /// Set collection property.
19 // ///19 // ///
113 /// "tokenLimit",113 /// "tokenLimit",
114 /// "sponsorTransferTimeout",114 /// "sponsorTransferTimeout",
115 /// "sponsorApproveTimeout"115 /// "sponsorApproveTimeout"
116 /// @param value Value of the limit.
117 /// @dev EVM selector for this function is: 0x6a3841db,
118 /// or in textual repr: setCollectionLimit(string,uint32)
119 function setCollectionLimit(string memory limit, uint32 value) external;
120
121 /// Set limits for the collection.
122 /// @dev Throws error if limit not found.
123 /// @param limit Name of the limit. Valid names:
124 /// "ownerCanTransfer",116 /// "ownerCanTransfer",
125 /// "ownerCanDestroy",117 /// "ownerCanDestroy",
126 /// "transfersEnabled"118 /// "transfersEnabled"
127 /// @param value Value of the limit.119 /// @param value Value of the limit.
128 /// @dev EVM selector for this function is: 0x993b7fba,120 /// @dev EVM selector for this function is: 0x4ad890a8,
129 /// or in textual repr: setCollectionLimit(string,bool)121 /// or in textual repr: setCollectionLimit(string,uint256)
130 function setCollectionLimit(string memory limit, bool value) external;122 function setCollectionLimit(string memory limit, uint256 value) external;
131123
132 /// Get contract address.124 /// Get contract address.
133 /// @dev EVM selector for this function is: 0xf6b4dfb4,125 /// @dev EVM selector for this function is: 0xf6b4dfb4,
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
80}80}
8181
82/// @title A contract that allows you to work with collections.82/// @title A contract that allows you to work with collections.
83/// @dev the ERC-165 identifier for this interface is 0x324a7f5b83/// @dev the ERC-165 identifier for this interface is 0x8b91d192
84interface Collection is Dummy, ERC165 {84interface Collection is Dummy, ERC165 {
85 // /// Set collection property.85 // /// Set collection property.
86 // ///86 // ///
180 /// "tokenLimit",180 /// "tokenLimit",
181 /// "sponsorTransferTimeout",181 /// "sponsorTransferTimeout",
182 /// "sponsorApproveTimeout"182 /// "sponsorApproveTimeout"
183 /// @param value Value of the limit.
184 /// @dev EVM selector for this function is: 0x6a3841db,
185 /// or in textual repr: setCollectionLimit(string,uint32)
186 function setCollectionLimit(string memory limit, uint32 value) external;
187
188 /// Set limits for the collection.
189 /// @dev Throws error if limit not found.
190 /// @param limit Name of the limit. Valid names:
191 /// "ownerCanTransfer",183 /// "ownerCanTransfer",
192 /// "ownerCanDestroy",184 /// "ownerCanDestroy",
193 /// "transfersEnabled"185 /// "transfersEnabled"
194 /// @param value Value of the limit.186 /// @param value Value of the limit.
195 /// @dev EVM selector for this function is: 0x993b7fba,187 /// @dev EVM selector for this function is: 0x4ad890a8,
196 /// or in textual repr: setCollectionLimit(string,bool)188 /// or in textual repr: setCollectionLimit(string,uint256)
197 function setCollectionLimit(string memory limit, bool value) external;189 function setCollectionLimit(string memory limit, uint256 value) external;
198190
199 /// Get contract address.191 /// Get contract address.
200 /// @dev EVM selector for this function is: 0xf6b4dfb4,192 /// @dev EVM selector for this function is: 0xf6b4dfb4,
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
80}80}
8181
82/// @title A contract that allows you to work with collections.82/// @title A contract that allows you to work with collections.
83/// @dev the ERC-165 identifier for this interface is 0x324a7f5b83/// @dev the ERC-165 identifier for this interface is 0x8b91d192
84interface Collection is Dummy, ERC165 {84interface Collection is Dummy, ERC165 {
85 // /// Set collection property.85 // /// Set collection property.
86 // ///86 // ///
180 /// "tokenLimit",180 /// "tokenLimit",
181 /// "sponsorTransferTimeout",181 /// "sponsorTransferTimeout",
182 /// "sponsorApproveTimeout"182 /// "sponsorApproveTimeout"
183 /// @param value Value of the limit.
184 /// @dev EVM selector for this function is: 0x6a3841db,
185 /// or in textual repr: setCollectionLimit(string,uint32)
186 function setCollectionLimit(string memory limit, uint32 value) external;
187
188 /// Set limits for the collection.
189 /// @dev Throws error if limit not found.
190 /// @param limit Name of the limit. Valid names:
191 /// "ownerCanTransfer",183 /// "ownerCanTransfer",
192 /// "ownerCanDestroy",184 /// "ownerCanDestroy",
193 /// "transfersEnabled"185 /// "transfersEnabled"
194 /// @param value Value of the limit.186 /// @param value Value of the limit.
195 /// @dev EVM selector for this function is: 0x993b7fba,187 /// @dev EVM selector for this function is: 0x4ad890a8,
196 /// or in textual repr: setCollectionLimit(string,bool)188 /// or in textual repr: setCollectionLimit(string,uint256)
197 function setCollectionLimit(string memory limit, bool value) external;189 function setCollectionLimit(string memory limit, uint256 value) external;
198190
199 /// Get contract address.191 /// Get contract address.
200 /// @dev EVM selector for this function is: 0xf6b4dfb4,192 /// @dev EVM selector for this function is: 0xf6b4dfb4,
modifiedtests/src/eth/createFTCollection.test.tsdiffbeforeafterboth
78 itEth('Set limits', async ({helper}) => {78 itEth('Set limits', async ({helper}) => {
79 const owner = await helper.eth.createAccountWithBalance(donor);79 const owner = await helper.eth.createAccountWithBalance(donor);
80 const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'INSI');80 const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'INSI');
81 const limits = {
82 accountTokenOwnershipLimit: 1000,
83 sponsoredDataSize: 1024,
84 sponsoredDataRateLimit: 30,
85 tokenLimit: 1000000,
86 sponsorTransferTimeout: 6,
87 sponsorApproveTimeout: 6,
88 ownerCanTransfer: 0,
89 ownerCanDestroy: 0,
90 transfersEnabled: 0,
91 };
92
81 const limits = {93 const expectedLimits = {
82 accountTokenOwnershipLimit: 1000,94 accountTokenOwnershipLimit: 1000,
83 sponsoredDataSize: 1024,95 sponsoredDataSize: 1024,
84 sponsoredDataRateLimit: 30,96 sponsoredDataRateLimit: 30,
91 };103 };
92104
93 const collection = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);105 const collection = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
94 await collection.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();106 await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
95 await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();107 await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();
96 await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();108 await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
97 await collection.methods['setCollectionLimit(string,uint32)']('tokenLimit', limits.tokenLimit).send();109 await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();
98 await collection.methods['setCollectionLimit(string,uint32)']('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();110 await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
99 await collection.methods['setCollectionLimit(string,uint32)']('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();111 await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
100 await collection.methods['setCollectionLimit(string,bool)']('ownerCanTransfer', limits.ownerCanTransfer).send();112 await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();
101 await collection.methods['setCollectionLimit(string,bool)']('ownerCanDestroy', limits.ownerCanDestroy).send();113 await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();
102 await collection.methods['setCollectionLimit(string,bool)']('transfersEnabled', limits.transfersEnabled).send();114 await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();
103 115
104 const data = (await helper.rft.getData(collectionId))!;116 const data = (await helper.rft.getData(collectionId))!;
105 expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(limits.accountTokenOwnershipLimit);117 expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
106 expect(data.raw.limits.sponsoredDataSize).to.be.eq(limits.sponsoredDataSize);118 expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
107 expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(limits.sponsoredDataRateLimit);119 expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
108 expect(data.raw.limits.tokenLimit).to.be.eq(limits.tokenLimit);120 expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
109 expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(limits.sponsorTransferTimeout);121 expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
110 expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(limits.sponsorApproveTimeout);122 expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
111 expect(data.raw.limits.ownerCanTransfer).to.be.eq(limits.ownerCanTransfer);123 expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
112 expect(data.raw.limits.ownerCanDestroy).to.be.eq(limits.ownerCanDestroy);124 expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
113 expect(data.raw.limits.transfersEnabled).to.be.eq(limits.transfersEnabled);125 expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
114 });126 });
115127
116 itEth('Collection address exist', async ({helper}) => {128 itEth('Collection address exist', async ({helper}) => {
258270
259 itEth('(!negative test!) Set limits', async ({helper}) => {271 itEth('(!negative test!) Set limits', async ({helper}) => {
272
273 const invalidLimits = {
274 accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
275 transfersEnabled: 3,
276 };
277
260 const owner = await helper.eth.createAccountWithBalance(donor);278 const owner = await helper.eth.createAccountWithBalance(donor);
261 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'ISNI');279 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'ISNI');
262 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);280 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
263 await expect(collectionEvm.methods281 await expect(collectionEvm.methods
264 .setCollectionLimit('badLimit', 'true')282 .setCollectionLimit('badLimit', '1')
265 .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');283 .call()).to.be.rejectedWith('unknown limit "badLimit"');
284
285 await expect(collectionEvm.methods
286 .setCollectionLimit(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)
287 .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
288
289 await expect(collectionEvm.methods
290 .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)
291 .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
266 });292 });
293
294
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
117 itEth('Set limits', async ({helper}) => {117 itEth('Set limits', async ({helper}) => {
118 const owner = await helper.eth.createAccountWithBalance(donor);118 const owner = await helper.eth.createAccountWithBalance(donor);
119 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'FLO');119 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'FLO');
120 const limits = {
121 accountTokenOwnershipLimit: 1000,
122 sponsoredDataSize: 1024,
123 sponsoredDataRateLimit: 30,
124 tokenLimit: 1000000,
125 sponsorTransferTimeout: 6,
126 sponsorApproveTimeout: 6,
127 ownerCanTransfer: 0,
128 ownerCanDestroy: 0,
129 transfersEnabled: 0,
130 };
131
120 const limits = {132 const expectedLimits = {
121 accountTokenOwnershipLimit: 1000,133 accountTokenOwnershipLimit: 1000,
122 sponsoredDataSize: 1024,134 sponsoredDataSize: 1024,
123 sponsoredDataRateLimit: 30,135 sponsoredDataRateLimit: 30,
130 };142 };
131143
132 const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);144 const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
133 await collection.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();145 await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
134 await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();146 await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();
135 await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();147 await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
136 await collection.methods['setCollectionLimit(string,uint32)']('tokenLimit', limits.tokenLimit).send();148 await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();
137 await collection.methods['setCollectionLimit(string,uint32)']('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();149 await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
138 await collection.methods['setCollectionLimit(string,uint32)']('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();150 await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
139 await collection.methods['setCollectionLimit(string,bool)']('ownerCanTransfer', limits.ownerCanTransfer).send();151 await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();
140 await collection.methods['setCollectionLimit(string,bool)']('ownerCanDestroy', limits.ownerCanDestroy).send();152 await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();
141 await collection.methods['setCollectionLimit(string,bool)']('transfersEnabled', limits.transfersEnabled).send();153 await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();
142154
143 const data = (await helper.nft.getData(collectionId))!;155 const data = (await helper.rft.getData(collectionId))!;
144 expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(limits.accountTokenOwnershipLimit);156 expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
145 expect(data.raw.limits.sponsoredDataSize).to.be.eq(limits.sponsoredDataSize);157 expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
146 expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(limits.sponsoredDataRateLimit);158 expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
147 expect(data.raw.limits.tokenLimit).to.be.eq(limits.tokenLimit);159 expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
148 expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(limits.sponsorTransferTimeout);160 expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
149 expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(limits.sponsorApproveTimeout);161 expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
150 expect(data.raw.limits.ownerCanTransfer).to.be.eq(limits.ownerCanTransfer);162 expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
151 expect(data.raw.limits.ownerCanDestroy).to.be.eq(limits.ownerCanDestroy);163 expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
152 expect(data.raw.limits.transfersEnabled).to.be.eq(limits.transfersEnabled);164 expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
153 });165 });
154166
155 itEth('Collection address exist', async ({helper}) => {167 itEth('Collection address exist', async ({helper}) => {
270 });282 });
271283
272 itEth('(!negative test!) Set limits', async ({helper}) => {284 itEth('(!negative test!) Set limits', async ({helper}) => {
285 const invalidLimits = {
286 accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
287 transfersEnabled: 3,
288 };
289
273 const owner = await helper.eth.createAccountWithBalance(donor);290 const owner = await helper.eth.createAccountWithBalance(donor);
274 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');291 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');
275 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);292 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
293
294 await expect(collectionEvm.methods
295 .setCollectionLimit(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)
296 .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
297
276 await expect(collectionEvm.methods298 await expect(collectionEvm.methods
277 .setCollectionLimit('badLimit', 'true')299 .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)
278 .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');300 .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
279 });301 });
280302
281 itEth('destroyCollection', async ({helper}) => {303 itEth('destroyCollection', async ({helper}) => {
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
152 itEth('Set limits', async ({helper}) => {152 itEth('Set limits', async ({helper}) => {
153 const owner = await helper.eth.createAccountWithBalance(donor);153 const owner = await helper.eth.createAccountWithBalance(donor);
154 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'INSI');154 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'INSI');
155 const limits = {
156 accountTokenOwnershipLimit: 1000,
157 sponsoredDataSize: 1024,
158 sponsoredDataRateLimit: 30,
159 tokenLimit: 1000000,
160 sponsorTransferTimeout: 6,
161 sponsorApproveTimeout: 6,
162 ownerCanTransfer: 0,
163 ownerCanDestroy: 0,
164 transfersEnabled: 0,
165 };
166
155 const limits = {167 const expectedLimits = {
156 accountTokenOwnershipLimit: 1000,168 accountTokenOwnershipLimit: 1000,
157 sponsoredDataSize: 1024,169 sponsoredDataSize: 1024,
158 sponsoredDataRateLimit: 30,170 sponsoredDataRateLimit: 30,
165 };177 };
166178
167 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);179 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
168 await collection.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();180 await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
169 await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();181 await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();
170 await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();182 await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
171 await collection.methods['setCollectionLimit(string,uint32)']('tokenLimit', limits.tokenLimit).send();183 await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();
172 await collection.methods['setCollectionLimit(string,uint32)']('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();184 await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
173 await collection.methods['setCollectionLimit(string,uint32)']('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();185 await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
174 await collection.methods['setCollectionLimit(string,bool)']('ownerCanTransfer', limits.ownerCanTransfer).send();186 await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();
175 await collection.methods['setCollectionLimit(string,bool)']('ownerCanDestroy', limits.ownerCanDestroy).send();187 await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();
176 await collection.methods['setCollectionLimit(string,bool)']('transfersEnabled', limits.transfersEnabled).send();188 await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();
177 189
178 const data = (await helper.rft.getData(collectionId))!;190 const data = (await helper.rft.getData(collectionId))!;
179 expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(limits.accountTokenOwnershipLimit);191 expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
180 expect(data.raw.limits.sponsoredDataSize).to.be.eq(limits.sponsoredDataSize);192 expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
181 expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(limits.sponsoredDataRateLimit);193 expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
182 expect(data.raw.limits.tokenLimit).to.be.eq(limits.tokenLimit);194 expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
183 expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(limits.sponsorTransferTimeout);195 expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
184 expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(limits.sponsorApproveTimeout);196 expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
185 expect(data.raw.limits.ownerCanTransfer).to.be.eq(limits.ownerCanTransfer);197 expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
186 expect(data.raw.limits.ownerCanDestroy).to.be.eq(limits.ownerCanDestroy);198 expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
187 expect(data.raw.limits.transfersEnabled).to.be.eq(limits.transfersEnabled);199 expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
188 });200 });
189201
190 itEth('Collection address exist', async ({helper}) => {202 itEth('Collection address exist', async ({helper}) => {
305 });317 });
306318
307 itEth('(!negative test!) Set limits', async ({helper}) => {319 itEth('(!negative test!) Set limits', async ({helper}) => {
320 const invalidLimits = {
321 accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
322 transfersEnabled: 3,
323 };
324
308 const owner = await helper.eth.createAccountWithBalance(donor);325 const owner = await helper.eth.createAccountWithBalance(donor);
309 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'ISNI');326 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'ISNI');
310 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);327 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
328
329 await expect(collectionEvm.methods
330 .setCollectionLimit(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)
331 .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
332
311 await expect(collectionEvm.methods333 await expect(collectionEvm.methods
312 .setCollectionLimit('badLimit', 'true')334 .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)
313 .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');335 .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
314 });336 });
315 337
316 itEth('destroyCollection', async ({helper}) => {338 itEth('destroyCollection', async ({helper}) => {