123456789101112131415161718import {IKeyringPair} from '@polkadot/types/types';19import {itSub, usingPlaygrounds, expect} from './util/playgrounds';2021describe('Integration Test setPublicAccessMode(): ', () => {22 let alice: IKeyringPair;23 let bob: IKeyringPair;24 25 before(async () => {26 await usingPlaygrounds(async (helper, privateKey) => {27 const donor = privateKey('//Alice');28 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);29 });30 });3132 itSub('Runs extrinsic with collection id parameters, sets the allowlist mode for the collection', async ({helper}) => {33 const collection = await helper.nft.mintCollection(alice, {name: 'PublicAccess-1', tokenPrefix: 'TF'});34 await collection.setPermissions(alice, {access: 'AllowList', mintMode: true});35 await collection.addToAllowList(alice, {Substrate: bob.address});36 37 await expect(collection.mintToken(bob, {Substrate: bob.address})).to.be.not.rejected;38 });3940 itSub('Allowlisted collection limits', async ({helper}) => {41 const collection = await helper.nft.mintCollection(alice, {name: 'PublicAccess-2', tokenPrefix: 'TF'});42 await collection.setPermissions(alice, {access: 'AllowList', mintMode: true});43 44 await expect(collection.mintToken(bob, {Substrate: bob.address}))45 .to.be.rejectedWith(/common\.AddressNotInAllowlist/);46 });4748 itSub('setPublicAccessMode by collection admin', async ({helper}) => {49 const collection = await helper.nft.mintCollection(alice, {name: 'PublicAccess-Neg-4', tokenPrefix: 'TF'});50 await collection.addAdmin(alice, {Substrate: bob.address});5152 await expect(collection.setPermissions(bob, {access: 'AllowList'})).to.be.not.rejected;53 });54});5556describe('Negative Integration Test ext. setPublicAccessMode(): ', () => {57 let alice: IKeyringPair;58 let bob: IKeyringPair;59 60 before(async () => {61 await usingPlaygrounds(async (helper, privateKey) => {62 const donor = privateKey('//Alice');63 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);64 });65 });6667 itSub('Sets a non-existent collection', async ({helper}) => {68 const collectionId = (1 << 32) - 1;69 await expect(helper.collection.setPermissions(alice, collectionId, {access: 'AllowList'}))70 .to.be.rejectedWith(/common\.CollectionNotFound/);71 });7273 itSub('Sets the collection that has been deleted', async ({helper}) => {74 const collection = await helper.nft.mintCollection(alice, {name: 'PublicAccess-Neg-1', tokenPrefix: 'TF'});75 await collection.burn(alice);7677 await expect(collection.setPermissions(alice, {access: 'AllowList'}))78 .to.be.rejectedWith(/common\.CollectionNotFound/);79 });8081 itSub('Re-sets the list mode already set in quantity', async ({helper}) => {82 const collection = await helper.nft.mintCollection(alice, {name: 'PublicAccess-Neg-2', tokenPrefix: 'TF'});83 await collection.setPermissions(alice, {access: 'AllowList'});84 await collection.setPermissions(alice, {access: 'AllowList'});85 });8687 itSub('Executes method as a malefactor', async ({helper}) => {88 const collection = await helper.nft.mintCollection(alice, {name: 'PublicAccess-Neg-3', tokenPrefix: 'TF'});8990 await expect(collection.setPermissions(bob, {access: 'AllowList'}))91 .to.be.rejectedWith(/common\.NoPermission/);92 });93});