1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import {itSub, usingPlaygrounds, expect} from './util/playgrounds';1920describe('Integration Test removeFromAllowList', () => {21 let alice: IKeyringPair;22 let bob: IKeyringPair;2324 before(async () => {25 await usingPlaygrounds(async (helper, privateKey) => {26 const donor = privateKey('//Alice');27 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);28 });29 });3031 itSub('ensure bob is not in allowlist after removal', async ({helper}) => {32 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveFromAllowList-1', tokenPrefix: 'RFAL'});3334 const collectionInfo = await collection.getData();35 expect(collectionInfo!.raw.permissions.access).to.not.equal('AllowList');3637 await collection.setPermissions(alice, {access: 'AllowList', mintMode: true});38 await collection.addToAllowList(alice, {Substrate: bob.address});39 expect(await collection.getAllowList()).to.deep.contains({Substrate: bob.address});40 41 await collection.removeFromAllowList(alice, {Substrate: bob.address});42 expect(await collection.getAllowList()).to.be.empty;43 });4445 itSub('allows removal from collection with unset allowlist status', async ({helper}) => {46 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveFromAllowList-2', tokenPrefix: 'RFAL'});4748 await collection.setPermissions(alice, {access: 'AllowList', mintMode: true});49 await collection.addToAllowList(alice, {Substrate: bob.address});50 expect(await collection.getAllowList()).to.deep.contains({Substrate: bob.address});5152 await collection.setPermissions(alice, {access: 'Normal'});53 54 await collection.removeFromAllowList(alice, {Substrate: bob.address});55 expect(await collection.getAllowList()).to.be.empty;56 });57});5859describe('Negative Integration Test removeFromAllowList', () => {60 let alice: IKeyringPair;61 let bob: IKeyringPair;6263 before(async () => {64 await usingPlaygrounds(async (helper, privateKey) => {65 const donor = privateKey('//Alice');66 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);67 });68 });6970 itSub('fails on removal from not existing collection', async ({helper}) => {71 const nonExistentCollectionId = (1 << 32) - 1;72 await expect(helper.collection.removeFromAllowList(alice, nonExistentCollectionId, {Substrate: alice.address}))73 .to.be.rejectedWith(/common\.CollectionNotFound/);74 });7576 itSub('fails on removal from removed collection', async ({helper}) => {77 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveFromAllowList-3', tokenPrefix: 'RFAL'});78 await collection.setPermissions(alice, {access: 'AllowList', mintMode: true});79 await collection.addToAllowList(alice, {Substrate: bob.address});8081 await collection.burn(alice);82 await expect(collection.removeFromAllowList(alice, {Substrate: bob.address}))83 .to.be.rejectedWith(/common\.CollectionNotFound/);84 });85});8687describe('Integration Test removeFromAllowList with collection admin permissions', () => {88 let alice: IKeyringPair;89 let bob: IKeyringPair;90 let charlie: IKeyringPair;9192 before(async () => {93 await usingPlaygrounds(async (helper, privateKey) => {94 const donor = privateKey('//Alice');95 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);96 });97 });9899 itSub('ensure address is not in allowlist after removal', async ({helper}) => {100 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveFromAllowList-4', tokenPrefix: 'RFAL'});101 102 await collection.setPermissions(alice, {access: 'AllowList', mintMode: true});103 await collection.addAdmin(alice, {Substrate: bob.address});104105 await collection.addToAllowList(bob, {Substrate: charlie.address});106 await collection.removeFromAllowList(bob, {Substrate: charlie.address});107108 expect(await collection.getAllowList()).to.be.empty;109 });110111 itSub('Collection admin allowed to remove from allowlist with unset allowlist status', async ({helper}) => {112 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveFromAllowList-5', tokenPrefix: 'RFAL'});113114 await collection.setPermissions(alice, {access: 'AllowList', mintMode: true});115 await collection.addAdmin(alice, {Substrate: bob.address});116 await collection.addToAllowList(alice, {Substrate: charlie.address});117118 await collection.setPermissions(bob, {access: 'Normal'});119 await collection.removeFromAllowList(bob, {Substrate: charlie.address});120121 expect(await collection.getAllowList()).to.be.empty;122 });123124 itSub('Regular user can`t remove from allowlist', async ({helper}) => {125 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveFromAllowList-6', tokenPrefix: 'RFAL'});126127 await collection.setPermissions(alice, {access: 'AllowList', mintMode: true});128 await collection.addToAllowList(alice, {Substrate: charlie.address});129130 await expect(collection.removeFromAllowList(bob, {Substrate: charlie.address}))131 .to.be.rejectedWith(/common\.NoPermission/);132 expect(await collection.getAllowList()).to.deep.contain({Substrate: charlie.address});133 });134});