1234567891011121314151617import type {IKeyringPair} from '@polkadot/types/types';18import {expect, itEth, usingEthPlaygrounds} from '@unique/test-utils/eth/util.js';192021describe('Create NFT collection from EVM', () => {22 let donor: IKeyringPair;2324 before(async function () {25 await usingEthPlaygrounds(async (_helper, privateKey) => {26 donor = await privateKey({url: import.meta.url});27 });28 });2930 itEth('Create collection', async ({helper}) => {31 const owner = await helper.eth.createAccountWithBalance(donor);3233 const name = 'CollectionEVM';34 const description = 'Some description';35 const prefix = 'token prefix';3637 38 const collectionCountBefore = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;39 const {collectionId, collectionAddress, events} = await helper.eth.createNFTCollection(owner, name, description, prefix);4041 expect(events).to.be.deep.equal([42 {43 address: '0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F',44 event: 'CollectionCreated',45 args: {46 owner: owner,47 collectionId: collectionAddress,48 },49 },50 ]);5152 const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;5354 const collection = helper.nft.getCollectionObject(collectionId);55 const data = (await collection.getData())!;5657 expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);58 expect(collectionId).to.be.eq(collectionCountAfter);59 expect(data.name).to.be.eq(name);60 expect(data.description).to.be.eq(description);61 expect(data.raw.tokenPrefix).to.be.eq(prefix);62 expect(data.raw.mode).to.be.eq('NFT');6364 const options = await collection.getOptions();6566 expect(options.tokenPropertyPermissions).to.be.empty;67 });6869 70 itEth('Check collection address exist', async ({helper}) => {71 const owner = await helper.eth.createAccountWithBalance(donor);7273 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;74 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);75 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);7677 expect(await collectionHelpers.methods78 .isCollectionExist(expectedCollectionAddress)79 .call()).to.be.false;8081 await collectionHelpers.methods82 .createNFTCollection('A', 'A', 'A')83 .send({value: Number(2n * helper.balance.getOneTokenNominal())});8485 expect(await collectionHelpers.methods86 .isCollectionExist(expectedCollectionAddress)87 .call()).to.be.true;88 });89});