git.delta.rocks / unique-network / refs/commits / da0f86127809

difftreelog

test run eslint --fix

Yaroslav Bolyukin2023-05-30parent: #833ab94.patch.diff
in: master

20 files changed

modifiedtests/src/benchmarks/mintFee/index.tsdiffbeforeafterboth
--- a/tests/src/benchmarks/mintFee/index.ts
+++ b/tests/src/benchmarks/mintFee/index.ts
@@ -222,9 +222,7 @@
       await collection.mintToken(
         donor,
         {Substrate: susbstrateReceiver.address},
-        PROPERTIES.slice(0, setup.propertiesNumber).map((p) => {
-          return {key: p.key, value: Buffer.from(p.value).toString()};
-        }),
+        PROPERTIES.slice(0, setup.propertiesNumber).map((p) => ({key: p.key, value: Buffer.from(p.value).toString()})),
       );
     },
   );
modifiedtests/src/benchmarks/opsFee/index.tsdiffbeforeafterboth
--- a/tests/src/benchmarks/opsFee/index.ts
+++ b/tests/src/benchmarks/opsFee/index.ts
@@ -379,7 +379,7 @@
   res['setCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(
     {Substrate: donor.address},
     () => collection.setProperties(donor, PROPERTIES.slice(0, 1)
-      .map(p => { return {key: p.key, value: p.value.toString()}; })),
+      .map(p => ({key: p.key, value: p.value.toString()}))),
   )));
 
   res['deleteCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(
@@ -755,7 +755,7 @@
   res['setCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(
     {Substrate: donor.address},
     () => collection.setProperties(donor, PROPERTIES.slice(0, 1)
-      .map(p => { return {key: p.key, value: p.value.toString()}; })),
+      .map(p => ({key: p.key, value: p.value.toString()}))),
   )));
 
   res['deleteCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(
modifiedtests/src/benchmarks/utils/common.tsdiffbeforeafterboth
--- a/tests/src/benchmarks/utils/common.ts
+++ b/tests/src/benchmarks/utils/common.ts
@@ -5,32 +5,26 @@
 
 export const PROPERTIES = Array(40)
   .fill(0)
-  .map((_, i) => {
-    return {
-      key: `key_${i}`,
-      value: Uint8Array.from(Buffer.from(`value_${i}`)),
-    };
-  });
+  .map((_, i) => ({
+    key: `key_${i}`,
+    value: Uint8Array.from(Buffer.from(`value_${i}`)),
+  }));
 
 export const SUBS_PROPERTIES = Array(40)
   .fill(0)
-  .map((_, i) => {
-    return {
-      key: `key_${i}`,
-      value: `value_${i}`,
-    };
-  });
+  .map((_, i) => ({
+    key: `key_${i}`,
+    value: `value_${i}`,
+  }));
 
-export const PERMISSIONS: ITokenPropertyPermission[] = PROPERTIES.map((p) => {
-  return {
-    key: p.key,
-    permission: {
-      tokenOwner: true,
-      collectionAdmin: true,
-      mutable: true,
-    },
-  };
-});
+export const PERMISSIONS: ITokenPropertyPermission[] = PROPERTIES.map((p) => ({
+  key: p.key,
+  permission: {
+    tokenOwner: true,
+    collectionAdmin: true,
+    mutable: true,
+  },
+}));
 
 export function convertToTokens(value: bigint, nominal = 1000_000_000_000_000_000n): number {
   return Number((value * 1000n) / nominal) / 1000;
modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionAdmin.test.ts
+++ b/tests/src/eth/collectionAdmin.test.ts
@@ -76,9 +76,7 @@
 
       // 2. Expect methods.collectionAdmins == api.rpc.unique.adminlist
       let adminListEth = await collectionEvm.methods.collectionAdmins().call();
-      adminListEth = adminListEth.map((element: IEthCrossAccountId) => {
-        return helper.address.convertCrossAccountFromEthCrossAccount(element);
-      });
+      adminListEth = adminListEth.map((element: IEthCrossAccountId) => helper.address.convertCrossAccountFromEthCrossAccount(element));
       expect(adminListRpc).to.be.like(adminListEth);
 
       // 3. check isOwnerOrAdminCross returns true:
modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionProperties.test.ts
+++ b/tests/src/eth/collectionProperties.test.ts
@@ -181,17 +181,11 @@
       const propertyPermissions = data2?.raw.tokenPropertyPermissions;
       expect(propertyPermissions?.length).to.equal(2);
 
-      expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => {
-        return tpp.key === 'URI' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner;
-      })).to.be.not.null;
+      expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => tpp.key === 'URI' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner)).to.be.not.null;
 
-      expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => {
-        return tpp.key === 'URISuffix' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner;
-      })).to.be.not.null;
+      expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => tpp.key === 'URISuffix' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner)).to.be.not.null;
 
-      expect(data2?.raw.properties?.find((property: IProperty) => {
-        return property.key === 'baseURI' && property.value === BASE_URI;
-      })).to.be.not.null;
+      expect(data2?.raw.properties?.find((property: IProperty) => property.key === 'baseURI' && property.value === BASE_URI)).to.be.not.null;
 
       const token1Result = await contract.methods.mint(bruh).send();
       const tokenId1 = token1Result.events.Transfer.returnValues.tokenId;
modifiedtests/src/eth/evmCoder.test.tsdiffbeforeafterboth
--- a/tests/src/eth/evmCoder.test.ts
+++ b/tests/src/eth/evmCoder.test.ts
@@ -17,8 +17,7 @@
 import {IKeyringPair} from '@polkadot/types/types';
 import {itEth, expect, usingEthPlaygrounds} from './util';
 
