difftreelog
fix replace old helpers with new ones
in: master
2 files changed
tests/src/eth/marketplace/marketplace.test.tsdiffbeforeafterboth17import {usingPlaygrounds} from './../../util/playgrounds/index';17import {usingPlaygrounds} from './../../util/playgrounds/index';18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import {readFile} from 'fs/promises';19import {readFile} from 'fs/promises';20import {collectionIdToAddress, contractHelpers, GAS_ARGS, SponsoringMode} from '../util/helpers';21import nonFungibleAbi from '../nonFungibleAbi.json';2223import {itEth, expect} from '../util/playgrounds';20import {itEth, expect, SponsoringMode} from '../util/playgrounds';2425const PRICE = 2000n;262127describe('Matcher contract usage', () => {22describe('Matcher contract usage', () => {23 const PRICE = 2000n;28 let donor: IKeyringPair;24 let donor: IKeyringPair;29 let alice: IKeyringPair;25 let alice: IKeyringPair;30 let aliceMirror: string;26 let aliceMirror: string;55 const matcherOwner = await helper.eth.createAccountWithBalance(donor);51 const matcherOwner = await helper.eth.createAccountWithBalance(donor);56 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {52 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {57 from: matcherOwner,53 from: matcherOwner,58 ...GAS_ARGS,54 gas: helper.eth.DEFAULT_GAS,59 });55 });60 const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments:[matcherOwner]}).send({from: matcherOwner});56 const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments:[matcherOwner]}).send({from: matcherOwner});615762 const sponsor = await helper.eth.createAccountWithBalance(donor);58 const sponsor = await helper.eth.createAccountWithBalance(donor);63 const helpers = contractHelpers(web3, matcherOwner);59 const helpers = helper.ethNativeContract.contractHelpers(matcherOwner);64 await helpers.methods.setSponsoringMode(matcher.options.address, SponsoringMode.Allowlisted).send({from: matcherOwner});60 await helpers.methods.setSponsoringMode(matcher.options.address, SponsoringMode.Allowlisted).send({from: matcherOwner});65 await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});61 await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});66 62 70 const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}, pendingSponsor: alice.address});66 const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}, pendingSponsor: alice.address});71 await collection.confirmSponsorship(alice);67 await collection.confirmSponsorship(alice);72 await collection.addToAllowList(alice, {Substrate: aliceDoubleMirror});68 await collection.addToAllowList(alice, {Substrate: aliceDoubleMirror});73 const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collection.collectionId), {from: matcherOwner});69 const evmCollection = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');74 await helper.eth.transferBalanceFromSubstrate(donor, aliceMirror);70 await helper.eth.transferBalanceFromSubstrate(donor, aliceMirror);757176 await helpers.methods.toggleAllowed(matcher.options.address, aliceMirror, true).send({from: matcherOwner});72 await helpers.methods.toggleAllowed(matcher.options.address, aliceMirror, true).send({from: matcherOwner});112 const matcherOwner = await helper.eth.createAccountWithBalance(donor);108 const matcherOwner = await helper.eth.createAccountWithBalance(donor);113 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {109 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {114 from: matcherOwner,110 from: matcherOwner,115 ...GAS_ARGS,111 gas: helper.eth.DEFAULT_GAS,116 });112 });117 const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments: [matcherOwner]}).send({from: matcherOwner, gas: 10000000});113 const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments: [matcherOwner]}).send({from: matcherOwner, gas: 10000000});118114119 const sponsor = await helper.eth.createAccountWithBalance(donor);115 const sponsor = await helper.eth.createAccountWithBalance(donor);120 const escrow = await helper.eth.createAccountWithBalance(donor);116 const escrow = await helper.eth.createAccountWithBalance(donor);121 await matcher.methods.setEscrow(escrow).send({from: matcherOwner});117 await matcher.methods.setEscrow(escrow).send({from: matcherOwner});122 const helpers = contractHelpers(web3, matcherOwner);118 const helpers = helper.ethNativeContract.contractHelpers(matcherOwner);123 await helpers.methods.setSponsoringMode(matcher.options.address, SponsoringMode.Allowlisted).send({from: matcherOwner});119 await helpers.methods.setSponsoringMode(matcher.options.address, SponsoringMode.Allowlisted).send({from: matcherOwner});124 await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});120 await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});125 121 129 const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}, pendingSponsor: alice.address});125 const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}, pendingSponsor: alice.address});130 await collection.confirmSponsorship(alice);126 await collection.confirmSponsorship(alice);131 await collection.addToAllowList(alice, {Substrate: aliceDoubleMirror});127 await collection.addToAllowList(alice, {Substrate: aliceDoubleMirror});132 const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collection.collectionId), {from: matcherOwner});128 const evmCollection = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');133 await helper.eth.transferBalanceFromSubstrate(donor, aliceMirror);129 await helper.eth.transferBalanceFromSubstrate(donor, aliceMirror);134130135131181 const matcherOwner = await helper.eth.createAccountWithBalance(donor);177 const matcherOwner = await helper.eth.createAccountWithBalance(donor);182 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {178 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {183 from: matcherOwner,179 from: matcherOwner,184 ...GAS_ARGS,180 gas: helper.eth.DEFAULT_GAS,185 });181 });186 const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments:[matcherOwner]}).send({from: matcherOwner});182 const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments:[matcherOwner]}).send({from: matcherOwner});187183188 await helper.eth.transferBalanceFromSubstrate(donor, matcher.options.address);184 await helper.eth.transferBalanceFromSubstrate(donor, matcher.options.address);189185190 const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}});186 const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}});191 const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collection.collectionId), {from: matcherOwner});187 const evmCollection = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');192188193 await helper.balance.transferToSubstrate(donor, seller.address, 100_000_000_000_000_000_000n);189 await helper.balance.transferToSubstrate(donor, seller.address, 100_000_000_000_000_000_000n);194 190 tests/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();