123456import { expect } from 'chai';7import privateKey from '../substrate/privateKey';8import { createCollectionExpectSuccess } from '../util/helpers';9import { collectionIdToAddress, createEthAccount, itWeb3, transferBalanceToEth } from './util/helpers';10import fungibleMetadataAbi from './fungibleMetadataAbi.json';1112describe('Common metadata', () => {13 itWeb3('Returns collection name', async ({ api, web3 }) => {14 const collection = await createCollectionExpectSuccess({15 name: 'token name',16 mode: { type: 'NFT' },17 });18 const caller = createEthAccount(web3);19 await transferBalanceToEth(api, privateKey('//Alice'), caller, 999999);2021 const address = collectionIdToAddress(collection);22 const contract = new web3.eth.Contract(fungibleMetadataAbi as any, address);23 const name = await contract.methods.name().call({ from: caller });2425 expect(name).to.equal('token name');26 });2728 itWeb3('Returns symbol name', async ({ api, web3 }) => {29 const collection = await createCollectionExpectSuccess({30 tokenPrefix: 'TOK',31 mode: { type: 'NFT' },32 });33 const caller = createEthAccount(web3);34 await transferBalanceToEth(api, privateKey('//Alice'), caller, 999999);3536 const address = collectionIdToAddress(collection);37 const contract = new web3.eth.Contract(fungibleMetadataAbi as any, address);38 const symbol = await contract.methods.symbol().call({ from: caller });3940 expect(symbol).to.equal('TOK');41 });42});4344describe('Fungible metadata', () => {45 itWeb3('Returns fungible decimals', async ({ api, web3 }) => {46 const collection = await createCollectionExpectSuccess({47 mode: { type: 'Fungible', decimalPoints: 6 },48 });49 const caller = createEthAccount(web3);50 await transferBalanceToEth(api, privateKey('//Alice'), caller, 999999);5152 const address = collectionIdToAddress(collection);53 const contract = new web3.eth.Contract(fungibleMetadataAbi as any, address);54 const decimals = await contract.methods.decimals().call({ from: caller });5556 expect(+decimals).to.equal(6);57 });58});