fix: get gas prices

This commit is contained in:
Danil Kovtonyuk 2021-06-29 00:48:01 +03:00
parent 96d937ee0d
commit 3d7a9b5f93

@ -28,17 +28,13 @@ function start() {
try {
web3 = new Web3(httpRpcUrl)
const { CONFIRMATIONS, MAX_GAS_PRICE } = process.env
let gasPriceOracleConfig = {}
const networksWithOracle = [56, 137]
if (networksWithOracle.includes(netId)) {
gasPriceOracleConfig = {
chainId: netId,
defaultFallbackGasPrices: GAS_PRICES,
}
gasPriceOracle = new GasPriceOracle(gasPriceOracleConfig)
const gasPriceOracleConfig = {
chainId: netId,
defaultFallbackGasPrices: GAS_PRICES,
}
gasPriceOracle = new GasPriceOracle(gasPriceOracleConfig)
txManager = new TxManager({
privateKey,
rpcUrl: httpRpcUrl,
@ -54,13 +50,12 @@ function start() {
}
async function getGasPrices() {
let gasPrices = GAS_PRICES
if (gasPriceOracle) {
gasPrices = await gasPriceOracle.gasPrices()
const networksWithOracle = [56, 137]
if (networksWithOracle.includes(netId)) {
return await gasPriceOracle.gasPrices()
}
return gasPrices
return GAS_PRICES
}
async function checkTornadoFee({ args, contract }) {
@ -92,19 +87,15 @@ async function getTxObject({ data }) {
const calldata = contract.methods.withdraw(data.contract, data.proof, ...data.args).encodeABI()
const tx = {
const { fast } = await getGasPrices()
return {
value: data.args[5],
to: contract._address,
data: calldata,
gasLimit: gasLimits[jobType.TORNADO_WITHDRAW],
gasPrice: toHex(toWei(fast.toString(), 'gwei')),
}
if (!gasPriceOracle) {
const { fast } = await getGasPrices()
tx.gasPrice = toHex(toWei(fast.toString(), 'gwei'))
}
return tx
}
async function processJob(job) {