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, submitTransactionExpectFailAsync } from '../substrate/substrate-api';7import {8 createCollectionExpectSuccess,9} from '../util/helpers';1011chai.use(chaiAsPromised);12const expect = chai.expect;13interface ITokenDataType {14 Owner: number[];15 ConstData: number[];16 VariableData: number[];17}18let Alice: IKeyringPair;19let Bob: IKeyringPair;20let Ferdie: IKeyringPair;21let Charlie: IKeyringPair;22let Eve: IKeyringPair;23let Dave: IKeyringPair;2425before(async () => {26 await usingApi(async () => {27 Alice = privateKey('//Alice');28 Bob = privateKey('//Bob');29 Ferdie = privateKey('//Ferdie');30 Charlie = privateKey('//Charlie');31 Eve = privateKey('//Eve');32 Dave = privateKey('//Dave');33 });34});3536describe('Deprivation of admin rights: ', () => {37 38 it('In the block, the collection admin adds a token or changes data, and the collection owner deprives the admin of rights ', async () => {39 await usingApi(async (api) => {40 const collectionId = await createCollectionExpectSuccess();41 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);42 await submitTransactionAsync(Alice, changeAdminTx);43 const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));44 await timeoutPromise(10000);45 46 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];47 const addItemAdm = api.tx.nft.createMultipleItems(collectionId, Bob.address, args);48 const removeAdm = api.tx.nft.removeCollectionAdmin(collectionId, Bob.address);49 await Promise.all50 ([51 addItemAdm.signAndSend(Bob),52 removeAdm.signAndSend(Alice),53 ]);54 await timeoutPromise(10000);55 const itemsListIndex = await api.query.nft.itemListIndex(collectionId) as unknown as BN;56 expect(itemsListIndex.toNumber()).to.be.equal(0);57 const adminList: any = (await api.query.nft.adminList(collectionId));58 expect(adminList).not.to.be.contains(Bob.address);59 await timeoutPromise(20000);60 });61 });62});