123456import { IKeyringPair } from '@polkadot/types/types';7import chai from 'chai';8import chaiAsPromised from 'chai-as-promised';9import privateKey from './substrate/privateKey';10import usingApi, { submitTransactionExpectFailAsync } from './substrate/substrate-api';11import {12 addToWhiteListExpectSuccess,13 createCollectionExpectSuccess,14 createItemExpectSuccess,15 destroyCollectionExpectSuccess,16 enablePublicMintingExpectSuccess,17 enableWhiteListExpectSuccess,18 normalizeAccountId,19} from './util/helpers';2021chai.use(chaiAsPromised);22const expect = chai.expect;2324let Alice: IKeyringPair;25let Bob: IKeyringPair;2627describe('Integration Test ext. addToWhiteList()', () => {2829 before(async () => {30 await usingApi(async () => {31 Alice = privateKey('//Alice');32 Bob = privateKey('//Bob');33 });34 });3536 it('Execute the extrinsic with parameters: Collection ID and address to add to the white list', async () => {37 const collectionId = await createCollectionExpectSuccess();38 await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);39 });4041 it('Whitelisted minting: list restrictions', async () => {42 const collectionId = await createCollectionExpectSuccess();43 await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);44 await enableWhiteListExpectSuccess(Alice, collectionId);45 await enablePublicMintingExpectSuccess(Alice, collectionId);46 await createItemExpectSuccess(Bob, collectionId, 'NFT', Bob.address);47 });48});4950describe('Negative Integration Test ext. addToWhiteList()', () => {5152 it('White list an address in the collection that does not exist', async () => {53 await usingApi(async (api) => {54 55 const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;56 const Bob = privateKey('//Bob');5758 const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(Bob.address));59 await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;60 });61 });6263 it('White list an address in the collection that was destroyed', async () => {64 await usingApi(async (api) => {65 const Alice = privateKey('//Alice');66 const Bob = privateKey('//Bob');67 68 const collectionId = await createCollectionExpectSuccess();69 await destroyCollectionExpectSuccess(collectionId);70 const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(Bob.address));71 await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;72 });73 });7475 it('White list an address in the collection that does not have white list access enabled', async () => {76 await usingApi(async (api) => {77 const Alice = privateKey('//Alice');78 const Ferdie = privateKey('//Ferdie');79 const collectionId = await createCollectionExpectSuccess();80 await enableWhiteListExpectSuccess(Alice, collectionId);81 await enablePublicMintingExpectSuccess(Alice, collectionId);82 const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(Ferdie.address), 'NFT');83 await expect(submitTransactionExpectFailAsync(Ferdie, tx)).to.be.rejected;84 });85 });8687});