git.delta.rocks / unique-network / refs/commits / 6994f61a23f1

difftreelog

source

tests/src/eth/collectionHelperAddress.test.ts3.3 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';18import {IKeyringPair} from '@polkadot/types/types';19import {Pallets} from '../util';2021const EVM_COLLECTION_HELPERS_ADDRESS = '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f';2223describe('[eth]CollectionHelperAddress test: ERC20/ERC721 ', () => {24  let donor: IKeyringPair;2526  before(async function() {27    await usingEthPlaygrounds(async (helper, privateKey) => {28      donor = await privateKey({filename: __filename});29    });30  });3132  itEth('NFT', async ({helper}) => {33    const owner =  await helper.eth.createAccountWithBalance(donor);3435    const {collectionAddress: nftCollectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');36    const nftCollection = await helper.ethNativeContract.collection(nftCollectionAddress, 'nft', owner);3738    expect((await nftCollection.methods.collectionHelperAddress().call())39      .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);40  });4142  itEth.ifWithPallets('RFT ', [Pallets.ReFungible], async ({helper}) => {43    const owner =  await helper.eth.createAccountWithBalance(donor);4445    const {collectionAddress: rftCollectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');4647    const rftCollection = await helper.ethNativeContract.collection(rftCollectionAddress, 'rft', owner);48    expect((await rftCollection.methods.collectionHelperAddress().call())49      .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);50  });5152  itEth('FT', async ({helper}) => {53    const owner = await helper.eth.createAccountWithBalance(donor);5455    const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', 18, 'absolutely anything', 'ROC');56    const collection = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);5758    expect((await collection.methods.collectionHelperAddress().call())59      .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);60  });6162  itEth('[collectionHelpers] convert collectionId into address', async ({helper}) => {63    const owner = await helper.eth.createAccountWithBalance(donor);64    const collectionId = 7;65    const collectionAddress = helper.ethAddress.fromCollectionId(collectionId);66    const helperContract = await helper.ethNativeContract.collectionHelpers(owner);6768    expect(await helperContract.methods.collectionAddress(collectionId).call()).to.be.equal(collectionAddress);69    expect(parseInt(await helperContract.methods.collectionId(collectionAddress).call())).to.be.equal(collectionId);70  });7172});