difftreelog
fix max token ownership = 100_000_000
in: master
3 files changed
js-packages/tests/apiConsts.test.tsdiffbeforeafterboth--- a/js-packages/tests/apiConsts.test.ts
+++ b/js-packages/tests/apiConsts.test.ts
@@ -30,7 +30,7 @@
const NESTING_BUDGET = 5n;
const DEFAULT_COLLETCTION_LIMIT = {
- accountTokenOwnershipLimit: '1,000,000',
+ accountTokenOwnershipLimit: '100,000,000',
sponsoredDataSize: '2,048',
sponsoredDataRateLimit: 'SponsoringDisabled',
tokenLimit: '4,294,967,295',
@@ -113,4 +113,4 @@
function checkConst<T>(constValue: any, expectedValue: T) {
expect(constValue.toBigInt()).equal(expectedValue);
-}
\ No newline at end of file
+}
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 './util/index.js';1920describe('Number of tokens per address (NFT)', () => {21 let alice: IKeyringPair;2223 before(async () => {24 await usingPlaygrounds(async (helper, privateKey) => {25 const donor = await privateKey({url: import.meta.url});26 [alice] = await helper.arrange.createAccounts([10n], donor);27 });28 });2930 itSub.skip('Collection limits allow greater number than chain limits, chain limits are enforced', async ({helper}) => {31 const collection = await helper.nft.mintCollection(alice, {});32 await collection.setLimits(alice, {accountTokenOwnershipLimit: 20});3334 for(let i = 0; i < 10; i++){35 await expect(collection.mintToken(alice)).to.be.not.rejected;36 }37 await expect(collection.mintToken(alice)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);38 for(let i = 1; i < 11; i++) {39 await expect(collection.burnToken(alice, i)).to.be.not.rejected;40 }41 await collection.burn(alice);42 });4344 itSub('Collection limits allow lower number than chain limits, collection limits are enforced', async ({helper}) => {45 const collection = await helper.nft.mintCollection(alice, {});46 await collection.setLimits(alice, {accountTokenOwnershipLimit: 1});4748 await collection.mintToken(alice);49 await expect(collection.mintToken(alice)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);5051 await collection.burnToken(alice, 1);52 await expect(collection.burn(alice)).to.be.not.rejected;53 });54});5556describe('Number of tokens per address (ReFungible)', () => {57 let alice: IKeyringPair;5859 before(async function() {60 await usingPlaygrounds(async (helper, privateKey) => {61 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);6263 const donor = await privateKey({url: import.meta.url});64 [alice] = await helper.arrange.createAccounts([10n], donor);65 });66 });6768 itSub.skip('Collection limits allow greater number than chain limits, chain limits are enforced', async ({helper}) => {69 const collection = await helper.rft.mintCollection(alice, {});70 await collection.setLimits(alice, {accountTokenOwnershipLimit: 20});7172 for(let i = 0; i < 10; i++){73 await expect(collection.mintToken(alice, 10n)).to.be.not.rejected;74 }75 await expect(collection.mintToken(alice, 10n)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);76 for(let i = 1; i < 11; i++) {77 await expect(collection.burnToken(alice, i, 10n)).to.be.not.rejected;78 }79 await collection.burn(alice);80 });8182 itSub('Collection limits allow lower number than chain limits, collection limits are enforced', async ({helper}) => {83 const collection = await helper.rft.mintCollection(alice, {});84 await collection.setLimits(alice, {accountTokenOwnershipLimit: 1});8586 await collection.mintToken(alice);87 await expect(collection.mintToken(alice)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);8889 await collection.burnToken(alice, 1);90 await expect(collection.burn(alice)).to.be.not.rejected;91 });92});9394// todo:playgrounds skipped ~ postponed95describe.skip('Sponsor timeout (NFT) (only for special chain limits test)', () => {96 /*let alice: IKeyringPair;97 let bob: IKeyringPair;98 let charlie: IKeyringPair;99100 before(async () => {101 await usingApi(async (api, privateKeyWrapper) => {102 alice = privateKeyWrapper('//Alice');103 bob = privateKeyWrapper('//Bob');104 charlie = privateKeyWrapper('//Charlie');105 });106 });107108 itSub.skip('Collection limits have greater timeout value than chain limits, collection limits are enforced', async ({helper}) => {109 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});110 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 7});111 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');112 await setCollectionSponsorExpectSuccess(collectionId, alice.address);113 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');114 await transferExpectSuccess(collectionId, tokenId, alice, bob);115 const aliceBalanceBefore = await getFreeBalance(alice);116117 // check setting SponsorTimeout = 5, fail118 await waitNewBlocks(5);119 await transferExpectSuccess(collectionId, tokenId, bob, charlie);120 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);121 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);122123 // check setting SponsorTimeout = 7, success124 await waitNewBlocks(2); // 5 + 2125 await transferExpectSuccess(collectionId, tokenId, charlie, bob);126 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);127 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;128 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);129 await destroyCollectionExpectSuccess(collectionId);130 });131132 itSub('Collection limits have lower timeout value than chain limits, chain limits are enforced', async ({helper}) => {133134 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});135 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 1});136 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');137 await setCollectionSponsorExpectSuccess(collectionId, alice.address);138 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');139 await transferExpectSuccess(collectionId, tokenId, alice, bob);140 const aliceBalanceBefore = await getFreeBalance(alice);141142 // check setting SponsorTimeout = 1, fail143 await waitNewBlocks(1);144 await transferExpectSuccess(collectionId, tokenId, bob, charlie);145 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);146 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);147148 // check setting SponsorTimeout = 5, success149 await waitNewBlocks(4);150 await transferExpectSuccess(collectionId, tokenId, charlie, bob);151 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);152 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;153 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);154 await destroyCollectionExpectSuccess(collectionId);155 });156});157158describe.skip('Sponsor timeout (Fungible) (only for special chain limits test)', () => {159 let alice: IKeyringPair;160 let bob: IKeyringPair;161 let charlie: IKeyringPair;162163 before(async () => {164 await usingApi(async (api, privateKeyWrapper) => {165 alice = privateKeyWrapper('//Alice');166 bob = privateKeyWrapper('//Bob');167 charlie = privateKeyWrapper('//Charlie');168 });169 });170171 itSub('Collection limits have greater timeout value than chain limits, collection limits are enforced', async ({helper}) => {172 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});173 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 7});174 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible');175 await setCollectionSponsorExpectSuccess(collectionId, alice.address);176 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');177 await transferExpectSuccess(collectionId, tokenId, alice, bob, 10, 'Fungible');178 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');179 const aliceBalanceBefore = await getFreeBalance(alice);180181 // check setting SponsorTimeout = 5, fail182 await waitNewBlocks(5);183 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');184 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);185 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);186187 // check setting SponsorTimeout = 7, success188 await waitNewBlocks(2); // 5 + 2189 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');190 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);191 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;192 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);193194 await destroyCollectionExpectSuccess(collectionId);195 });196197 itSub('Collection limits have lower timeout value than chain limits, chain limits are enforced', async ({helper}) => {198199 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});200 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 1});201 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible');202 await setCollectionSponsorExpectSuccess(collectionId, alice.address);203 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');204 await transferExpectSuccess(collectionId, tokenId, alice, bob, 10, 'Fungible');205 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');206 const aliceBalanceBefore = await getFreeBalance(alice);207208 // check setting SponsorTimeout = 1, fail209 await waitNewBlocks(1);210 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');211 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);212 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);213214 // check setting SponsorTimeout = 5, success215 await waitNewBlocks(4);216 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');217 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);218 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;219 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);220221 await destroyCollectionExpectSuccess(collectionId);222 });223});224225describe.skip('Sponsor timeout (ReFungible) (only for special chain limits test)', () => {226 let alice: IKeyringPair;227 let bob: IKeyringPair;228 let charlie: IKeyringPair;229230 before(async () => {231 await usingApi(async (api, privateKeyWrapper) => {232 alice = privateKeyWrapper('//Alice');233 bob = privateKeyWrapper('//Bob');234 charlie = privateKeyWrapper('//Charlie');235 });236 });237238 itSub('Collection limits have greater timeout value than chain limits, collection limits are enforced', async ({helper}) => {239 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});240 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 7});241 const tokenId = await createItemExpectSuccess(alice, collectionId, 'ReFungible');242 await setCollectionSponsorExpectSuccess(collectionId, alice.address);243 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');244 await transferExpectSuccess(collectionId, tokenId, alice, bob, 100, 'ReFungible');245 const aliceBalanceBefore = await getFreeBalance(alice);246247 // check setting SponsorTimeout = 5, fail248 await waitNewBlocks(5);249 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 20, 'ReFungible');250 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);251 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);252253 // check setting SponsorTimeout = 7, success254 await waitNewBlocks(2); // 5 + 2255 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 20, 'ReFungible');256 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);257 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;258 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);259 await destroyCollectionExpectSuccess(collectionId);260 });261262 itSub('Collection limits have lower timeout value than chain limits, chain limits are enforced', async ({helper}) => {263264 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});265 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 1});266 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');267 await setCollectionSponsorExpectSuccess(collectionId, alice.address);268 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');269 await transferExpectSuccess(collectionId, tokenId, alice, bob);270 const aliceBalanceBefore = await getFreeBalance(alice);271272 // check setting SponsorTimeout = 1, fail273 await waitNewBlocks(1);274 await transferExpectSuccess(collectionId, tokenId, bob, charlie);275 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);276 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);277278 // check setting SponsorTimeout = 5, success279 await waitNewBlocks(4);280 await transferExpectSuccess(collectionId, tokenId, charlie, bob);281 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);282 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;283 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);284 await destroyCollectionExpectSuccess(collectionId);285 });*/286});287288describe('Collection zero limits (NFT)', () => {289 let alice: IKeyringPair;290 let bob: IKeyringPair;291 let charlie: IKeyringPair;292293 before(async () => {294 await usingPlaygrounds(async (helper, privateKey) => {295 const donor = await privateKey({url: import.meta.url});296 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);297 });298 });299300 itSub.skip('Limits have 0 in tokens per address field, the chain limits are applied', async ({helper}) => {301 const collection = await helper.nft.mintCollection(alice, {});302 await collection.setLimits(alice, {accountTokenOwnershipLimit: 0});303304 for(let i = 0; i < 10; i++){305 await collection.mintToken(alice);306 }307 await expect(collection.mintToken(alice)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);308 });309310 itSub('Limits have 0 in sponsor timeout, no limits are applied', async ({helper}) => {311 const collection = await helper.nft.mintCollection(alice, {});312 await collection.setLimits(alice, {sponsorTransferTimeout: 0});313 const token = await collection.mintToken(alice);314315 await collection.setSponsor(alice, alice.address);316 await collection.confirmSponsorship(alice);317318 await token.transfer(alice, {Substrate: bob.address});319 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);320321 // check setting SponsorTimeout = 0, success with next block322 await helper.wait.newBlocks(1);323 await token.transfer(bob, {Substrate: charlie.address});324 const aliceBalanceAfterSponsoredTransaction1 = await helper.balance.getSubstrate(alice.address);325 expect(aliceBalanceAfterSponsoredTransaction1 < aliceBalanceBefore).to.be.true;326 });327});328329describe('Collection zero limits (Fungible)', () => {330 let alice: IKeyringPair;331 let bob: IKeyringPair;332 let charlie: IKeyringPair;333334 before(async () => {335 await usingPlaygrounds(async (helper, privateKey) => {336 const donor = await privateKey({url: import.meta.url});337 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);338 });339 });340341 itSub('Limits have 0 in sponsor timeout, no limits are applied', async ({helper}) => {342 const collection = await helper.ft.mintCollection(alice, {});343 await collection.setLimits(alice, {sponsorTransferTimeout: 0});344 await collection.mint(alice, 3n);345346 await collection.setSponsor(alice, alice.address);347 await collection.confirmSponsorship(alice);348349 await collection.transfer(alice, {Substrate: bob.address}, 2n);350 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);351352 // check setting SponsorTimeout = 0, success with next block353 await helper.wait.newBlocks(1);354 await collection.transfer(bob, {Substrate: charlie.address});355 const aliceBalanceAfterSponsoredTransaction1 = await helper.balance.getSubstrate(alice.address);356 expect(aliceBalanceAfterSponsoredTransaction1 < aliceBalanceBefore).to.be.true;357 });358});359360describe('Collection zero limits (ReFungible)', () => {361 let alice: IKeyringPair;362 let bob: IKeyringPair;363 let charlie: IKeyringPair;364365 before(async function() {366 await usingPlaygrounds(async (helper, privateKey) => {367 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);368369 const donor = await privateKey({url: import.meta.url});370 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);371 });372 });373374 itSub.skip('Limits have 0 in tokens per address field, the chain limits are applied', async ({helper}) => {375 const collection = await helper.rft.mintCollection(alice, {});376 await collection.setLimits(alice, {accountTokenOwnershipLimit: 0});377 for(let i = 0; i < 10; i++){378 await collection.mintToken(alice);379 }380 await expect(collection.mintToken(alice)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);381 });382383 itSub('Limits have 0 in sponsor timeout, no limits are applied', async ({helper}) => {384 const collection = await helper.rft.mintCollection(alice, {});385 await collection.setLimits(alice, {sponsorTransferTimeout: 0});386 const token = await collection.mintToken(alice, 3n);387388 await collection.setSponsor(alice, alice.address);389 await collection.confirmSponsorship(alice);390391 await token.transfer(alice, {Substrate: bob.address}, 2n);392 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);393394 // check setting SponsorTimeout = 0, success with next block395 await helper.wait.newBlocks(1);396 await token.transfer(bob, {Substrate: charlie.address});397 const aliceBalanceAfterSponsoredTransaction1 = await helper.balance.getSubstrate(alice.address);398 expect(aliceBalanceAfterSponsoredTransaction1 < aliceBalanceBefore).to.be.true;399 });400});401402describe('Effective collection limits (NFT)', () => {403 let alice: IKeyringPair;404405 before(async () => {406 await usingPlaygrounds(async (helper, privateKey) => {407 const donor = await privateKey({url: import.meta.url});408 [alice] = await helper.arrange.createAccounts([10n], donor);409 });410 });411412 itSub('Effective collection limits', async ({helper}) => {413 const collection = await helper.nft.mintCollection(alice, {});414 await collection.setLimits(alice, {ownerCanTransfer: true});415416 {417 // Check that limits are undefined418 const collectionInfo = await collection.getData();419 const limits = collectionInfo?.raw.limits;420 expect(limits).to.be.any;421422 expect(limits.accountTokenOwnershipLimit).to.be.null;423 expect(limits.sponsoredDataSize).to.be.null;424 expect(limits.sponsoredDataRateLimit).to.be.null;425 expect(limits.tokenLimit).to.be.null;426 expect(limits.sponsorTransferTimeout).to.be.null;427 expect(limits.sponsorApproveTimeout).to.be.null;428 expect(limits.ownerCanTransfer).to.be.true;429 expect(limits.ownerCanDestroy).to.be.null;430 expect(limits.transfersEnabled).to.be.null;431 }432433 { // Check that limits is undefined for non-existent collection434 const limits = await helper.collection.getEffectiveLimits(999999);435 expect(limits).to.be.null;436 }437438 { // Check that default values defined for collection limits439 const limits = await collection.getEffectiveLimits();440441 expect(limits.accountTokenOwnershipLimit).to.be.eq(100000);442 expect(limits.sponsoredDataSize).to.be.eq(2048);443 expect(limits.sponsoredDataRateLimit).to.be.deep.eq({sponsoringDisabled: null});444 expect(limits.tokenLimit).to.be.eq(4294967295);445 expect(limits.sponsorTransferTimeout).to.be.eq(5);446 expect(limits.sponsorApproveTimeout).to.be.eq(5);447 expect(limits.ownerCanTransfer).to.be.true;448 expect(limits.ownerCanDestroy).to.be.true;449 expect(limits.transfersEnabled).to.be.true;450 }451452 {453 // Check the values for collection limits454 await collection.setLimits(alice, {455 accountTokenOwnershipLimit: 99_999,456 sponsoredDataSize: 1024,457 tokenLimit: 123,458 transfersEnabled: false,459 });460461 const limits = await collection.getEffectiveLimits();462463 expect(limits.accountTokenOwnershipLimit).to.be.eq(99999);464 expect(limits.sponsoredDataSize).to.be.eq(1024);465 expect(limits.sponsoredDataRateLimit).to.be.deep.eq({sponsoringDisabled: null});466 expect(limits.tokenLimit).to.be.eq(123);467 expect(limits.sponsorTransferTimeout).to.be.eq(5);468 expect(limits.sponsorApproveTimeout).to.be.eq(5);469 expect(limits.ownerCanTransfer).to.be.true;470 expect(limits.ownerCanDestroy).to.be.true;471 expect(limits.transfersEnabled).to.be.false;472 }473 });474});1// 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 './util/index.js';1920describe('Number of tokens per address (NFT)', () => {21 let alice: IKeyringPair;2223 before(async () => {24 await usingPlaygrounds(async (helper, privateKey) => {25 const donor = await privateKey({url: import.meta.url});26 [alice] = await helper.arrange.createAccounts([10n], donor);27 });28 });2930 itSub.skip('Collection limits allow greater number than chain limits, chain limits are enforced', async ({helper}) => {31 const collection = await helper.nft.mintCollection(alice, {});32 await collection.setLimits(alice, {accountTokenOwnershipLimit: 20});3334 for(let i = 0; i < 10; i++){35 await expect(collection.mintToken(alice)).to.be.not.rejected;36 }37 await expect(collection.mintToken(alice)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);38 for(let i = 1; i < 11; i++) {39 await expect(collection.burnToken(alice, i)).to.be.not.rejected;40 }41 await collection.burn(alice);42 });4344 itSub('Collection limits allow lower number than chain limits, collection limits are enforced', async ({helper}) => {45 const collection = await helper.nft.mintCollection(alice, {});46 await collection.setLimits(alice, {accountTokenOwnershipLimit: 1});4748 await collection.mintToken(alice);49 await expect(collection.mintToken(alice)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);5051 await collection.burnToken(alice, 1);52 await expect(collection.burn(alice)).to.be.not.rejected;53 });54});5556describe('Number of tokens per address (ReFungible)', () => {57 let alice: IKeyringPair;5859 before(async function() {60 await usingPlaygrounds(async (helper, privateKey) => {61 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);6263 const donor = await privateKey({url: import.meta.url});64 [alice] = await helper.arrange.createAccounts([10n], donor);65 });66 });6768 itSub.skip('Collection limits allow greater number than chain limits, chain limits are enforced', async ({helper}) => {69 const collection = await helper.rft.mintCollection(alice, {});70 await collection.setLimits(alice, {accountTokenOwnershipLimit: 20});7172 for(let i = 0; i < 10; i++){73 await expect(collection.mintToken(alice, 10n)).to.be.not.rejected;74 }75 await expect(collection.mintToken(alice, 10n)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);76 for(let i = 1; i < 11; i++) {77 await expect(collection.burnToken(alice, i, 10n)).to.be.not.rejected;78 }79 await collection.burn(alice);80 });8182 itSub('Collection limits allow lower number than chain limits, collection limits are enforced', async ({helper}) => {83 const collection = await helper.rft.mintCollection(alice, {});84 await collection.setLimits(alice, {accountTokenOwnershipLimit: 1});8586 await collection.mintToken(alice);87 await expect(collection.mintToken(alice)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);8889 await collection.burnToken(alice, 1);90 await expect(collection.burn(alice)).to.be.not.rejected;91 });92});9394// todo:playgrounds skipped ~ postponed95describe.skip('Sponsor timeout (NFT) (only for special chain limits test)', () => {96 /*let alice: IKeyringPair;97 let bob: IKeyringPair;98 let charlie: IKeyringPair;99100 before(async () => {101 await usingApi(async (api, privateKeyWrapper) => {102 alice = privateKeyWrapper('//Alice');103 bob = privateKeyWrapper('//Bob');104 charlie = privateKeyWrapper('//Charlie');105 });106 });107108 itSub.skip('Collection limits have greater timeout value than chain limits, collection limits are enforced', async ({helper}) => {109 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});110 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 7});111 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');112 await setCollectionSponsorExpectSuccess(collectionId, alice.address);113 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');114 await transferExpectSuccess(collectionId, tokenId, alice, bob);115 const aliceBalanceBefore = await getFreeBalance(alice);116117 // check setting SponsorTimeout = 5, fail118 await waitNewBlocks(5);119 await transferExpectSuccess(collectionId, tokenId, bob, charlie);120 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);121 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);122123 // check setting SponsorTimeout = 7, success124 await waitNewBlocks(2); // 5 + 2125 await transferExpectSuccess(collectionId, tokenId, charlie, bob);126 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);127 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;128 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);129 await destroyCollectionExpectSuccess(collectionId);130 });131132 itSub('Collection limits have lower timeout value than chain limits, chain limits are enforced', async ({helper}) => {133134 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});135 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 1});136 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');137 await setCollectionSponsorExpectSuccess(collectionId, alice.address);138 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');139 await transferExpectSuccess(collectionId, tokenId, alice, bob);140 const aliceBalanceBefore = await getFreeBalance(alice);141142 // check setting SponsorTimeout = 1, fail143 await waitNewBlocks(1);144 await transferExpectSuccess(collectionId, tokenId, bob, charlie);145 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);146 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);147148 // check setting SponsorTimeout = 5, success149 await waitNewBlocks(4);150 await transferExpectSuccess(collectionId, tokenId, charlie, bob);151 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);152 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;153 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);154 await destroyCollectionExpectSuccess(collectionId);155 });156});157158describe.skip('Sponsor timeout (Fungible) (only for special chain limits test)', () => {159 let alice: IKeyringPair;160 let bob: IKeyringPair;161 let charlie: IKeyringPair;162163 before(async () => {164 await usingApi(async (api, privateKeyWrapper) => {165 alice = privateKeyWrapper('//Alice');166 bob = privateKeyWrapper('//Bob');167 charlie = privateKeyWrapper('//Charlie');168 });169 });170171 itSub('Collection limits have greater timeout value than chain limits, collection limits are enforced', async ({helper}) => {172 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});173 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 7});174 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible');175 await setCollectionSponsorExpectSuccess(collectionId, alice.address);176 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');177 await transferExpectSuccess(collectionId, tokenId, alice, bob, 10, 'Fungible');178 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');179 const aliceBalanceBefore = await getFreeBalance(alice);180181 // check setting SponsorTimeout = 5, fail182 await waitNewBlocks(5);183 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');184 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);185 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);186187 // check setting SponsorTimeout = 7, success188 await waitNewBlocks(2); // 5 + 2189 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');190 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);191 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;192 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);193194 await destroyCollectionExpectSuccess(collectionId);195 });196197 itSub('Collection limits have lower timeout value than chain limits, chain limits are enforced', async ({helper}) => {198199 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});200 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 1});201 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible');202 await setCollectionSponsorExpectSuccess(collectionId, alice.address);203 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');204 await transferExpectSuccess(collectionId, tokenId, alice, bob, 10, 'Fungible');205 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');206 const aliceBalanceBefore = await getFreeBalance(alice);207208 // check setting SponsorTimeout = 1, fail209 await waitNewBlocks(1);210 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');211 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);212 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);213214 // check setting SponsorTimeout = 5, success215 await waitNewBlocks(4);216 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');217 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);218 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;219 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);220221 await destroyCollectionExpectSuccess(collectionId);222 });223});224225describe.skip('Sponsor timeout (ReFungible) (only for special chain limits test)', () => {226 let alice: IKeyringPair;227 let bob: IKeyringPair;228 let charlie: IKeyringPair;229230 before(async () => {231 await usingApi(async (api, privateKeyWrapper) => {232 alice = privateKeyWrapper('//Alice');233 bob = privateKeyWrapper('//Bob');234 charlie = privateKeyWrapper('//Charlie');235 });236 });237238 itSub('Collection limits have greater timeout value than chain limits, collection limits are enforced', async ({helper}) => {239 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});240 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 7});241 const tokenId = await createItemExpectSuccess(alice, collectionId, 'ReFungible');242 await setCollectionSponsorExpectSuccess(collectionId, alice.address);243 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');244 await transferExpectSuccess(collectionId, tokenId, alice, bob, 100, 'ReFungible');245 const aliceBalanceBefore = await getFreeBalance(alice);246247 // check setting SponsorTimeout = 5, fail248 await waitNewBlocks(5);249 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 20, 'ReFungible');250 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);251 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);252253 // check setting SponsorTimeout = 7, success254 await waitNewBlocks(2); // 5 + 2255 await transferExpectSuccess(collectionId, tokenId, bob, charlie, 20, 'ReFungible');256 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);257 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;258 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);259 await destroyCollectionExpectSuccess(collectionId);260 });261262 itSub('Collection limits have lower timeout value than chain limits, chain limits are enforced', async ({helper}) => {263264 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});265 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 1});266 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');267 await setCollectionSponsorExpectSuccess(collectionId, alice.address);268 await confirmSponsorshipExpectSuccess(collectionId, '//Alice');269 await transferExpectSuccess(collectionId, tokenId, alice, bob);270 const aliceBalanceBefore = await getFreeBalance(alice);271272 // check setting SponsorTimeout = 1, fail273 await waitNewBlocks(1);274 await transferExpectSuccess(collectionId, tokenId, bob, charlie);275 const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);276 expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);277278 // check setting SponsorTimeout = 5, success279 await waitNewBlocks(4);280 await transferExpectSuccess(collectionId, tokenId, charlie, bob);281 const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);282 expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;283 //expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);284 await destroyCollectionExpectSuccess(collectionId);285 });*/286});287288describe('Collection zero limits (NFT)', () => {289 let alice: IKeyringPair;290 let bob: IKeyringPair;291 let charlie: IKeyringPair;292293 before(async () => {294 await usingPlaygrounds(async (helper, privateKey) => {295 const donor = await privateKey({url: import.meta.url});296 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);297 });298 });299300 itSub.skip('Limits have 0 in tokens per address field, the chain limits are applied', async ({helper}) => {301 const collection = await helper.nft.mintCollection(alice, {});302 await collection.setLimits(alice, {accountTokenOwnershipLimit: 0});303304 for(let i = 0; i < 10; i++){305 await collection.mintToken(alice);306 }307 await expect(collection.mintToken(alice)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);308 });309310 itSub('Limits have 0 in sponsor timeout, no limits are applied', async ({helper}) => {311 const collection = await helper.nft.mintCollection(alice, {});312 await collection.setLimits(alice, {sponsorTransferTimeout: 0});313 const token = await collection.mintToken(alice);314315 await collection.setSponsor(alice, alice.address);316 await collection.confirmSponsorship(alice);317318 await token.transfer(alice, {Substrate: bob.address});319 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);320321 // check setting SponsorTimeout = 0, success with next block322 await helper.wait.newBlocks(1);323 await token.transfer(bob, {Substrate: charlie.address});324 const aliceBalanceAfterSponsoredTransaction1 = await helper.balance.getSubstrate(alice.address);325 expect(aliceBalanceAfterSponsoredTransaction1 < aliceBalanceBefore).to.be.true;326 });327});328329describe('Collection zero limits (Fungible)', () => {330 let alice: IKeyringPair;331 let bob: IKeyringPair;332 let charlie: IKeyringPair;333334 before(async () => {335 await usingPlaygrounds(async (helper, privateKey) => {336 const donor = await privateKey({url: import.meta.url});337 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);338 });339 });340341 itSub('Limits have 0 in sponsor timeout, no limits are applied', async ({helper}) => {342 const collection = await helper.ft.mintCollection(alice, {});343 await collection.setLimits(alice, {sponsorTransferTimeout: 0});344 await collection.mint(alice, 3n);345346 await collection.setSponsor(alice, alice.address);347 await collection.confirmSponsorship(alice);348349 await collection.transfer(alice, {Substrate: bob.address}, 2n);350 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);351352 // check setting SponsorTimeout = 0, success with next block353 await helper.wait.newBlocks(1);354 await collection.transfer(bob, {Substrate: charlie.address});355 const aliceBalanceAfterSponsoredTransaction1 = await helper.balance.getSubstrate(alice.address);356 expect(aliceBalanceAfterSponsoredTransaction1 < aliceBalanceBefore).to.be.true;357 });358});359360describe('Collection zero limits (ReFungible)', () => {361 let alice: IKeyringPair;362 let bob: IKeyringPair;363 let charlie: IKeyringPair;364365 before(async function() {366 await usingPlaygrounds(async (helper, privateKey) => {367 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);368369 const donor = await privateKey({url: import.meta.url});370 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);371 });372 });373374 itSub.skip('Limits have 0 in tokens per address field, the chain limits are applied', async ({helper}) => {375 const collection = await helper.rft.mintCollection(alice, {});376 await collection.setLimits(alice, {accountTokenOwnershipLimit: 0});377 for(let i = 0; i < 10; i++){378 await collection.mintToken(alice);379 }380 await expect(collection.mintToken(alice)).to.be.rejectedWith(/common\.AccountTokenLimitExceeded/);381 });382383 itSub('Limits have 0 in sponsor timeout, no limits are applied', async ({helper}) => {384 const collection = await helper.rft.mintCollection(alice, {});385 await collection.setLimits(alice, {sponsorTransferTimeout: 0});386 const token = await collection.mintToken(alice, 3n);387388 await collection.setSponsor(alice, alice.address);389 await collection.confirmSponsorship(alice);390391 await token.transfer(alice, {Substrate: bob.address}, 2n);392 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);393394 // check setting SponsorTimeout = 0, success with next block395 await helper.wait.newBlocks(1);396 await token.transfer(bob, {Substrate: charlie.address});397 const aliceBalanceAfterSponsoredTransaction1 = await helper.balance.getSubstrate(alice.address);398 expect(aliceBalanceAfterSponsoredTransaction1 < aliceBalanceBefore).to.be.true;399 });400});401402describe('Effective collection limits (NFT)', () => {403 let alice: IKeyringPair;404405 before(async () => {406 await usingPlaygrounds(async (helper, privateKey) => {407 const donor = await privateKey({url: import.meta.url});408 [alice] = await helper.arrange.createAccounts([10n], donor);409 });410 });411412 itSub('Effective collection limits', async ({helper}) => {413 const collection = await helper.nft.mintCollection(alice, {});414 await collection.setLimits(alice, {ownerCanTransfer: true});415416 {417 // Check that limits are undefined418 const collectionInfo = await collection.getData();419 const limits = collectionInfo?.raw.limits;420 expect(limits).to.be.any;421422 expect(limits.accountTokenOwnershipLimit).to.be.null;423 expect(limits.sponsoredDataSize).to.be.null;424 expect(limits.sponsoredDataRateLimit).to.be.null;425 expect(limits.tokenLimit).to.be.null;426 expect(limits.sponsorTransferTimeout).to.be.null;427 expect(limits.sponsorApproveTimeout).to.be.null;428 expect(limits.ownerCanTransfer).to.be.true;429 expect(limits.ownerCanDestroy).to.be.null;430 expect(limits.transfersEnabled).to.be.null;431 }432433 { // Check that limits is undefined for non-existent collection434 const limits = await helper.collection.getEffectiveLimits(999999);435 expect(limits).to.be.null;436 }437438 { // Check that default values defined for collection limits439 const limits = await collection.getEffectiveLimits();440441 expect(limits.accountTokenOwnershipLimit).to.be.eq(100000000);442 expect(limits.sponsoredDataSize).to.be.eq(2048);443 expect(limits.sponsoredDataRateLimit).to.be.deep.eq({sponsoringDisabled: null});444 expect(limits.tokenLimit).to.be.eq(4294967295);445 expect(limits.sponsorTransferTimeout).to.be.eq(5);446 expect(limits.sponsorApproveTimeout).to.be.eq(5);447 expect(limits.ownerCanTransfer).to.be.true;448 expect(limits.ownerCanDestroy).to.be.true;449 expect(limits.transfersEnabled).to.be.true;450 }451452 {453 // Check the values for collection limits454 await collection.setLimits(alice, {455 accountTokenOwnershipLimit: 99_999,456 sponsoredDataSize: 1024,457 tokenLimit: 123,458 transfersEnabled: false,459 });460461 const limits = await collection.getEffectiveLimits();462463 expect(limits.accountTokenOwnershipLimit).to.be.eq(99999);464 expect(limits.sponsoredDataSize).to.be.eq(1024);465 expect(limits.sponsoredDataRateLimit).to.be.deep.eq({sponsoringDisabled: null});466 expect(limits.tokenLimit).to.be.eq(123);467 expect(limits.sponsorTransferTimeout).to.be.eq(5);468 expect(limits.sponsorApproveTimeout).to.be.eq(5);469 expect(limits.ownerCanTransfer).to.be.true;470 expect(limits.ownerCanDestroy).to.be.true;471 expect(limits.transfersEnabled).to.be.false;472 }473 });474});primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -56,7 +56,7 @@
/// Maximum tokens for user.
pub const MAX_TOKEN_OWNERSHIP: u32 = if cfg!(not(feature = "limit-testing")) {
- 100_000
+ 100_000_000
} else {
10
};
@@ -83,7 +83,7 @@
/// Maximum tokens per account.
pub const ACCOUNT_TOKEN_OWNERSHIP_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {
- 1_000_000
+ 100_000_000
} else {
10
};