-const getContractSource = (collectionAddress: string, contractAddress: string): string => {
-  return `
+const getContractSource = (collectionAddress: string, contractAddress: string): string => `
   // SPDX-License-Identifier: MIT
   pragma solidity ^0.8.0;
   interface ITest {
@@ -51,7 +50,6 @@
     }
   }
   `;
-};
 
 
 describe('Evm Coder tests', () => {
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
before · tests/src/eth/nonFungible.test.ts
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';20import {ITokenPropertyPermission} from '../util/playgrounds/types';2122describe('Check ERC721 token URI for NFT', () => {23  let donor: IKeyringPair;2425  before(async function() {26    await usingEthPlaygrounds(async (_helper, privateKey) => {27      donor = await privateKey({url: import.meta.url});28    });29  });3031  async function setup(helper: EthUniqueHelper, baseUri: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {32    const owner = await helper.eth.createAccountWithBalance(donor);33    const receiver = helper.eth.createAccount();3435    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', 'a', 'b', baseUri);36    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);3738    const result = await contract.methods.mint(receiver).send();39    const tokenId = result.events.Transfer.returnValues.tokenId;40    expect(tokenId).to.be.equal('1');4142    if (propertyKey && propertyValue) {43      // Set URL or suffix44      await contract.methods.setProperties(tokenId, [{key: propertyKey, value: Buffer.from(propertyValue)}]).send();45    }4647    const event = result.events.Transfer;48    expect(event.address).to.be.equal(collectionAddress);49    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');50    expect(event.returnValues.to).to.be.equal(receiver);51    expect(event.returnValues.tokenId).to.be.equal(tokenId);5253    return {contract, nextTokenId: tokenId};54  }5556  itEth('Empty tokenURI', async ({helper}) => {57    const {contract, nextTokenId} = await setup(helper, '');58    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('');59  });6061  itEth('TokenURI from url', async ({helper}) => {62    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URI', 'Token URI');63    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');64  });6566  itEth('TokenURI from baseURI', async ({helper}) => {67    const {contract, nextTokenId} = await setup(helper, 'BaseURI_');68    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_');69  });7071  itEth('TokenURI from baseURI + suffix', async ({helper}) => {72    const suffix = '/some/suffix';73    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URISuffix', suffix);74    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);75  });76});7778describe('NFT: Plain calls', () => {79  let donor: IKeyringPair;80  let minter: IKeyringPair;81  let bob: IKeyringPair;82  let charlie: IKeyringPair;8384  before(async function() {85    await usingEthPlaygrounds(async (helper, privateKey) => {86      donor = await privateKey({url: import.meta.url});87      [minter, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);88    });89  });9091  // TODO combine all minting tests in one place92  [93    'substrate' as const,94    'ethereum' as const,95  ].map(testCase => {96    itEth(`Can perform mintCross() for ${testCase} address`, async ({helper}) => {97      const collectionAdmin = await helper.eth.createAccountWithBalance(donor);9899      const receiverEth = helper.eth.createAccount();100      const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);101      const receiverSub = bob;102      const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(receiverSub);103104      // const receiverCross = helper.ethCrossAccount.fromKeyringPair(bob);105      const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });106      const permissions: ITokenPropertyPermission[] = properties107        .map(p => {108          return {109            key: p.key, permission: {110              tokenOwner: false,111              collectionAdmin: true,112              mutable: false,113            },114          };115        });116117      const collection = await helper.nft.mintCollection(minter, {118        tokenPrefix: 'ethp',119        tokenPropertyPermissions: permissions,120      });121      await collection.addAdmin(minter, {Ethereum: collectionAdmin});122123      const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);124      const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', collectionAdmin, true);125      let expectedTokenId = await contract.methods.nextTokenId().call();126      let result = await contract.methods.mintCross(testCase === 'ethereum' ? receiverCrossEth : receiverCrossSub, []).send();127      let tokenId = result.events.Transfer.returnValues.tokenId;128      expect(tokenId).to.be.equal(expectedTokenId);129130      let event = result.events.Transfer;131      expect(event.address).to.be.equal(collectionAddress);132      expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');133      expect(event.returnValues.to).to.be.equal(testCase === 'ethereum' ? receiverEth : helper.address.substrateToEth(bob.address));134      expect(await contract.methods.properties(tokenId, []).call()).to.be.like([]);135136      expectedTokenId = await contract.methods.nextTokenId().call();137      result = await contract.methods.mintCross(testCase === 'ethereum' ? receiverCrossEth : receiverCrossSub, properties).send();138      event = result.events.Transfer;139      expect(event.address).to.be.equal(collectionAddress);140      expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');141      expect(event.returnValues.to).to.be.equal(testCase === 'ethereum' ? receiverEth : helper.address.substrateToEth(bob.address));142      expect(await contract.methods.properties(tokenId, []).call()).to.be.like([]);143144      tokenId = result.events.Transfer.returnValues.tokenId;145146      expect(tokenId).to.be.equal(expectedTokenId);147148      expect(await contract.methods.properties(tokenId, []).call()).to.be.like(properties149        .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); }));150151      expect(await helper.nft.getTokenOwner(collection.collectionId, tokenId))152        .to.deep.eq(testCase === 'ethereum' ? {Ethereum: receiverEth.toLowerCase()} : {Substrate: receiverSub.address});153    });154  });155156  itEth('Non-owner and non admin cannot mintCross', async ({helper}) => {157    const nonOwner = await helper.eth.createAccountWithBalance(donor);158    const nonOwnerCross = helper.ethCrossAccount.fromAddress(nonOwner);159160    const collection = await helper.nft.mintCollection(minter);161    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);162    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft');163164    await expect(collectionEvm.methods.mintCross(nonOwnerCross, []).call({from: nonOwner}))165      .to.be.rejectedWith('PublicMintingNotAllowed');166  });167168  //TODO: CORE-302 add eth methods169  itEth.skip('Can perform mintBulk()', async ({helper}) => {170    const caller = await helper.eth.createAccountWithBalance(donor);171    const receiver = helper.eth.createAccount();172173    const collection = await helper.nft.mintCollection(minter);174    await collection.addAdmin(minter, {Ethereum: caller});175176    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);177    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', caller);178    {179      const bulkSize = 3;180      const nextTokenId = await contract.methods.nextTokenId().call();181      expect(nextTokenId).to.be.equal('1');182      const result = await contract.methods.mintBulkWithTokenURI(183        receiver,184        Array.from({length: bulkSize}, (_, i) => (185          [+nextTokenId + i, `Test URI ${i}`]186        )),187      ).send({from: caller});188189      const events = result.events.Transfer.sort((a: any, b: any) => +a.returnValues.tokenId - b.returnValues.tokenId);190      for (let i = 0; i < bulkSize; i++) {191        const event = events[i];192        expect(event.address).to.equal(collectionAddress);193        expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');194        expect(event.returnValues.to).to.equal(receiver);195        expect(event.returnValues.tokenId).to.equal(`${+nextTokenId + i}`);196197        expect(await contract.methods.tokenURI(+nextTokenId + i).call()).to.be.equal(`Test URI ${i}`);198      }199    }200  });201202  itEth('Can perform burn()', async ({helper}) => {203    const caller = await helper.eth.createAccountWithBalance(donor);204205    const collection = await helper.nft.mintCollection(minter, {});206    const {tokenId} = await collection.mintToken(minter, {Ethereum: caller});207208    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);209    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', caller);210211    {212      const result = await contract.methods.burn(tokenId).send({from: caller});213214      const event = result.events.Transfer;215      expect(event.address).to.be.equal(collectionAddress);216      expect(event.returnValues.from).to.be.equal(caller);217      expect(event.returnValues.to).to.be.equal('0x0000000000000000000000000000000000000000');218      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);219    }220  });221222  itEth('Can perform approve()', async ({helper}) => {223    const owner = await helper.eth.createAccountWithBalance(donor);224    const spender = helper.eth.createAccount();225226    const collection = await helper.nft.mintCollection(minter, {});227    const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});228229    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);230    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);231232    {233      const badTokenId = await contract.methods.nextTokenId().call() + 1;234      await expect(contract.methods.getApproved(badTokenId).call()).to.be.rejectedWith('revert TokenNotFound');235    }236    {237      const approved = await contract.methods.getApproved(tokenId).call();238      expect(approved).to.be.equal('0x0000000000000000000000000000000000000000');239    }240    {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    {250      const approved = await contract.methods.getApproved(tokenId).call();251      expect(approved).to.be.equal(spender);252    }253  });254255  itEth('Can perform setApprovalForAll()', async ({helper}) => {256    const owner = await helper.eth.createAccountWithBalance(donor);257    const operator = helper.eth.createAccount();258259    const collection = await helper.nft.mintCollection(minter, {});260261    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);262    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);263264    const approvedBefore = await contract.methods.isApprovedForAll(owner, operator).call();265    expect(approvedBefore).to.be.equal(false);266267    {268      const result = await contract.methods.setApprovalForAll(operator, true).send({from: owner});269270      expect(result.events.ApprovalForAll).to.be.like({271        address: collectionAddress,272        event: 'ApprovalForAll',273        returnValues: {274          owner,275          operator,276          approved: true,277        },278      });279280      const approvedAfter = await contract.methods.isApprovedForAll(owner, operator).call();281      expect(approvedAfter).to.be.equal(true);282    }283284    {285      const result = await contract.methods.setApprovalForAll(operator, false).send({from: owner});286287      expect(result.events.ApprovalForAll).to.be.like({288        address: collectionAddress,289        event: 'ApprovalForAll',290        returnValues: {291          owner,292          operator,293          approved: false,294        },295      });296297      const approvedAfter = await contract.methods.isApprovedForAll(owner, operator).call();298      expect(approvedAfter).to.be.equal(false);299    }300  });301302  itEth('Can perform burn with ApprovalForAll', async ({helper}) => {303    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});304305    const owner = await helper.eth.createAccountWithBalance(donor);306    const operator = await helper.eth.createAccountWithBalance(donor);307308    const token = await collection.mintToken(minter, {Ethereum: owner});309310    const address = helper.ethAddress.fromCollectionId(collection.collectionId);311    const contract = await helper.ethNativeContract.collection(address, 'nft');312313    {314      await contract.methods.setApprovalForAll(operator, true).send({from: owner});315      const ownerCross = helper.ethCrossAccount.fromAddress(owner);316      const result = await contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: operator});317      const events = result.events.Transfer;318319      expect(events).to.be.like({320        address,321        event: 'Transfer',322        returnValues: {323          from: owner,324          to: '0x0000000000000000000000000000000000000000',325          tokenId: token.tokenId.toString(),326        },327      });328    }329330    expect(await helper.nft.doesTokenExist(collection.collectionId, token.tokenId)).to.be.false;331  });332333  itEth('Can perform transfer with ApprovalForAll', async ({helper}) => {334    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});335336    const owner = await helper.eth.createAccountWithBalance(donor);337    const operator = await helper.eth.createAccountWithBalance(donor);338    const receiver = charlie;339340    const token = await collection.mintToken(minter, {Ethereum: owner});341342    const address = helper.ethAddress.fromCollectionId(collection.collectionId);343    const contract = await helper.ethNativeContract.collection(address, 'nft');344345    {346      await contract.methods.setApprovalForAll(operator, true).send({from: owner});347      const ownerCross = helper.ethCrossAccount.fromAddress(owner);348      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);349      const result = await contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: operator});350      const event = result.events.Transfer;351      expect(event).to.be.like({352        address: helper.ethAddress.fromCollectionId(collection.collectionId),353        event: 'Transfer',354        returnValues: {355          from: owner,356          to: helper.address.substrateToEth(receiver.address),357          tokenId: token.tokenId.toString(),358        },359      });360    }361362    expect(await token.getOwner()).to.be.like({Substrate: receiver.address});363  });364365  itEth('Can perform burnFromCross()', async ({helper}) => {366    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});367    const ownerSub = bob;368    const ownerCrossSub = helper.ethCrossAccount.fromKeyringPair(ownerSub);369    const ownerEth = await helper.eth.createAccountWithBalance(donor);370    const ownerCrossEth = helper.ethCrossAccount.fromAddress(ownerEth);371372    const burnerEth = await helper.eth.createAccountWithBalance(donor);373    const burnerCrossEth = helper.ethCrossAccount.fromAddress(burnerEth);374375    const token1 = await collection.mintToken(minter, {Substrate: ownerSub.address});376    const token2 = await collection.mintToken(minter, {Ethereum: ownerEth});377378    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);379    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft');380381    // Approve tokens from substrate and ethereum:382    await token1.approve(ownerSub, {Ethereum: burnerEth});383    await collectionEvm.methods.approveCross(burnerCrossEth, token2.tokenId).send({from: ownerEth});384385    // can burnFromCross:386    const result1 = await collectionEvm.methods.burnFromCross(ownerCrossSub, token1.tokenId).send({from: burnerEth});387    const result2 = await collectionEvm.methods.burnFromCross(ownerCrossEth, token2.tokenId).send({from: burnerEth});388    const events1 = result1.events.Transfer;389    const events2 = result2.events.Transfer;390391    // Check events for burnFromCross (substrate and ethereum):392    [393      [events1, token1, helper.address.substrateToEth(ownerSub.address)],394      [events2, token2, ownerEth],395    ].map(burnData => {396      expect(burnData[0]).to.be.like({397        address: collectionAddress,398        event: 'Transfer',399        returnValues: {400          from: burnData[2],401          to: '0x0000000000000000000000000000000000000000',402          tokenId: burnData[1].tokenId.toString(),403        },404      });405    });406407    expect(await token1.doesExist()).to.be.false;408    expect(await token2.doesExist()).to.be.false;409  });410411  // TODO combine all approve tests in one place412  itEth('Can perform approveCross()', async ({helper}) => {413    // arrange: create accounts414    const owner = await helper.eth.createAccountWithBalance(donor);415    const ownerCross = helper.ethCrossAccount.fromAddress(owner);416    const receiverSub = charlie;417    const recieverCrossSub = helper.ethCrossAccount.fromKeyringPair(receiverSub);418    const receiverEth = await helper.eth.createAccountWithBalance(donor);419    const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);420421    // arrange: create collection and tokens:422    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});423    const token1 = await collection.mintToken(minter, {Ethereum: owner});424    const token2 = await collection.mintToken(minter, {Ethereum: owner});425426    const collectionEvm = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');427428    // Can approveCross substrate and ethereum address:429    const resultSub = await collectionEvm.methods.approveCross(recieverCrossSub, token1.tokenId).send({from: owner});430    const resultEth = await collectionEvm.methods.approveCross(receiverCrossEth, token2.tokenId).send({from: owner});431    const eventSub = resultSub.events.Approval;432    const eventEth = resultEth.events.Approval;433    expect(eventSub).to.be.like({434      address: helper.ethAddress.fromCollectionId(collection.collectionId),435      event: 'Approval',436      returnValues: {437        owner,438        approved: helper.address.substrateToEth(receiverSub.address),439        tokenId: token1.tokenId.toString(),440      },441    });442    expect(eventEth).to.be.like({443      address: helper.ethAddress.fromCollectionId(collection.collectionId),444      event: 'Approval',445      returnValues: {446        owner,447        approved: receiverEth,448        tokenId: token2.tokenId.toString(),449      },450    });451452    // Substrate address can transferFrom approved tokens:453    await helper.nft.transferTokenFrom(receiverSub, collection.collectionId, token1.tokenId, {Ethereum: owner}, {Substrate: receiverSub.address});454    expect(await helper.nft.getTokenOwner(collection.collectionId, token1.tokenId)).to.deep.eq({Substrate: receiverSub.address});455    // Ethereum address can transferFromCross approved tokens:456    await collectionEvm.methods.transferFromCross(ownerCross, receiverCrossEth, token2.tokenId).send({from: receiverEth});457    expect(await helper.nft.getTokenOwner(collection.collectionId, token2.tokenId)).to.deep.eq({Ethereum: receiverEth.toLowerCase()});458  });459460  itEth('Non-owner and non admin cannot approveCross', async ({helper}) => {461    const nonOwner = await helper.eth.createAccountWithBalance(donor);462    const nonOwnerCross = helper.ethCrossAccount.fromAddress(nonOwner);463    const owner = await helper.eth.createAccountWithBalance(donor);464    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});465    const collectionEvm = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');466    const token = await collection.mintToken(minter, {Ethereum: owner});467468    await expect(collectionEvm.methods.approveCross(nonOwnerCross, token.tokenId).call({from: nonOwner})).to.be.rejectedWith('CantApproveMoreThanOwned');469  });470471  itEth('Can reaffirm approved address', async ({helper}) => {472    const owner = await helper.eth.createAccountWithBalance(donor);473    const ownerCrossEth = helper.ethCrossAccount.fromAddress(owner);474    const [receiver1, receiver2] = await helper.arrange.createAccounts([100n, 100n], donor);475    const receiver1Cross = helper.ethCrossAccount.fromKeyringPair(receiver1);476    const receiver2Cross = helper.ethCrossAccount.fromKeyringPair(receiver2);477    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});478    const token1 = await collection.mintToken(minter, {Ethereum: owner});479    const token2 = await collection.mintToken(minter, {Ethereum: owner});480    const collectionEvm = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');481482    // Can approve and reaffirm approved address:483    await collectionEvm.methods.approveCross(receiver1Cross, token1.tokenId).send({from: owner});484    await collectionEvm.methods.approveCross(receiver2Cross, token1.tokenId).send({from: owner});485486    // receiver1 cannot transferFrom:487    await expect(helper.nft.transferTokenFrom(receiver1, collection.collectionId, token1.tokenId, {Ethereum: owner}, {Substrate: receiver1.address})).to.be.rejected;488    // receiver2 can transferFrom:489    await helper.nft.transferTokenFrom(receiver2, collection.collectionId, token1.tokenId, {Ethereum: owner}, {Substrate: receiver2.address});490491    // can set approved address to self address to remove approval:492    await collectionEvm.methods.approveCross(receiver1Cross, token2.tokenId).send({from: owner});493    await collectionEvm.methods.approveCross(ownerCrossEth, token2.tokenId).send({from: owner});494495    // receiver1 cannot transfer token anymore:496    await expect(helper.nft.transferTokenFrom(receiver1, collection.collectionId, token2.tokenId, {Ethereum: owner}, {Substrate: receiver1.address})).to.be.rejected;497  });498499  itEth('Can perform transferFrom()', async ({helper}) => {500    const owner = await helper.eth.createAccountWithBalance(donor);501    const spender = await helper.eth.createAccountWithBalance(donor);502    const receiver = helper.eth.createAccount();503504    const collection = await helper.nft.mintCollection(minter, {});505    const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});506507    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);508    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);509510    await contract.methods.approve(spender, tokenId).send({from: owner});511512    {513      const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({from: spender});514515      const event = result.events.Transfer;516      expect(event.address).to.be.equal(collectionAddress);517      expect(event.returnValues.from).to.be.equal(owner);518      expect(event.returnValues.to).to.be.equal(receiver);519      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);520    }521522    {523      const balance = await contract.methods.balanceOf(receiver).call();524      expect(+balance).to.equal(1);525    }526527    {528      const balance = await contract.methods.balanceOf(owner).call();529      expect(+balance).to.equal(0);530    }531  });532533  itEth('Can perform transferFromCross()', async ({helper}) => {534    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});535536    const [owner, receiver] = await helper.arrange.createAccounts([100n, 100n], donor);537    const spender = await helper.eth.createAccountWithBalance(donor);538539    const token = await collection.mintToken(minter, {Substrate: owner.address});540541    const address = helper.ethAddress.fromCollectionId(collection.collectionId);542    const contract = await helper.ethNativeContract.collection(address, 'nft');543544    await token.approve(owner, {Ethereum: spender});545546    {547      const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);548      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);549      const result = await contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender});550      const event = result.events.Transfer;551      expect(event).to.be.like({552        address: helper.ethAddress.fromCollectionId(collection.collectionId),553        event: 'Transfer',554        returnValues: {555          from: helper.address.substrateToEth(owner.address),556          to: helper.address.substrateToEth(receiver.address),557          tokenId: token.tokenId.toString(),558        },559      });560    }561562    expect(await token.getOwner()).to.be.like({Substrate: receiver.address});563  });564565  itEth('Can perform transfer()', async ({helper}) => {566    const collection = await helper.nft.mintCollection(minter, {});567    const owner = await helper.eth.createAccountWithBalance(donor);568    const receiver = helper.eth.createAccount();569570    const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});571572    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);573    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);574575    {576      const result = await contract.methods.transfer(receiver, tokenId).send({from: owner});577578      const event = result.events.Transfer;579      expect(event.address).to.be.equal(collectionAddress);580      expect(event.returnValues.from).to.be.equal(owner);581      expect(event.returnValues.to).to.be.equal(receiver);582      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);583    }584585    {586      const balance = await contract.methods.balanceOf(owner).call();587      expect(+balance).to.equal(0);588    }589590    {591      const balance = await contract.methods.balanceOf(receiver).call();592      expect(+balance).to.equal(1);593    }594  });595596  itEth('Can perform transferCross()', async ({helper}) => {597    const collection = await helper.nft.mintCollection(minter, {});598    const owner = await helper.eth.createAccountWithBalance(donor);599    const receiverEth = await helper.eth.createAccountWithBalance(donor);600    const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);601    const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(minter);602603    const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});604605    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);606    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);607608    {609      // Can transferCross to ethereum address:610      const result = await collectionEvm.methods.transferCross(receiverCrossEth, tokenId).send({from: owner});611      // Check events:612      const event = result.events.Transfer;613      expect(event.address).to.be.equal(collectionAddress);614      expect(event.returnValues.from).to.be.equal(owner);615      expect(event.returnValues.to).to.be.equal(receiverEth);616      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);617618      // owner has balance = 0:619      const ownerBalance = await collectionEvm.methods.balanceOf(owner).call();620      expect(+ownerBalance).to.equal(0);621      // receiver owns token:622      const receiverBalance = await collectionEvm.methods.balanceOf(receiverEth).call();623      expect(+receiverBalance).to.equal(1);624      expect(await helper.nft.getTokenOwner(collection.collectionId, tokenId)).to.deep.eq({Ethereum: receiverEth.toLowerCase()});625    }626627    {628      // Can transferCross to substrate address:629      const substrateResult = await collectionEvm.methods.transferCross(receiverCrossSub, tokenId).send({from: receiverEth});630      // Check events:631      const event = substrateResult.events.Transfer;632      expect(event.address).to.be.equal(collectionAddress);633      expect(event.returnValues.from).to.be.equal(receiverEth);634      expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(minter.address));635      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);636637      // owner has balance = 0:638      const ownerBalance = await collectionEvm.methods.balanceOf(receiverEth).call();639      expect(+ownerBalance).to.equal(0);640      // receiver owns token:641      const receiverBalance = await helper.nft.getTokensByAddress(collection.collectionId, {Substrate: minter.address});642      expect(receiverBalance).to.contain(tokenId);643    }644  });645646  ['transfer', 'transferCross'].map(testCase => itEth(`Cannot ${testCase} non-owned token`, async ({helper}) => {647    const sender = await helper.eth.createAccountWithBalance(donor);648    const tokenOwner = await helper.eth.createAccountWithBalance(donor);649    const receiverSub = minter;650    const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(minter);651652    const collection = await helper.nft.mintCollection(minter, {});653    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);654    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', sender);655656    await collection.mintToken(minter, {Ethereum: sender});657    const nonSendersToken = await collection.mintToken(minter, {Ethereum: tokenOwner});658659    // Cannot transferCross someone else's token:660    const receiver = testCase === 'transfer' ? helper.address.substrateToEth(receiverSub.address) : receiverCrossSub;661    await expect(collectionEvm.methods[testCase](receiver, nonSendersToken.tokenId).send({from: sender})).to.be.rejected;662    // Cannot transfer token if it does not exist:663    await expect(collectionEvm.methods[testCase](receiver, 999999).send({from: sender})).to.be.rejected;664  }));665666  itEth('Check balanceOfCross()', async ({helper}) => {667    const collection = await helper.nft.mintCollection(minter, {});668    const owner = await helper.ethCrossAccount.createAccountWithBalance(donor);669    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);670    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner.eth);671672    expect(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq('0');673674    for (let i = 1; i < 10; i++) {675      await collection.mintToken(minter, {Ethereum: owner.eth});676      expect(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq(i.toString());677    }678  });679680  itEth('Check ownerOfCross()', async ({helper}) => {681    const collection = await helper.nft.mintCollection(minter, {});682    let owner = await helper.ethCrossAccount.createAccountWithBalance(donor);683    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);684    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner.eth);685    const {tokenId} = await collection.mintToken(minter, {Ethereum: owner.eth});686687    for (let i = 1n; i < 10n; i++) {688      const ownerCross = await collectionEvm.methods.ownerOfCross(tokenId).call({from: owner.eth});689      expect(ownerCross.eth).to.be.eq(owner.eth);690      expect(ownerCross.sub).to.be.eq(owner.sub);691692      const newOwner = await helper.ethCrossAccount.createAccountWithBalance(donor);693      await collectionEvm.methods.transferCross(newOwner, tokenId).send({from: owner.eth});694      owner = newOwner;695    }696  });697});698699describe('NFT: Fees', () => {700  let donor: IKeyringPair;701  let alice: IKeyringPair;702  let bob: IKeyringPair;703  let charlie: IKeyringPair;704705  before(async function() {706    await usingEthPlaygrounds(async (helper, privateKey) => {707      donor = await privateKey({url: import.meta.url});708      [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);709    });710  });711712  itEth('approve() call fee is less than 0.2UNQ', async ({helper}) => {713    const owner = await helper.eth.createAccountWithBalance(donor);714    const spender = helper.eth.createAccount();715716    const collection = await helper.nft.mintCollection(alice, {});717    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});718719    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);720721    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, tokenId).send({from: owner}));722    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));723  });724725  itEth('transferFrom() call fee is less than 0.2UNQ', async ({helper}) => {726    const owner = await helper.eth.createAccountWithBalance(donor);727    const spender = await helper.eth.createAccountWithBalance(donor);728729    const collection = await helper.nft.mintCollection(alice, {});730    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});731732    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);733734    await contract.methods.approve(spender, tokenId).send({from: owner});735736    const cost = await helper.eth.recordCallFee(spender, () => contract.methods.transferFrom(owner, spender, tokenId).send({from: spender}));737    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));738  });739740  itEth('Can perform transferFromCross()', async ({helper}) => {741    const collectionMinter = alice;742    const owner = bob;743    const receiver = charlie;744    const collection = await helper.nft.mintCollection(collectionMinter, {name: 'A', description: 'B', tokenPrefix: 'C'});745746    const spender = await helper.eth.createAccountWithBalance(donor);747748    const token = await collection.mintToken(collectionMinter, {Substrate: owner.address});749750    const address = helper.ethAddress.fromCollectionId(collection.collectionId);751    const contract = await helper.ethNativeContract.collection(address, 'nft');752753    await token.approve(owner, {Ethereum: spender});754755    {756      const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);757      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);758      const result = await contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender});759      const event = result.events.Transfer;760      expect(event).to.be.like({761        address: helper.ethAddress.fromCollectionId(collection.collectionId),762        event: 'Transfer',763        returnValues: {764          from: helper.address.substrateToEth(owner.address),765          to: helper.address.substrateToEth(receiver.address),766          tokenId: token.tokenId.toString(),767        },768      });769    }770771    expect(await token.getOwner()).to.be.like({Substrate: receiver.address});772  });773774  itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {775    const owner = await helper.eth.createAccountWithBalance(donor);776    const receiver = helper.eth.createAccount();777778    const collection = await helper.nft.mintCollection(alice, {});779    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});780781    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);782783    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, tokenId).send({from: owner}));784    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));785  });786});787788describe('NFT: Substrate calls', () => {789  let donor: IKeyringPair;790  let alice: IKeyringPair;791792  before(async function() {793    await usingEthPlaygrounds(async (helper, privateKey) => {794      donor = await privateKey({url: import.meta.url});795      [alice] = await helper.arrange.createAccounts([20n], donor);796    });797  });798799  itEth('Events emitted for mint()', async ({helper}) => {800    const collection = await helper.nft.mintCollection(alice, {});801    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);802    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');803804    const events: any = [];805    contract.events.allEvents((_: any, event: any) => {806      events.push(event);807    });808809    const {tokenId} = await collection.mintToken(alice);810    if (events.length == 0) await helper.wait.newBlocks(1);811    const event = events[0];812813    expect(event.event).to.be.equal('Transfer');814    expect(event.address).to.be.equal(collectionAddress);815    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');816    expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(alice.address));817    expect(event.returnValues.tokenId).to.be.equal(tokenId.toString());818  });819820  itEth('Events emitted for burn()', async ({helper}) => {821    const collection = await helper.nft.mintCollection(alice, {});822    const token = await collection.mintToken(alice);823824    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);825    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');826827    const events: any = [];828    contract.events.allEvents((_: any, event: any) => {829      events.push(event);830    });831832    await token.burn(alice);833    if (events.length == 0) await helper.wait.newBlocks(1);834    const event = events[0];835836    expect(event.event).to.be.equal('Transfer');837    expect(event.address).to.be.equal(collectionAddress);838    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));839    expect(event.returnValues.to).to.be.equal('0x0000000000000000000000000000000000000000');840    expect(event.returnValues.tokenId).to.be.equal(token.tokenId.toString());841  });842843  itEth('Events emitted for approve()', async ({helper}) => {844    const receiver = helper.eth.createAccount();845846    const collection = await helper.nft.mintCollection(alice, {});847    const token = await collection.mintToken(alice);848849    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);850    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');851852    const events: any = [];853    contract.events.allEvents((_: any, event: any) => {854      events.push(event);855    });856857    await token.approve(alice, {Ethereum: receiver});858    if (events.length == 0) await helper.wait.newBlocks(1);859    const event = events[0];860861    expect(event.event).to.be.equal('Approval');862    expect(event.address).to.be.equal(collectionAddress);863    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));864    expect(event.returnValues.approved).to.be.equal(receiver);865    expect(event.returnValues.tokenId).to.be.equal(token.tokenId.toString());866  });867868  itEth('Events emitted for transferFrom()', async ({helper}) => {869    const [bob] = await helper.arrange.createAccounts([10n], donor);870    const receiver = helper.eth.createAccount();871872    const collection = await helper.nft.mintCollection(alice, {});873    const token = await collection.mintToken(alice);874    await token.approve(alice, {Substrate: bob.address});875876    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);877    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');878879    const events: any = [];880    contract.events.allEvents((_: any, event: any) => {881      events.push(event);882    });883884    await token.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver});885886    if (events.length == 0) await helper.wait.newBlocks(1);887    const event = events[0];888889    expect(event.address).to.be.equal(collectionAddress);890    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));891    expect(event.returnValues.to).to.be.equal(receiver);892    expect(event.returnValues.tokenId).to.be.equal(`${token.tokenId}`);893  });894895  itEth('Events emitted for transfer()', async ({helper}) => {896    const receiver = helper.eth.createAccount();897898    const collection = await helper.nft.mintCollection(alice, {});899    const token = await collection.mintToken(alice);900901    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);902    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');903904    const events: any = [];905    contract.events.allEvents((_: any, event: any) => {906      events.push(event);907    });908909    await token.transfer(alice, {Ethereum: receiver});910911    if (events.length == 0) await helper.wait.newBlocks(1);912    const event = events[0];913914    expect(event.address).to.be.equal(collectionAddress);915    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));916    expect(event.returnValues.to).to.be.equal(receiver);917    expect(event.returnValues.tokenId).to.be.equal(`${token.tokenId}`);918  });919});920921describe('Common metadata', () => {922  let donor: IKeyringPair;923  let alice: IKeyringPair;924925  before(async function() {926    await usingEthPlaygrounds(async (helper, privateKey) => {927      donor = await privateKey({url: import.meta.url});928      [alice] = await helper.arrange.createAccounts([20n], donor);929    });930  });931932  itEth('Returns collection name', async ({helper}) => {933    // FIXME: should not have balance to use .call()934    const caller = await helper.eth.createAccountWithBalance(donor);935    const tokenPropertyPermissions = [{936      key: 'URI',937      permission: {938        mutable: true,939        collectionAdmin: true,940        tokenOwner: false,941      },942    }];943    const collection = await helper.nft.mintCollection(944      alice,945      {946        name: 'oh River',947        tokenPrefix: 'CHANGE',948        properties: [{key: 'ERC721Metadata', value: '1'}],949        tokenPropertyPermissions,950      },951    );952953    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);954    const name = await contract.methods.name().call();955    expect(name).to.equal('oh River');956  });957958  itEth('Returns symbol name', async ({helper}) => {959    const caller = await helper.eth.createAccountWithBalance(donor);960    const tokenPropertyPermissions = [{961      key: 'URI',962      permission: {963        mutable: true,964        collectionAdmin: true,965        tokenOwner: false,966      },967    }];968    const collection = await helper.nft.mintCollection(969      alice,970      {971        name: 'oh River',972        tokenPrefix: 'CHANGE',973        properties: [{key: 'ERC721Metadata', value: '1'}],974        tokenPropertyPermissions,975      },976    );977978    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);979    const symbol = await contract.methods.symbol().call();980    expect(symbol).to.equal('CHANGE');981  });982});983984describe('Negative tests', () => {985  let donor: IKeyringPair;986  let minter: IKeyringPair;987  let alice: IKeyringPair;988989  before(async function() {990    await usingEthPlaygrounds(async (helper, privateKey) => {991      donor = await privateKey({url: import.meta.url});992      [minter, alice] = await helper.arrange.createAccounts([100n, 100n], donor);993    });994  });995996  itEth('[negative] Cant perform burn without approval', async ({helper}) => {997    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});998999    const owner = await helper.eth.createAccountWithBalance(donor);1000    const spender = await helper.eth.createAccountWithBalance(donor);10011002    const token = await collection.mintToken(minter, {Ethereum: owner});10031004    const address = helper.ethAddress.fromCollectionId(collection.collectionId);1005    const contract = await helper.ethNativeContract.collection(address, 'nft');10061007    const ownerCross = helper.ethCrossAccount.fromAddress(owner);1008    await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;10091010    await contract.methods.setApprovalForAll(spender, true).send({from: owner});1011    await contract.methods.setApprovalForAll(spender, false).send({from: owner});10121013    await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;1014  });10151016  itEth('[negative] Cant perform transfer without approval', async ({helper}) => {1017    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});1018    const receiver = alice;10191020    const owner = await helper.eth.createAccountWithBalance(donor);1021    const spender = await helper.eth.createAccountWithBalance(donor);10221023    const token = await collection.mintToken(minter, {Ethereum: owner});10241025    const address = helper.ethAddress.fromCollectionId(collection.collectionId);1026    const contract = await helper.ethNativeContract.collection(address, 'nft');10271028    const ownerCross = helper.ethCrossAccount.fromAddress(owner);1029    const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);10301031    await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;10321033    await contract.methods.setApprovalForAll(spender, true).send({from: owner});1034    await contract.methods.setApprovalForAll(spender, false).send({from: owner});10351036    await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;1037  });1038});
after · tests/src/eth/nonFungible.test.ts
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';20import {ITokenPropertyPermission} from '../util/playgrounds/types';2122describe('Check ERC721 token URI for NFT', () => {23  let donor: IKeyringPair;2425  before(async function() {26    await usingEthPlaygrounds(async (_helper, privateKey) => {27      donor = await privateKey({url: import.meta.url});28    });29  });3031  async function setup(helper: EthUniqueHelper, baseUri: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {32    const owner = await helper.eth.createAccountWithBalance(donor);33    const receiver = helper.eth.createAccount();3435    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', 'a', 'b', baseUri);36    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);3738    const result = await contract.methods.mint(receiver).send();39    const tokenId = result.events.Transfer.returnValues.tokenId;40    expect(tokenId).to.be.equal('1');4142    if (propertyKey && propertyValue) {43      // Set URL or suffix44      await contract.methods.setProperties(tokenId, [{key: propertyKey, value: Buffer.from(propertyValue)}]).send();45    }4647    const event = result.events.Transfer;48    expect(event.address).to.be.equal(collectionAddress);49    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');50    expect(event.returnValues.to).to.be.equal(receiver);51    expect(event.returnValues.tokenId).to.be.equal(tokenId);5253    return {contract, nextTokenId: tokenId};54  }5556  itEth('Empty tokenURI', async ({helper}) => {57    const {contract, nextTokenId} = await setup(helper, '');58    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('');59  });6061  itEth('TokenURI from url', async ({helper}) => {62    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URI', 'Token URI');63    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');64  });6566  itEth('TokenURI from baseURI', async ({helper}) => {67    const {contract, nextTokenId} = await setup(helper, 'BaseURI_');68    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_');69  });7071  itEth('TokenURI from baseURI + suffix', async ({helper}) => {72    const suffix = '/some/suffix';73    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URISuffix', suffix);74    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);75  });76});7778describe('NFT: Plain calls', () => {79  let donor: IKeyringPair;80  let minter: IKeyringPair;81  let bob: IKeyringPair;82  let charlie: IKeyringPair;8384  before(async function() {85    await usingEthPlaygrounds(async (helper, privateKey) => {86      donor = await privateKey({url: import.meta.url});87      [minter, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);88    });89  });9091  // TODO combine all minting tests in one place92  [93    'substrate' as const,94    'ethereum' as const,95  ].map(testCase => {96    itEth(`Can perform mintCross() for ${testCase} address`, async ({helper}) => {97      const collectionAdmin = await helper.eth.createAccountWithBalance(donor);9899      const receiverEth = helper.eth.createAccount();100      const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);101      const receiverSub = bob;102      const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(receiverSub);103104      // const receiverCross = helper.ethCrossAccount.fromKeyringPair(bob);105      const properties = Array(5).fill(0).map((_, i) => ({key: `key_${i}`, value: Buffer.from(`value_${i}`)}));106      const permissions: ITokenPropertyPermission[] = properties107        .map(p => ({108          key: p.key, permission: {109            tokenOwner: false,110            collectionAdmin: true,111            mutable: false,112          },113        }));114115      const collection = await helper.nft.mintCollection(minter, {116        tokenPrefix: 'ethp',117        tokenPropertyPermissions: permissions,118      });119      await collection.addAdmin(minter, {Ethereum: collectionAdmin});120121      const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);122      const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', collectionAdmin, true);123      let expectedTokenId = await contract.methods.nextTokenId().call();124      let result = await contract.methods.mintCross(testCase === 'ethereum' ? receiverCrossEth : receiverCrossSub, []).send();125      let tokenId = result.events.Transfer.returnValues.tokenId;126      expect(tokenId).to.be.equal(expectedTokenId);127128      let event = result.events.Transfer;129      expect(event.address).to.be.equal(collectionAddress);130      expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');131      expect(event.returnValues.to).to.be.equal(testCase === 'ethereum' ? receiverEth : helper.address.substrateToEth(bob.address));132      expect(await contract.methods.properties(tokenId, []).call()).to.be.like([]);133134      expectedTokenId = await contract.methods.nextTokenId().call();135      result = await contract.methods.mintCross(testCase === 'ethereum' ? receiverCrossEth : receiverCrossSub, properties).send();136      event = result.events.Transfer;137      expect(event.address).to.be.equal(collectionAddress);138      expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');139      expect(event.returnValues.to).to.be.equal(testCase === 'ethereum' ? receiverEth : helper.address.substrateToEth(bob.address));140      expect(await contract.methods.properties(tokenId, []).call()).to.be.like([]);141142      tokenId = result.events.Transfer.returnValues.tokenId;143144      expect(tokenId).to.be.equal(expectedTokenId);145146      expect(await contract.methods.properties(tokenId, []).call()).to.be.like(properties147        .map(p => helper.ethProperty.property(p.key, p.value.toString())));148149      expect(await helper.nft.getTokenOwner(collection.collectionId, tokenId))150        .to.deep.eq(testCase === 'ethereum' ? {Ethereum: receiverEth.toLowerCase()} : {Substrate: receiverSub.address});151    });152  });153154  itEth('Non-owner and non admin cannot mintCross', async ({helper}) => {155    const nonOwner = await helper.eth.createAccountWithBalance(donor);156    const nonOwnerCross = helper.ethCrossAccount.fromAddress(nonOwner);157158    const collection = await helper.nft.mintCollection(minter);159    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);160    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft');161162    await expect(collectionEvm.methods.mintCross(nonOwnerCross, []).call({from: nonOwner}))163      .to.be.rejectedWith('PublicMintingNotAllowed');164  });165166  //TODO: CORE-302 add eth methods167  itEth.skip('Can perform mintBulk()', async ({helper}) => {168    const caller = await helper.eth.createAccountWithBalance(donor);169    const receiver = helper.eth.createAccount();170171    const collection = await helper.nft.mintCollection(minter);172    await collection.addAdmin(minter, {Ethereum: caller});173174    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);175    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', caller);176    {177      const bulkSize = 3;178      const nextTokenId = await contract.methods.nextTokenId().call();179      expect(nextTokenId).to.be.equal('1');180      const result = await contract.methods.mintBulkWithTokenURI(181        receiver,182        Array.from({length: bulkSize}, (_, i) => (183          [+nextTokenId + i, `Test URI ${i}`]184        )),185      ).send({from: caller});186187      const events = result.events.Transfer.sort((a: any, b: any) => +a.returnValues.tokenId - b.returnValues.tokenId);188      for (let i = 0; i < bulkSize; i++) {189        const event = events[i];190        expect(event.address).to.equal(collectionAddress);191        expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');192        expect(event.returnValues.to).to.equal(receiver);193        expect(event.returnValues.tokenId).to.equal(`${+nextTokenId + i}`);194195        expect(await contract.methods.tokenURI(+nextTokenId + i).call()).to.be.equal(`Test URI ${i}`);196      }197    }198  });199200  itEth('Can perform burn()', async ({helper}) => {201    const caller = await helper.eth.createAccountWithBalance(donor);202203    const collection = await helper.nft.mintCollection(minter, {});204    const {tokenId} = await collection.mintToken(minter, {Ethereum: caller});205206    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);207    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', caller);208209    {210      const result = await contract.methods.burn(tokenId).send({from: caller});211212      const event = result.events.Transfer;213      expect(event.address).to.be.equal(collectionAddress);214      expect(event.returnValues.from).to.be.equal(caller);215      expect(event.returnValues.to).to.be.equal('0x0000000000000000000000000000000000000000');216      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);217    }218  });219220  itEth('Can perform approve()', async ({helper}) => {221    const owner = await helper.eth.createAccountWithBalance(donor);222    const spender = helper.eth.createAccount();223224    const collection = await helper.nft.mintCollection(minter, {});225    const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});226227    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);228    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);229230    {231      const badTokenId = await contract.methods.nextTokenId().call() + 1;232      await expect(contract.methods.getApproved(badTokenId).call()).to.be.rejectedWith('revert TokenNotFound');233    }234    {235      const approved = await contract.methods.getApproved(tokenId).call();236      expect(approved).to.be.equal('0x0000000000000000000000000000000000000000');237    }238    {239      const result = await contract.methods.approve(spender, tokenId).send({from: owner});240241      const event = result.events.Approval;242      expect(event.address).to.be.equal(collectionAddress);243      expect(event.returnValues.owner).to.be.equal(owner);244      expect(event.returnValues.approved).to.be.equal(spender);245      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);246    }247    {248      const approved = await contract.methods.getApproved(tokenId).call();249      expect(approved).to.be.equal(spender);250    }251  });252253  itEth('Can perform setApprovalForAll()', async ({helper}) => {254    const owner = await helper.eth.createAccountWithBalance(donor);255    const operator = helper.eth.createAccount();256257    const collection = await helper.nft.mintCollection(minter, {});258259    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);260    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);261262    const approvedBefore = await contract.methods.isApprovedForAll(owner, operator).call();263    expect(approvedBefore).to.be.equal(false);264265    {266      const result = await contract.methods.setApprovalForAll(operator, true).send({from: owner});267268      expect(result.events.ApprovalForAll).to.be.like({269        address: collectionAddress,270        event: 'ApprovalForAll',271        returnValues: {272          owner,273          operator,274          approved: true,275        },276      });277278      const approvedAfter = await contract.methods.isApprovedForAll(owner, operator).call();279      expect(approvedAfter).to.be.equal(true);280    }281282    {283      const result = await contract.methods.setApprovalForAll(operator, false).send({from: owner});284285      expect(result.events.ApprovalForAll).to.be.like({286        address: collectionAddress,287        event: 'ApprovalForAll',288        returnValues: {289          owner,290          operator,291          approved: false,292        },293      });294295      const approvedAfter = await contract.methods.isApprovedForAll(owner, operator).call();296      expect(approvedAfter).to.be.equal(false);297    }298  });299300  itEth('Can perform burn with ApprovalForAll', async ({helper}) => {301    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});302303    const owner = await helper.eth.createAccountWithBalance(donor);304    const operator = await helper.eth.createAccountWithBalance(donor);305306    const token = await collection.mintToken(minter, {Ethereum: owner});307308    const address = helper.ethAddress.fromCollectionId(collection.collectionId);309    const contract = await helper.ethNativeContract.collection(address, 'nft');310311    {312      await contract.methods.setApprovalForAll(operator, true).send({from: owner});313      const ownerCross = helper.ethCrossAccount.fromAddress(owner);314      const result = await contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: operator});315      const events = result.events.Transfer;316317      expect(events).to.be.like({318        address,319        event: 'Transfer',320        returnValues: {321          from: owner,322          to: '0x0000000000000000000000000000000000000000',323          tokenId: token.tokenId.toString(),324        },325      });326    }327328    expect(await helper.nft.doesTokenExist(collection.collectionId, token.tokenId)).to.be.false;329  });330331  itEth('Can perform transfer with ApprovalForAll', async ({helper}) => {332    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});333334    const owner = await helper.eth.createAccountWithBalance(donor);335    const operator = await helper.eth.createAccountWithBalance(donor);336    const receiver = charlie;337338    const token = await collection.mintToken(minter, {Ethereum: owner});339340    const address = helper.ethAddress.fromCollectionId(collection.collectionId);341    const contract = await helper.ethNativeContract.collection(address, 'nft');342343    {344      await contract.methods.setApprovalForAll(operator, true).send({from: owner});345      const ownerCross = helper.ethCrossAccount.fromAddress(owner);346      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);347      const result = await contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: operator});348      const event = result.events.Transfer;349      expect(event).to.be.like({350        address: helper.ethAddress.fromCollectionId(collection.collectionId),351        event: 'Transfer',352        returnValues: {353          from: owner,354          to: helper.address.substrateToEth(receiver.address),355          tokenId: token.tokenId.toString(),356        },357      });358    }359360    expect(await token.getOwner()).to.be.like({Substrate: receiver.address});361  });362363  itEth('Can perform burnFromCross()', async ({helper}) => {364    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});365    const ownerSub = bob;366    const ownerCrossSub = helper.ethCrossAccount.fromKeyringPair(ownerSub);367    const ownerEth = await helper.eth.createAccountWithBalance(donor);368    const ownerCrossEth = helper.ethCrossAccount.fromAddress(ownerEth);369370    const burnerEth = await helper.eth.createAccountWithBalance(donor);371    const burnerCrossEth = helper.ethCrossAccount.fromAddress(burnerEth);372373    const token1 = await collection.mintToken(minter, {Substrate: ownerSub.address});374    const token2 = await collection.mintToken(minter, {Ethereum: ownerEth});375376    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);377    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft');378379    // Approve tokens from substrate and ethereum:380    await token1.approve(ownerSub, {Ethereum: burnerEth});381    await collectionEvm.methods.approveCross(burnerCrossEth, token2.tokenId).send({from: ownerEth});382383    // can burnFromCross:384    const result1 = await collectionEvm.methods.burnFromCross(ownerCrossSub, token1.tokenId).send({from: burnerEth});385    const result2 = await collectionEvm.methods.burnFromCross(ownerCrossEth, token2.tokenId).send({from: burnerEth});386    const events1 = result1.events.Transfer;387    const events2 = result2.events.Transfer;388389    // Check events for burnFromCross (substrate and ethereum):390    [391      [events1, token1, helper.address.substrateToEth(ownerSub.address)],392      [events2, token2, ownerEth],393    ].map(burnData => {394      expect(burnData[0]).to.be.like({395        address: collectionAddress,396        event: 'Transfer',397        returnValues: {398          from: burnData[2],399          to: '0x0000000000000000000000000000000000000000',400          tokenId: burnData[1].tokenId.toString(),401        },402      });403    });404405    expect(await token1.doesExist()).to.be.false;406    expect(await token2.doesExist()).to.be.false;407  });408409  // TODO combine all approve tests in one place410  itEth('Can perform approveCross()', async ({helper}) => {411    // arrange: create accounts412    const owner = await helper.eth.createAccountWithBalance(donor);413    const ownerCross = helper.ethCrossAccount.fromAddress(owner);414    const receiverSub = charlie;415    const recieverCrossSub = helper.ethCrossAccount.fromKeyringPair(receiverSub);416    const receiverEth = await helper.eth.createAccountWithBalance(donor);417    const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);418419    // arrange: create collection and tokens:420    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});421    const token1 = await collection.mintToken(minter, {Ethereum: owner});422    const token2 = await collection.mintToken(minter, {Ethereum: owner});423424    const collectionEvm = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');425426    // Can approveCross substrate and ethereum address:427    const resultSub = await collectionEvm.methods.approveCross(recieverCrossSub, token1.tokenId).send({from: owner});428    const resultEth = await collectionEvm.methods.approveCross(receiverCrossEth, token2.tokenId).send({from: owner});429    const eventSub = resultSub.events.Approval;430    const eventEth = resultEth.events.Approval;431    expect(eventSub).to.be.like({432      address: helper.ethAddress.fromCollectionId(collection.collectionId),433      event: 'Approval',434      returnValues: {435        owner,436        approved: helper.address.substrateToEth(receiverSub.address),437        tokenId: token1.tokenId.toString(),438      },439    });440    expect(eventEth).to.be.like({441      address: helper.ethAddress.fromCollectionId(collection.collectionId),442      event: 'Approval',443      returnValues: {444        owner,445        approved: receiverEth,446        tokenId: token2.tokenId.toString(),447      },448    });449450    // Substrate address can transferFrom approved tokens:451    await helper.nft.transferTokenFrom(receiverSub, collection.collectionId, token1.tokenId, {Ethereum: owner}, {Substrate: receiverSub.address});452    expect(await helper.nft.getTokenOwner(collection.collectionId, token1.tokenId)).to.deep.eq({Substrate: receiverSub.address});453    // Ethereum address can transferFromCross approved tokens:454    await collectionEvm.methods.transferFromCross(ownerCross, receiverCrossEth, token2.tokenId).send({from: receiverEth});455    expect(await helper.nft.getTokenOwner(collection.collectionId, token2.tokenId)).to.deep.eq({Ethereum: receiverEth.toLowerCase()});456  });457458  itEth('Non-owner and non admin cannot approveCross', async ({helper}) => {459    const nonOwner = await helper.eth.createAccountWithBalance(donor);460    const nonOwnerCross = helper.ethCrossAccount.fromAddress(nonOwner);461    const owner = await helper.eth.createAccountWithBalance(donor);462    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});463    const collectionEvm = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');464    const token = await collection.mintToken(minter, {Ethereum: owner});465466    await expect(collectionEvm.methods.approveCross(nonOwnerCross, token.tokenId).call({from: nonOwner})).to.be.rejectedWith('CantApproveMoreThanOwned');467  });468469  itEth('Can reaffirm approved address', async ({helper}) => {470    const owner = await helper.eth.createAccountWithBalance(donor);471    const ownerCrossEth = helper.ethCrossAccount.fromAddress(owner);472    const [receiver1, receiver2] = await helper.arrange.createAccounts([100n, 100n], donor);473    const receiver1Cross = helper.ethCrossAccount.fromKeyringPair(receiver1);474    const receiver2Cross = helper.ethCrossAccount.fromKeyringPair(receiver2);475    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});476    const token1 = await collection.mintToken(minter, {Ethereum: owner});477    const token2 = await collection.mintToken(minter, {Ethereum: owner});478    const collectionEvm = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');479480    // Can approve and reaffirm approved address:481    await collectionEvm.methods.approveCross(receiver1Cross, token1.tokenId).send({from: owner});482    await collectionEvm.methods.approveCross(receiver2Cross, token1.tokenId).send({from: owner});483484    // receiver1 cannot transferFrom:485    await expect(helper.nft.transferTokenFrom(receiver1, collection.collectionId, token1.tokenId, {Ethereum: owner}, {Substrate: receiver1.address})).to.be.rejected;486    // receiver2 can transferFrom:487    await helper.nft.transferTokenFrom(receiver2, collection.collectionId, token1.tokenId, {Ethereum: owner}, {Substrate: receiver2.address});488489    // can set approved address to self address to remove approval:490    await collectionEvm.methods.approveCross(receiver1Cross, token2.tokenId).send({from: owner});491    await collectionEvm.methods.approveCross(ownerCrossEth, token2.tokenId).send({from: owner});492493    // receiver1 cannot transfer token anymore:494    await expect(helper.nft.transferTokenFrom(receiver1, collection.collectionId, token2.tokenId, {Ethereum: owner}, {Substrate: receiver1.address})).to.be.rejected;495  });496497  itEth('Can perform transferFrom()', async ({helper}) => {498    const owner = await helper.eth.createAccountWithBalance(donor);499    const spender = await helper.eth.createAccountWithBalance(donor);500    const receiver = helper.eth.createAccount();501502    const collection = await helper.nft.mintCollection(minter, {});503    const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});504505    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);506    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);507508    await contract.methods.approve(spender, tokenId).send({from: owner});509510    {511      const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({from: spender});512513      const event = result.events.Transfer;514      expect(event.address).to.be.equal(collectionAddress);515      expect(event.returnValues.from).to.be.equal(owner);516      expect(event.returnValues.to).to.be.equal(receiver);517      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);518    }519520    {521      const balance = await contract.methods.balanceOf(receiver).call();522      expect(+balance).to.equal(1);523    }524525    {526      const balance = await contract.methods.balanceOf(owner).call();527      expect(+balance).to.equal(0);528    }529  });530531  itEth('Can perform transferFromCross()', async ({helper}) => {532    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});533534    const [owner, receiver] = await helper.arrange.createAccounts([100n, 100n], donor);535    const spender = await helper.eth.createAccountWithBalance(donor);536537    const token = await collection.mintToken(minter, {Substrate: owner.address});538539    const address = helper.ethAddress.fromCollectionId(collection.collectionId);540    const contract = await helper.ethNativeContract.collection(address, 'nft');541542    await token.approve(owner, {Ethereum: spender});543544    {545      const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);546      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);547      const result = await contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender});548      const event = result.events.Transfer;549      expect(event).to.be.like({550        address: helper.ethAddress.fromCollectionId(collection.collectionId),551        event: 'Transfer',552        returnValues: {553          from: helper.address.substrateToEth(owner.address),554          to: helper.address.substrateToEth(receiver.address),555          tokenId: token.tokenId.toString(),556        },557      });558    }559560    expect(await token.getOwner()).to.be.like({Substrate: receiver.address});561  });562563  itEth('Can perform transfer()', async ({helper}) => {564    const collection = await helper.nft.mintCollection(minter, {});565    const owner = await helper.eth.createAccountWithBalance(donor);566    const receiver = helper.eth.createAccount();567568    const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});569570    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);571    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);572573    {574      const result = await contract.methods.transfer(receiver, tokenId).send({from: owner});575576      const event = result.events.Transfer;577      expect(event.address).to.be.equal(collectionAddress);578      expect(event.returnValues.from).to.be.equal(owner);579      expect(event.returnValues.to).to.be.equal(receiver);580      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);581    }582583    {584      const balance = await contract.methods.balanceOf(owner).call();585      expect(+balance).to.equal(0);586    }587588    {589      const balance = await contract.methods.balanceOf(receiver).call();590      expect(+balance).to.equal(1);591    }592  });593594  itEth('Can perform transferCross()', async ({helper}) => {595    const collection = await helper.nft.mintCollection(minter, {});596    const owner = await helper.eth.createAccountWithBalance(donor);597    const receiverEth = await helper.eth.createAccountWithBalance(donor);598    const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);599    const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(minter);600601    const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});602603    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);604    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);605606    {607      // Can transferCross to ethereum address:608      const result = await collectionEvm.methods.transferCross(receiverCrossEth, tokenId).send({from: owner});609      // Check events:610      const event = result.events.Transfer;611      expect(event.address).to.be.equal(collectionAddress);612      expect(event.returnValues.from).to.be.equal(owner);613      expect(event.returnValues.to).to.be.equal(receiverEth);614      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);615616      // owner has balance = 0:617      const ownerBalance = await collectionEvm.methods.balanceOf(owner).call();618      expect(+ownerBalance).to.equal(0);619      // receiver owns token:620      const receiverBalance = await collectionEvm.methods.balanceOf(receiverEth).call();621      expect(+receiverBalance).to.equal(1);622      expect(await helper.nft.getTokenOwner(collection.collectionId, tokenId)).to.deep.eq({Ethereum: receiverEth.toLowerCase()});623    }624625    {626      // Can transferCross to substrate address:627      const substrateResult = await collectionEvm.methods.transferCross(receiverCrossSub, tokenId).send({from: receiverEth});628      // Check events:629      const event = substrateResult.events.Transfer;630      expect(event.address).to.be.equal(collectionAddress);631      expect(event.returnValues.from).to.be.equal(receiverEth);632      expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(minter.address));633      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);634635      // owner has balance = 0:636      const ownerBalance = await collectionEvm.methods.balanceOf(receiverEth).call();637      expect(+ownerBalance).to.equal(0);638      // receiver owns token:639      const receiverBalance = await helper.nft.getTokensByAddress(collection.collectionId, {Substrate: minter.address});640      expect(receiverBalance).to.contain(tokenId);641    }642  });643644  ['transfer', 'transferCross'].map(testCase => itEth(`Cannot ${testCase} non-owned token`, async ({helper}) => {645    const sender = await helper.eth.createAccountWithBalance(donor);646    const tokenOwner = await helper.eth.createAccountWithBalance(donor);647    const receiverSub = minter;648    const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(minter);649650    const collection = await helper.nft.mintCollection(minter, {});651    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);652    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', sender);653654    await collection.mintToken(minter, {Ethereum: sender});655    const nonSendersToken = await collection.mintToken(minter, {Ethereum: tokenOwner});656657    // Cannot transferCross someone else's token:658    const receiver = testCase === 'transfer' ? helper.address.substrateToEth(receiverSub.address) : receiverCrossSub;659    await expect(collectionEvm.methods[testCase](receiver, nonSendersToken.tokenId).send({from: sender})).to.be.rejected;660    // Cannot transfer token if it does not exist:661    await expect(collectionEvm.methods[testCase](receiver, 999999).send({from: sender})).to.be.rejected;662  }));663664  itEth('Check balanceOfCross()', async ({helper}) => {665    const collection = await helper.nft.mintCollection(minter, {});666    const owner = await helper.ethCrossAccount.createAccountWithBalance(donor);667    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);668    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner.eth);669670    expect(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq('0');671672    for (let i = 1; i < 10; i++) {673      await collection.mintToken(minter, {Ethereum: owner.eth});674      expect(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq(i.toString());675    }676  });677678  itEth('Check ownerOfCross()', async ({helper}) => {679    const collection = await helper.nft.mintCollection(minter, {});680    let owner = await helper.ethCrossAccount.createAccountWithBalance(donor);681    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);682    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner.eth);683    const {tokenId} = await collection.mintToken(minter, {Ethereum: owner.eth});684685    for (let i = 1n; i < 10n; i++) {686      const ownerCross = await collectionEvm.methods.ownerOfCross(tokenId).call({from: owner.eth});687      expect(ownerCross.eth).to.be.eq(owner.eth);688      expect(ownerCross.sub).to.be.eq(owner.sub);689690      const newOwner = await helper.ethCrossAccount.createAccountWithBalance(donor);691      await collectionEvm.methods.transferCross(newOwner, tokenId).send({from: owner.eth});692      owner = newOwner;693    }694  });695});696697describe('NFT: Fees', () => {698  let donor: IKeyringPair;699  let alice: IKeyringPair;700  let bob: IKeyringPair;701  let charlie: IKeyringPair;702703  before(async function() {704    await usingEthPlaygrounds(async (helper, privateKey) => {705      donor = await privateKey({url: import.meta.url});706      [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);707    });708  });709710  itEth('approve() call fee is less than 0.2UNQ', async ({helper}) => {711    const owner = await helper.eth.createAccountWithBalance(donor);712    const spender = helper.eth.createAccount();713714    const collection = await helper.nft.mintCollection(alice, {});715    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});716717    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);718719    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, tokenId).send({from: owner}));720    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));721  });722723  itEth('transferFrom() call fee is less than 0.2UNQ', async ({helper}) => {724    const owner = await helper.eth.createAccountWithBalance(donor);725    const spender = await helper.eth.createAccountWithBalance(donor);726727    const collection = await helper.nft.mintCollection(alice, {});728    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});729730    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);731732    await contract.methods.approve(spender, tokenId).send({from: owner});733734    const cost = await helper.eth.recordCallFee(spender, () => contract.methods.transferFrom(owner, spender, tokenId).send({from: spender}));735    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));736  });737738  itEth('Can perform transferFromCross()', async ({helper}) => {739    const collectionMinter = alice;740    const owner = bob;741    const receiver = charlie;742    const collection = await helper.nft.mintCollection(collectionMinter, {name: 'A', description: 'B', tokenPrefix: 'C'});743744    const spender = await helper.eth.createAccountWithBalance(donor);745746    const token = await collection.mintToken(collectionMinter, {Substrate: owner.address});747748    const address = helper.ethAddress.fromCollectionId(collection.collectionId);749    const contract = await helper.ethNativeContract.collection(address, 'nft');750751    await token.approve(owner, {Ethereum: spender});752753    {754      const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);755      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);756      const result = await contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender});757      const event = result.events.Transfer;758      expect(event).to.be.like({759        address: helper.ethAddress.fromCollectionId(collection.collectionId),760        event: 'Transfer',761        returnValues: {762          from: helper.address.substrateToEth(owner.address),763          to: helper.address.substrateToEth(receiver.address),764          tokenId: token.tokenId.toString(),765        },766      });767    }768769    expect(await token.getOwner()).to.be.like({Substrate: receiver.address});770  });771772  itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {773    const owner = await helper.eth.createAccountWithBalance(donor);774    const receiver = helper.eth.createAccount();775776    const collection = await helper.nft.mintCollection(alice, {});777    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});778779    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);780781    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, tokenId).send({from: owner}));782    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));783  });784});785786describe('NFT: Substrate calls', () => {787  let donor: IKeyringPair;788  let alice: IKeyringPair;789790  before(async function() {791    await usingEthPlaygrounds(async (helper, privateKey) => {792      donor = await privateKey({url: import.meta.url});793      [alice] = await helper.arrange.createAccounts([20n], donor);794    });795  });796797  itEth('Events emitted for mint()', async ({helper}) => {798    const collection = await helper.nft.mintCollection(alice, {});799    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);800    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');801802    const events: any = [];803    contract.events.allEvents((_: any, event: any) => {804      events.push(event);805    });806807    const {tokenId} = await collection.mintToken(alice);808    if (events.length == 0) await helper.wait.newBlocks(1);809    const event = events[0];810811    expect(event.event).to.be.equal('Transfer');812    expect(event.address).to.be.equal(collectionAddress);813    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');814    expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(alice.address));815    expect(event.returnValues.tokenId).to.be.equal(tokenId.toString());816  });817818  itEth('Events emitted for burn()', async ({helper}) => {819    const collection = await helper.nft.mintCollection(alice, {});820    const token = await collection.mintToken(alice);821822    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);823    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');824825    const events: any = [];826    contract.events.allEvents((_: any, event: any) => {827      events.push(event);828    });829830    await token.burn(alice);831    if (events.length == 0) await helper.wait.newBlocks(1);832    const event = events[0];833834    expect(event.event).to.be.equal('Transfer');835    expect(event.address).to.be.equal(collectionAddress);836    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));837    expect(event.returnValues.to).to.be.equal('0x0000000000000000000000000000000000000000');838    expect(event.returnValues.tokenId).to.be.equal(token.tokenId.toString());839  });840841  itEth('Events emitted for approve()', async ({helper}) => {842    const receiver = helper.eth.createAccount();843844    const collection = await helper.nft.mintCollection(alice, {});845    const token = await collection.mintToken(alice);846847    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);848    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');849850    const events: any = [];851    contract.events.allEvents((_: any, event: any) => {852      events.push(event);853    });854855    await token.approve(alice, {Ethereum: receiver});856    if (events.length == 0) await helper.wait.newBlocks(1);857    const event = events[0];858859    expect(event.event).to.be.equal('Approval');860    expect(event.address).to.be.equal(collectionAddress);861    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));862    expect(event.returnValues.approved).to.be.equal(receiver);863    expect(event.returnValues.tokenId).to.be.equal(token.tokenId.toString());864  });865866  itEth('Events emitted for transferFrom()', async ({helper}) => {867    const [bob] = await helper.arrange.createAccounts([10n], donor);868    const receiver = helper.eth.createAccount();869870    const collection = await helper.nft.mintCollection(alice, {});871    const token = await collection.mintToken(alice);872    await token.approve(alice, {Substrate: bob.address});873874    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);875    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');876877    const events: any = [];878    contract.events.allEvents((_: any, event: any) => {879      events.push(event);880    });881882    await token.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver});883884    if (events.length == 0) await helper.wait.newBlocks(1);885    const event = events[0];886887    expect(event.address).to.be.equal(collectionAddress);888    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));889    expect(event.returnValues.to).to.be.equal(receiver);890    expect(event.returnValues.tokenId).to.be.equal(`${token.tokenId}`);891  });892893  itEth('Events emitted for transfer()', async ({helper}) => {894    const receiver = helper.eth.createAccount();895896    const collection = await helper.nft.mintCollection(alice, {});897    const token = await collection.mintToken(alice);898899    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);900    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');901902    const events: any = [];903    contract.events.allEvents((_: any, event: any) => {904      events.push(event);905    });906907    await token.transfer(alice, {Ethereum: receiver});908909    if (events.length == 0) await helper.wait.newBlocks(1);910    const event = events[0];911912    expect(event.address).to.be.equal(collectionAddress);913    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));914    expect(event.returnValues.to).to.be.equal(receiver);915    expect(event.returnValues.tokenId).to.be.equal(`${token.tokenId}`);916  });917});918919describe('Common metadata', () => {920  let donor: IKeyringPair;921  let alice: IKeyringPair;922923  before(async function() {924    await usingEthPlaygrounds(async (helper, privateKey) => {925      donor = await privateKey({url: import.meta.url});926      [alice] = await helper.arrange.createAccounts([20n], donor);927    });928  });929930  itEth('Returns collection name', async ({helper}) => {931    // FIXME: should not have balance to use .call()932    const caller = await helper.eth.createAccountWithBalance(donor);933    const tokenPropertyPermissions = [{934      key: 'URI',935      permission: {936        mutable: true,937        collectionAdmin: true,938        tokenOwner: false,939      },940    }];941    const collection = await helper.nft.mintCollection(942      alice,943      {944        name: 'oh River',945        tokenPrefix: 'CHANGE',946        properties: [{key: 'ERC721Metadata', value: '1'}],947        tokenPropertyPermissions,948      },949    );950951    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);952    const name = await contract.methods.name().call();953    expect(name).to.equal('oh River');954  });955956  itEth('Returns symbol name', async ({helper}) => {957    const caller = await helper.eth.createAccountWithBalance(donor);958    const tokenPropertyPermissions = [{959      key: 'URI',960      permission: {961        mutable: true,962        collectionAdmin: true,963        tokenOwner: false,964      },965    }];966    const collection = await helper.nft.mintCollection(967      alice,968      {969        name: 'oh River',970        tokenPrefix: 'CHANGE',971        properties: [{key: 'ERC721Metadata', value: '1'}],972        tokenPropertyPermissions,973      },974    );975976    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);977    const symbol = await contract.methods.symbol().call();978    expect(symbol).to.equal('CHANGE');979  });980});981982describe('Negative tests', () => {983  let donor: IKeyringPair;984  let minter: IKeyringPair;985  let alice: IKeyringPair;986987  before(async function() {988    await usingEthPlaygrounds(async (helper, privateKey) => {989      donor = await privateKey({url: import.meta.url});990      [minter, alice] = await helper.arrange.createAccounts([100n, 100n], donor);991    });992  });993994  itEth('[negative] Cant perform burn without approval', async ({helper}) => {995    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});996997    const owner = await helper.eth.createAccountWithBalance(donor);998    const spender = await helper.eth.createAccountWithBalance(donor);9991000    const token = await collection.mintToken(minter, {Ethereum: owner});10011002    const address = helper.ethAddress.fromCollectionId(collection.collectionId);1003    const contract = await helper.ethNativeContract.collection(address, 'nft');10041005    const ownerCross = helper.ethCrossAccount.fromAddress(owner);1006    await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;10071008    await contract.methods.setApprovalForAll(spender, true).send({from: owner});1009    await contract.methods.setApprovalForAll(spender, false).send({from: owner});10101011    await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;1012  });10131014  itEth('[negative] Cant perform transfer without approval', async ({helper}) => {1015    const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});1016    const receiver = alice;10171018    const owner = await helper.eth.createAccountWithBalance(donor);1019    const spender = await helper.eth.createAccountWithBalance(donor);10201021    const token = await collection.mintToken(minter, {Ethereum: owner});10221023    const address = helper.ethAddress.fromCollectionId(collection.collectionId);1024    const contract = await helper.ethNativeContract.collection(address, 'nft');10251026    const ownerCross = helper.ethCrossAccount.fromAddress(owner);1027    const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);10281029    await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;10301031    await contract.methods.setApprovalForAll(spender, true).send({from: owner});1032    await contract.methods.setApprovalForAll(spender, false).send({from: owner});10331034    await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;1035  });1036});
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -46,12 +46,11 @@
       const receiverSub = bob;
       const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(receiverSub);
 
-      const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });
-      const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.key, permission: {
+      const properties = Array(5).fill(0).map((_, i) => ({key: `key_${i}`, value: Buffer.from(`value_${i}`)}));
+      const permissions: ITokenPropertyPermission[] = properties.map(p => ({key: p.key, permission: {
         tokenOwner: false,
         collectionAdmin: true,
-        mutable: false}};
-      });
+        mutable: false}}));
 
 
       const collection = await helper.rft.mintCollection(minter, {
@@ -86,7 +85,7 @@
       expect(tokenId).to.be.equal(expectedTokenId);
 
       expect(await contract.methods.properties(tokenId, []).call()).to.be.like(properties
-        .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); }));
+        .map(p => helper.ethProperty.property(p.key, p.value.toString())));
 
       expect(await helper.nft.getTokenOwner(collection.collectionId, tokenId))
         .to.deep.eq(testCase === 'ethereum' ? {Ethereum: receiverEth.toLowerCase()} : {Substrate: receiverSub.address});
modifiedtests/src/eth/tokenProperties.test.tsdiffbeforeafterboth
--- a/tests/src/eth/tokenProperties.test.ts
+++ b/tests/src/eth/tokenProperties.test.ts
@@ -241,10 +241,10 @@
     itEth.ifWithPallets(`Can be multiple set/read for ${testCase.mode}`, testCase.requiredPallets, async({helper}) => {
       const caller = await helper.eth.createAccountWithBalance(donor);
 
-      const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });
-      const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.key, permission: {tokenOwner: true,
+      const properties = Array(5).fill(0).map((_, i) => ({key: `key_${i}`, value: Buffer.from(`value_${i}`)}));
+      const permissions: ITokenPropertyPermission[] = properties.map(p => ({key: p.key, permission: {tokenOwner: true,
         collectionAdmin: true,
-        mutable: true}}; });
+        mutable: true}}));
 
       const collection = await helper[testCase.mode].mintCollection(alice, {
         tokenPrefix: 'ethp',
@@ -267,10 +267,10 @@
       await contract.methods.setProperties(token.tokenId, properties).send({from: caller});
 
       const values = await token.getProperties(properties.map(p => p.key));
-      expect(values).to.be.deep.equal(properties.map(p => { return {key: p.key, value: p.value.toString()}; }));
+      expect(values).to.be.deep.equal(properties.map(p => ({key: p.key, value: p.value.toString()})));
 
       expect(await contract.methods.properties(token.tokenId, []).call()).to.be.like(properties
-        .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); }));
+        .map(p => helper.ethProperty.property(p.key, p.value.toString())));
 
       expect(await contract.methods.properties(token.tokenId, [properties[0].key]).call())
         .to.be.like([helper.ethProperty.property(properties[0].key, properties[0].value.toString())]);
modifiedtests/src/fungible.test.tsdiffbeforeafterboth
--- a/tests/src/fungible.test.ts
+++ b/tests/src/fungible.test.ts
@@ -46,7 +46,7 @@
 
   itSub('RPC method tokenOnewrs for fungible collection and token', async ({helper}) => {
     const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
-    const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => {return {Substrate: keyring.address};});
+    const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => ({Substrate: keyring.address}));
 
     const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
 
modifiedtests/src/getPropertiesRpc.test.tsdiffbeforeafterboth
--- a/tests/src/getPropertiesRpc.test.ts
+++ b/tests/src/getPropertiesRpc.test.ts
@@ -48,17 +48,13 @@
 describe('query properties RPC', () => {
   let alice: IKeyringPair;
 
-  const mintCollection = async (helper: UniqueHelper) => {
-    return await helper.nft.mintCollection(alice, {
-      tokenPrefix: 'prps',
-      properties: collectionProps,
-      tokenPropertyPermissions: tokenPropPermissions,
-    });
-  };
+  const mintCollection = async (helper: UniqueHelper) => await helper.nft.mintCollection(alice, {
+    tokenPrefix: 'prps',
+    properties: collectionProps,
+    tokenPropertyPermissions: tokenPropPermissions,
+  });
 
-  const mintToken = async (collection: UniqueNFTCollection) => {
-    return await collection.mintToken(alice, {Substrate: alice.address}, tokenProps);
-  };
+  const mintToken = async (collection: UniqueNFTCollection) => await collection.mintToken(alice, {Substrate: alice.address}, tokenProps);
 
 
   before(async () => {
modifiedtests/src/nesting/tokenProperties.test.tsdiffbeforeafterboth
--- a/tests/src/nesting/tokenProperties.test.ts
+++ b/tests/src/nesting/tokenProperties.test.ts
@@ -44,7 +44,7 @@
   async function mintCollectionWithAllPermissionsAndToken(helper: UniqueHelper, mode: 'NFT' | 'RFT'): Promise<[UniqueNFToken | UniqueRFToken, bigint]> {
     const collection = await (mode == 'NFT' ? helper.nft : helper.rft).mintCollection(alice, {
       tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>
-        signers.map(signer => {return {key: `${i+1}_${signer.address}`, permission};})),
+        signers.map(signer => ({key: `${i+1}_${signer.address}`, permission}))),
     });
     return mode == 'NFT' ? [await collection.mintToken(alice), 1n] : [await collection.mintToken(alice, 100n as any), 100n];
   }
@@ -201,7 +201,7 @@
     const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});
     const collectionB = await helper.nft.mintCollection(alice, {
       tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>
-        signers.map(signer => {return {key: `${i+1}_${signer.address}`, permission};})),
+        signers.map(signer => ({key: `${i+1}_${signer.address}`, permission}))),
     });
     const targetToken = await collectionA.mintToken(alice);
     const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAccount());
@@ -239,7 +239,7 @@
     const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});
     const collectionB = await helper.nft.mintCollection(alice, {
       tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>
-        signers.map(signer => {return {key: `${i+1}_${signer.address}`, permission};})),
+        signers.map(signer => ({key: `${i+1}_${signer.address}`, permission}))),
     });
     const targetToken = await collectionA.mintToken(alice);
     const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAccount());
@@ -284,7 +284,7 @@
     const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});
     const collectionB = await helper.nft.mintCollection(alice, {
       tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>
-        signers.map(signer => {return {key: `${i+1}_${signer.address}`, permission};})),
+        signers.map(signer => ({key: `${i+1}_${signer.address}`, permission}))),
     });
     const targetToken = await collectionA.mintToken(alice);
     const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAccount());
@@ -477,7 +477,7 @@
 
   async function mintCollectionWithAllPermissionsAndToken(helper: UniqueHelper, mode: 'NFT' | 'RFT'): Promise<[UniqueNFToken | UniqueRFToken, bigint]> {
     const collection = await (mode == 'NFT' ? helper.nft : helper.rft).mintCollection(alice, {
-      tokenPropertyPermissions: constitution.map(({permission}, i) => {return {key: `${i+1}`, permission};}),
+      tokenPropertyPermissions: constitution.map(({permission}, i) => ({key: `${i+1}`, permission})),
     });
     return mode == 'NFT' ? [await collection.mintToken(alice), 1n] : [await collection.mintToken(alice, 100n as any), 100n];
   }
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -64,7 +64,7 @@
 
   itSub('RPC method tokenOwners for refungible collection and token', async ({helper}) => {
     const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
-    const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => {return {Substrate: keyring.address};});
+    const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => ({Substrate: keyring.address}));
 
     const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
 
modifiedtests/src/rpc.test.tsdiffbeforeafterboth
--- a/tests/src/rpc.test.ts
+++ b/tests/src/rpc.test.ts
@@ -40,7 +40,7 @@
     // Set-up a few token owners of all stripes
     const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
     const facelessCrowd = (await helper.arrange.createAccounts([0n, 0n, 0n, 0n, 0n, 0n, 0n], donor))
-      .map(i => {return {Substrate: i.address};});
+      .map(i => ({Substrate: i.address}));
 
     const collection = await helper.ft.mintCollection(alice, {name: 'RPC-2', tokenPrefix: 'RPC'});
     // mint some maximum (u128) amounts of tokens possible
modifiedtests/src/sub/appPromotion/appPromotion.test.tsdiffbeforeafterboth
--- a/tests/src/sub/appPromotion/appPromotion.test.ts
+++ b/tests/src/sub/appPromotion/appPromotion.test.ts
@@ -357,11 +357,9 @@
         const stakers = await getAccounts(3);
 
         await Promise.all(stakers.map(staker => helper.staking.stake(staker, 100n * nominal)));
-        await Promise.all(stakers.map(staker => {
-          return testCase.method === 'unstakeAll'
-            ? helper.staking.unstakeAll(staker)
-            : helper.staking.unstakePartial(staker, 100n * nominal);
-        }));
+        await Promise.all(stakers.map(staker => testCase.method === 'unstakeAll'
+          ? helper.staking.unstakeAll(staker)
+          : helper.staking.unstakePartial(staker, 100n * nominal)));
 
         await Promise.all(stakers.map(async (staker) => {
           expect(await helper.staking.getPendingUnstake({Substrate: staker.address})).to.be.equal(100n * nominal);
@@ -375,11 +373,9 @@
         const stakers = await getAccounts(10);
 
         await Promise.all(stakers.map(staker => helper.staking.stake(staker, 100n * nominal)));
-        const unstakingResults = await Promise.allSettled(stakers.map((staker, i) => {
-          return i % 2 === 0
-            ? helper.staking.unstakeAll(staker)
-            : helper.staking.unstakePartial(staker, 100n * nominal);
-        }));
+        const unstakingResults = await Promise.allSettled(stakers.map((staker, i) => i % 2 === 0
+          ? helper.staking.unstakeAll(staker)
+          : helper.staking.unstakePartial(staker, 100n * nominal)));
 
         const successfulUnstakes = unstakingResults.filter(result => result.status === 'fulfilled');
         expect(successfulUnstakes).to.have.length(3);
modifiedtests/src/util/index.tsdiffbeforeafterboth
--- a/tests/src/util/index.ts
+++ b/tests/src/util/index.ts
@@ -19,13 +19,9 @@
 chai.use(chaiSubset);
 export const expect = chai.expect;
 
-const getTestHash = (filename: string) => {
-  return crypto.createHash('md5').update(filename).digest('hex');
-};
+const getTestHash = (filename: string) => crypto.createHash('md5').update(filename).digest('hex');
 
-export const getTestSeed = (filename: string) => {
-  return `//Alice+${getTestHash(filename)}`;
-};
+export const getTestSeed = (filename: string) => `//Alice+${getTestHash(filename)}`;
 
 async function usingPlaygroundsGeneral<T extends ChainHelperBase>(helperType: new(logger: ILogger) => T, url: string, code: (helper: T, privateKey: (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>) {
   const silentConsole = new SilentConsole();
@@ -65,49 +61,27 @@
   }
 }
 
-export const usingPlaygrounds = (code: (helper: DevUniqueHelper, privateKey: (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>, url: string = config.substrateUrl) => {
-  return usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);
-};
+export const usingPlaygrounds = (code: (helper: DevUniqueHelper, privateKey: (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>, url: string = config.substrateUrl) => usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);
 
-export const usingWestmintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
-  return usingPlaygroundsGeneral<DevWestmintHelper>(DevWestmintHelper, url, code);
-};
+export const usingWestmintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevWestmintHelper>(DevWestmintHelper, url, code);
 
-export const usingStateminePlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
-  return usingPlaygroundsGeneral<DevStatemineHelper>(DevWestmintHelper, url, code);
-};
+export const usingStateminePlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevStatemineHelper>(DevWestmintHelper, url, code);
 
-export const usingStatemintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
-  return usingPlaygroundsGeneral<DevStatemintHelper>(DevWestmintHelper, url, code);
-};
+export const usingStatemintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevStatemintHelper>(DevWestmintHelper, url, code);
 
