1import { IKeyringPair } from '@polkadot/types/types';2import BN from 'bn.js';3import chai from 'chai';4import chaiAsPromised from 'chai-as-promised';5import privateKey from '../substrate/privateKey';6import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';7import {8 createCollectionExpectSuccess,9 normalizeAccountId,10} from '../util/helpers';1112chai.use(chaiAsPromised);13const expect = chai.expect;14let Alice: IKeyringPair;15let Bob: IKeyringPair;1617before(async () => {18 await usingApi(async () => {19 Alice = privateKey('//Alice');20 Bob = privateKey('//Bob');21 });22});2324describe('Deprivation of admin rights: ', () => {25 26 it('In the block, the collection admin adds a token or changes data, and the collection owner deprives the admin of rights ', async () => {27 await usingApi(async (api) => {28 const collectionId = await createCollectionExpectSuccess();29 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));30 await submitTransactionAsync(Alice, changeAdminTx);31 const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));32 await timeoutPromise(10000);33 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];34 const addItemAdm = api.tx.nft.createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);35 const removeAdm = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(Bob.address));36 await Promise.all([37 addItemAdm.signAndSend(Bob),38 removeAdm.signAndSend(Alice),39 ]);40 await timeoutPromise(20000);41 const itemsListIndex = await api.query.nft.itemListIndex(collectionId) as unknown as BN;42 expect(itemsListIndex.toNumber()).to.be.equal(0);43 const adminList: any = (await api.query.nft.adminList(collectionId));44 expect(adminList).not.to.be.contains(normalizeAccountId(Bob.address));45 await timeoutPromise(20000);46 });47 });48});