From 4ad2532d647c6350ed939e067e1cc5101cbd0929 Mon Sep 17 00:00:00 2001 From: Maksandre Date: Wed, 05 Oct 2022 06:43:55 +0000 Subject: [PATCH] Fix: replace old helpers with new ones --- --- a/tests/src/eth/marketplace/marketplace.test.ts +++ b/tests/src/eth/marketplace/marketplace.test.ts @@ -17,14 +17,10 @@ import {usingPlaygrounds} from './../../util/playgrounds/index'; import {IKeyringPair} from '@polkadot/types/types'; import {readFile} from 'fs/promises'; -import {collectionIdToAddress, contractHelpers, GAS_ARGS, SponsoringMode} from '../util/helpers'; -import nonFungibleAbi from '../nonFungibleAbi.json'; - -import {itEth, expect} from '../util/playgrounds'; - -const PRICE = 2000n; +import {itEth, expect, SponsoringMode} from '../util/playgrounds'; describe('Matcher contract usage', () => { + const PRICE = 2000n; let donor: IKeyringPair; let alice: IKeyringPair; let aliceMirror: string; @@ -55,12 +51,12 @@ const matcherOwner = await helper.eth.createAccountWithBalance(donor); const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, { from: matcherOwner, - ...GAS_ARGS, + gas: helper.eth.DEFAULT_GAS, }); const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments:[matcherOwner]}).send({from: matcherOwner}); const sponsor = await helper.eth.createAccountWithBalance(donor); - const helpers = contractHelpers(web3, matcherOwner); + const helpers = helper.ethNativeContract.contractHelpers(matcherOwner); await helpers.methods.setSponsoringMode(matcher.options.address, SponsoringMode.Allowlisted).send({from: matcherOwner}); await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner}); @@ -70,7 +66,7 @@ const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}, pendingSponsor: alice.address}); await collection.confirmSponsorship(alice); await collection.addToAllowList(alice, {Substrate: aliceDoubleMirror}); - const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collection.collectionId), {from: matcherOwner}); + const evmCollection = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft'); await helper.eth.transferBalanceFromSubstrate(donor, aliceMirror); await helpers.methods.toggleAllowed(matcher.options.address, aliceMirror, true).send({from: matcherOwner}); @@ -112,14 +108,14 @@ const matcherOwner = await helper.eth.createAccountWithBalance(donor); const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, { from: matcherOwner, - ...GAS_ARGS, + gas: helper.eth.DEFAULT_GAS, }); const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments: [matcherOwner]}).send({from: matcherOwner, gas: 10000000}); const sponsor = await helper.eth.createAccountWithBalance(donor); const escrow = await helper.eth.createAccountWithBalance(donor); await matcher.methods.setEscrow(escrow).send({from: matcherOwner}); - const helpers = contractHelpers(web3, matcherOwner); + const helpers = helper.ethNativeContract.contractHelpers(matcherOwner); await helpers.methods.setSponsoringMode(matcher.options.address, SponsoringMode.Allowlisted).send({from: matcherOwner}); await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner}); @@ -129,7 +125,7 @@ const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}, pendingSponsor: alice.address}); await collection.confirmSponsorship(alice); await collection.addToAllowList(alice, {Substrate: aliceDoubleMirror}); - const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collection.collectionId), {from: matcherOwner}); + const evmCollection = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft'); await helper.eth.transferBalanceFromSubstrate(donor, aliceMirror); @@ -181,14 +177,14 @@ const matcherOwner = await helper.eth.createAccountWithBalance(donor); const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, { from: matcherOwner, - ...GAS_ARGS, + gas: helper.eth.DEFAULT_GAS, }); const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments:[matcherOwner]}).send({from: matcherOwner}); await helper.eth.transferBalanceFromSubstrate(donor, matcher.options.address); const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}}); - const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collection.collectionId), {from: matcherOwner}); + const evmCollection = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft'); await helper.balance.transferToSubstrate(donor, seller.address, 100_000_000_000_000_000_000n); --- 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) => { const silentConsole = new SilentConsole(); silentConsole.enable(); -- gitstuff