-export const usingRelayPlaygrounds = (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
-  return usingPlaygroundsGeneral<DevRelayHelper>(DevRelayHelper, url, code);
-};
+export const usingRelayPlaygrounds = (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevRelayHelper>(DevRelayHelper, url, code);
 
-export const usingAcalaPlaygrounds = (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
-  return usingPlaygroundsGeneral<DevAcalaHelper>(DevAcalaHelper, url, code);
-};
+export const usingAcalaPlaygrounds = (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevAcalaHelper>(DevAcalaHelper, url, code);
 
-export const usingKaruraPlaygrounds = (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
-  return usingPlaygroundsGeneral<DevKaruraHelper>(DevAcalaHelper, url, code);
-};
+export const usingKaruraPlaygrounds = (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevKaruraHelper>(DevAcalaHelper, url, code);
 
-export const usingMoonbeamPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
-  return usingPlaygroundsGeneral<DevMoonbeamHelper>(DevMoonbeamHelper, url, code);
-};
+export const usingMoonbeamPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevMoonbeamHelper>(DevMoonbeamHelper, url, code);
 
-export const usingMoonriverPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
-  return usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);
-};
+export const usingMoonriverPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);
 
-export const usingAstarPlaygrounds = (url: string, code: (helper: DevAstarHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
-  return usingPlaygroundsGeneral<DevAstarHelper>(DevAstarHelper, url, code);
-};
+export const usingAstarPlaygrounds = (url: string, code: (helper: DevAstarHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevAstarHelper>(DevAstarHelper, url, code);
 
-export const usingShidenPlaygrounds = (url: string, code: (helper: DevShidenHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
-  return usingPlaygroundsGeneral<DevShidenHelper>(DevShidenHelper, url, code);
-};
+export const usingShidenPlaygrounds = (url: string, code: (helper: DevShidenHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevShidenHelper>(DevShidenHelper, url, code);
 
 export const MINIMUM_DONOR_FUND = 100_000n;
 export const DONOR_FUNDING = 2_000_000n;
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -771,9 +771,7 @@
     // <<< Referendum voting <<<
 
     // Wait the proposal to pass
-    await this.helper.wait.expectEvent(3, Event.Democracy.Passed, event => {
-      return event.referendumIndex() == referendumIndex;
-    });
+    await this.helper.wait.expectEvent(3, Event.Democracy.Passed, event => event.referendumIndex() == referendumIndex);
 
     await this.helper.wait.newBlocks(1);
 
@@ -924,7 +922,7 @@
   event<T extends IEventHelper>(
     maxBlocksToWait: number,
     eventHelperType: new () => T,
-    filter: (_: T) => boolean = () => { return true; },
+    filter: (_: T) => boolean = () => true,
   ) {
     // eslint-disable-next-line no-async-promise-executor
     const promise = new Promise<T | null>(async (resolve) => {
@@ -970,7 +968,7 @@
   async expectEvent<T extends IEventHelper>(
     maxBlocksToWait: number,
     eventHelperType: new () => T,
-    filter: (e: T) => boolean = () => { return true; },
+    filter: (e: T) => boolean = () => true,
   ) {
     const e = await this.event(maxBlocksToWait, eventHelperType, filter);
     if (e == null) {
@@ -1077,9 +1075,7 @@
   async startCapture() {
     this.stopCapture();
     this.unsubscribe = (await this.helper.getApi().query.system.events((eventRecords: FrameSystemEventRecord[]) => {
-      const newEvents = eventRecords.filter(r => {
-        return r.event.section == this.eventSection && r.event.method == this.eventMethod;
-      });
+      const newEvents = eventRecords.filter(r => r.event.section == this.eventSection && r.event.method == this.eventMethod);
 
       this.events.push(...newEvents);
     })) as any;
@@ -1105,12 +1101,10 @@
 
   async payoutStakers(signer: IKeyringPair, stakersToPayout: number):  Promise<{staker: string, stake: bigint, payout: bigint}[]> {
     const payoutResult = await this.helper.executeExtrinsic(signer, 'api.tx.appPromotion.payoutStakers', [stakersToPayout], true);
-    return payoutResult.result.events.filter(e => e.event.method === 'StakingRecalculation').map(e => {
-      return {
-        staker: e.event.data[0].toString(),
-        stake: e.event.data[1].toBigInt(),
-        payout: e.event.data[2].toBigInt(),
-      };
-    });
+    return payoutResult.result.events.filter(e => e.event.method === 'StakingRecalculation').map(e => ({
+      staker: e.event.data[0].toString(),
+      stake: e.event.data[1].toBigInt(),
+      payout: e.event.data[2].toBigInt(),
+    }));
   }
 }
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -2395,7 +2395,7 @@
     return total.toBigInt();
   }
 
-  async getLocked(address: TSubstrateAccount): Promise<[{ id: string, amount: bigint, reason: string }]> {
+  async getLocked(address: TSubstrateAccount): Promise<{ id: string, amount: bigint, reason: string }[]> {
     const locks = (await this.helper.callRpc('api.query.balances.locks', [address])).toHuman();
     return locks.map((lock: any) => ({id: lock.id, amount: BigInt(lock.amount.replace(/,/g, '')), reasons: lock.reasons}));
   }
@@ -2581,14 +2581,12 @@
    */
   async getVestingSchedules(address: TSubstrateAccount): Promise<{ start: bigint, period: bigint, periodCount: bigint, perPeriod: bigint }[]> {
     const schedule = (await this.helper.callRpc('api.query.vesting.vestingSchedules', [address])).toJSON();
-    return schedule.map((schedule: any) => {
-      return {
-        start: BigInt(schedule.start),
-        period: BigInt(schedule.period),
-        periodCount: BigInt(schedule.periodCount),
-        perPeriod: BigInt(schedule.perPeriod),
-      };
-    });
+    return schedule.map((schedule: any) => ({
+      start: BigInt(schedule.start),
+      period: BigInt(schedule.period),
+      periodCount: BigInt(schedule.periodCount),
+      perPeriod: BigInt(schedule.perPeriod),
+    }));
   }
 
   /**
@@ -2804,12 +2802,10 @@
    */
   async getTotalStakedPerBlock(address: ICrossAccountId): Promise<IStakingInfo[]> {
     const rawTotalStakerdPerBlock = await this.helper.callRpc('api.rpc.appPromotion.totalStakedPerBlock', [address]);
-    return rawTotalStakerdPerBlock.map(([block, amount]: any[]) => {
-      return {
-        block: block.toBigInt(),
-        amount: amount.toBigInt(),
-      };
-    });
+    return rawTotalStakerdPerBlock.map(([block, amount]: any[]) => ({
+      block: block.toBigInt(),
+      amount: amount.toBigInt(),
+    }));
   }
 
   /**
@@ -2828,12 +2824,10 @@
    */
   async getPendingUnstakePerBlock(address: ICrossAccountId): Promise<IStakingInfo[]> {
     const rawUnstakedPerBlock = await this.helper.callRpc('api.rpc.appPromotion.pendingUnstakePerBlock', [address]);
-    const result = rawUnstakedPerBlock.map(([block, amount]: any[]) => {
-      return {
-        block: block.toBigInt(),
-        amount: amount.toBigInt(),
-      };
-    });
+    const result = rawUnstakedPerBlock.map(([block, amount]: any[]) => ({
+      block: block.toBigInt(),
+      amount: amount.toBigInt(),
+    }));
     return result;
   }
 }
modifiedtests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth
--- a/tests/src/xcm/xcmQuartz.test.ts
+++ b/tests/src/xcm/xcmQuartz.test.ts
@@ -682,10 +682,8 @@
       maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramSent.messageHash()
-        && event.outcome().isFailedToTransactAsset;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
+        && event.outcome().isFailedToTransactAsset);
 
     targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(targetAccountBalance).to.be.equal(0n);
@@ -765,10 +763,8 @@
       maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
-        && event.outcome().isUntrustedReserveLocation;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
+        && event.outcome().isUntrustedReserveLocation);
 
     let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(accountBalance).to.be.equal(0n);
@@ -780,10 +776,8 @@
       maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
-        && event.outcome().isUntrustedReserveLocation;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
+        && event.outcome().isUntrustedReserveLocation);
 
     accountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(accountBalance).to.be.equal(0n);
@@ -858,10 +852,8 @@
   });
 
   const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == messageSent.messageHash()
-        && event.outcome().isFailedToTransactAsset;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == messageSent.messageHash()
+        && event.outcome().isFailedToTransactAsset);
   };
 
   itSub('Quartz rejects KAR tokens from Karura', async ({helper}) => {
@@ -1172,10 +1164,8 @@
       maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramSent.messageHash()
-        && event.outcome().isFailedToTransactAsset;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
+        && event.outcome().isFailedToTransactAsset);
 
     targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(targetAccountBalance).to.be.equal(0n);
@@ -1263,10 +1253,8 @@
       maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
-        && event.outcome().isUntrustedReserveLocation;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
+        && event.outcome().isUntrustedReserveLocation);
 
     let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(accountBalance).to.be.equal(0n);
@@ -1282,10 +1270,8 @@
       maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
-        && event.outcome().isUntrustedReserveLocation;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
+        && event.outcome().isUntrustedReserveLocation);
 
     accountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(accountBalance).to.be.equal(0n);
@@ -1544,10 +1530,8 @@
       maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramSent.messageHash()
-        && event.outcome().isFailedToTransactAsset;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
+        && event.outcome().isFailedToTransactAsset);
 
     targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(targetAccountBalance).to.be.equal(0n);
@@ -1627,10 +1611,8 @@
       maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
-        && event.outcome().isUntrustedReserveLocation;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
+        && event.outcome().isUntrustedReserveLocation);
 
     let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(accountBalance).to.be.equal(0n);
