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

difftreelog

Merge pull request #627 from UniqueNetwork/test/eth-market

ut-akuznetsov2022-10-05parents: #8b875cb #4ad2532.patch.diff
in: master
Test/eth market to playgrounds

3 files changed

modifiedtests/src/eth/marketplace/marketplace.test.tsdiffbeforeafterboth
before · tests/src/eth/marketplace/marketplace.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 {readFile} from 'fs/promises';18import {getBalanceSingle} from '../../substrate/get-balance';19import {20  addToAllowListExpectSuccess, 21  confirmSponsorshipExpectSuccess, 22  createCollectionExpectSuccess, 23  createItemExpectSuccess, 24  getTokenOwner,25  setCollectionLimitsExpectSuccess, 26  setCollectionSponsorExpectSuccess, 27  transferExpectSuccess, 28  transferFromExpectSuccess,29  transferBalanceTo,30} from '../../util/helpers';31import {collectionIdToAddress, contractHelpers, createEthAccountWithBalance, executeEthTxOnSub, GAS_ARGS, itWeb3, SponsoringMode, subToEth, subToEthLowercase, transferBalanceToEth} from '../util/helpers';32import {evmToAddress} from '@polkadot/util-crypto';33import nonFungibleAbi from '../nonFungibleAbi.json';3435import {expect} from 'chai';3637const PRICE = 2000n;3839describe('Matcher contract usage', () => {40  itWeb3('With UNQ', async ({api, web3, privateKeyWrapper}) => {41    const alice = privateKeyWrapper('//Alice');42    const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);43    const matcherOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);44    const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {45      from: matcherOwner,46      ...GAS_ARGS,47    });48    const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments:[matcherOwner]}).send({from: matcherOwner});49    const helpers = contractHelpers(web3, matcherOwner);50    await helpers.methods.setSponsoringMode(matcher.options.address, SponsoringMode.Allowlisted).send({from: matcherOwner});51    await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});52    53    await helpers.methods.setSponsor(matcher.options.address, sponsor).send({from: matcherOwner});54    await helpers.methods.confirmSponsorship(matcher.options.address).send({from: sponsor});5556    const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});57    await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorApproveTimeout: 1});58    const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});59    await setCollectionSponsorExpectSuccess(collectionId, alice.address);60    await transferBalanceToEth(api, alice, subToEth(alice.address));61    await confirmSponsorshipExpectSuccess(collectionId);6263    await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});64    await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));6566    const seller = privateKeyWrapper(`//Seller/${Date.now()}`);67    await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});6869    const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);7071    // To transfer item to matcher it first needs to be transfered to EVM account of bob72    await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});7374    // Token is owned by seller initially75    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});7677    // Ask78    {79      await executeEthTxOnSub(web3, api, seller, evmCollection, m => m.approve(matcher.options.address, tokenId));80      await executeEthTxOnSub(web3, api, seller, matcher, m => m.addAsk(PRICE, '0x0000000000000000000000000000000000000001', evmCollection.options.address, tokenId));81    }8283    // Token is transferred to matcher84    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: matcher.options.address.toLowerCase()});8586    // Buy87    {88      const sellerBalanceBeforePurchase = await getBalanceSingle(api, seller.address);89      await executeEthTxOnSub(web3, api, alice, matcher, m => m.buy(evmCollection.options.address, tokenId), {value: PRICE});90      expect(await getBalanceSingle(api, seller.address) - sellerBalanceBeforePurchase === PRICE);91    }9293    // Token is transferred to evm account of alice94    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(alice.address)});9596    // Transfer token to substrate side of alice97    await transferFromExpectSuccess(collectionId, tokenId, alice, {Ethereum: subToEth(alice.address)}, {Substrate: alice.address});9899    // Token is transferred to substrate account of alice, seller received funds100    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Substrate: alice.address});101  });102103104  itWeb3('With escrow', async ({api, web3, privateKeyWrapper}) => {105    const alice = privateKeyWrapper('//Alice');106    const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);107    const matcherOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);108    const escrow = await createEthAccountWithBalance(api, web3, privateKeyWrapper);109    const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {110      from: matcherOwner,111      ...GAS_ARGS,112    });113    const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments: [matcherOwner]}).send({from: matcherOwner, gas: 10000000});114    await matcher.methods.setEscrow(escrow).send({from: matcherOwner});115    const helpers = contractHelpers(web3, matcherOwner);116    await helpers.methods.setSponsoringMode(matcher.options.address, SponsoringMode.Allowlisted).send({from: matcherOwner});117    await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});118    119    await helpers.methods.setSponsor(matcher.options.address, sponsor).send({from: matcherOwner});120    await helpers.methods.confirmSponsorship(matcher.options.address).send({from: sponsor});121122    const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});123    await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorApproveTimeout: 1});124    const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});125    await setCollectionSponsorExpectSuccess(collectionId, alice.address);126    await transferBalanceToEth(api, alice, subToEth(alice.address));127    await confirmSponsorshipExpectSuccess(collectionId);128129    await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});130    await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));131132    const seller = privateKeyWrapper(`//Seller/${Date.now()}`);133    await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});134135    const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);136137    // To transfer item to matcher it first needs to be transfered to EVM account of bob138    await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});139140    // Token is owned by seller initially141    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});142143    // Ask144    {145      await executeEthTxOnSub(web3, api, seller, evmCollection, m => m.approve(matcher.options.address, tokenId));146      await executeEthTxOnSub(web3, api, seller, matcher, m => m.addAsk(PRICE, '0x0000000000000000000000000000000000000001', evmCollection.options.address, tokenId));147    }148149    // Token is transferred to matcher150    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: matcher.options.address.toLowerCase()});151152    // Give buyer KSM153    await matcher.methods.depositKSM(PRICE, subToEth(alice.address)).send({from: escrow});154155    // Buy156    {157      expect(await matcher.methods.balanceKSM(subToEth(seller.address)).call()).to.be.equal('0');158      expect(await matcher.methods.balanceKSM(subToEth(alice.address)).call()).to.be.equal(PRICE.toString());159160      await executeEthTxOnSub(web3, api, alice, matcher, m => m.buyKSM(evmCollection.options.address, tokenId, subToEth(alice.address), subToEth(alice.address)));161162      // Price is removed from buyer balance, and added to seller163      expect(await matcher.methods.balanceKSM(subToEth(alice.address)).call()).to.be.equal('0');164      expect(await matcher.methods.balanceKSM(subToEth(seller.address)).call()).to.be.equal(PRICE.toString());165    }166167    // Token is transferred to evm account of alice168    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(alice.address)});169170    // Transfer token to substrate side of alice171    await transferFromExpectSuccess(collectionId, tokenId, alice, {Ethereum: subToEth(alice.address)}, {Substrate: alice.address});172173    // Token is transferred to substrate account of alice, seller received funds174    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Substrate: alice.address});175  });176177178  itWeb3('Sell tokens from substrate user via EVM contract', async ({api, web3, privateKeyWrapper}) => {179    const alice = privateKeyWrapper('//Alice');180    const matcherOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);181    const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {182      from: matcherOwner,183      ...GAS_ARGS,184    });185    const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments:[matcherOwner]}).send({from: matcherOwner});186    await transferBalanceToEth(api, alice, matcher.options.address);187188    const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});189    await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorApproveTimeout: 1});190    const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});191192    const seller = privateKeyWrapper(`//Seller/${Date.now()}`);193    await transferBalanceTo(api, alice, seller.address);194    195    const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);196197    // To transfer item to matcher it first needs to be transfered to EVM account of bob198    await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});199200    // Token is owned by seller initially201    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});202203    // Ask204    {205      await executeEthTxOnSub(web3, api, seller, evmCollection, m => m.approve(matcher.options.address, tokenId));206      await executeEthTxOnSub(web3, api, seller, matcher, m => m.addAsk(PRICE, '0x0000000000000000000000000000000000000001', evmCollection.options.address, tokenId));207    }208209    // Token is transferred to matcher210    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: matcher.options.address.toLowerCase()});211212    // Buy213    {214      const sellerBalanceBeforePurchase = await getBalanceSingle(api, seller.address);215      await executeEthTxOnSub(web3, api, alice, matcher, m => m.buy(evmCollection.options.address, tokenId), {value: PRICE});216      expect(await getBalanceSingle(api, seller.address) - sellerBalanceBeforePurchase === PRICE);217    }218219    // Token is transferred to evm account of alice220    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(alice.address)});221222    // Transfer token to substrate side of alice223    await transferFromExpectSuccess(collectionId, tokenId, alice, {Ethereum: subToEth(alice.address)}, {Substrate: alice.address});224225    // Token is transferred to substrate account of alice, seller received funds226    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Substrate: alice.address});227  });228});
after · tests/src/eth/marketplace/marketplace.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 {usingPlaygrounds} from './../../util/playgrounds/index';18import {IKeyringPair} from '@polkadot/types/types';19import {readFile} from 'fs/promises';20import {itEth, expect, SponsoringMode} from '../util/playgrounds';2122describe('Matcher contract usage', () => {23  const PRICE = 2000n;24  let donor: IKeyringPair;25  let alice: IKeyringPair;26  let aliceMirror: string;27  let aliceDoubleMirror: string;28  let seller: IKeyringPair;29  let sellerMirror: string;3031  before(async () => {32    await usingPlaygrounds(async (_helper, privateKey) => {33      donor = privateKey('//Alice');34    }); 35  });3637  beforeEach(async () => {38    await usingPlaygrounds(async (helper, privateKey) => {39      [alice] = await helper.arrange.createAccounts([10000n], donor);40      aliceMirror = helper.address.substrateToEth(alice.address).toLowerCase();41      aliceDoubleMirror = helper.address.ethToSubstrate(aliceMirror);42      seller = privateKey(`//Seller/${Date.now()}`);43      sellerMirror = helper.address.substrateToEth(seller.address).toLowerCase();4445      await helper.balance.transferToSubstrate(donor, aliceDoubleMirror, 10_000_000_000_000_000_000n);46    });47  });4849  itEth('With UNQ', async ({helper}) => {50    const web3 = helper.getWeb3();51    const matcherOwner = await helper.eth.createAccountWithBalance(donor);52    const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {53      from: matcherOwner,54      gas: helper.eth.DEFAULT_GAS,55    });56    const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments:[matcherOwner]}).send({from: matcherOwner});5758    const sponsor = await helper.eth.createAccountWithBalance(donor);59    const helpers = helper.ethNativeContract.contractHelpers(matcherOwner);60    await helpers.methods.setSponsoringMode(matcher.options.address, SponsoringMode.Allowlisted).send({from: matcherOwner});61    await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});62    63    await helpers.methods.setSponsor(matcher.options.address, sponsor).send({from: matcherOwner});64    await helpers.methods.confirmSponsorship(matcher.options.address).send({from: sponsor});6566    const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}, pendingSponsor: alice.address});67    await collection.confirmSponsorship(alice);68    await collection.addToAllowList(alice, {Substrate: aliceDoubleMirror});69    const evmCollection = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');70    await helper.eth.transferBalanceFromSubstrate(donor, aliceMirror);7172    await helpers.methods.toggleAllowed(matcher.options.address, aliceMirror, true).send({from: matcherOwner});73    await helpers.methods.toggleAllowed(matcher.options.address, sellerMirror, true).send({from: matcherOwner});7475    const token = await collection.mintToken(alice, {Ethereum: sellerMirror});7677    // Token is owned by seller initially78    expect(await token.getOwner()).to.be.deep.equal({Ethereum: sellerMirror});7980    // Ask81    {82      await helper.eth.sendEVM(seller, evmCollection.options.address, evmCollection.methods.approve(matcher.options.address, token.tokenId).encodeABI(), '0');83      await helper.eth.sendEVM(seller, matcher.options.address, matcher.methods.addAsk(PRICE, '0x0000000000000000000000000000000000000001', evmCollection.options.address, token.tokenId).encodeABI(), '0');84    }8586    // Token is transferred to matcher87    expect(await token.getOwner()).to.be.deep.equal({Ethereum: matcher.options.address.toLowerCase()});8889    // Buy90    {91      const sellerBalanceBeforePurchase = await helper.balance.getSubstrate(seller.address);92      await helper.eth.sendEVM(alice, matcher.options.address, matcher.methods.buy(evmCollection.options.address, token.tokenId).encodeABI(), PRICE.toString());93      expect(await helper.balance.getSubstrate(seller.address) - sellerBalanceBeforePurchase === PRICE);94    }9596    // Token is transferred to evm account of alice97    expect(await token.getOwner()).to.be.deep.equal({Ethereum: aliceMirror});9899    // Transfer token to substrate side of alice100    await token.transferFrom(alice, {Ethereum: aliceMirror}, {Substrate: alice.address});101102    // Token is transferred to substrate account of alice, seller received funds103    expect(await token.getOwner()).to.be.deep.equal({Substrate: alice.address});104  });105106  itEth('With escrow', async ({helper}) => {107    const web3 = helper.getWeb3();108    const matcherOwner = await helper.eth.createAccountWithBalance(donor);109    const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {110      from: matcherOwner,111      gas: helper.eth.DEFAULT_GAS,112    });113    const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments: [matcherOwner]}).send({from: matcherOwner, gas: 10000000});114115    const sponsor = await helper.eth.createAccountWithBalance(donor);116    const escrow = await helper.eth.createAccountWithBalance(donor);117    await matcher.methods.setEscrow(escrow).send({from: matcherOwner});118    const helpers = helper.ethNativeContract.contractHelpers(matcherOwner);119    await helpers.methods.setSponsoringMode(matcher.options.address, SponsoringMode.Allowlisted).send({from: matcherOwner});120    await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});121    122    await helpers.methods.setSponsor(matcher.options.address, sponsor).send({from: matcherOwner});123    await helpers.methods.confirmSponsorship(matcher.options.address).send({from: sponsor});124125    const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}, pendingSponsor: alice.address});126    await collection.confirmSponsorship(alice);127    await collection.addToAllowList(alice, {Substrate: aliceDoubleMirror});128    const evmCollection = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');129    await helper.eth.transferBalanceFromSubstrate(donor, aliceMirror);130131132    await helpers.methods.toggleAllowed(matcher.options.address, aliceMirror, true).send({from: matcherOwner});133134    await helpers.methods.toggleAllowed(matcher.options.address, sellerMirror, true).send({from: matcherOwner});135136    const token = await collection.mintToken(alice, {Ethereum: sellerMirror});137138    // Token is owned by seller initially139    expect(await token.getOwner()).to.be.deep.equal({Ethereum: sellerMirror});140141    // Ask142    {143      await helper.eth.sendEVM(seller, evmCollection.options.address, evmCollection.methods.approve(matcher.options.address, token.tokenId).encodeABI(), '0');144      await helper.eth.sendEVM(seller, matcher.options.address, matcher.methods.addAsk(PRICE, '0x0000000000000000000000000000000000000001', evmCollection.options.address, token.tokenId).encodeABI(), '0');145    }146147    // Token is transferred to matcher148    expect(await token.getOwner()).to.be.deep.equal({Ethereum: matcher.options.address.toLowerCase()});149150    // Give buyer KSM151    await matcher.methods.depositKSM(PRICE, aliceMirror).send({from: escrow});152153    // Buy154    {155      expect(await matcher.methods.balanceKSM(sellerMirror).call()).to.be.equal('0');156      expect(await matcher.methods.balanceKSM(aliceMirror).call()).to.be.equal(PRICE.toString());157158      await helper.eth.sendEVM(alice, matcher.options.address, matcher.methods.buyKSM(evmCollection.options.address, token.tokenId, aliceMirror, aliceMirror).encodeABI(), '0');159160      // Price is removed from buyer balance, and added to seller161      expect(await matcher.methods.balanceKSM(aliceMirror).call()).to.be.equal('0');162      expect(await matcher.methods.balanceKSM(sellerMirror).call()).to.be.equal(PRICE.toString());163    }164165    // Token is transferred to evm account of alice166    expect(await token.getOwner()).to.be.deep.equal({Ethereum: aliceMirror});167168    // Transfer token to substrate side of alice169    await token.transferFrom(alice, {Ethereum: aliceMirror}, {Substrate: alice.address});170171    // Token is transferred to substrate account of alice, seller received funds172    expect(await token.getOwner()).to.be.deep.equal({Substrate: alice.address});173  });174175  itEth('Sell tokens from substrate user via EVM contract', async ({helper}) => {176    const web3 = helper.getWeb3();177    const matcherOwner = await helper.eth.createAccountWithBalance(donor);178    const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {179      from: matcherOwner,180      gas: helper.eth.DEFAULT_GAS,181    });182    const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments:[matcherOwner]}).send({from: matcherOwner});183184    await helper.eth.transferBalanceFromSubstrate(donor, matcher.options.address);185186    const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}});187    const evmCollection = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');188189    await helper.balance.transferToSubstrate(donor, seller.address, 100_000_000_000_000_000_000n);190    191    const token = await collection.mintToken(alice, {Ethereum: sellerMirror});192193    // Token is owned by seller initially194    expect(await token.getOwner()).to.be.deep.equal({Ethereum: sellerMirror});195196    // Ask197    {198      await helper.eth.sendEVM(seller, evmCollection.options.address, evmCollection.methods.approve(matcher.options.address, token.tokenId).encodeABI(), '0');199      await helper.eth.sendEVM(seller, matcher.options.address, matcher.methods.addAsk(PRICE, '0x0000000000000000000000000000000000000001', evmCollection.options.address, token.tokenId).encodeABI(), '0');200    }201202    // Token is transferred to matcher203    expect(await token.getOwner()).to.be.deep.equal({Ethereum: matcher.options.address.toLowerCase()});204205    // Buy206    {207      const sellerBalanceBeforePurchase = await helper.balance.getSubstrate(seller.address);208      await helper.eth.sendEVM(alice, matcher.options.address, matcher.methods.buy(evmCollection.options.address, token.tokenId).encodeABI(), PRICE.toString());209      expect(await helper.balance.getSubstrate(seller.address) - sellerBalanceBeforePurchase === PRICE);210    }211212    // Token is transferred to evm account of alice213    expect(await token.getOwner()).to.be.deep.equal({Ethereum: aliceMirror});214215    // Transfer token to substrate side of alice216    await token.transferFrom(alice, {Ethereum: aliceMirror}, {Substrate: alice.address});217218    // Token is transferred to substrate account of alice, seller received funds219    expect(await token.getOwner()).to.be.deep.equal({Substrate: alice.address});220  });221});
modifiedtests/src/eth/util/playgrounds/index.tsdiffbeforeafterboth
--- a/tests/src/eth/util/playgrounds/index.ts
+++ b/tests/src/eth/util/playgrounds/index.ts
@@ -18,6 +18,12 @@
 chai.use(chaiLike);
 export const expect = chai.expect;
 
