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

difftreelog

Add call-methods checks

Max Andreev2022-12-22parent: #7d30844.patch.diff
in: master

6 files changed

modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionAdmin.test.ts
+++ b/tests/src/eth/collectionAdmin.test.ts
@@ -62,6 +62,8 @@
       expect(await collectionEvm.methods.isOwnerOrAdminCross(adminCrossSub).call()).to.be.false;
       expect(await collectionEvm.methods.isOwnerOrAdminCross(adminCrossEth).call()).to.be.false;
       expect(await collectionEvm.methods.isOwnerOrAdminCross(helper.ethCrossAccount.fromAddress(adminDeprecated)).call()).to.be.false;
+      expect(await collectionEvm.methods.collectionAdmins().call()).to.be.like([]);
+
       
       // Soft-deprecated: can addCollectionAdmin 
       await collectionEvm.methods.addCollectionAdmin(adminDeprecated).send();
modifiedtests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth
before · tests/src/eth/collectionSponsoring.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 {IKeyringPair} from '@polkadot/types/types';18import {usingPlaygrounds} from '../util/index';19import {itEth, expect} from './util';2021describe('evm collection sponsoring', () => {22  let donor: IKeyringPair;23  let alice: IKeyringPair;24  let nominal: bigint;2526  before(async () => {27    await usingPlaygrounds(async (helper, privateKey) => {28      donor = await privateKey({filename: __filename});29      [alice] = await helper.arrange.createAccounts([100n], donor);30      nominal = helper.balance.getOneTokenNominal();31    });32  });33  34  // TODO: move to substrate tests35  itEth('sponsors mint transactions', async ({helper}) => {36    const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'spnr', permissions: {mintMode: true}});37    await collection.setSponsor(alice, alice.address);38    await collection.confirmSponsorship(alice);3940    const minter = helper.eth.createAccount();41    expect(await helper.balance.getEthereum(minter)).to.equal(0n);4243    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);44    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', minter);4546    await collection.addToAllowList(alice, {Ethereum: minter});4748    const result = await contract.methods.mint(minter).send();4950    const events = helper.eth.normalizeEvents(result.events);51    expect(events).to.be.deep.equal([52      {53        address: collectionAddress,54        event: 'Transfer',55        args: {56          from: '0x0000000000000000000000000000000000000000',57          to: minter,58          tokenId: '1',59        },60      },61    ]);62  });6364  // TODO: Temprorary off. Need refactor65  // itWeb3('Set substrate sponsor', async ({api, web3, privateKeyWrapper}) => {66  //   const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);67  //   const collectionHelpers = evmCollectionHelpers(web3, owner);68  //   let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send();69  //   const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);70  //   const sponsor = privateKeyWrapper('//Alice');71  //   const collectionEvm = evmCollection(web3, owner, collectionIdAddress);7273  //   expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;74  //   result = await collectionEvm.methods.setCollectionSponsorSubstrate(sponsor.addressRaw).send({from: owner});75  //   expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;7677  //   const confirmTx = await api.tx.unique.confirmSponsorship(collectionId);78  //   await submitTransactionAsync(sponsor, confirmTx);79  //   expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;8081  //   const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});82  //   expect(bigIntToSub(api, BigInt(sponsorTuple[1]))).to.be.eq(sponsor.address);83  // });8485  [86    'setCollectionSponsorCross',87    'setCollectionSponsor', // Soft-deprecated88  ].map(testCase => 89    itEth(`[${testCase}] can remove collection sponsor`, async ({helper}) => {90      const owner = await helper.eth.createAccountWithBalance(donor);91      const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);92  93      let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send({value: Number(2n * nominal)});94      const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);95      const sponsor = await helper.eth.createAccountWithBalance(donor);96      const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);97      const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner, testCase === 'setCollectionSponsor');98  99      expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;100      result = await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsor : sponsorCross).send({from: owner});101      expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;102  103      await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});104      expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;105  106      await collectionEvm.methods.removeCollectionSponsor().send({from: owner});107  108      const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});109      expect(sponsorTuple.eth).to.be.eq('0x0000000000000000000000000000000000000000');110    }));111112  [113    'setCollectionSponsorCross',114    'setCollectionSponsor', // Soft-deprecated115  ].map(testCase => 116    itEth(`[${testCase}] Can sponsor from evm address via access list`, async ({helper}) => {117      const owner = await helper.eth.createAccountWithBalance(donor);118      const sponsorEth = await helper.eth.createAccountWithBalance(donor);119      const sponsorCrossEth = helper.ethCrossAccount.fromAddress(sponsorEth);120  121      const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Sponsor collection', '1', '1', '');122  123      const collectionSub = helper.nft.getCollectionObject(collectionId);124      const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, testCase === 'setCollectionSponsor');125  126      // Set collection sponsor:127      await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsorEth : sponsorCrossEth).send({from: owner});128      let sponsorship = (await collectionSub.getData())!.raw.sponsorship;129      expect(sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsorEth, true));130      // Account cannot confirm sponsorship if it is not set as a sponsor131      await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');132      133      // Sponsor can confirm sponsorship:134      await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsorEth});135      sponsorship = (await collectionSub.getData())!.raw.sponsorship;136      expect(sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsorEth, true));137  138      // Create user with no balance:139      const user = helper.eth.createAccount();140      const userCross = helper.ethCrossAccount.fromAddress(user);141      const nextTokenId = await collectionEvm.methods.nextTokenId().call();142      expect(nextTokenId).to.be.equal('1');143  144      // Set collection permissions:145      const oldPermissions = (await collectionSub.getData())!.raw.permissions; // (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();146      expect(oldPermissions.mintMode).to.be.false;147      expect(oldPermissions.access).to.be.equal('Normal');148149      await collectionEvm.methods.setCollectionAccess(1 /*'AllowList'*/).send({from: owner});150      await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});151      await collectionEvm.methods.setCollectionMintMode(true).send({from: owner});152  153      const newPermissions = (await collectionSub.getData())!.raw.permissions; // (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();154      expect(newPermissions.mintMode).to.be.true;155      expect(newPermissions.access).to.be.equal('AllowList');156  157      const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));158      const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsorEth));159160      // User can mint token without balance:161      {162        const result = await collectionEvm.methods.mintWithTokenURI(user, 'Test URI').send({from: user});163        const event = helper.eth.normalizeEvents(result.events)164          .find(event => event.event === 'Transfer');165  166        expect(event).to.be.deep.equal({167          address: collectionAddress,168          event: 'Transfer',169          args: {170            from: '0x0000000000000000000000000000000000000000',171            to: user,172            tokenId: '1',173          },174        });175  176        const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));177        const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsorEth));178        const userBalanceAfter =  await helper.balance.getSubstrate(helper.address.ethToSubstrate(user));179  180        expect(await collectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');181        expect(ownerBalanceBefore).to.be.eq(ownerBalanceAfter);182        expect(userBalanceAfter).to.be.eq(0n);183        expect(sponsorBalanceBefore > sponsorBalanceAfter).to.be.true;184      }185    }));186187  // TODO: Temprorary off. Need refactor188  // itWeb3('Sponsoring collection from substrate address via access list', async ({api, web3, privateKeyWrapper}) => {189  //   const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);190  //   const collectionHelpers = evmCollectionHelpers(web3, owner);191  //   const result = await collectionHelpers.methods.createERC721MetadataCompatibleNFTCollection('Sponsor collection', '1', '1', '').send();192  //   const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);193  //   const sponsor = privateKeyWrapper('//Alice');194  //   const collectionEvm = evmCollection(web3, owner, collectionIdAddress);195196  //   await collectionEvm.methods.setCollectionSponsorSubstrate(sponsor.addressRaw).send({from: owner});197198  //   const confirmTx = await api.tx.unique.confirmSponsorship(collectionId);199  //   await submitTransactionAsync(sponsor, confirmTx);200201  //   const user = createEthAccount(web3);202  //   const nextTokenId = await collectionEvm.methods.nextTokenId().call();203  //   expect(nextTokenId).to.be.equal('1');204205  //   await collectionEvm.methods.setCollectionAccess(1 /*'AllowList'*/).send({from: owner});206  //   await collectionEvm.methods.addToCollectionAllowList(user).send({from: owner});207  //   await collectionEvm.methods.setCollectionMintMode(true).send({from: owner});208209  //   const ownerBalanceBefore = await ethBalanceViaSub(api, owner);210  //   const sponsorBalanceBefore = (await getBalance(api, [sponsor.address]))[0];211212  //   {213  //     const nextTokenId = await collectionEvm.methods.nextTokenId().call();214  //     expect(nextTokenId).to.be.equal('1');215  //     const result = await collectionEvm.methods.mintWithTokenURI(216  //       user,217  //       nextTokenId,218  //       'Test URI',219  //     ).send({from: user});220  //     const events = normalizeEvents(result.events);221222  //     expect(events).to.be.deep.equal([223  //       {224  //         address: collectionIdAddress,225  //         event: 'Transfer',226  //         args: {227  //           from: '0x0000000000000000000000000000000000000000',228  //           to: user,229  //           tokenId: nextTokenId,230  //         },231  //       },232  //     ]);233234  //     const ownerBalanceAfter = await ethBalanceViaSub(api, owner);235  //     const sponsorBalanceAfter = (await getBalance(api, [sponsor.address]))[0];236237  //     expect(await collectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');238  //     expect(ownerBalanceBefore).to.be.eq(ownerBalanceAfter);239  //     expect(sponsorBalanceBefore > sponsorBalanceAfter).to.be.true;240  //   }241  // });242243  [244    'setCollectionSponsorCross',245    'setCollectionSponsor', // Soft-deprecated246  ].map(testCase => 247    itEth(`[${testCase}] Check that transaction via EVM spend money from sponsor address`, async ({helper}) => {248      const owner = await helper.eth.createAccountWithBalance(donor);249      const sponsor = await helper.eth.createAccountWithBalance(donor);250      const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);251  252      const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');253254      const collectionSub = helper.nft.getCollectionObject(collectionId);255      const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, testCase === 'setCollectionSponsor');256      // Set collection sponsor:257      await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsor : sponsorCross).send();258      let collectionData = (await collectionSub.getData())!;259      expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));260      await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');261  262      await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});263      collectionData = (await collectionSub.getData())!;264      expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));265  266      const user = helper.eth.createAccount();267      const userCross = helper.ethCrossAccount.fromAddress(user);268      await collectionEvm.methods.addCollectionAdminCross(userCross).send();269  270      const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));271      const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));272    273      const mintingResult = await collectionEvm.methods.mintWithTokenURI(user, 'Test URI').send({from: user});274      const tokenId = mintingResult.events.Transfer.returnValues.tokenId;275  276      const event = helper.eth.normalizeEvents(mintingResult.events)277        .find(event => event.event === 'Transfer');278      const address = helper.ethAddress.fromCollectionId(collectionId);279  280      expect(event).to.be.deep.equal({281        address,282        event: 'Transfer',283        args: {284          from: '0x0000000000000000000000000000000000000000',285          to: user,286          tokenId: '1',287        },288      });289      expect(await collectionEvm.methods.tokenURI(tokenId).call({from: user})).to.be.equal('Test URI');290  291      const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));292      expect(ownerBalanceAfter).to.be.eq(ownerBalanceBefore);293      const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));294      expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;295    }));296297  itEth('Can reassign collection sponsor', async ({helper}) => {298    const owner = await helper.eth.createAccountWithBalance(donor);299    const sponsorEth = await helper.eth.createAccountWithBalance(donor);300    const sponsorCrossEth = helper.ethCrossAccount.fromAddress(sponsorEth);301    const [sponsorSub] = await helper.arrange.createAccounts([100n], donor);302    const sponsorCrossSub = helper.ethCrossAccount.fromKeyringPair(sponsorSub);303304    const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');305    const collectionSub = helper.nft.getCollectionObject(collectionId);306    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);307308    // Set and confirm sponsor:309    await collectionEvm.methods.setCollectionSponsorCross(sponsorCrossEth).send({from: owner});310    await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsorEth});311312    // Can reassign sponsor:313    await collectionEvm.methods.setCollectionSponsorCross(sponsorCrossSub).send({from: owner});314    const collectionSponsor = (await collectionSub.getData())?.raw.sponsorship;315    expect(collectionSponsor).to.deep.eq({Unconfirmed: sponsorSub.address});316  });317});
after · tests/src/eth/collectionSponsoring.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 {IKeyringPair} from '@polkadot/types/types';18import {usingPlaygrounds} from '../util/index';19import {itEth, expect} from './util';2021describe('evm collection sponsoring', () => {22  let donor: IKeyringPair;23  let alice: IKeyringPair;24  let nominal: bigint;2526  before(async () => {27    await usingPlaygrounds(async (helper, privateKey) => {28      donor = await privateKey({filename: __filename});29      [alice] = await helper.arrange.createAccounts([100n], donor);30      nominal = helper.balance.getOneTokenNominal();31    });32  });33  34  // TODO: move to substrate tests35  itEth('sponsors mint transactions', async ({helper}) => {36    const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'spnr', permissions: {mintMode: true}});37    await collection.setSponsor(alice, alice.address);38    await collection.confirmSponsorship(alice);3940    const minter = helper.eth.createAccount();41    expect(await helper.balance.getEthereum(minter)).to.equal(0n);4243    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);44    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', minter);4546    await collection.addToAllowList(alice, {Ethereum: minter});4748    const result = await contract.methods.mint(minter).send();4950    const events = helper.eth.normalizeEvents(result.events);51    expect(events).to.be.deep.equal([52      {53        address: collectionAddress,54        event: 'Transfer',55        args: {56          from: '0x0000000000000000000000000000000000000000',57          to: minter,58          tokenId: '1',59        },60      },61    ]);62  });6364  // TODO: Temprorary off. Need refactor65  // itWeb3('Set substrate sponsor', async ({api, web3, privateKeyWrapper}) => {66  //   const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);67  //   const collectionHelpers = evmCollectionHelpers(web3, owner);68  //   let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send();69  //   const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);70  //   const sponsor = privateKeyWrapper('//Alice');71  //   const collectionEvm = evmCollection(web3, owner, collectionIdAddress);7273  //   expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;74  //   result = await collectionEvm.methods.setCollectionSponsorSubstrate(sponsor.addressRaw).send({from: owner});75  //   expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;7677  //   const confirmTx = await api.tx.unique.confirmSponsorship(collectionId);78  //   await submitTransactionAsync(sponsor, confirmTx);79  //   expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;8081  //   const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});82  //   expect(bigIntToSub(api, BigInt(sponsorTuple[1]))).to.be.eq(sponsor.address);83  // });8485  [86    'setCollectionSponsorCross',87    'setCollectionSponsor', // Soft-deprecated88  ].map(testCase => 89    itEth(`[${testCase}] can remove collection sponsor`, async ({helper}) => {90      const owner = await helper.eth.createAccountWithBalance(donor);91      const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);92  93      let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send({value: Number(2n * nominal)});94      const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);95      const sponsor = await helper.eth.createAccountWithBalance(donor);96      const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);97      const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner, testCase === 'setCollectionSponsor');98  99      expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;100      result = await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsor : sponsorCross).send({from: owner});101      expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;102  103      await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});104      let sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});105      expect(helper.address.restoreCrossAccountFromBigInt(BigInt(sponsorTuple.sub))).to.be.eq(helper.address.ethToSubstrate(sponsor));106      expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;107  108      await collectionEvm.methods.removeCollectionSponsor().send({from: owner});109  110      sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});111      expect(sponsorTuple.eth).to.be.eq('0x0000000000000000000000000000000000000000');112    }));113114  [115    'setCollectionSponsorCross',116    'setCollectionSponsor', // Soft-deprecated117  ].map(testCase => 118    itEth(`[${testCase}] Can sponsor from evm address via access list`, async ({helper}) => {119      const owner = await helper.eth.createAccountWithBalance(donor);120      const sponsorEth = await helper.eth.createAccountWithBalance(donor);121      const sponsorCrossEth = helper.ethCrossAccount.fromAddress(sponsorEth);122  123      const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Sponsor collection', '1', '1', '');124  125      const collectionSub = helper.nft.getCollectionObject(collectionId);126      const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, testCase === 'setCollectionSponsor');127  128      // Set collection sponsor:129      await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsorEth : sponsorCrossEth).send({from: owner});130      let sponsorship = (await collectionSub.getData())!.raw.sponsorship;131      expect(sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsorEth, true));132      // Account cannot confirm sponsorship if it is not set as a sponsor133      await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');134      135      // Sponsor can confirm sponsorship:136      await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsorEth});137      sponsorship = (await collectionSub.getData())!.raw.sponsorship;138      expect(sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsorEth, true));139  140      // Create user with no balance:141      const user = helper.eth.createAccount();142      const userCross = helper.ethCrossAccount.fromAddress(user);143      const nextTokenId = await collectionEvm.methods.nextTokenId().call();144      expect(nextTokenId).to.be.equal('1');145  146      // Set collection permissions:147      const oldPermissions = (await collectionSub.getData())!.raw.permissions; // (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();148      expect(oldPermissions.mintMode).to.be.false;149      expect(oldPermissions.access).to.be.equal('Normal');150151      await collectionEvm.methods.setCollectionAccess(1 /*'AllowList'*/).send({from: owner});152      await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});153      await collectionEvm.methods.setCollectionMintMode(true).send({from: owner});154  155      const newPermissions = (await collectionSub.getData())!.raw.permissions; // (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();156      expect(newPermissions.mintMode).to.be.true;157      expect(newPermissions.access).to.be.equal('AllowList');158  159      const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));160      const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsorEth));161162      // User can mint token without balance:163      {164        const result = await collectionEvm.methods.mintWithTokenURI(user, 'Test URI').send({from: user});165        const event = helper.eth.normalizeEvents(result.events)166          .find(event => event.event === 'Transfer');167  168        expect(event).to.be.deep.equal({169          address: collectionAddress,170          event: 'Transfer',171          args: {172            from: '0x0000000000000000000000000000000000000000',173            to: user,174            tokenId: '1',175          },176        });177  178        const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));179        const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsorEth));180        const userBalanceAfter =  await helper.balance.getSubstrate(helper.address.ethToSubstrate(user));181  182        expect(await collectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');183        expect(ownerBalanceBefore).to.be.eq(ownerBalanceAfter);184        expect(userBalanceAfter).to.be.eq(0n);185        expect(sponsorBalanceBefore > sponsorBalanceAfter).to.be.true;186      }187    }));188189  // TODO: Temprorary off. Need refactor190  // itWeb3('Sponsoring collection from substrate address via access list', async ({api, web3, privateKeyWrapper}) => {191  //   const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);192  //   const collectionHelpers = evmCollectionHelpers(web3, owner);193  //   const result = await collectionHelpers.methods.createERC721MetadataCompatibleNFTCollection('Sponsor collection', '1', '1', '').send();194  //   const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);195  //   const sponsor = privateKeyWrapper('//Alice');196  //   const collectionEvm = evmCollection(web3, owner, collectionIdAddress);197198  //   await collectionEvm.methods.setCollectionSponsorSubstrate(sponsor.addressRaw).send({from: owner});199200  //   const confirmTx = await api.tx.unique.confirmSponsorship(collectionId);201  //   await submitTransactionAsync(sponsor, confirmTx);202203  //   const user = createEthAccount(web3);204  //   const nextTokenId = await collectionEvm.methods.nextTokenId().call();205  //   expect(nextTokenId).to.be.equal('1');206207  //   await collectionEvm.methods.setCollectionAccess(1 /*'AllowList'*/).send({from: owner});208  //   await collectionEvm.methods.addToCollectionAllowList(user).send({from: owner});209  //   await collectionEvm.methods.setCollectionMintMode(true).send({from: owner});210211  //   const ownerBalanceBefore = await ethBalanceViaSub(api, owner);212  //   const sponsorBalanceBefore = (await getBalance(api, [sponsor.address]))[0];213214  //   {215  //     const nextTokenId = await collectionEvm.methods.nextTokenId().call();216  //     expect(nextTokenId).to.be.equal('1');217  //     const result = await collectionEvm.methods.mintWithTokenURI(218  //       user,219  //       nextTokenId,220  //       'Test URI',221  //     ).send({from: user});222  //     const events = normalizeEvents(result.events);223224  //     expect(events).to.be.deep.equal([225  //       {226  //         address: collectionIdAddress,227  //         event: 'Transfer',228  //         args: {229  //           from: '0x0000000000000000000000000000000000000000',230  //           to: user,231  //           tokenId: nextTokenId,232  //         },233  //       },234  //     ]);235236  //     const ownerBalanceAfter = await ethBalanceViaSub(api, owner);237  //     const sponsorBalanceAfter = (await getBalance(api, [sponsor.address]))[0];238239  //     expect(await collectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');240  //     expect(ownerBalanceBefore).to.be.eq(ownerBalanceAfter);241  //     expect(sponsorBalanceBefore > sponsorBalanceAfter).to.be.true;242  //   }243  // });244245  [246    'setCollectionSponsorCross',247    'setCollectionSponsor', // Soft-deprecated248  ].map(testCase => 249    itEth(`[${testCase}] Check that transaction via EVM spend money from sponsor address`, async ({helper}) => {250      const owner = await helper.eth.createAccountWithBalance(donor);251      const sponsor = await helper.eth.createAccountWithBalance(donor);252      const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);253  254      const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');255256      const collectionSub = helper.nft.getCollectionObject(collectionId);257      const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, testCase === 'setCollectionSponsor');258      // Set collection sponsor:259      await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsor : sponsorCross).send();260      let collectionData = (await collectionSub.getData())!;261      expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));262      await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');263  264      await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});265      collectionData = (await collectionSub.getData())!;266      expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));267  268      const user = helper.eth.createAccount();269      const userCross = helper.ethCrossAccount.fromAddress(user);270      await collectionEvm.methods.addCollectionAdminCross(userCross).send();271  272      const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));273      const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));274    275      const mintingResult = await collectionEvm.methods.mintWithTokenURI(user, 'Test URI').send({from: user});276      const tokenId = mintingResult.events.Transfer.returnValues.tokenId;277  278      const event = helper.eth.normalizeEvents(mintingResult.events)279        .find(event => event.event === 'Transfer');280      const address = helper.ethAddress.fromCollectionId(collectionId);281  282      expect(event).to.be.deep.equal({283        address,284        event: 'Transfer',285        args: {286          from: '0x0000000000000000000000000000000000000000',287          to: user,288          tokenId: '1',289        },290      });291      expect(await collectionEvm.methods.tokenURI(tokenId).call({from: user})).to.be.equal('Test URI');292  293      const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));294      expect(ownerBalanceAfter).to.be.eq(ownerBalanceBefore);295      const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));296      expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;297    }));298299  itEth('Can reassign collection sponsor', async ({helper}) => {300    const owner = await helper.eth.createAccountWithBalance(donor);301    const sponsorEth = await helper.eth.createAccountWithBalance(donor);302    const sponsorCrossEth = helper.ethCrossAccount.fromAddress(sponsorEth);303    const [sponsorSub] = await helper.arrange.createAccounts([100n], donor);304    const sponsorCrossSub = helper.ethCrossAccount.fromKeyringPair(sponsorSub);305306    const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');307    const collectionSub = helper.nft.getCollectionObject(collectionId);308    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);309310    // Set and confirm sponsor:311    await collectionEvm.methods.setCollectionSponsorCross(sponsorCrossEth).send({from: owner});312    await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsorEth});313314    // Can reassign sponsor:315    await collectionEvm.methods.setCollectionSponsorCross(sponsorCrossSub).send({from: owner});316    const collectionSponsor = (await collectionSub.getData())?.raw.sponsorship;317    expect(collectionSponsor).to.deep.eq({Unconfirmed: sponsorSub.address});318  });319});
modifiedtests/src/eth/createFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createFTCollection.test.ts
+++ b/tests/src/eth/createFTCollection.test.ts
@@ -18,7 +18,7 @@
 import {evmToAddress} from '@polkadot/util-crypto';
 import {Pallets, requirePalletsOrSkip} from '../util';
 import {expect, itEth, usingEthPlaygrounds} from './util';
-import { CollectionLimits } from './util/playgrounds/types';
+import {CollectionLimits} from './util/playgrounds/types';
 
 const DECIMALS = 18;
 
@@ -32,6 +32,7 @@
     });
   });
   
