1234567891011121314151617import {Pallets, requirePalletsOrSkip} from '../../util';18import {expect, itEth, usingEthPlaygrounds} from '../util';19import {IKeyringPair} from '@polkadot/types/types';2021[22 {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},23 {mode: 'nft' as const, requiredPallets: []},24].map(testCase => {25 describe(`${testCase.mode.toUpperCase()}: ERC-721 call methods`, () => {26 let donor: IKeyringPair;2728 before(async function() {29 await usingEthPlaygrounds(async (helper, privateKey) => {30 requirePalletsOrSkip(this, helper, testCase.requiredPallets);3132 donor = await privateKey({filename: __filename});33 });34 });3536 itEth('name/symbol/description', async ({helper}) => {37 const callerEth = await helper.eth.createAccountWithBalance(donor);38 const [callerSub] = await helper.arrange.createAccounts([100n], donor);39 const [name, description, tokenPrefix] = ['Name', 'Description', 'Symbol'];4041 const {collection: collectionEth} = await helper.eth.createCollection(testCase.mode, callerEth, name, description, tokenPrefix);42 await collectionEth.methods.mint(callerEth).send({from: callerEth});43 const {collectionId} = await helper[testCase.mode].mintCollection(callerSub, {name, description, tokenPrefix});44 const collectionSub = await helper.ethNativeContract.collectionById(collectionId, testCase.mode, callerEth);4546 47 expect(await collectionEth.methods.name().call()).to.eq(name);48 expect(await collectionEth.methods.symbol().call()).to.eq(tokenPrefix);49 expect(await collectionEth.methods.description().call()).to.eq(description);50 51 expect(await collectionSub.methods.name().call()).to.eq(name);52 expect(await collectionSub.methods.symbol().call()).to.eq(tokenPrefix);53 expect(await collectionSub.methods.description().call()).to.eq(description);54 });5556 itEth('totalSupply', async ({helper}) => {57 const caller = await helper.eth.createAccountWithBalance(donor);5859 const {collection} = await helper.eth.createCollection(testCase.mode, caller, 'TotalSupply', '6', '6');60 await collection.methods.mint(caller).send({from: caller});6162 const totalSupply = await collection.methods.totalSupply().call();63 expect(totalSupply).to.equal('1');64 });6566 itEth('balanceOf', async ({helper}) => {67 const caller = await helper.eth.createAccountWithBalance(donor);6869 const {collection} = await helper.eth.createCollection(testCase.mode, caller, 'BalanceOf', 'Descroption', 'Prefix');70 await collection.methods.mint(caller).send({from: caller});71 await collection.methods.mint(caller).send({from: caller});72 await collection.methods.mint(caller).send({from: caller});7374 const balance = await collection.methods.balanceOf(caller).call();75 expect(balance).to.equal('3');76 });7778 itEth('ownerOf', async ({helper}) => {79 const caller = await helper.eth.createAccountWithBalance(donor);80 const {collection} = await helper.eth.createCollection(testCase.mode, caller, 'OwnerOf', '6', '6');8182 const result = await collection.methods.mint(caller).send();83 const tokenId = result.events.Transfer.returnValues.tokenId;8485 const owner = await collection.methods.ownerOf(tokenId).call();86 expect(owner).to.equal(caller);87 });8889 90 91 92 93 94 9596 97 98 99100 101 102103 104105 106 107 108109 110 111 112 113 114 115116 117 118 119120 121 122123 124 125 126 });127});