+export enum SponsoringMode {
+  Disabled = 0,
+  Allowlisted = 1,
+  Generous = 2,
+}
+
 export const usingEthPlaygrounds = async (code: (helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {
   const silentConsole = new SilentConsole();
   silentConsole.enable();
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -275,6 +275,7 @@
   }
   
   private static extractData(data: any, type: any): any {
+    if(!type) return data.toHuman();
     if (['u16', 'u32'].indexOf(type.type) > -1) return data.toNumber();
     if (['u64', 'u128', 'u256'].indexOf(type.type) > -1) return data.toBigInt();
     if(type.hasOwnProperty('sub')) return this.extractSub(data, type.sub);
@@ -2160,7 +2161,7 @@
    */
   async stake(signer: TSigner, amountToStake: bigint, label?: string): Promise<boolean> {
     if(typeof label === 'undefined') label = `${signer.address} amount: ${amountToStake}`;
-    const stakeResult = await this.helper.executeExtrinsic(
+    const _stakeResult = await this.helper.executeExtrinsic(
       signer, 'api.tx.appPromotion.stake',
       [amountToStake], true,
     );
@@ -2177,7 +2178,7 @@
    */
   async unstake(signer: TSigner, label?: string): Promise<number> {
     if(typeof label === 'undefined') label = `${signer.address}`;
-    const unstakeResult = await this.helper.executeExtrinsic(
+    const _unstakeResult = await this.helper.executeExtrinsic(
       signer, 'api.tx.appPromotion.unstake',
       [], true,
     );