fix: get gas prices
This commit is contained in:
parent
96d937ee0d
commit
3d7a9b5f93
@ -28,17 +28,13 @@ function start() {
|
|||||||
try {
|
try {
|
||||||
web3 = new Web3(httpRpcUrl)
|
web3 = new Web3(httpRpcUrl)
|
||||||
const { CONFIRMATIONS, MAX_GAS_PRICE } = process.env
|
const { CONFIRMATIONS, MAX_GAS_PRICE } = process.env
|
||||||
let gasPriceOracleConfig = {}
|
const gasPriceOracleConfig = {
|
||||||
|
chainId: netId,
|
||||||
const networksWithOracle = [56, 137]
|
defaultFallbackGasPrices: GAS_PRICES,
|
||||||
if (networksWithOracle.includes(netId)) {
|
|
||||||
gasPriceOracleConfig = {
|
|
||||||
chainId: netId,
|
|
||||||
defaultFallbackGasPrices: GAS_PRICES,
|
|
||||||
}
|
|
||||||
gasPriceOracle = new GasPriceOracle(gasPriceOracleConfig)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gasPriceOracle = new GasPriceOracle(gasPriceOracleConfig)
|
||||||
|
|
||||||
txManager = new TxManager({
|
txManager = new TxManager({
|
||||||
privateKey,
|
privateKey,
|
||||||
rpcUrl: httpRpcUrl,
|
rpcUrl: httpRpcUrl,
|
||||||
@ -54,13 +50,12 @@ function start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getGasPrices() {
|
async function getGasPrices() {
|
||||||
let gasPrices = GAS_PRICES
|
const networksWithOracle = [56, 137]
|
||||||
|
if (networksWithOracle.includes(netId)) {
|
||||||
if (gasPriceOracle) {
|
return await gasPriceOracle.gasPrices()
|
||||||
gasPrices = await gasPriceOracle.gasPrices()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return gasPrices
|
return GAS_PRICES
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkTornadoFee({ args, contract }) {
|
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 calldata = contract.methods.withdraw(data.contract, data.proof, ...data.args).encodeABI()
|
||||||
|
|
||||||
const tx = {
|
const { fast } = await getGasPrices()
|
||||||
|
|
||||||
|
return {
|
||||||
value: data.args[5],
|
value: data.args[5],
|
||||||
to: contract._address,
|
to: contract._address,
|
||||||
data: calldata,
|
data: calldata,
|
||||||
gasLimit: gasLimits[jobType.TORNADO_WITHDRAW],
|
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) {
|
async function processJob(job) {
|
||||||
|
Loading…
Reference in New Issue
Block a user