git.delta.rocks / unique-network / refs/commits / 5543fa933a08

difftreelog

source

js-packages/tests/eth/collectionHelperAddress.test.ts3.2 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.89// 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 {itEth, usingEthPlaygrounds, expect} from './util/index.js';18import type {IKeyringPair} from '@polkadot/types/types';19import {COLLECTION_HELPER, Pallets} from '@unique/test-utils/util.js';2021describe('[eth]CollectionHelperAddress test: ERC20/ERC721 ', () => {22  let donor: IKeyringPair;2324  before(async function() {25    await usingEthPlaygrounds(async (_, privateKey) => {26      donor = await privateKey({url: import.meta.url});27    });28  });2930  itEth('NFT', async ({helper}) => {31    const owner =  await helper.eth.createAccountWithBalance(donor);3233    const {collectionAddress: nftCollectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');34    const nftCollection = await helper.ethNativeContract.collection(nftCollectionAddress, 'nft', owner);3536    expect((await nftCollection.methods.collectionHelperAddress().call())37      .toString().toLowerCase()).to.be.equal(COLLECTION_HELPER);38  });3940  itEth.ifWithPallets('RFT ', [Pallets.ReFungible], async ({helper}) => {41    const owner =  await helper.eth.createAccountWithBalance(donor);4243    const {collectionAddress: rftCollectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');4445    const rftCollection = await helper.ethNativeContract.collection(rftCollectionAddress, 'rft', owner);46    expect((await rftCollection.methods.collectionHelperAddress().call())47      .toString().toLowerCase()).to.be.equal(COLLECTION_HELPER);48  });4950  itEth('FT', async ({helper}) => {51    const owner = await helper.eth.createAccountWithBalance(donor);5253    const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', 18, 'absolutely anything', 'ROC');54    const collection = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);5556    expect((await collection.methods.collectionHelperAddress().call())57      .toString().toLowerCase()).to.be.equal(COLLECTION_HELPER);58  });5960  itEth('[collectionHelpers] convert collectionId into address', async ({helper}) => {61    const owner = await helper.eth.createAccountWithBalance(donor);62    const collectionId = 7;63    const collectionAddress = helper.ethAddress.fromCollectionId(collectionId);64    const helperContract = await helper.ethNativeContract.collectionHelpers(owner);6566    expect(await helperContract.methods.collectionAddress(collectionId).call()).to.be.equal(collectionAddress);67    expect(parseInt(await helperContract.methods.collectionId(collectionAddress).call())).to.be.equal(collectionId);68  });6970});