123456import {IKeyringPair} from '@polkadot/types/types';7import privateKey from './substrate/privateKey';8import usingApi from './substrate/substrate-api';9import {10 addToWhiteListExpectSuccess,11 createCollectionExpectSuccess,12 createItemExpectFailure,13 createItemExpectSuccess,14 enableWhiteListExpectSuccess,15 setMintPermissionExpectSuccess,16 addCollectionAdminExpectSuccess,17 disableWhiteListExpectSuccess,18} from './util/helpers';1920describe('Integration Test public minting', () => {21 let alice: IKeyringPair;22 let bob: IKeyringPair;2324 before(async () => {25 await usingApi(async () => {26 alice = privateKey('//Alice');27 bob = privateKey('//Bob');28 });29 });3031 it('If the AllowList mode is enabled, then the address added to the whitelist and not the owner or administrator can create tokens', async () => {32 await usingApi(async () => {33 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});34 await enableWhiteListExpectSuccess(alice, collectionId);35 await setMintPermissionExpectSuccess(alice, collectionId, true);36 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);3738 await createItemExpectSuccess(bob, collectionId, 'NFT');39 });40 });4142 it('If the AllowList mode is enabled, address not included in whitelist that is regular user cannot create tokens', async () => {43 await usingApi(async () => {44 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});45 await enableWhiteListExpectSuccess(alice, collectionId);46 await setMintPermissionExpectSuccess(alice, collectionId, true);47 await createItemExpectFailure(bob, collectionId, 'NFT');48 });49 });5051 it('If the AllowList mode is enabled, address not included in whitelist that is admin can create tokens', async () => {52 await usingApi(async () => {53 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});54 await enableWhiteListExpectSuccess(alice, collectionId);55 await setMintPermissionExpectSuccess(alice, collectionId, true);56 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);57 await createItemExpectSuccess(bob, collectionId, 'NFT');58 });59 });6061 it('If the AllowList mode is enabled, address not included in whitelist that is owner can create tokens', async () => {62 await usingApi(async () => {63 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});64 await enableWhiteListExpectSuccess(alice, collectionId);65 await setMintPermissionExpectSuccess(alice, collectionId, true);66 await createItemExpectSuccess(alice, collectionId, 'NFT');67 });68 });6970 it('If the AllowList mode is disabled, owner can create tokens', async () => {71 await usingApi(async () => {72 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});73 await disableWhiteListExpectSuccess(alice, collectionId);74 await setMintPermissionExpectSuccess(alice, collectionId, true);75 await createItemExpectSuccess(alice, collectionId, 'NFT');76 });77 });7879 it('If the AllowList mode is disabled, collection admin can create tokens', async () => {80 await usingApi(async () => {81 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});82 await disableWhiteListExpectSuccess(alice, collectionId);83 await setMintPermissionExpectSuccess(alice, collectionId, true);84 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);85 await createItemExpectSuccess(bob, collectionId, 'NFT');86 });87 });8889 it('If the AllowList mode is disabled, regular user can`t create tokens', async () => {90 await usingApi(async () => {91 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});92 await disableWhiteListExpectSuccess(alice, collectionId);93 await setMintPermissionExpectSuccess(alice, collectionId, true);94 await createItemExpectFailure(bob, collectionId, 'NFT');95 });96 });97});9899describe('Integration Test private minting', () => {100 let alice: IKeyringPair;101 let bob: IKeyringPair;102103 before(async () => {104 await usingApi(async () => {105 alice = privateKey('//Alice');106 bob = privateKey('//Bob');107 });108 });109110 it('Address that is the not owner or not admin cannot create tokens', async () => {111 await usingApi(async () => {112 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});113 await enableWhiteListExpectSuccess(alice, collectionId);114 await setMintPermissionExpectSuccess(alice, collectionId, false);115 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);116 await createItemExpectFailure(bob, collectionId, 'NFT');117 });118 });119120 it('Address that is collection owner can create tokens', async () => {121 await usingApi(async () => {122 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});123 await disableWhiteListExpectSuccess(alice, collectionId);124 await setMintPermissionExpectSuccess(alice, collectionId, false);125 await createItemExpectSuccess(alice, collectionId, 'NFT');126 });127 });128129 it('Address that is admin can create tokens', async () => {130 await usingApi(async () => {131 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});132 await disableWhiteListExpectSuccess(alice, collectionId);133 await setMintPermissionExpectSuccess(alice, collectionId, false);134 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);135 await createItemExpectSuccess(bob, collectionId, 'NFT');136 });137 });138});