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 waitNewBlocks from '../substrate/wait-new-blocks';
7import {
8 addToWhiteListExpectSuccess,
9 createCollectionExpectSuccess,
10 setMintPermissionExpectSuccess,
11} from '../util/helpers';
12
13chai.use(chaiAsPromised);
14const expect = chai.expect;
15let Alice: IKeyringPair;
16let Bob: IKeyringPair;
17let Ferdie: IKeyringPair;
18
19before(async () => {
20 await usingApi(async () => {
21 Alice = privateKey('//Alice');
22 Bob = privateKey('//Bob');
23 Ferdie = privateKey('//Ferdie');
24 });
25});
26
27describe('Turns off minting mode: ', () => {
28
29 it('The collection owner turns off minting mode and there are minting transactions in the same block ', async () => {
30 await usingApi(async (api) => {
31 const collectionId = await createCollectionExpectSuccess();
32 const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
33 await setMintPermissionExpectSuccess(Alice, collectionId, true);
34 await addToWhiteListExpectSuccess(Alice, collectionId, Ferdie.address);
35
36 const mintItem = api.tx.nft.createItem(collectionId, Ferdie.address, 'NFT');
37 const offMinting = api.tx.nft.setMintPermission(collectionId, false);
38 await Promise.all
39 ([
40 mintItem.signAndSend(Ferdie),
41 offMinting.signAndSend(Alice),
42 ]);
43 let itemList: boolean = false;
44 itemList = (await (api.query.nft.nftItemList(collectionId, mintItem))).toJSON() as boolean;
45
46 expect(itemList).to.be.null;
47 await timeoutPromise(20000);
48 });
49 });
50});