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 waitNewBlocks,11} from '../util/helpers';1213chai.use(chaiAsPromised);14const expect = chai.expect;15let Alice: IKeyringPair;16let Bob: IKeyringPair;17let Ferdie: IKeyringPair;1819before(async () => {20 await usingApi(async () => {21 Alice = privateKey('//Alice');22 Bob = privateKey('//Bob');23 Ferdie = privateKey('//Ferdie');24 });25});2627describe('Admin vs Owner take token: ', () => {28 29 it('The collection admin burns the token and in the same block the token owner performs a transaction on it ', async () => {30 await usingApi(async (api) => {31 const collectionId = await createCollectionExpectSuccess();32 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));33 await submitTransactionAsync(Alice, changeAdminTx);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 waitNewBlocks(2);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 waitNewBlocks(2);48 });49 });50});