1234567891011121314151617import {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 105 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 171 172 173 174 });175176 177 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 406 itEth('Can perform transferCross()', async ({helper}) => {407 const collection = await helper.nft.mintCollection(minter, {});408 const owner = await helper.eth.createAccountWithBalance(donor);409 const receiver = helper.eth.createAccount();410 const to = helper.ethCrossAccount.fromAddress(receiver);411 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});412413 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);414 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);415416 {417 const result = await contract.methods.transferCross(to, tokenId).send({from: owner});418419 const event = result.events.Transfer;420 expect(event.address).to.be.equal(collectionAddress);421 expect(event.returnValues.from).to.be.equal(owner);422 expect(event.returnValues.to).to.be.equal(receiver);423 expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);424 }425426 {427 const balance = await contract.methods.balanceOf(owner).call();428 expect(+balance).to.equal(0);429 }430431 {432 const balance = await contract.methods.balanceOf(receiver).call();433 expect(+balance).to.equal(1);434 }435 });436});437438describe('NFT: Fees', () => {439 let donor: IKeyringPair;440 let alice: IKeyringPair;441 let bob: IKeyringPair;442 let charlie: IKeyringPair;443444 before(async function() {445 await usingEthPlaygrounds(async (helper, privateKey) => {446 donor = await privateKey({filename: __filename});447 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);448 });449 });450451 itEth('approve() call fee is less than 0.2UNQ', async ({helper}) => {452 const owner = await helper.eth.createAccountWithBalance(donor);453 const spender = helper.eth.createAccount();454455 const collection = await helper.nft.mintCollection(alice, {});456 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});457458 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);459460 const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, tokenId).send({from: owner}));461 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));462 });463464 itEth('transferFrom() call fee is less than 0.2UNQ', async ({helper}) => {465 const owner = await helper.eth.createAccountWithBalance(donor);466 const spender = await helper.eth.createAccountWithBalance(donor);467468 const collection = await helper.nft.mintCollection(alice, {});469 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});470471 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);472473 await contract.methods.approve(spender, tokenId).send({from: owner});474475 const cost = await helper.eth.recordCallFee(spender, () => contract.methods.transferFrom(owner, spender, tokenId).send({from: spender}));476 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));477 });478479 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {480 const collectionMinter = alice;481 const owner = bob;482 const receiver = charlie;483 const collection = await helper.nft.mintCollection(collectionMinter, {name: 'A', description: 'B', tokenPrefix: 'C'});484485 const spender = await helper.eth.createAccountWithBalance(donor, 100n);486487 const token = await collection.mintToken(collectionMinter, {Substrate: owner.address});488489 const address = helper.ethAddress.fromCollectionId(collection.collectionId);490 const contract = helper.ethNativeContract.collection(address, 'nft');491492 await token.approve(owner, {Ethereum: spender});493494 {495 const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);496 const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);497 const result = await contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender});498 const event = result.events.Transfer;499 expect(event).to.be.like({500 address: helper.ethAddress.fromCollectionId(collection.collectionId),501 event: 'Transfer',502 returnValues: {503 from: helper.address.substrateToEth(owner.address),504 to: helper.address.substrateToEth(receiver.address),505 tokenId: token.tokenId.toString(),506 },507 });508 }509510 expect(await token.getOwner()).to.be.like({Substrate: receiver.address});511 });512513 itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {514 const owner = await helper.eth.createAccountWithBalance(donor);515 const receiver = helper.eth.createAccount();516517 const collection = await helper.nft.mintCollection(alice, {});518 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});519520 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);521522 const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, tokenId).send({from: owner}));523 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));524 });525});526527describe('NFT: Substrate calls', () => {528 let donor: IKeyringPair;529 let alice: IKeyringPair;530531 before(async function() {532 await usingEthPlaygrounds(async (helper, privateKey) => {533 donor = await privateKey({filename: __filename});534 [alice] = await helper.arrange.createAccounts([20n], donor);535 });536 });537538 itEth('Events emitted for mint()', async ({helper}) => {539 const collection = await helper.nft.mintCollection(alice, {});540 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);541 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');542543 const events: any = [];544 contract.events.allEvents((_: any, event: any) => {545 events.push(event);546 });547548 const {tokenId} = await collection.mintToken(alice);549 if (events.length == 0) await helper.wait.newBlocks(1);550 const event = events[0];551552 expect(event.event).to.be.equal('Transfer');553 expect(event.address).to.be.equal(collectionAddress);554 expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');555 expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(alice.address));556 expect(event.returnValues.tokenId).to.be.equal(tokenId.toString());557 });558559 itEth('Events emitted for burn()', async ({helper}) => {560 const collection = await helper.nft.mintCollection(alice, {});561 const token = await collection.mintToken(alice);562563 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);564 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');565566 const events: any = [];567 contract.events.allEvents((_: any, event: any) => {568 events.push(event);569 });570571 await token.burn(alice);572 if (events.length == 0) await helper.wait.newBlocks(1);573 const event = events[0];574575 expect(event.event).to.be.equal('Transfer');576 expect(event.address).to.be.equal(collectionAddress);577 expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));578 expect(event.returnValues.to).to.be.equal('0x0000000000000000000000000000000000000000');579 expect(event.returnValues.tokenId).to.be.equal(token.tokenId.toString());580 });581582 itEth('Events emitted for approve()', async ({helper}) => {583 const receiver = helper.eth.createAccount();584585 const collection = await helper.nft.mintCollection(alice, {});586 const token = await collection.mintToken(alice);587588 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);589 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');590591 const events: any = [];592 contract.events.allEvents((_: any, event: any) => {593 events.push(event);594 });595596 await token.approve(alice, {Ethereum: receiver});597 if (events.length == 0) await helper.wait.newBlocks(1);598 const event = events[0];599600 expect(event.event).to.be.equal('Approval');601 expect(event.address).to.be.equal(collectionAddress);602 expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));603 expect(event.returnValues.approved).to.be.equal(receiver);604 expect(event.returnValues.tokenId).to.be.equal(token.tokenId.toString());605 });606607 itEth('Events emitted for transferFrom()', async ({helper}) => {608 const [bob] = await helper.arrange.createAccounts([10n], donor);609 const receiver = helper.eth.createAccount();610611 const collection = await helper.nft.mintCollection(alice, {});612 const token = await collection.mintToken(alice);613 await token.approve(alice, {Substrate: bob.address});614615 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);616 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');617618 const events: any = [];619 contract.events.allEvents((_: any, event: any) => {620 events.push(event);621 });622623 await token.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver});624625 if (events.length == 0) await helper.wait.newBlocks(1);626 const event = events[0];627628 expect(event.address).to.be.equal(collectionAddress);629 expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));630 expect(event.returnValues.to).to.be.equal(receiver);631 expect(event.returnValues.tokenId).to.be.equal(`${token.tokenId}`);632 });633634 itEth('Events emitted for transfer()', async ({helper}) => {635 const receiver = helper.eth.createAccount();636637 const collection = await helper.nft.mintCollection(alice, {});638 const token = await collection.mintToken(alice);639640 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);641 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');642643 const events: any = [];644 contract.events.allEvents((_: any, event: any) => {645 events.push(event);646 });647648 await token.transfer(alice, {Ethereum: receiver});649650 if (events.length == 0) await helper.wait.newBlocks(1);651 const event = events[0];652653 expect(event.address).to.be.equal(collectionAddress);654 expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));655 expect(event.returnValues.to).to.be.equal(receiver);656 expect(event.returnValues.tokenId).to.be.equal(`${token.tokenId}`);657 });658});659660describe('Common metadata', () => {661 let donor: IKeyringPair;662 let alice: IKeyringPair;663664 before(async function() {665 await usingEthPlaygrounds(async (helper, privateKey) => {666 donor = await privateKey({filename: __filename});667 [alice] = await helper.arrange.createAccounts([20n], donor);668 });669 });670671 itEth('Returns collection name', async ({helper}) => {672 const caller = await helper.eth.createAccountWithBalance(donor);673 const tokenPropertyPermissions = [{674 key: 'URI',675 permission: {676 mutable: true,677 collectionAdmin: true,678 tokenOwner: false,679 },680 }];681 const collection = await helper.nft.mintCollection(682 alice,683 {684 name: 'oh River',685 tokenPrefix: 'CHANGE',686 properties: [{key: 'ERC721Metadata', value: '1'}],687 tokenPropertyPermissions,688 },689 );690691 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);692 const name = await contract.methods.name().call();693 expect(name).to.equal('oh River');694 });695696 itEth('Returns symbol name', async ({helper}) => {697 const caller = await helper.eth.createAccountWithBalance(donor);698 const tokenPropertyPermissions = [{699 key: 'URI',700 permission: {701 mutable: true,702 collectionAdmin: true,703 tokenOwner: false,704 },705 }];706 const collection = await helper.nft.mintCollection(707 alice,708 {709 name: 'oh River',710 tokenPrefix: 'CHANGE',711 properties: [{key: 'ERC721Metadata', value: '1'}],712 tokenPropertyPermissions,713 },714 );715716 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);717 const symbol = await contract.methods.symbol().call();718 expect(symbol).to.equal('CHANGE');719 });720});