difftreelog
fix account token ownership limit when transfer (#1080)
in: master
* fix: account token ownership limit when mint * fix: limit tests * fix: account token ownership limit rft mint * Revert "fix: account token ownership limit rft mint" This reverts commit 054110e015fd237fed77be1ef21bba6cea13fbea. * Revert "fix: limit tests" This reverts commit 75699574656bb0a34caddf3c9abdbffef79ba85d. * Revert "fix: account token ownership limit when mint" This reverts commit b89a3c86d3bf0888a636bc7da1949affa12d867d. * fix: account token ownership limit when transfer * test: account token ownership transfer tests ---------
3 files changed
js-packages/tests/limits.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.89// 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 type {IKeyringPair} from '@polkadot/types/types';18import {expect, itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds} from '@unique/test-utils/util.js';1920describe('Number of tokens per address (NFT)', () => {21 let alice: IKeyringPair;22 let bob: IKeyringPair;2324 before(async () => {25 await usingPlaygrounds(async (helper, privateKey) => {26 const donor = await privateKey({url: import.meta.url});27 [alice, bob] = await helper.arrange.createAccounts([10n, 0n], donor);28 });29 });3031 itSub.skip('Collection limits allow greater number than chain limits, chain limits are enforced', async ({helper}) => {32 const collection = await helper.nft.mintCollection(alice, {});33 await collection.setLimits(alice, {accountTokenOwnershipLimit: 20});3435 for(let i = 0; i < 10; i++){36 await expect(collection.mintToken(alice)).to.be.not.rejected;37 }38 await expect(collection.mintToken(alice)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);39 for(let i = 1; i < 11; i++) {40 await expect(collection.burnToken(alice, i)).to.be.not.rejected;41 }42 await collection.burn(alice);43 });4445 itSub('Collection limits allow lower number than chain limits, collection limits are enforced', async ({helper}) => {46 const collection = await helper.nft.mintCollection(alice, {});47 await collection.setLimits(alice, {accountTokenOwnershipLimit: 1});4849 await collection.mintToken(alice);50 await expect(collection.mintToken(alice)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);5152 await collection.burnToken(alice, 1);53 await expect(collection.burn(alice)).to.be.not.rejected;54 });5556 itSub('Can transfer tokens to address equal to accountTokenOwnershipLimit', async ({helper}) => {57 const collection = await helper.nft.mintCollection(alice, {});58 await collection.setLimits(alice, {accountTokenOwnershipLimit: 1});5960 // Limit 1 - can transfer #1 token61 const tkn1 = await collection.mintToken(alice);62 await collection.transferToken(alice, tkn1.tokenId, {Substrate: bob.address});6364 // Limit 1 - cannot transfer #2 token65 const tkn2 = await collection.mintToken(alice);66 await expect(collection.transferToken(alice, tkn2.tokenId, {Substrate: bob.address})).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);6768 // Increase limit to 269 // Now can transfer token #270 await collection.setLimits(alice, {accountTokenOwnershipLimit: 2});71 await collection.transferToken(alice, tkn2.tokenId, {Substrate: bob.address});7273 // But cannot transfer token #374 const tkn3 = await collection.mintToken(alice);75 await expect(collection.transferToken(alice, tkn3.tokenId, {Substrate: bob.address})).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);76 });77});7879describe('Number of tokens per address (ReFungible)', () => {80 let alice: IKeyringPair;81 let bob: IKeyringPair;8283 before(async function() {84 await usingPlaygrounds(async (helper, privateKey) => {85 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);8687 const donor = await privateKey({url: import.meta.url});88 [alice, bob] = await helper.arrange.createAccounts([10n, 0n], donor);89 });90 });9192 itSub.skip('Collection limits allow greater number than chain limits, chain limits are enforced', async ({helper}) => {93 const collection = await helper.rft.mintCollection(alice, {});94 await collection.setLimits(alice, {accountTokenOwnershipLimit: 20});9596 for(let i = 0; i < 10; i++){97 await expect(collection.mintToken(alice, 10n)).to.be.not.rejected;98 }99 await expect(collection.mintToken(alice, 10n)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);100 for(let i = 1; i < 11; i++) {101 await expect(collection.burnToken(alice, i, 10n)).to.be.not.rejected;102 }103 await collection.burn(alice);104 });105106 itSub('Collection limits allow lower number than chain limits, collection limits are enforced', async ({helper}) => {107 const collection = await helper.rft.mintCollection(alice, {});108 await collection.setLimits(alice, {accountTokenOwnershipLimit: 1});109110 await collection.mintToken(alice);111 await expect(collection.mintToken(alice)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);112113 await collection.burnToken(alice, 1);114 await expect(collection.burn(alice)).to.be.not.rejected;115 });116117 itSub('Can transfer tokens to address equal to accountTokenOwnershipLimit', async ({helper}) => {118 const collection = await helper.rft.mintCollection(alice, {});119 await collection.setLimits(alice, {accountTokenOwnershipLimit: 1});120121 // Limit 1 - can transfer #1 token122 const tkn1 = await collection.mintToken(alice);123 await collection.transferToken(alice, tkn1.tokenId, {Substrate: bob.address});124125 // Limit 1 - cannot transfer #2 token126 const tkn2 = await collection.mintToken(alice);127 await expect(collection.transferToken(alice, tkn2.tokenId, {Substrate: bob.address})).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);128129 // Increase limit to 2130 // Now can transfer token #2131 await collection.setLimits(alice, {accountTokenOwnershipLimit: 2});132 await collection.transferToken(alice, tkn2.tokenId, {Substrate: bob.address});133134 // But cannot transfer token #3135 const tkn3 = await collection.mintToken(alice);136 await expect(collection.transferToken(alice, tkn3.tokenId, {Substrate: bob.address})).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);137 });138});139140// todo:playgrounds skipped ~ postponed141describe.skip('Sponsor timeout (NFT) (only for special chain limits test)', () => {142 /*let alice: IKeyringPair;143 let bob: IKeyringPair;144 let charlie: IKeyringPair;145146 before(async () => {147 await usingApi(async (api, privateKeyWrapper) => {148 alice = privateKeyWrapper('//Alice');149 bob = privateKeyWrapper('//Bob');150 charlie = privateKeyWrapper('//Charlie');151 });152 });153154 itSub.skip('Collection limits have greater timeout value than chain limits, collection limits are enforced', async ({helper}) => {155 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});156 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 7});157 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');158 await setCollectionSponsorExpectSuccess(collectionId, alice.address);159 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');160 await transferExpectSuccess(collectionId, tokenId, alice, bob);161 const aliceBalanceBefore = await getFreeBalance(alice);162163 // check setting SponsorTimeout = 5, fail164 await waitNewBlocks(5);165 await transferExpectSuccess(collectionId, tokenId, bob, charlie);166 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);167 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);168169 // check setting SponsorTimeout = 7, success170 await waitNewBlocks(2); // 5 + 2171 await transferExpectSuccess(collectionId, tokenId, charlie, bob);172 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);173 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;174 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);175 await destroyCollectionExpectSuccess(collectionId);176 });177178 itSub('Collection limits have lower timeout value than chain limits, chain limits are enforced', async ({helper}) => {179180 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});181 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 1});182 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');183 await setCollectionSponsorExpectSuccess(collectionId, alice.address);184 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');185 await transferExpectSuccess(collectionId, tokenId, alice, bob);186 const aliceBalanceBefore = await getFreeBalance(alice);187188 // check setting SponsorTimeout = 1, fail189 await waitNewBlocks(1);190 await transferExpectSuccess(collectionId, tokenId, bob, charlie);191 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);192 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);193194 // check setting SponsorTimeout = 5, success195 await waitNewBlocks(4);196 await transferExpectSuccess(collectionId, tokenId, charlie, bob);197 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);198 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;199 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);200 await destroyCollectionExpectSuccess(collectionId);201 });202});203204describe.skip('Sponsor timeout (Fungible) (only for special chain limits test)', () => {205 let alice: IKeyringPair;206 let bob: IKeyringPair;207 let charlie: IKeyringPair;208209 before(async () => {210 await usingApi(async (api, privateKeyWrapper) => {211 alice = privateKeyWrapper('//Alice');212 bob = privateKeyWrapper('//Bob');213 charlie = privateKeyWrapper('//Charlie');214 });215 });216217 itSub('Collection limits have greater timeout value than chain limits, collection limits are enforced', async ({helper}) => {218 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});219 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 7});220 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible');221 await setCollectionSponsorExpectSuccess(collectionId, alice.address);222 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');223 await transferExpectSuccess(collectionId, tokenId, alice, bob, 10, 'Fungible');224 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');225 const aliceBalanceBefore = await getFreeBalance(alice);226227 // check setting SponsorTimeout = 5, fail228 await waitNewBlocks(5);229 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');230 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);231 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);232233 // check setting SponsorTimeout = 7, success234 await waitNewBlocks(2); // 5 + 2235 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');236 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);237 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;238 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);239240 await destroyCollectionExpectSuccess(collectionId);241 });242243 itSub('Collection limits have lower timeout value than chain limits, chain limits are enforced', async ({helper}) => {244245 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});246 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 1});247 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible');248 await setCollectionSponsorExpectSuccess(collectionId, alice.address);249 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');250 await transferExpectSuccess(collectionId, tokenId, alice, bob, 10, 'Fungible');251 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');252 const aliceBalanceBefore = await getFreeBalance(alice);253254 // check setting SponsorTimeout = 1, fail255 await waitNewBlocks(1);256 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');257 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);258 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);259260 // check setting SponsorTimeout = 5, success261 await waitNewBlocks(4);262 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');263 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);264 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;265 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);266267 await destroyCollectionExpectSuccess(collectionId);268 });269});270271describe.skip('Sponsor timeout (ReFungible) (only for special chain limits test)', () => {272 let alice: IKeyringPair;273 let bob: IKeyringPair;274 let charlie: IKeyringPair;275276 before(async () => {277 await usingApi(async (api, privateKeyWrapper) => {278 alice = privateKeyWrapper('//Alice');279 bob = privateKeyWrapper('//Bob');280 charlie = privateKeyWrapper('//Charlie');281 });282 });283284 itSub('Collection limits have greater timeout value than chain limits, collection limits are enforced', async ({helper}) => {285 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});286 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 7});287 const tokenId = await createItemExpectSuccess(alice, collectionId, 'ReFungible');288 await setCollectionSponsorExpectSuccess(collectionId, alice.address);289 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');290 await transferExpectSuccess(collectionId, tokenId, alice, bob, 100, 'ReFungible');291 const aliceBalanceBefore = await getFreeBalance(alice);292293 // check setting SponsorTimeout = 5, fail294 await waitNewBlocks(5);295 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 20, 'ReFungible');296 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);297 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);298299 // check setting SponsorTimeout = 7, success300 await waitNewBlocks(2); // 5 + 2301 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 20, 'ReFungible');302 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);303 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;304 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);305 await destroyCollectionExpectSuccess(collectionId);306 });307308 itSub('Collection limits have lower timeout value than chain limits, chain limits are enforced', async ({helper}) => {309310 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});311 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 1});312 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');313 await setCollectionSponsorExpectSuccess(collectionId, alice.address);314 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');315 await transferExpectSuccess(collectionId, tokenId, alice, bob);316 const aliceBalanceBefore = await getFreeBalance(alice);317318 // check setting SponsorTimeout = 1, fail319 await waitNewBlocks(1);320 await transferExpectSuccess(collectionId, tokenId, bob, charlie);321 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);322 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);323324 // check setting SponsorTimeout = 5, success325 await waitNewBlocks(4);326 await transferExpectSuccess(collectionId, tokenId, charlie, bob);327 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);328 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;329 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);330 await destroyCollectionExpectSuccess(collectionId);331 });*/332});333334describe('Collection zero limits (NFT)', () => {335 let alice: IKeyringPair;336 let bob: IKeyringPair;337 let charlie: IKeyringPair;338339 before(async () => {340 await usingPlaygrounds(async (helper, privateKey) => {341 const donor = await privateKey({url: import.meta.url});342 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);343 });344 });345346 itSub.skip('Limits have 0 in tokens per address field, the chain limits are applied', async ({helper}) => {347 const collection = await helper.nft.mintCollection(alice, {});348 await collection.setLimits(alice, {accountTokenOwnershipLimit: 0});349350 for(let i = 0; i < 10; i++){351 await collection.mintToken(alice);352 }353 await expect(collection.mintToken(alice)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);354 });355356 itSub('Limits have 0 in sponsor timeout, no limits are applied', async ({helper}) => {357 const collection = await helper.nft.mintCollection(alice, {});358 await collection.setLimits(alice, {sponsorTransferTimeout: 0});359 const token = await collection.mintToken(alice);360361 await collection.setSponsor(alice, alice.address);362 await collection.confirmSponsorship(alice);363364 await token.transfer(alice, {Substrate: bob.address});365 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);366367 // check setting SponsorTimeout = 0, success with next block368 await helper.wait.newBlocks(1);369 await token.transfer(bob, {Substrate: charlie.address});370 const aliceBalanceAfterSponsoredTransaction1 = await helper.balance.getSubstrate(alice.address);371 expect(aliceBalanceAfterSponsoredTransaction1 < aliceBalanceBefore).to.be.true;372 });373});374375describe('Collection zero limits (Fungible)', () => {376 let alice: IKeyringPair;377 let bob: IKeyringPair;378 let charlie: IKeyringPair;379380 before(async () => {381 await usingPlaygrounds(async (helper, privateKey) => {382 const donor = await privateKey({url: import.meta.url});383 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);384 });385 });386387 itSub('Limits have 0 in sponsor timeout, no limits are applied', async ({helper}) => {388 const collection = await helper.ft.mintCollection(alice, {});389 await collection.setLimits(alice, {sponsorTransferTimeout: 0});390 await collection.mint(alice, 3n);391392 await collection.setSponsor(alice, alice.address);393 await collection.confirmSponsorship(alice);394395 await collection.transfer(alice, {Substrate: bob.address}, 2n);396 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);397398 // check setting SponsorTimeout = 0, success with next block399 await helper.wait.newBlocks(1);400 await collection.transfer(bob, {Substrate: charlie.address});401 const aliceBalanceAfterSponsoredTransaction1 = await helper.balance.getSubstrate(alice.address);402 expect(aliceBalanceAfterSponsoredTransaction1 < aliceBalanceBefore).to.be.true;403 });404});405406describe('Collection zero limits (ReFungible)', () => {407 let alice: IKeyringPair;408 let bob: IKeyringPair;409 let charlie: IKeyringPair;410411 before(async function() {412 await usingPlaygrounds(async (helper, privateKey) => {413 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);414415 const donor = await privateKey({url: import.meta.url});416 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);417 });418 });419420 itSub.skip('Limits have 0 in tokens per address field, the chain limits are applied', async ({helper}) => {421 const collection = await helper.rft.mintCollection(alice, {});422 await collection.setLimits(alice, {accountTokenOwnershipLimit: 0});423 for(let i = 0; i < 10; i++){424 await collection.mintToken(alice);425 }426 await expect(collection.mintToken(alice)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);427 });428429 itSub('Limits have 0 in sponsor timeout, no limits are applied', async ({helper}) => {430 const collection = await helper.rft.mintCollection(alice, {});431 await collection.setLimits(alice, {sponsorTransferTimeout: 0});432 const token = await collection.mintToken(alice, 3n);433434 await collection.setSponsor(alice, alice.address);435 await collection.confirmSponsorship(alice);436437 await token.transfer(alice, {Substrate: bob.address}, 2n);438 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);439440 // check setting SponsorTimeout = 0, success with next block441 await helper.wait.newBlocks(1);442 await token.transfer(bob, {Substrate: charlie.address});443 const aliceBalanceAfterSponsoredTransaction1 = await helper.balance.getSubstrate(alice.address);444 expect(aliceBalanceAfterSponsoredTransaction1 < aliceBalanceBefore).to.be.true;445 });446});447448describe('Effective collection limits (NFT)', () => {449 let alice: IKeyringPair;450451 before(async () => {452 await usingPlaygrounds(async (helper, privateKey) => {453 const donor = await privateKey({url: import.meta.url});454 [alice] = await helper.arrange.createAccounts([10n], donor);455 });456 });457458 itSub('Effective collection limits', async ({helper}) => {459 const collection = await helper.nft.mintCollection(alice, {});460 await collection.setLimits(alice, {ownerCanTransfer: true});461462 {463 // Check that limits are undefined464 const collectionInfo = await collection.getData();465 const limits = collectionInfo?.raw.limits;466 expect(limits).to.be.any;467468 expect(limits.accountTokenOwnershipLimit).to.be.null;469 expect(limits.sponsoredDataSize).to.be.null;470 expect(limits.sponsoredDataRateLimit).to.be.null;471 expect(limits.tokenLimit).to.be.null;472 expect(limits.sponsorTransferTimeout).to.be.null;473 expect(limits.sponsorApproveTimeout).to.be.null;474 expect(limits.ownerCanTransfer).to.be.true;475 expect(limits.ownerCanDestroy).to.be.null;476 expect(limits.transfersEnabled).to.be.null;477 }478479 { // Check that limits is undefined for non-existent collection480 const limits = await helper.collection.getEffectiveLimits(999999);481 expect(limits).to.be.null;482 }483484 { // Check that default values defined for collection limits485 const limits = await collection.getEffectiveLimits();486487 expect(limits.accountTokenOwnershipLimit).to.be.eq(100000000);488 expect(limits.sponsoredDataSize).to.be.eq(2048);489 expect(limits.sponsoredDataRateLimit).to.be.deep.eq({sponsoringDisabled: null});490 expect(limits.tokenLimit).to.be.eq(4294967295);491 expect(limits.sponsorTransferTimeout).to.be.eq(5);492 expect(limits.sponsorApproveTimeout).to.be.eq(5);493 expect(limits.ownerCanTransfer).to.be.true;494 expect(limits.ownerCanDestroy).to.be.true;495 expect(limits.transfersEnabled).to.be.true;496 }497498 {499 // Check the values for collection limits500 await collection.setLimits(alice, {501 accountTokenOwnershipLimit: 99_999,502 sponsoredDataSize: 1024,503 tokenLimit: 123,504 transfersEnabled: false,505 });506507 const limits = await collection.getEffectiveLimits();508509 expect(limits.accountTokenOwnershipLimit).to.be.eq(99999);510 expect(limits.sponsoredDataSize).to.be.eq(1024);511 expect(limits.sponsoredDataRateLimit).to.be.deep.eq({sponsoringDisabled: null});512 expect(limits.tokenLimit).to.be.eq(123);513 expect(limits.sponsorTransferTimeout).to.be.eq(5);514 expect(limits.sponsorApproveTimeout).to.be.eq(5);515 expect(limits.ownerCanTransfer).to.be.true;516 expect(limits.ownerCanDestroy).to.be.true;517 expect(limits.transfersEnabled).to.be.false;518 }519 });520});pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -746,7 +746,7 @@
.ok_or(ArithmeticError::Overflow)?;
ensure!(
- balance_to < collection.limits.account_token_ownership_limit(),
+ balance_to <= collection.limits.account_token_ownership_limit(),
<CommonError<T>>::AccountTokenLimitExceeded,
);
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -679,7 +679,7 @@
.checked_add(1)
.ok_or(ArithmeticError::Overflow)?;
ensure!(
- account_balance_to < collection.limits.account_token_ownership_limit(),
+ account_balance_to <= collection.limits.account_token_ownership_limit(),
<CommonError<T>>::AccountTokenLimitExceeded,
);