1import { IKeyringPair } from '@polkadot/types/types';2import chai from 'chai';3import chaiAsPromised from 'chai-as-promised';4import privateKey from '../substrate/privateKey';5import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';6import {7 createCollectionExpectSuccess,8 normalizeAccountId,9} from '../util/helpers';1011chai.use(chaiAsPromised);12const expect = chai.expect;13let Alice: IKeyringPair;14let Bob: IKeyringPair;15let Ferdie: IKeyringPair;1617before(async () => {18 await usingApi(async () => {19 Alice = privateKey('//Alice');20 Bob = privateKey('//Bob');21 Ferdie = privateKey('//Ferdie');22 });23});2425describe('Deleting a collection while add address to whitelist: ', () => {26 27 it('Adding an address to the collection whitelist in a block by the admin, and deleting the collection by the owner ', async () => {28 await usingApi(async (api) => {29 const collectionId = await createCollectionExpectSuccess();30 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));31 await submitTransactionAsync(Alice, changeAdminTx);32 const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));33 await timeoutPromise(10000);34 35 const addWhitelistAdm = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(Ferdie.address));36 const destroyCollection = api.tx.nft.destroyCollection(collectionId);37 await Promise.all([38 addWhitelistAdm.signAndSend(Bob),39 destroyCollection.signAndSend(Alice),40 ]);41 await timeoutPromise(10000);42 let whiteList = false;43 whiteList = (await api.query.nft.whiteList(collectionId, Ferdie.address)).toJSON() as boolean;44 45 expect(whiteList).to.be.false;46 await timeoutPromise(20000);47 });48 });49});