difftreelog
test update gas prices for new frontier
in: master
4 files changed
node/cli/src/chain_spec.rsdiffbeforeafterboth--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -213,7 +213,8 @@
balances: endowed_accounts
.iter()
.cloned()
- .map(|k| (k, 1 << 70))
+ // 1e13 UNQ
+ .map(|k| (k, 1 << 100))
.collect(),
},
treasury: Default::default(),
tests/src/eth/marketplace/marketplace.test.tsdiffbeforeafterboth--- a/tests/src/eth/marketplace/marketplace.test.ts
+++ b/tests/src/eth/marketplace/marketplace.test.ts
@@ -13,38 +13,41 @@
describe('Matcher contract usage', () => {
itWeb3('With UNQ', async ({api, web3}) => {
const alice = privateKey('//Alice');
- const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId));
const matcherOwner = await createEthAccountWithBalance(api, web3);
- const helpers = contractHelpers(web3, matcherOwner);
-
const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {
from: matcherOwner,
...GAS_ARGS,
});
const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments:[matcherOwner]}).send({from: matcherOwner});
-
+ const helpers = contractHelpers(web3, matcherOwner);
+ await helpers.methods.toggleSponsoring(matcher.options.address, true).send({from: matcherOwner});
+ await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});
await transferBalanceToEth(api, alice, matcher.options.address);
- await helpers.methods.toggleSponsoring(matcher.options.address, true).send({from: matcherOwner});
- await transferBalanceToEth(api, alice, subToEth(alice.address));
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});
await setCollectionSponsorExpectSuccess(collectionId, alice.address);
await confirmSponsorshipExpectSuccess(collectionId);
- const seller = privateKey('//Seller/' + Date.now());
- await addToAllowListExpectSuccess(alice, collectionId, {Ethereum:subToEth(seller.address)});
+ await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});
+ await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));
+
+ const seller = privateKey('//Bob');
await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});
+ await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(seller.address)));
const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);
- // To transfer item to matcher it first needs to be transfered to EVM account of seller
+ // To transfer item to matcher it first needs to be transfered to EVM account of bob
await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});
+
+ // Token is owned by seller initially
expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});
// Ask
{
await executeEthTxOnSub(web3, api, seller, evmCollection, m => m.approve(matcher.options.address, tokenId));
- await executeEthTxOnSub(web3, api, seller, matcher, m => m.setAsk(PRICE, '0x0000000000000000000000000000000000000001', evmCollection.options.address, tokenId));
+ await executeEthTxOnSub(web3, api, seller, matcher, m => m.addAsk(PRICE, '0x0000000000000000000000000000000000000001', evmCollection.options.address, tokenId));
}
// Token is transferred to matcher
@@ -69,6 +72,7 @@
// selling for custom tokens excluded from release
itWeb3.skip('With custom ERC20', async ({api, web3}) => {
+ const alice = privateKey('//Alice');
const matcherOwner = await createEthAccountWithBalance(api, web3);
const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {
from: matcherOwner,
@@ -76,7 +80,6 @@
});
const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments: [matcherOwner]}).send({from: matcherOwner});
- const alice = privateKey('//Alice');
const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});
@@ -100,7 +103,7 @@
// Ask
{
await executeEthTxOnSub(web3, api, seller, evmCollection, m => m.approve(matcher.options.address, tokenId));
- await executeEthTxOnSub(web3, api, seller, matcher, m => m.setAsk(PRICE, evmFungible.options.address, evmCollection.options.address, tokenId, 1));
+ await executeEthTxOnSub(web3, api, seller, matcher, m => m.addAsk(PRICE, evmFungible.options.address, evmCollection.options.address, tokenId, 1));
}
// Token is transferred to matcher
@@ -134,40 +137,43 @@
itWeb3('With escrow', async ({api, web3}) => {
const alice = privateKey('//Alice');
- const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId));
const matcherOwner = await createEthAccountWithBalance(api, web3);
- const helpers = contractHelpers(web3, matcherOwner);
const escrow = await createEthAccountWithBalance(api, web3);
-
const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {
from: matcherOwner,
...GAS_ARGS,
});
- const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments: [matcherOwner]}).send({from: matcherOwner});
+ const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments: [matcherOwner]}).send({from: matcherOwner, gas: 10000000});
await matcher.methods.setEscrow(escrow).send({from: matcherOwner});
-
- await transferBalanceToEth(api, alice, matcher.options.address);
+ const helpers = contractHelpers(web3, matcherOwner);
await helpers.methods.toggleSponsoring(matcher.options.address, true).send({from: matcherOwner});
+ await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});
+ await transferBalanceToEth(api, alice, matcher.options.address);
- await transferBalanceToEth(api, alice, subToEth(alice.address));
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});
await setCollectionSponsorExpectSuccess(collectionId, alice.address);
await confirmSponsorshipExpectSuccess(collectionId);
- const seller = privateKey('//Seller/' + Date.now());
+ await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});
+ await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));
+
+ const seller = privateKey('//Bob');
await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});
await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(seller.address)));
const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);
- // To transfer item to matcher it first needs to be transfered to EVM account of seller
+ // To transfer item to matcher it first needs to be transfered to EVM account of bob
await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});
+
+ // Token is owned by seller initially
expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});
// Ask
{
await executeEthTxOnSub(web3, api, seller, evmCollection, m => m.approve(matcher.options.address, tokenId));
- await executeEthTxOnSub(web3, api, seller, matcher, m => m.setAsk(PRICE, '0x0000000000000000000000000000000000000001', evmCollection.options.address, tokenId));
+ await executeEthTxOnSub(web3, api, seller, matcher, m => m.addAsk(PRICE, '0x0000000000000000000000000000000000000001', evmCollection.options.address, tokenId));
}
// Token is transferred to matcher
tests/src/eth/payable.test.tsdiffbeforeafterboth--- a/tests/src/eth/payable.test.ts
+++ b/tests/src/eth/payable.test.ts
@@ -1,7 +1,7 @@
import {expect} from 'chai';
import privateKey from '../substrate/privateKey';
import {submitTransactionAsync} from '../substrate/substrate-api';
-import {createEthAccountWithBalance, deployCollector, GAS_ARGS, itWeb3, subToEth} from './util/helpers';
+import {createEthAccountWithBalance, deployCollector, GAS_ARGS, itWeb3, subToEth, transferBalanceToEth} from './util/helpers';
import {evmToAddress} from '@polkadot/util-crypto';
import {getGenericResult} from '../util/helpers';
import {getBalanceSingle, transferBalanceExpectSuccess} from '../substrate/get-balance';
@@ -23,7 +23,7 @@
// Transaction fee/value will be payed from subToEth(sender) evm balance,
// which is backed by evmToAddress(subToEth(sender)) substrate balance
- await transferBalanceExpectSuccess(api, alice, evmToAddress(subToEth(alice.address)), '1000000000000');
+ await transferBalanceToEth(api, alice, subToEth(alice.address));
{
const tx = api.tx.evm.call(
tests/src/eth/util/helpers.tsdiffbeforeafterboth19import contractHelpersAbi from './contractHelpersAbi.json';19import contractHelpersAbi from './contractHelpersAbi.json';20import getBalance from '../../substrate/get-balance';20import getBalance from '../../substrate/get-balance';212122export const GAS_ARGS = {gas: 1000000};22export const GAS_ARGS = {gas: 2500000};232324let web3Connected = false;24let web3Connected = false;25export async function usingWeb3<T>(cb: (web3: Web3) => Promise<T> | T): Promise<T> {25export async function usingWeb3<T>(cb: (web3: Web3) => Promise<T> | T): Promise<T> {63 return account;63 return account;64}64}656566export async function transferBalanceToEth(api: ApiPromise, source: IKeyringPair, target: string, amount = 10000n * UNIQUE) {66export async function transferBalanceToEth(api: ApiPromise, source: IKeyringPair, target: string, amount = 1000n * UNIQUE) {67 const tx = api.tx.balances.transfer(evmToAddress(target), amount);67 const tx = api.tx.balances.transfer(evmToAddress(target), amount);68 const events = await submitTransactionAsync(source, tx);68 const events = await submitTransactionAsync(source, tx);69 const result = getGenericResult(events);69 const result = getGenericResult(events);228 return new web3.eth.Contract(contractHelpersAbi as any, '0x842899ECF380553E8a4de75bF534cdf6fBF64049', {from: caller, ...GAS_ARGS});228 return new web3.eth.Contract(contractHelpersAbi as any, '0x842899ECF380553E8a4de75bF534cdf6fBF64049', {from: caller, ...GAS_ARGS});229}229}230230231/**231/**232 * Execute ethereum method call using substrate account232 * Execute ethereum method call using substrate account233 * @param to target contract233 * @param to target contract234 * @param mkTx - closure, receiving `contract.methods`, and returning method call,234 * @param mkTx - closure, receiving `contract.methods`, and returning method call,235 * to be used as following (assuming `to` = erc20 contract):235 * to be used as following (assuming `to` = erc20 contract):236 * `m => m.transfer(to, amount)`236 * `m => m.transfer(to, amount)`237 * 237 *238 * # Example238 * # Example239 * ```ts239 * ```ts240 * executeEthTxOnSub(api, alice, erc20Contract, m => m.transfer(target, amount));240 * executeEthTxOnSub(api, alice, erc20Contract, m => m.transfer(target, amount));241 * ```241 * ```242 */242 */243export async function executeEthTxOnSub(web3: Web3, api: ApiPromise, from: IKeyringPair, to: any, mkTx: (methods: any) => any, {value = 0}: {value?: bigint | number} = { }) {243export async function executeEthTxOnSub(web3: Web3, api: ApiPromise, from: IKeyringPair, to: any, mkTx: (methods: any) => any, {value = 0}: {value?: bigint | number} = { }) {244 const tx = api.tx.evm.call(244 const tx = api.tx.evm.call(245 subToEth(from.address),245 subToEth(from.address),258 return (await getBalance(api, [evmToAddress(address)]))[0];258 return (await getBalance(api, [evmToAddress(address)]))[0];259}259}260260261/**261/**262 * Measure how much gas given closure consumes262 * Measure how much gas given closure consumes263 * 263 *264 * @param user which user balance will be checked264 * @param user which user balance will be checked265 */265 */266export async function recordEthFee(api: ApiPromise, user: string, call: () => Promise<any>): Promise<bigint> {266export async function recordEthFee(api: ApiPromise, user: string, call: () => Promise<any>): Promise<bigint> {267 const before = await ethBalanceViaSub(api, user);267 const before = await ethBalanceViaSub(api, user);268268