1234567891011121314151617import type {IKeyringPair} from '@polkadot/types/types';18import {Pallets, requirePalletsOrSkip} from '@unique/test-utils/util.js';19import {expect, itEth, usingEthPlaygrounds} from '@unique/test-utils/eth/util.js';2021const DECIMALS = 18;2223describe('Create FT collection from EVM', () => {24 let donor: IKeyringPair;2526 before(async function() {27 await usingEthPlaygrounds(async (helper, privateKey) => {28 requirePalletsOrSkip(this, helper, [Pallets.Fungible]);29 donor = await privateKey({url: import.meta.url});30 });31 });3233 itEth('Create collection', async ({helper}) => {34 const owner = await helper.eth.createAccountWithBalance(donor);3536 const name = 'CollectionEVM';37 const description = 'Some description';38 const prefix = 'token prefix';3940 41 const collectionCountBefore = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;4243 const {collectionId} = await helper.eth.createFungibleCollection(owner, name, DECIMALS, description, prefix);4445 const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;46 const data = (await helper.ft.getData(collectionId))!;4748 expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);49 expect(collectionId).to.be.eq(collectionCountAfter);50 expect(data.name).to.be.eq(name);51 expect(data.description).to.be.eq(description);52 expect(data.raw.tokenPrefix).to.be.eq(prefix);53 expect(data.raw.mode).to.be.deep.eq({Fungible: DECIMALS.toString()});54 });5556 57 itEth('Check collection address exist', async ({helper}) => {58 const owner = await helper.eth.createAccountWithBalance(donor);5960 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;61 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);62 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);6364 expect(await collectionHelpers.methods65 .isCollectionExist(expectedCollectionAddress)66 .call()).to.be.false;676869 await helper.eth.createFungibleCollection(owner, 'A', DECIMALS, 'A', 'A');707172 expect(await collectionHelpers.methods73 .isCollectionExist(expectedCollectionAddress)74 .call()).to.be.true;75 });76});