@@ -1642,10 +1624,8 @@
       maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
-        && event.outcome().isUntrustedReserveLocation;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
+        && event.outcome().isUntrustedReserveLocation);
 
     accountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(accountBalance).to.be.equal(0n);
modifiedtests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth
--- a/tests/src/xcm/xcmUnique.test.ts
+++ b/tests/src/xcm/xcmUnique.test.ts
@@ -684,10 +684,8 @@
       maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramSent.messageHash()
-        && event.outcome().isFailedToTransactAsset;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
+        && event.outcome().isFailedToTransactAsset);
 
     targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(targetAccountBalance).to.be.equal(0n);
@@ -767,10 +765,8 @@
       maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
-        && event.outcome().isUntrustedReserveLocation;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
+        && event.outcome().isUntrustedReserveLocation);
 
     let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(accountBalance).to.be.equal(0n);
@@ -782,10 +778,8 @@
       maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
-        && event.outcome().isUntrustedReserveLocation;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
+        && event.outcome().isUntrustedReserveLocation);
 
     accountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(accountBalance).to.be.equal(0n);
@@ -860,10 +854,8 @@
   });
 
   const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == messageSent.messageHash()
-        && event.outcome().isFailedToTransactAsset;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == messageSent.messageHash()
+        && event.outcome().isFailedToTransactAsset);
   };
 
   itSub('Unique rejects ACA tokens from Acala', async ({helper}) => {
@@ -1175,10 +1167,8 @@
       maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramSent.messageHash()
-        && event.outcome().isFailedToTransactAsset;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
+        && event.outcome().isFailedToTransactAsset);
 
     targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(targetAccountBalance).to.be.equal(0n);
@@ -1266,10 +1256,8 @@
       maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
-        && event.outcome().isUntrustedReserveLocation;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
+        && event.outcome().isUntrustedReserveLocation);
 
     let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(accountBalance).to.be.equal(0n);
@@ -1285,10 +1273,8 @@
       maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
-        && event.outcome().isUntrustedReserveLocation;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
+        && event.outcome().isUntrustedReserveLocation);
 
     accountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(accountBalance).to.be.equal(0n);
@@ -1546,10 +1532,8 @@
       maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramSent.messageHash()
-        && event.outcome().isFailedToTransactAsset;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
+        && event.outcome().isFailedToTransactAsset);
 
     targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(targetAccountBalance).to.be.equal(0n);
@@ -1629,10 +1613,8 @@
       maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
-        && event.outcome().isUntrustedReserveLocation;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
+        && event.outcome().isUntrustedReserveLocation);
 
     let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(accountBalance).to.be.equal(0n);
@@ -1644,10 +1626,8 @@
       maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
 
-    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
-      return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
-        && event.outcome().isUntrustedReserveLocation;
-    });
+    await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
+        && event.outcome().isUntrustedReserveLocation);
 
     accountBalance = await helper.balance.getSubstrate(targetAccount.address);
     expect(accountBalance).to.be.equal(0n);