1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import usingApi from './substrate/substrate-api';19import {20 addToAllowListExpectSuccess,21 createCollectionExpectSuccess,22 createItemExpectFailure,23 createItemExpectSuccess,24 enableAllowListExpectSuccess,25 setMintPermissionExpectSuccess,26 addCollectionAdminExpectSuccess,27 disableAllowListExpectSuccess,28} from './util/helpers';2930describe('Integration Test public minting', () => {31 let alice: IKeyringPair;32 let bob: IKeyringPair;3334 before(async () => {35 await usingApi(async (api, privateKeyWrapper) => {36 alice = privateKeyWrapper('//Alice');37 bob = privateKeyWrapper('//Bob');38 });39 });4041 it('If the AllowList mode is enabled, then the address added to the allowlist and not the owner or administrator can create tokens', async () => {42 await usingApi(async () => {43 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});44 await enableAllowListExpectSuccess(alice, collectionId);45 await setMintPermissionExpectSuccess(alice, collectionId, true);46 await addToAllowListExpectSuccess(alice, collectionId, bob.address);4748 await createItemExpectSuccess(bob, collectionId, 'NFT');49 });50 });5152 it('If the AllowList mode is enabled, address not included in allowlist that is regular user cannot create tokens', async () => {53 await usingApi(async () => {54 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});55 await enableAllowListExpectSuccess(alice, collectionId);56 await setMintPermissionExpectSuccess(alice, collectionId, true);57 await createItemExpectFailure(bob, collectionId, 'NFT');58 });59 });6061 it('If the AllowList mode is enabled, address not included in allowlist that is admin can create tokens', async () => {62 await usingApi(async () => {63 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});64 await enableAllowListExpectSuccess(alice, collectionId);65 await setMintPermissionExpectSuccess(alice, collectionId, true);66 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);67 await createItemExpectSuccess(bob, collectionId, 'NFT');68 });69 });7071 it('If the AllowList mode is enabled, address not included in allowlist that is owner can create tokens', async () => {72 await usingApi(async () => {73 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});74 await enableAllowListExpectSuccess(alice, collectionId);75 await setMintPermissionExpectSuccess(alice, collectionId, true);76 await createItemExpectSuccess(alice, collectionId, 'NFT');77 });78 });7980 it('If the AllowList mode is disabled, owner can create tokens', async () => {81 await usingApi(async () => {82 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});83 await disableAllowListExpectSuccess(alice, collectionId);84 await setMintPermissionExpectSuccess(alice, collectionId, true);85 await createItemExpectSuccess(alice, collectionId, 'NFT');86 });87 });8889 it('If the AllowList mode is disabled, collection admin can create tokens', async () => {90 await usingApi(async () => {91 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});92 await disableAllowListExpectSuccess(alice, collectionId);93 await setMintPermissionExpectSuccess(alice, collectionId, true);94 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);95 await createItemExpectSuccess(bob, collectionId, 'NFT');96 });97 });9899 it('If the AllowList mode is disabled, regular user can`t create tokens', async () => {100 await usingApi(async () => {101 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});102 await disableAllowListExpectSuccess(alice, collectionId);103 await setMintPermissionExpectSuccess(alice, collectionId, true);104 await createItemExpectFailure(bob, collectionId, 'NFT');105 });106 });107});108109describe('Integration Test private minting', () => {110 let alice: IKeyringPair;111 let bob: IKeyringPair;112113 before(async () => {114 await usingApi(async (api, privateKeyWrapper) => {115 alice = privateKeyWrapper('//Alice');116 bob = privateKeyWrapper('//Bob');117 });118 });119120 it('Address that is the not owner or not admin cannot create tokens', async () => {121 await usingApi(async () => {122 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});123 await enableAllowListExpectSuccess(alice, collectionId);124 await setMintPermissionExpectSuccess(alice, collectionId, false);125 await addToAllowListExpectSuccess(alice, collectionId, bob.address);126 await createItemExpectFailure(bob, collectionId, 'NFT');127 });128 });129130 it('Address that is collection owner can create tokens', async () => {131 await usingApi(async () => {132 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});133 await disableAllowListExpectSuccess(alice, collectionId);134 await setMintPermissionExpectSuccess(alice, collectionId, false);135 await createItemExpectSuccess(alice, collectionId, 'NFT');136 });137 });138139 it('Address that is admin can create tokens', async () => {140 await usingApi(async () => {141 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});142 await disableAllowListExpectSuccess(alice, collectionId);143 await setMintPermissionExpectSuccess(alice, collectionId, false);144 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);145 await createItemExpectSuccess(bob, collectionId, 'NFT');146 });147 });148});