difftreelog
CORE-337 Rewrite set limits
in: master
9 files changed
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -16,10 +16,11 @@
use evm_coder::{solidity_interface, types::*, execution::{Result, Error}};
pub use pallet_evm::{PrecompileOutput, PrecompileResult, account::CrossAccountId};
-use pallet_evm_coder_substrate::{dispatch_to_evm, SubstrateRecorder};
+use pallet_evm_coder_substrate::dispatch_to_evm;
use sp_core::{H160, U256};
use sp_std::vec::Vec;
-use up_data_structs::Property;
+use up_data_structs::{Property, SponsoringRateLimit};
+use alloc::format;
use crate::{Pallet, CollectionHandle, Config, CollectionProperties};
@@ -87,37 +88,53 @@
Ok(())
}
- fn set_limits(
- &self,
+ fn set_limit(
+ &mut self,
caller: caller,
- limits_json: string,
+ limit: string,
+ value: string,
) -> Result<void> {
- // let mut collection = collection_from_address::<T>(self.contract_address(caller).unwrap(), self.1.gas_left())?;
- // check_is_owner(caller, &collection)?;
+ check_is_owner(caller, self)?;
+ let mut limits = self.limits.clone();
- // let limits = serde_json_core::from_str(limits_json.as_ref())
- // .map_err(|e| Error::Revert(format!("Parse JSON error: {}", e)))?;
- // collection.limits = limits.0;
- // collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
+ match limit.as_str() {
+ "accountTokenOwnershipLimit" => {
+ limits.account_token_ownership_limit = parse_int(value)?;
+ },
+ "sponsoredDataSize" => {
+ limits.sponsored_data_size = parse_int(value)?;
+ },
+ "sponsoredDataRateLimit" => {
+ limits.sponsored_data_rate_limit = Some(SponsoringRateLimit::Blocks(parse_int(value)?.unwrap()));
+ },
+ "tokenLimit" => {
+ limits.token_limit = parse_int(value)?;
+ },
+ "sponsorTransferTimeout" => {
+ limits.sponsor_transfer_timeout = parse_int(value)?;
+ },
+ "sponsorApproveTimeout" => {
+ limits.sponsor_approve_timeout = parse_int(value)?;
+ },
+ "ownerCanTransfer" => {
+ limits.owner_can_transfer = parse_bool(value)?;
+ },
+ "ownerCanDestroy" => {
+ limits.owner_can_destroy = parse_bool(value)?;
+ },
+ "transfersEnabled" => {
+ limits.transfers_enabled = parse_bool(value)?;
+ },
+ _ => return Err(Error::Revert(format!("Unknown limit \"{}\"", limit)))
+ }
+ self.limits = limits;
+ save(self);
Ok(())
}
fn contract_address(&self, _caller: caller) -> Result<address> {
Ok(crate::eth::collection_id_to_address(self.id))
}
-}
-
-fn collection_from_address<T: Config>(
- collection_address: address,
- gas_limit: u64
-) -> Result<CollectionHandle<T>> {
- let collection_id = crate::eth::map_eth_to_id(&collection_address)
- .ok_or(Error::Revert("Contract is not an unique collection".into()))?;
- let recorder = <SubstrateRecorder<T>>::new(gas_limit);
- let collection =
- CollectionHandle::new_with_recorder(collection_id, recorder)
- .ok_or(Error::Revert("Create collection handle error".into()))?;
- Ok(collection)
}
fn check_is_owner<T: Config>(caller: caller, collection: &CollectionHandle<T>) -> Result<()> {
@@ -130,4 +147,16 @@
fn save<T: Config>(collection: &CollectionHandle<T>) {
<crate::CollectionById<T>>::insert(collection.id, collection.collection.clone());
+}
+
+fn parse_int(value: string) -> Result<Option<u32>> {
+ value.parse::<u32>()
+ .map_err(|e| Error::Revert(format!("Int value \"{}\" parse error: {}", value, e)))
+ .map(|value| Some(value))
+}
+
+fn parse_bool(value: string) -> Result<Option<bool>> {
+ value.parse::<bool>()
+ .map_err(|e| Error::Revert(format!("Bool value \"{}\" parse error: {}", value, e)))
+ .map(|value| Some(value))
}
\ No newline at end of file
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
@@ -51,67 +51,6 @@
event MintingFinished();
}
-// Selector: 38e33c60
-contract Collection is Dummy, ERC165 {
- // Selector: setCollectionProperty(string,bytes) 2f073f66
- function setCollectionProperty(string memory key, bytes memory value)
- public
- {
- require(false, stub_error);
- key;
- value;
- dummy = 0;
- }
-
- // Selector: deleteCollectionProperty(string) 7b7debce
- function deleteCollectionProperty(string memory key) public {
- require(false, stub_error);
- key;
- dummy = 0;
- }
-
- // Throws error if key not found
- //
- // Selector: collectionProperty(string) cf24fd6d
- function collectionProperty(string memory key)
- public
- view
- returns (bytes memory)
- {
- require(false, stub_error);
- key;
- dummy;
- return hex"";
- }
-
- // Selector: ethSetSponsor(address) 8f9af356
- function ethSetSponsor(address sponsor) public {
- require(false, stub_error);
- sponsor;
- dummy = 0;
- }
-
- // Selector: ethConfirmSponsorship() a8580d1a
- function ethConfirmSponsorship() public {
- require(false, stub_error);
- dummy = 0;
- }
-
- // Selector: setLimits(string) 72cb345d
- function setLimits(string memory limitsJson) public view {
- require(false, stub_error);
- limitsJson;
- dummy;
- }
-
- // Selector: contractAddress() f6b4dfb4
- function contractAddress() public view returns (address) {
- require(false, stub_error);
- dummy;
- return 0x0000000000000000000000000000000000000000;
- }
-}
-
// Selector: 41369377
contract TokenProperties is Dummy, ERC165 {
// Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa
@@ -441,6 +380,68 @@
}
}
+// Selector: f5652829
+contract Collection is Dummy, ERC165 {
+ // Selector: setCollectionProperty(string,bytes) 2f073f66
+ function setCollectionProperty(string memory key, bytes memory value)
+ public
+ {
+ require(false, stub_error);
+ key;
+ value;
+ dummy = 0;
+ }
+
+ // Selector: deleteCollectionProperty(string) 7b7debce
+ function deleteCollectionProperty(string memory key) public {
+ require(false, stub_error);
+ key;
+ dummy = 0;
+ }
+
+ // Throws error if key not found
+ //
+ // Selector: collectionProperty(string) cf24fd6d
+ function collectionProperty(string memory key)
+ public
+ view
+ returns (bytes memory)
+ {
+ require(false, stub_error);
+ key;
+ dummy;
+ return hex"";
+ }
+
+ // Selector: ethSetSponsor(address) 8f9af356
+ function ethSetSponsor(address sponsor) public {
+ require(false, stub_error);
+ sponsor;
+ dummy = 0;
+ }
+
+ // Selector: ethConfirmSponsorship() a8580d1a
+ function ethConfirmSponsorship() public {
+ require(false, stub_error);
+ dummy = 0;
+ }
+
+ // Selector: setLimit(string,string) bf4d2014
+ function setLimit(string memory limit, string memory value) public {
+ require(false, stub_error);
+ limit;
+ value;
+ dummy = 0;
+ }
+
+ // Selector: contractAddress() f6b4dfb4
+ function contractAddress() public view returns (address) {
+ require(false, stub_error);
+ dummy;
+ return 0x0000000000000000000000000000000000000000;
+ }
+}
+
contract UniqueNFT is
Dummy,
ERC165,
pallets/unique/src/eth/mod.rsdiffbeforeafterboth--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -26,7 +26,7 @@
};
use frame_support::traits::Get;
use sp_core::H160;
- use pallet_common::{CollectionHandle, CollectionById};
+ use pallet_common::CollectionById;
use sp_std::vec::Vec;
use alloc::format;
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -368,30 +368,21 @@
#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct CollectionLimits {
- #[serde(alias = "accountTokenOwnershipLimit")]
pub account_token_ownership_limit: Option<u32>,
- #[serde(alias = "sponsoredDataSize")]
pub sponsored_data_size: Option<u32>,
/// FIXME should we delete this or repurpose it?
/// None - setVariableMetadata is not sponsored
/// Some(v) - setVariableMetadata is sponsored
/// if there is v block between txs
- #[serde(alias = "sponsoredDataRateLimit")]
pub sponsored_data_rate_limit: Option<SponsoringRateLimit>,
- #[serde(alias = "tokenLimit")]
pub token_limit: Option<u32>,
// Timeouts for item types in passed blocks
- #[serde(alias = "sponsorTransferTimeout")]
pub sponsor_transfer_timeout: Option<u32>,
- #[serde(alias = "sponsorApproveTimeout")]
pub sponsor_approve_timeout: Option<u32>,
- #[serde(alias = "ownerCanTransfer")]
pub owner_can_transfer: Option<bool>,
- #[serde(alias = "ownerCanDestroy")]
pub owner_can_destroy: Option<bool>,
- #[serde(alias = "transfersEnabled")]
pub transfers_enabled: Option<bool>,
}
tests/src/eth/api/Collection.soldiffbeforeafterboth--- a/tests/src/eth/api/Collection.sol
+++ /dev/null
@@ -1,28 +0,0 @@
-// SPDX-License-Identifier: OTHER
-// This code is automatically generated
-
-pragma solidity >=0.8.0 <0.9.0;
-
-// Common stubs holder
-interface Dummy {
-
-}
-
-interface ERC165 is Dummy {
- function supportsInterface(bytes4 interfaceID) external view returns (bool);
-}
-
-// Selector: 15cc740e
-interface Collection is Dummy, ERC165 {
- // Selector: setSponsor(address) 59753fb1
- function setSponsor(address sponsor) external view;
-
- // Selector: confirmSponsorship() c8c6a056
- function confirmSponsorship() external view;
-
- // Selector: setLimits(string) 72cb345d
- function setLimits(string memory limitsJson) external view;
-
- // Selector: contractAddress() f6b4dfb4
- function contractAddress() external view returns (address);
-}
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -42,36 +42,6 @@
event MintingFinished();
}
-// Selector: 38e33c60
-interface Collection is Dummy, ERC165 {
- // Selector: setCollectionProperty(string,bytes) 2f073f66
- function setCollectionProperty(string memory key, bytes memory value)
- external;
-
- // Selector: deleteCollectionProperty(string) 7b7debce
- function deleteCollectionProperty(string memory key) external;
-
- // Throws error if key not found
- //
- // Selector: collectionProperty(string) cf24fd6d
- function collectionProperty(string memory key)
- external
- view
- returns (bytes memory);
-
- // Selector: ethSetSponsor(address) 8f9af356
- function ethSetSponsor(address sponsor) external;
-
- // Selector: ethConfirmSponsorship() a8580d1a
- function ethConfirmSponsorship() external;
-
- // Selector: setLimits(string) 72cb345d
- function setLimits(string memory limitsJson) external view;
-
- // Selector: contractAddress() f6b4dfb4
- function contractAddress() external view returns (address);
-}
-
// Selector: 41369377
interface TokenProperties is Dummy, ERC165 {
// Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa
@@ -243,6 +213,36 @@
returns (bool);
}
+// Selector: f5652829
+interface Collection is Dummy, ERC165 {
+ // Selector: setCollectionProperty(string,bytes) 2f073f66
+ function setCollectionProperty(string memory key, bytes memory value)
+ external;
+
+ // Selector: deleteCollectionProperty(string) 7b7debce
+ function deleteCollectionProperty(string memory key) external;
+
+ // Throws error if key not found
+ //
+ // Selector: collectionProperty(string) cf24fd6d
+ function collectionProperty(string memory key)
+ external
+ view
+ returns (bytes memory);
+
+ // Selector: ethSetSponsor(address) 8f9af356
+ function ethSetSponsor(address sponsor) external;
+
+ // Selector: ethConfirmSponsorship() a8580d1a
+ function ethConfirmSponsorship() external;
+
+ // Selector: setLimit(string,string) bf4d2014
+ function setLimit(string memory limit, string memory value) external;
+
+ // Selector: contractAddress() f6b4dfb4
+ function contractAddress() external view returns (address);
+}
+
interface UniqueNFT is
Dummy,
ERC165,
tests/src/eth/createCollection.test.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.8//9// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import nonFungibleAbi from './nonFungibleAbi.json';18import {ApiPromise} from '@polkadot/api';19import {evmToAddress} from '@polkadot/util-crypto';20import {expect} from 'chai';21import {getCreatedCollectionCount, getDetailedCollectionInfo} from '../util/helpers';22import {23 evmCollectionHelper,24 collectionIdFromAddress,25 collectionIdToAddress,26 createEthAccount,27 createEthAccountWithBalance,28 evmCollection,29 GAS_ARGS,30 itWeb3,31 normalizeAddress,32 normalizeEvents,33} from './util/helpers';3435async function getCollectionAddressFromResult(api: ApiPromise, result: any) {36 const collectionIdAddress = normalizeAddress(result.events[0].raw.topics[2]);37 const collectionId = collectionIdFromAddress(collectionIdAddress); 38 const collection = (await getDetailedCollectionInfo(api, collectionId))!;39 return {collectionIdAddress, collectionId, collection};40}4142describe('Create collection from EVM', () => {43 itWeb3('Create collection', async ({api, web3}) => {44 const owner = await createEthAccountWithBalance(api, web3);45 const helper = evmCollectionHelper(web3, owner);46 const collectionName = 'CollectionEVM';47 const description = 'Some description';48 const tokenPrefix = 'token prefix';49 50 const collectionCountBefore = await getCreatedCollectionCount(api);51 const result = await helper.methods52 .create721Collection(collectionName, description, tokenPrefix)53 .send();54 const collectionCountAfter = await getCreatedCollectionCount(api);55 56 const {collectionId, collection} = await getCollectionAddressFromResult(api, result);57 expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);58 expect(collectionId).to.be.eq(collectionCountAfter);59 expect(collection.name.map(v => String.fromCharCode(v.toNumber())).join('')).to.be.eq(collectionName);60 expect(collection.description.map(v => String.fromCharCode(v.toNumber())).join('')).to.be.eq(description);61 expect(collection.tokenPrefix.toHuman()).to.be.eq(tokenPrefix);62 expect(collection.schemaVersion.type).to.be.eq('ImageURL');63 });6465 itWeb3('Check collection address exist', async ({api, web3}) => {66 const owner = await createEthAccountWithBalance(api, web3);67 const collectionHelper = evmCollectionHelper(web3, owner);68 69 const expectedCollectionId = await getCreatedCollectionCount(api) + 1;70 const expectedCollectionAddress = collectionIdToAddress(expectedCollectionId);71 expect(await collectionHelper.methods72 .isCollectionExist(expectedCollectionAddress)73 .call()).to.be.false;7475 await collectionHelper.methods76 .create721Collection('A', 'A', 'A')77 .send();78 79 expect(await collectionHelper.methods80 .isCollectionExist(expectedCollectionAddress)81 .call()).to.be.true;82 });83 84 itWeb3('Set sponsorship', async ({api, web3}) => {85 const owner = await createEthAccountWithBalance(api, web3);86 const collectionHelper = evmCollectionHelper(web3, owner);87 let result = await collectionHelper.methods.create721Collection('Sponsor collection', '1', '1').send();88 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);89 const sponsor = await createEthAccountWithBalance(api, web3);90 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);91 result = await collectionEvm.methods.ethSetSponsor(sponsor).send();92 let collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;93 expect(collectionSub.sponsorship.isUnconfirmed).to.be.true;94 expect(collectionSub.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));95 await expect(collectionEvm.methods.ethConfirmSponsorship().call()).to.be.rejectedWith('Caller is not set as sponsor');96 const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);97 await sponsorCollection.methods.ethConfirmSponsorship().send();98 collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;99 expect(collectionSub.sponsorship.isConfirmed).to.be.true;100 expect(collectionSub.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));101 });102103 itWeb3('Set limits', async ({api, web3}) => {104 const owner = await createEthAccountWithBalance(api, web3);105 const collectionHelper = evmCollectionHelper(web3, owner);106 const result = await collectionHelper.methods.create721Collection('Const collection', '5', '5').send();107 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);108 const limits = {109 accountTokenOwnershipLimit: 1000,110 sponsoredDataSize: 1024,111 sponsoredDataRateLimit: {Blocks: 30},112 tokenLimit: 1000000,113 sponsorTransferTimeout: 6,114 sponsorApproveTimeout: 6,115 ownerCanTransfer: false,116 ownerCanDestroy: false,117 transfersEnabled: false,118 };119120 const limitsJson = JSON.stringify(limits, null, 1);121 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);122 await collectionEvm.methods.setLimits(limitsJson).send();123 124 const collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;125 expect(collectionSub.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.be.eq(limits.accountTokenOwnershipLimit);126 expect(collectionSub.limits.sponsoredDataSize.unwrap().toNumber()).to.be.eq(limits.sponsoredDataSize);127 expect(collectionSub.limits.sponsoredDataRateLimit.unwrap().asBlocks.toNumber()).to.be.eq(limits.sponsoredDataRateLimit.Blocks);128 expect(collectionSub.limits.tokenLimit.unwrap().toNumber()).to.be.eq(limits.tokenLimit);129 expect(collectionSub.limits.sponsorTransferTimeout.unwrap().toNumber()).to.be.eq(limits.sponsorTransferTimeout);130 expect(collectionSub.limits.sponsorApproveTimeout.unwrap().toNumber()).to.be.eq(limits.sponsorApproveTimeout);131 expect(collectionSub.limits.ownerCanTransfer.toHuman()).to.be.eq(limits.ownerCanTransfer);132 expect(collectionSub.limits.ownerCanDestroy.toHuman()).to.be.eq(limits.ownerCanDestroy);133 expect(collectionSub.limits.transfersEnabled.toHuman()).to.be.eq(limits.transfersEnabled);134 });135136 itWeb3('Check tokenURI', async ({web3, api}) => {137 const owner = await createEthAccountWithBalance(api, web3);138 const helper = evmCollectionHelper(web3, owner);139 let result = await helper.methods.create721Collection('Mint collection', '6', '6').send();140 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);141 const receiver = createEthAccount(web3);142 const contract = new web3.eth.Contract(nonFungibleAbi as any, collectionIdAddress, {from: owner, ...GAS_ARGS});143 const nextTokenId = await contract.methods.nextTokenId().call();144145 expect(nextTokenId).to.be.equal('1');146 result = await contract.methods.mintWithTokenURI(147 receiver,148 nextTokenId,149 'Test URI',150 ).send();151152 const events = normalizeEvents(result.events);153 const address = collectionIdToAddress(collectionId);154155 expect(events).to.be.deep.equal([156 {157 address,158 event: 'Transfer',159 args: {160 from: '0x0000000000000000000000000000000000000000',161 to: receiver,162 tokenId: nextTokenId,163 },164 },165 ]);166167 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');168169 // TODO: this wont work right now, need release 919000 first170 // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();171 // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();172 // expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`);173 });174});175176describe('(!negative tests!) Create collection from EVM', () => {177 itWeb3('(!negative test!) Create collection (bad lengths)', async ({api, web3}) => {178 const owner = await createEthAccountWithBalance(api, web3);179 const helper = evmCollectionHelper(web3, owner);180 {181 const MAX_NAME_LENGHT = 64;182 const collectionName = 'A'.repeat(MAX_NAME_LENGHT + 1);183 const description = 'A';184 const tokenPrefix = 'A';185 186 await expect(helper.methods187 .create721Collection(collectionName, description, tokenPrefix)188 .call()).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGHT);189 190 }191 { 192 const MAX_DESCRIPTION_LENGHT = 256;193 const collectionName = 'A';194 const description = 'A'.repeat(MAX_DESCRIPTION_LENGHT + 1);195 const tokenPrefix = 'A';196 await expect(helper.methods197 .create721Collection(collectionName, description, tokenPrefix)198 .call()).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGHT);199 }200 { 201 const MAX_TOKEN_PREFIX_LENGHT = 16;202 const collectionName = 'A';203 const description = 'A';204 const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGHT + 1);205 await expect(helper.methods206 .create721Collection(collectionName, description, tokenPrefix)207 .call()).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGHT);208 }209 });210 211 itWeb3('(!negative test!) Create collection (no funds)', async ({web3}) => {212 const owner = await createEthAccount(web3);213 const helper = evmCollectionHelper(web3, owner);214 const collectionName = 'A';215 const description = 'A';216 const tokenPrefix = 'A';217 218 await expect(helper.methods219 .create721Collection(collectionName, description, tokenPrefix)220 .call()).to.be.rejectedWith('NotSufficientFounds');221 });222223 itWeb3('(!negative test!) Collection address (Create collection handle error)', async ({api, web3}) => {224 const owner = await createEthAccountWithBalance(api, web3);225 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';226 const collectionEvm = evmCollection(web3, owner, collectionAddressForNonexistentCollection);227 const EXPECTED_ERROR = 'Create collection handle error';228 {229 const sponsor = await createEthAccountWithBalance(api, web3);230 await expect(collectionEvm.methods231 .setSponsor(sponsor)232 .call()).to.be.rejectedWith(EXPECTED_ERROR);233 234 const sponsorCollection = evmCollection(web3, sponsor, collectionAddressForNonexistentCollection);235 await expect(sponsorCollection.methods236 .confirmSponsorship()237 .call()).to.be.rejectedWith(EXPECTED_ERROR);238 }239 {240 const limits = '{"account_token_ownership_limit":1000}';241 await expect(collectionEvm.methods242 .setLimits(limits)243 .call()).to.be.rejectedWith(EXPECTED_ERROR);244 }245 });246247 itWeb3('(!negative test!) Check owner', async ({api, web3}) => {248 const owner = await createEthAccountWithBalance(api, web3);249 const notOwner = await createEthAccount(web3);250 const collectionHelper = evmCollectionHelper(web3, owner);251 const result = await collectionHelper.methods.create721Collection('A', 'A', 'A').send();252 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);253 const contractEvmFromNotOwner = evmCollection(web3, notOwner, collectionIdAddress);254 const EXPECTED_ERROR = 'NoPermission';255 {256 const sponsor = await createEthAccountWithBalance(api, web3);257 await expect(contractEvmFromNotOwner.methods258 .setSponsor(sponsor)259 .call()).to.be.rejectedWith(EXPECTED_ERROR);260 261 const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);262 await expect(sponsorCollection.methods263 .confirmSponsorship()264 .call()).to.be.rejectedWith('Caller is not set as sponsor');265 }266 {267 const limits = '{"account_token_ownership_limit":1000}';268 await expect(contractEvmFromNotOwner.methods269 .setLimits(limits)270 .call()).to.be.rejectedWith(EXPECTED_ERROR);271 }272 });273274 itWeb3('(!negative test!) Set limits', async ({api, web3}) => {275 const owner = await createEthAccountWithBalance(api, web3);276 const collectionHelper = evmCollectionHelper(web3, owner);277 const result = await collectionHelper.methods.create721Collection('Schema collection', 'A', 'A').send();278 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);279 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);280 const badJson = '{accountTokenOwnershipLimit: 1000}';281 await expect(collectionEvm.methods282 .setLimits(badJson)283 .call()).to.be.rejectedWith('Parse JSON error:');284 });285});tests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/nonFungibleAbi.json
+++ b/tests/src/eth/nonFungibleAbi.json
@@ -325,11 +325,12 @@
},
{
"inputs": [
- { "internalType": "string", "name": "limitsJson", "type": "string" }
+ { "internalType": "string", "name": "limit", "type": "string" },
+ { "internalType": "string", "name": "value", "type": "string" }
],
- "name": "setLimits",
+ "name": "setLimit",
"outputs": [],
- "stateMutability": "view",
+ "stateMutability": "nonpayable",
"type": "function"
},
{