1import { IKeyringPair } from '@polkadot/types/types';
2import chai from 'chai';
3import chaiAsPromised from 'chai-as-promised';
4import { alicesPublicKey, bobsPublicKey } from '../accounts';
5import getBalance from '../substrate/get-balance';
6import privateKey from '../substrate/privateKey';
7import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';
8import waitNewBlocks from '../substrate/wait-new-blocks';
9import {
10 createCollectionExpectSuccess,
11 createItemExpectSuccess,
12 setCollectionSponsorExpectSuccess,
13} from '../util/helpers';
14
15chai.use(chaiAsPromised);
16const expect = chai.expect;
17let Alice: IKeyringPair;
18let Bob: IKeyringPair;
19let Ferdie: IKeyringPair;
20
21before(async () => {
22 await usingApi(async () => {
23 Alice = privateKey('//Alice');
24 Bob = privateKey('//Bob');
25 Ferdie = privateKey('//Ferdie');
26 });
27});
28
29describe('Admin vs Owner take token: ', () => {
30
31 it('The collection admin burns the token and in the same block the token owner performs a transaction on it ', async () => {
32 await usingApi(async (api) => {
33 const collectionId = await createCollectionExpectSuccess();
34 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
35 await submitTransactionAsync(Alice, changeAdminTx);
36 const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
37 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');
38
39 const sendItem = api.tx.nft.transfer(Ferdie.address, collectionId, itemId, 1);
40 const burnItem = api.tx.nft.burnItem(collectionId, itemId, 1);
41 await Promise.all
42 ([
43 sendItem.signAndSend(Bob),
44 burnItem.signAndSend(Alice),
45 ]);
46 await timeoutPromise(10000);
47 let itemBurn: boolean = false;
48 itemBurn = (await (api.query.nft.nftItemList(collectionId, itemId))).toJSON() as boolean;
49
50 expect(itemBurn).to.be.null;
51 await timeoutPromise(20000);
52 });
53 });
54});