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 createItemExpectSuccess,9 normalizeAccountId,10} from '../util/helpers';1112chai.use(chaiAsPromised);13const expect = chai.expect;14let Alice: IKeyringPair;15let Bob: IKeyringPair;16let Ferdie: IKeyringPair;1718before(async () => {19 await usingApi(async () => {20 Alice = privateKey('//Alice');21 Bob = privateKey('//Bob');22 Ferdie = privateKey('//Ferdie');23 });24});2526describe('Admin vs Owner take token: ', () => {27 28 it('The collection admin burns the token and in the same block the token owner performs a transaction on it ', async () => {29 await usingApi(async (api) => {30 const collectionId = await createCollectionExpectSuccess();31 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));32 await submitTransactionAsync(Alice, changeAdminTx);33 const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));34 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');35 36 const sendItem = api.tx.nft.transfer(normalizeAccountId(Ferdie.address), collectionId, itemId, 1);37 const burnItem = api.tx.nft.burnItem(collectionId, itemId, 1);38 await Promise.all([39 sendItem.signAndSend(Bob),40 burnItem.signAndSend(Alice),41 ]);42 await timeoutPromise(20000);43 let itemBurn = false;44 itemBurn = (await (api.query.nft.nftItemList(collectionId, itemId))).toJSON() as boolean;45 46 expect(itemBurn).to.be.null;47 await timeoutPromise(20000);48 });49 });50});