git.delta.rocks / unique-network / refs/commits / 769ffcff2cc4

difftreelog

source

js-packages/tests/eth/createFTCollection.seqtest.ts3.1 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.8//9// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import 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    // todo:playgrounds this might fail when in async environment.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  // todo:playgrounds this test will fail when in async environment.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});