1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import usingApi from './substrate/substrate-api';19import {20 addToAllowListExpectSuccess,21 createCollectionExpectSuccess,22 createItemExpectFailure,23 createItemExpectSuccess,24 destroyCollectionExpectSuccess,25 enableAllowListExpectSuccess,26 findNotExistingCollection,27 setMintPermissionExpectFailure,28 setMintPermissionExpectSuccess,29 addCollectionAdminExpectSuccess,30} from './util/helpers';3132describe('Integration Test setMintPermission', () => {33 let alice: IKeyringPair;34 let bob: IKeyringPair;3536 before(async () => {37 await usingApi(async (api, privateKeyWrapper) => {38 alice = privateKeyWrapper('//Alice');39 bob = privateKeyWrapper('//Bob');40 });41 });4243 it('ensure allow-listed non-privileged address can mint tokens', async () => {44 await usingApi(async () => {45 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});46 await enableAllowListExpectSuccess(alice, collectionId);47 await setMintPermissionExpectSuccess(alice, collectionId, true);48 await addToAllowListExpectSuccess(alice, collectionId, bob.address);4950 await createItemExpectSuccess(bob, collectionId, 'NFT');51 });52 });5354 it('can be enabled twice', async () => {55 await usingApi(async () => {56 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});57 await setMintPermissionExpectSuccess(alice, collectionId, true);58 await setMintPermissionExpectSuccess(alice, collectionId, true);59 });60 });6162 it('can be disabled twice', async () => {63 await usingApi(async () => {64 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});65 await setMintPermissionExpectSuccess(alice, collectionId, true);66 await setMintPermissionExpectSuccess(alice, collectionId, false);67 await setMintPermissionExpectSuccess(alice, collectionId, false);68 });69 });70});7172describe('Negative Integration Test setMintPermission', () => {73 let alice: IKeyringPair;74 let bob: IKeyringPair;7576 before(async () => {77 await usingApi(async (api, privateKeyWrapper) => {78 alice = privateKeyWrapper('//Alice');79 bob = privateKeyWrapper('//Bob');80 });81 });8283 it('fails on not existing collection', async () => {84 await usingApi(async (api) => {85 const nonExistingCollection = await findNotExistingCollection(api);86 await setMintPermissionExpectFailure(alice, nonExistingCollection, true);87 });88 });8990 it('fails on removed collection', async () => {91 await usingApi(async () => {92 const removedCollectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});93 await destroyCollectionExpectSuccess(removedCollectionId);9495 await setMintPermissionExpectFailure(alice, removedCollectionId, true);96 });97 });9899 it('fails when not collection owner tries to set mint status', async () => {100 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});101 await enableAllowListExpectSuccess(alice, collectionId);102 await setMintPermissionExpectFailure(bob, collectionId, true);103 });104105 it('Collection admin fails on set', async () => {106 await usingApi(async () => {107 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});108 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);109 await setMintPermissionExpectFailure(bob, collectionId, true);110 });111 });112113 it('ensure non-allow-listed non-privileged address can\'t mint tokens', async () => {114 await usingApi(async () => {115 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});116 await enableAllowListExpectSuccess(alice, collectionId);117 await setMintPermissionExpectSuccess(alice, collectionId, true);118119 await createItemExpectFailure(bob, collectionId, 'NFT');120 });121 });122});