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 itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');
37
38 const sendItem = api.tx.nft.transfer(Ferdie.address, collectionId, itemId, 1);
39 const burnItem = api.tx.nft.burnItem(collectionId, itemId, 1);
40 await Promise.all
41 ([
42 sendItem.signAndSend(Bob),
43 burnItem.signAndSend(Alice),
44 ]);
45 const itemBurn: any = await api.query.nft.nftItemList(collectionId, itemId);
46 expect(itemBurn.Owner.toString()).to.be.eq('5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM');
47 const blockHash = await api.query.system.number();
48 console.log(`blockHash: ${blockHash}`);
49 });
50 });
51});