git.delta.rocks / unique-network / refs/commits / 786ff7ed1061

difftreelog

source

tests/src/eth/nonFungible.test.ts27.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, EthUniqueHelper} from './util';18import {IKeyringPair} from '@polkadot/types/types';19import {Contract} from 'web3-eth-contract';202122describe('NFT: Information getting', () => {23  let donor: IKeyringPair;24  let alice: IKeyringPair;2526  before(async function() {27    await usingEthPlaygrounds(async (helper, privateKey) => {28      donor = await privateKey({filename: __filename});29      [alice] = await helper.arrange.createAccounts([10n], donor);30    });31  });3233  itEth('totalSupply', async ({helper}) => {34    const collection = await helper.nft.mintCollection(alice, {});35    await collection.mintToken(alice);3637    const caller = await helper.eth.createAccountWithBalance(donor);3839    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);40    const totalSupply = await contract.methods.totalSupply().call();4142    expect(totalSupply).to.equal('1');43  });4445  itEth('balanceOf', async ({helper}) => {46    const collection = await helper.nft.mintCollection(alice, {});47    const caller = await helper.eth.createAccountWithBalance(donor);4849    await collection.mintToken(alice, {Ethereum: caller});50    await collection.mintToken(alice, {Ethereum: caller});51    await collection.mintToken(alice, {Ethereum: caller});5253    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);54    const balance = await contract.methods.balanceOf(caller).call();5556    expect(balance).to.equal('3');57  });5859  itEth('ownerOf', async ({helper}) => {60    const collection = await helper.nft.mintCollection(alice, {});61    const caller = await helper.eth.createAccountWithBalance(donor);6263    const token = await collection.mintToken(alice, {Ethereum: caller});6465    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);6667    const owner = await contract.methods.ownerOf(token.tokenId).call();6869    expect(owner).to.equal(caller);70  });7172  itEth('name/symbol is available regardless of ERC721Metadata support', async ({helper}) => {73    const collection = await helper.nft.mintCollection(alice, {name: 'test', tokenPrefix: 'TEST'});74    const caller = helper.eth.createAccount();7576    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);7778    expect(await contract.methods.name().call()).to.equal('test');79    expect(await contract.methods.symbol().call()).to.equal('TEST');80  });81});8283describe('Check ERC721 token URI for NFT', () => {84  let donor: IKeyringPair;8586  before(async function() {87    await usingEthPlaygrounds(async (_helper, privateKey) => {88      donor = await privateKey({filename: __filename});89    });90  });9192  async function setup(helper: EthUniqueHelper, baseUri: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {93    const owner = await helper.eth.createAccountWithBalance(donor);94    const receiver = helper.eth.createAccount();9596    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', 'a', 'b', baseUri);97    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);9899    const result = await contract.methods.mint(receiver).send();100    const tokenId = result.events.Transfer.returnValues.tokenId;101    expect(tokenId).to.be.equal('1');102103    if (propertyKey && propertyValue) {104      // Set URL or suffix105      await contract.methods.setProperty(tokenId, propertyKey, Buffer.from(propertyValue)).send();106    }107108    const event = result.events.Transfer;109    expect(event.address).to.be.equal(collectionAddress);110    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');111    expect(event.returnValues.to).to.be.equal(receiver);112    expect(event.returnValues.tokenId).to.be.equal(tokenId);113114    return {contract, nextTokenId: tokenId};115  }116117  itEth('Empty tokenURI', async ({helper}) => {118    const {contract, nextTokenId} = await setup(helper, '');119    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('');120  });121122  itEth('TokenURI from url', async ({helper}) => {123    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URI', 'Token URI');124    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');125  });126127  itEth('TokenURI from baseURI', async ({helper}) => {128    const {contract, nextTokenId} = await setup(helper, 'BaseURI_');129    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_');130  });131132  itEth('TokenURI from baseURI + suffix', async ({helper}) => {133    const suffix = '/some/suffix';134    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URISuffix', suffix);135    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);136  });137});138139describe('NFT: Plain calls', () => {140  let donor: IKeyringPair;141  let minter: IKeyringPair;142  let bob: IKeyringPair;143  let charlie: IKeyringPair;144145  before(async function() {146    await usingEthPlaygrounds(async (helper, privateKey) => {147      donor = await privateKey({filename: __filename});148      [minter, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);149    });150  });151152  itEth('Can perform mint()', async ({helper}) => {153    const owner = await helper.eth.createAccountWithBalance(donor);154    const receiver = helper.eth.createAccount();155156    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', '6', '6', '');157    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);158159    const result = await contract.methods.mintWithTokenURI(receiver, 'Test URI').send();160    const tokenId = result.events.Transfer.returnValues.tokenId;161    expect(tokenId).to.be.equal('1');162163    const event = result.events.Transfer;164    expect(event.address).to.be.equal(collectionAddress);165    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');166    expect(event.returnValues.to).to.be.equal(receiver);167168    expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');169170    // TODO: this wont work right now, need release 919000 first171    // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();172    // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();173    // expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`);174  });175176  //TODO: CORE-302 add eth methods177  itEth.skip('Can perform mintBulk()', async ({helper}) => {178    const caller = await helper.eth.createAccountWithBalance(donor);179    const receiver = helper.eth.createAccount();180181    const collection = await helper.nft.mintCollection(minter);182    await collection.addAdmin(minter, {Ethereum: caller});183184    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);185    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);186    {187      const bulkSize = 3;188      const nextTokenId = await contract.methods.nextTokenId().call();189      expect(nextTokenId).to.be.equal('1');190      const result = await contract.methods.mintBulkWithTokenURI(191        receiver,192        Array.from({length: bulkSize}, (_, i) => (193          [+nextTokenId + i, `Test URI ${i}`]194        )),195      ).send({from: caller});196197      const events = result.events.Transfer.sort((a: any, b: any) => +a.returnValues.tokenId - b.returnValues.tokenId);198      for (let i = 0; i < bulkSize; i++) {199        const event = events[i];200        expect(event.address).to.equal(collectionAddress);201        expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');202        expect(event.returnValues.to).to.equal(receiver);203        expect(event.returnValues.tokenId).to.equal(`${+nextTokenId + i}`);204205        expect(await contract.methods.tokenURI(+nextTokenId + i).call()).to.be.equal(`Test URI ${i}`);206      }207    }208  });209210  itEth('Can perform burn()', async ({helper}) => {211    const caller = await helper.eth.createAccountWithBalance(donor);212213    const collection = await helper.nft.mintCollection(minter, {});214    const {tokenId} = await collection.mintToken(minter, {Ethereum: caller});215216    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);217    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);218219    {220      const result = await contract.methods.burn(tokenId).send({from: caller});221222      const event = result.events.Transfer;223      expect(event.address).to.be.equal(collectionAddress);224      expect(event.returnValues.from).to.be.equal(caller);225      expect(event.returnValues.to).to.be.equal('0x0000000000000000000000000000000000000000');226      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);227    }228  });229230  itEth('Can perform approve()', async ({helper}) => {231    const owner = await helper.eth.createAccountWithBalance(donor);232    const spender = helper.eth.createAccount();233234    const collection = await helper.nft.mintCollection(minter, {});235    const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});236237    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);238    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);239240    {241      const result = await contract.methods.approve(spender, tokenId).send({from: owner});242243      const event = result.events.Approval;244      expect(event.address).to.be.equal(collectionAddress);245      expect(event.returnValues.owner).to.be.equal(owner);246      expect(event.returnValues.approved).to.be.equal(spender);247      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);248    }249  });250251  itEth('Can perform burnFromCross()', async ({helper}) => {252    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});253254    const owner = bob;255    const spender = await helper.eth.createAccountWithBalance(donor, 100n);256257    const token = await collection.mintToken(minter, {Substrate: owner.address});258259    const address = helper.ethAddress.fromCollectionId(collection.collectionId);260    const contract = helper.ethNativeContract.collection(address, 'nft');261262    {263      await token.approve(owner, {Ethereum: spender});264      const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);265      const result = await contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender});266      const events = result.events.Transfer;267268      expect(events).to.be.like({269        address,270        event: 'Transfer',271        returnValues: {272          from: helper.address.substrateToEth(owner.address),273          to: '0x0000000000000000000000000000000000000000',274          tokenId: token.tokenId.toString(),275        },276      });277    }278  });279280  itEth('Can perform approveCross()', async ({helper}) => {281    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});282283    const owner = await helper.eth.createAccountWithBalance(donor, 100n);284    const receiver = charlie;285286    const token = await collection.mintToken(minter, {Ethereum: owner});287288    const address = helper.ethAddress.fromCollectionId(collection.collectionId);289    const contract = helper.ethNativeContract.collection(address, 'nft');290291    {292      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);293      const result = await contract.methods.approveCross(recieverCross, token.tokenId).send({from: owner});294      const event = result.events.Approval;295      expect(event).to.be.like({296        address: helper.ethAddress.fromCollectionId(collection.collectionId),297        event: 'Approval',298        returnValues: {299          owner,300          approved: helper.address.substrateToEth(receiver.address),301          tokenId: token.tokenId.toString(),302        },303      });304    }305  });306307  itEth('Can perform transferFrom()', async ({helper}) => {308    const owner = await helper.eth.createAccountWithBalance(donor);309    const spender = await helper.eth.createAccountWithBalance(donor);310    const receiver = helper.eth.createAccount();311312    const collection = await helper.nft.mintCollection(minter, {});313    const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});314315    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);316    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);317318    await contract.methods.approve(spender, tokenId).send({from: owner});319320    {321      const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({from: spender});322323      const event = result.events.Transfer;324      expect(event.address).to.be.equal(collectionAddress);325      expect(event.returnValues.from).to.be.equal(owner);326      expect(event.returnValues.to).to.be.equal(receiver);327      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);328    }329330    {331      const balance = await contract.methods.balanceOf(receiver).call();332      expect(+balance).to.equal(1);333    }334335    {336      const balance = await contract.methods.balanceOf(owner).call();337      expect(+balance).to.equal(0);338    }339  });340341  itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {342    const minter = await privateKey('//Alice');343    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});344345    const owner = await privateKey('//Bob');346    const spender = await helper.eth.createAccountWithBalance(donor);347    const receiver = await privateKey('//Charlie');348349    const token = await collection.mintToken(minter, {Substrate: owner.address});350351    const address = helper.ethAddress.fromCollectionId(collection.collectionId);352    const contract = helper.ethNativeContract.collection(address, 'nft');353354    await token.approve(owner, {Ethereum: spender});355356    {357      const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);358      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);359      const result = await contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender});360      const event = result.events.Transfer;361      expect(event).to.be.like({362        address: helper.ethAddress.fromCollectionId(collection.collectionId),363        event: 'Transfer',364        returnValues: {365          from: helper.address.substrateToEth(owner.address),366          to: helper.address.substrateToEth(receiver.address),367          tokenId: token.tokenId.toString(),368        },369      });370    }371372    expect(await token.getOwner()).to.be.like({Substrate: receiver.address});373  });374375  itEth('Can perform transfer()', async ({helper}) => {376    const collection = await helper.nft.mintCollection(minter, {});377    const owner = await helper.eth.createAccountWithBalance(donor);378    const receiver = helper.eth.createAccount();379380    const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});381382    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);383    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);384385    {386      const result = await contract.methods.transfer(receiver, tokenId).send({from: owner});387388      const event = result.events.Transfer;389      expect(event.address).to.be.equal(collectionAddress);390      expect(event.returnValues.from).to.be.equal(owner);391      expect(event.returnValues.to).to.be.equal(receiver);392      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);393    }394395    {396      const balance = await contract.methods.balanceOf(owner).call();397      expect(+balance).to.equal(0);398    }399400    {401      const balance = await contract.methods.balanceOf(receiver).call();402      expect(+balance).to.equal(1);403    }404  });405});406407describe('NFT: Fees', () => {408  let donor: IKeyringPair;409  let alice: IKeyringPair;410  let bob: IKeyringPair;411  let charlie: IKeyringPair;412413  before(async function() {414    await usingEthPlaygrounds(async (helper, privateKey) => {415      donor = await privateKey({filename: __filename});416      [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);417    });418  });419420  itEth('approve() call fee is less than 0.2UNQ', async ({helper}) => {421    const owner = await helper.eth.createAccountWithBalance(donor);422    const spender = helper.eth.createAccount();423424    const collection = await helper.nft.mintCollection(alice, {});425    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});426427    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);428429    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, tokenId).send({from: owner}));430    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));431  });432433  itEth('transferFrom() call fee is less than 0.2UNQ', async ({helper}) => {434    const owner = await helper.eth.createAccountWithBalance(donor);435    const spender = await helper.eth.createAccountWithBalance(donor);436437    const collection = await helper.nft.mintCollection(alice, {});438    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});439440    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);441442    await contract.methods.approve(spender, tokenId).send({from: owner});443444    const cost = await helper.eth.recordCallFee(spender, () => contract.methods.transferFrom(owner, spender, tokenId).send({from: spender}));445    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));446  });447448  itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {449    const collectionMinter = alice;450    const owner = bob;451    const receiver = charlie;452    const collection = await helper.nft.mintCollection(collectionMinter, {name: 'A', description: 'B', tokenPrefix: 'C'});453454    const spender = await helper.eth.createAccountWithBalance(donor, 100n);455456    const token = await collection.mintToken(collectionMinter, {Substrate: owner.address});457458    const address = helper.ethAddress.fromCollectionId(collection.collectionId);459    const contract = helper.ethNativeContract.collection(address, 'nft');460461    await token.approve(owner, {Ethereum: spender});462463    {464      const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);465      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);466      const result = await contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender});467      const event = result.events.Transfer;468      expect(event).to.be.like({469        address: helper.ethAddress.fromCollectionId(collection.collectionId),470        event: 'Transfer',471        returnValues: {472          from: helper.address.substrateToEth(owner.address),473          to: helper.address.substrateToEth(receiver.address),474          tokenId: token.tokenId.toString(),475        },476      });477    }478479    expect(await token.getOwner()).to.be.like({Substrate: receiver.address});480  });481482  itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {483    const owner = await helper.eth.createAccountWithBalance(donor);484    const receiver = helper.eth.createAccount();485486    const collection = await helper.nft.mintCollection(alice, {});487    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});488489    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);490491    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, tokenId).send({from: owner}));492    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));493  });494});495496describe('NFT: Substrate calls', () => {497  let donor: IKeyringPair;498  let alice: IKeyringPair;499500  before(async function() {501    await usingEthPlaygrounds(async (helper, privateKey) => {502      donor = await privateKey({filename: __filename});503      [alice] = await helper.arrange.createAccounts([20n], donor);504    });505  });506507  itEth('Events emitted for mint()', async ({helper}) => {508    const collection = await helper.nft.mintCollection(alice, {});509    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);510    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');511512    const events: any = [];513    contract.events.allEvents((_: any, event: any) => {514      events.push(event);515    });516517    const {tokenId} = await collection.mintToken(alice);518    if (events.length == 0) await helper.wait.newBlocks(1);519    const event = events[0];520521    expect(event.event).to.be.equal('Transfer');522    expect(event.address).to.be.equal(collectionAddress);523    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');524    expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(alice.address));525    expect(event.returnValues.tokenId).to.be.equal(tokenId.toString());526  });527528  itEth('Events emitted for burn()', async ({helper}) => {529    const collection = await helper.nft.mintCollection(alice, {});530    const token = await collection.mintToken(alice);531532    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);533    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');534535    const events: any = [];536    contract.events.allEvents((_: any, event: any) => {537      events.push(event);538    });539540    await token.burn(alice);541    if (events.length == 0) await helper.wait.newBlocks(1);542    const event = events[0];543544    expect(event.event).to.be.equal('Transfer');545    expect(event.address).to.be.equal(collectionAddress);546    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));547    expect(event.returnValues.to).to.be.equal('0x0000000000000000000000000000000000000000');548    expect(event.returnValues.tokenId).to.be.equal(token.tokenId.toString());549  });550551  itEth('Events emitted for approve()', async ({helper}) => {552    const receiver = helper.eth.createAccount();553554    const collection = await helper.nft.mintCollection(alice, {});555    const token = await collection.mintToken(alice);556557    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);558    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');559560    const events: any = [];561    contract.events.allEvents((_: any, event: any) => {562      events.push(event);563    });564565    await token.approve(alice, {Ethereum: receiver});566    if (events.length == 0) await helper.wait.newBlocks(1);567    const event = events[0];568569    expect(event.event).to.be.equal('Approval');570    expect(event.address).to.be.equal(collectionAddress);571    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));572    expect(event.returnValues.approved).to.be.equal(receiver);573    expect(event.returnValues.tokenId).to.be.equal(token.tokenId.toString());574  });575576  itEth('Events emitted for transferFrom()', async ({helper}) => {577    const [bob] = await helper.arrange.createAccounts([10n], donor);578    const receiver = helper.eth.createAccount();579580    const collection = await helper.nft.mintCollection(alice, {});581    const token = await collection.mintToken(alice);582    await token.approve(alice, {Substrate: bob.address});583584    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);585    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');586587    const events: any = [];588    contract.events.allEvents((_: any, event: any) => {589      events.push(event);590    });591592    await token.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver});593594    if (events.length == 0) await helper.wait.newBlocks(1);595    const event = events[0];596597    expect(event.address).to.be.equal(collectionAddress);598    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));599    expect(event.returnValues.to).to.be.equal(receiver);600    expect(event.returnValues.tokenId).to.be.equal(`${token.tokenId}`);601  });602603  itEth('Events emitted for transfer()', async ({helper}) => {604    const receiver = helper.eth.createAccount();605606    const collection = await helper.nft.mintCollection(alice, {});607    const token = await collection.mintToken(alice);608609    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);610    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');611612    const events: any = [];613    contract.events.allEvents((_: any, event: any) => {614      events.push(event);615    });616617    await token.transfer(alice, {Ethereum: receiver});618619    if (events.length == 0) await helper.wait.newBlocks(1);620    const event = events[0];621622    expect(event.address).to.be.equal(collectionAddress);623    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));624    expect(event.returnValues.to).to.be.equal(receiver);625    expect(event.returnValues.tokenId).to.be.equal(`${token.tokenId}`);626  });627});628629describe('Common metadata', () => {630  let donor: IKeyringPair;631  let alice: IKeyringPair;632633  before(async function() {634    await usingEthPlaygrounds(async (helper, privateKey) => {635      donor = await privateKey({filename: __filename});636      [alice] = await helper.arrange.createAccounts([20n], donor);637    });638  });639640  itEth('Returns collection name', async ({helper}) => {641    const caller = await helper.eth.createAccountWithBalance(donor);642    const tokenPropertyPermissions = [{643      key: 'URI',644      permission: {645        mutable: true,646        collectionAdmin: true,647        tokenOwner: false,648      },649    }];650    const collection = await helper.nft.mintCollection(651      alice,652      {653        name: 'oh River',654        tokenPrefix: 'CHANGE',655        properties: [{key: 'ERC721Metadata', value: '1'}],656        tokenPropertyPermissions,657      },658    );659660    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);661    const name = await contract.methods.name().call();662    expect(name).to.equal('oh River');663  });664665  itEth('Returns symbol name', async ({helper}) => {666    const caller = await helper.eth.createAccountWithBalance(donor);667    const tokenPropertyPermissions = [{668      key: 'URI',669      permission: {670        mutable: true,671        collectionAdmin: true,672        tokenOwner: false,673      },674    }];675    const collection = await helper.nft.mintCollection(676      alice,677      {678        name: 'oh River',679        tokenPrefix: 'CHANGE',680        properties: [{key: 'ERC721Metadata', value: '1'}],681        tokenPropertyPermissions,682      },683    );684685    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);686    const symbol = await contract.methods.symbol().call();687    expect(symbol).to.equal('CHANGE');688  });689});