+  // TODO move sponsorship tests to another file:
   // Soft-deprecated
   itEth('[eth] Set sponsorship', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
@@ -91,6 +92,11 @@
     expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)
       .methods.isCollectionExist(collectionAddress).call())
       .to.be.true;
+    
+    // check collectionOwner:
+    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);
+    const collectionOwner = await collectionEvm.methods.collectionOwner().call();
+    expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner));
   });
   
   itEth('destroyCollection', async ({helper}) => {
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createNFTCollection.test.ts
+++ b/tests/src/eth/createNFTCollection.test.ts
@@ -132,6 +132,11 @@
     expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)
       .methods.isCollectionExist(collectionAddress).call())
       .to.be.true;
+
+    // check collectionOwner:
+    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);
+    const collectionOwner = await collectionEvm.methods.collectionOwner().call();
+    expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner));
   });
 });
 
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -88,27 +88,6 @@
     ]);
   });
   
-  // this test will occasionally fail when in async environment.
-  itEth.skip('Check collection address exist', async ({helper}) => {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-
-    const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;
-    const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);
-    const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
-
-    expect(await collectionHelpers.methods
-      .isCollectionExist(expectedCollectionAddress)
-      .call()).to.be.false;
-
-    await collectionHelpers.methods
-      .createRFTCollection('A', 'A', 'A')
-      .send({value: Number(2n * helper.balance.getOneTokenNominal())});
-    
-    expect(await collectionHelpers.methods
-      .isCollectionExist(expectedCollectionAddress)
-      .call()).to.be.true;
-  });
-  
   // Soft-deprecated
   itEth('[eth] Set sponsorship', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
@@ -164,6 +143,11 @@
     expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)
       .methods.isCollectionExist(collectionAddress).call())
       .to.be.true;
+
+    // check collectionOwner:
+    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);
+    const collectionOwner = await collectionEvm.methods.collectionOwner().call();
+    expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner));
   });
 });
 
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -167,7 +167,6 @@
     expect(event.returnValues.to).to.be.equal(receiver);
 
     expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
-    console.log(await contract.methods.crossOwnerOf(tokenId).call());
     expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
     // TODO: this wont work right now, need release 919000 first
     // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();
@@ -200,8 +199,7 @@
             },
           };
         });
-    
-    
+
       const collection = await helper.nft.mintCollection(minter, {
         tokenPrefix: 'ethp',
         tokenPropertyPermissions: permissions,