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 changes the data in the token: ', () => {
30 it('The collection admin changes the data in the token and in the same block the token owner also changes the data in it ', async () => {
31 await usingApi(async (api) => {
32 const AliceData = [31];
33 const BobData = [32];
34 const collectionId = await createCollectionExpectSuccess();
35 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
36 await submitTransactionAsync(Alice, changeAdminTx);
37 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');
38
39
40 const AliceTx = api.tx.nft.setVariableMetaData(collectionId, itemId, '0x' + Buffer.from(AliceData).toString('hex'));
41
42 const BobTx = api.tx.nft.setVariableMetaData(collectionId, itemId, '0x' + Buffer.from(BobData).toString('hex'));
43 await Promise.all
44 ([
45 AliceTx.signAndSend(Alice),
46 BobTx.signAndSend(Bob),
47 ]);
48 const item: any = await api.query.nft.nftItemList(collectionId, itemId);
49 expect(Array.from(item.VariableData)).to.deep.equal(Array.from([]));
50 const blockHash = await api.query.system.number();
51 console.log(`blockHash: ${blockHash}`);
52 });
53 });
54});