use gas price from message on gas estimate for amb events
This commit is contained in:
parent
7ca3b0079c
commit
95f4a0acc6
@ -8,10 +8,11 @@ const logger = require('../../services/logger').child({
|
||||
module: 'processAffirmationRequests:estimateGas'
|
||||
})
|
||||
|
||||
async function estimateGas({ web3, homeBridge, validatorContract, message, address }) {
|
||||
async function estimateGas({ web3, homeBridge, validatorContract, message, address, gasPrice }) {
|
||||
try {
|
||||
const gasEstimate = await homeBridge.methods.executeAffirmation(message).estimateGas({
|
||||
from: address
|
||||
from: address,
|
||||
gasPrice
|
||||
})
|
||||
|
||||
return gasEstimate
|
||||
|
@ -61,7 +61,8 @@ function processAffirmationRequestsBuilder(config) {
|
||||
homeBridge,
|
||||
validatorContract,
|
||||
message,
|
||||
address: config.validatorAddress
|
||||
address: config.validatorAddress,
|
||||
gasPrice
|
||||
})
|
||||
logger.debug({ gasEstimate }, 'Gas estimated')
|
||||
} catch (e) {
|
||||
|
@ -21,13 +21,15 @@ async function estimateGas({
|
||||
r,
|
||||
s,
|
||||
txHash,
|
||||
address
|
||||
address,
|
||||
gasPrice
|
||||
}) {
|
||||
try {
|
||||
const gasEstimate = await foreignBridge.methods
|
||||
.executeSignatures(message, v, r, s)
|
||||
.estimateGas({
|
||||
from: address
|
||||
from: address,
|
||||
gasPrice
|
||||
})
|
||||
return gasEstimate
|
||||
} catch (e) {
|
||||
|
@ -90,7 +90,8 @@ function processCollectedSignaturesBuilder(config) {
|
||||
message,
|
||||
numberOfCollectedSignatures: NumberOfCollectedSignatures,
|
||||
txHash,
|
||||
address: config.validatorAddress
|
||||
address: config.validatorAddress,
|
||||
gasPrice
|
||||
})
|
||||
logger.debug({ gasEstimate }, 'Gas estimated')
|
||||
} catch (e) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
const BigNumber = require('bignumber.js')
|
||||
const promiseRetry = require('promise-retry')
|
||||
const Web3 = require('web3')
|
||||
const Web3Utils = require('web3-utils')
|
||||
const { GAS_PRICE_OPTIONS } = require('./constants')
|
||||
|
||||
async function syncForEach(array, callback) {
|
||||
@ -102,7 +103,7 @@ function generateGasPriceOptions({ dataType, gasPrice, gasPriceSpeed }) {
|
||||
if (dataType === GAS_PRICE_OPTIONS.GAS_PRICE) {
|
||||
gasPriceOptions = {
|
||||
type: dataType,
|
||||
value: gasPrice
|
||||
value: Web3Utils.hexToNumberString(gasPrice)
|
||||
}
|
||||
} else if (dataType === GAS_PRICE_OPTIONS.SPEED) {
|
||||
gasPriceOptions = {
|
||||
|
@ -3,6 +3,7 @@ const chai = require('chai')
|
||||
const chaiAsPromised = require('chai-as-promised')
|
||||
const BigNumber = require('bignumber.js')
|
||||
const proxyquire = require('proxyquire')
|
||||
const Web3Utils = require('web3-utils')
|
||||
const { addExtraGas, syncForEach, generateGasPriceOptions } = require('../src/utils/utils')
|
||||
const { GAS_PRICE_OPTIONS, ORACLE_GAS_PRICE_SPEEDS } = require('../src/utils/constants')
|
||||
|
||||
@ -139,12 +140,14 @@ describe('utils', () => {
|
||||
it('should work for GAS_PRICE option', () => {
|
||||
// given
|
||||
const dataType = GAS_PRICE_OPTIONS.GAS_PRICE
|
||||
const gasPrice = BigNumber('0000000000000000000000000000000000000000000000000000000165a0bc00')
|
||||
const gasPrice = Web3Utils.toBN(
|
||||
'0000000000000000000000000000000000000000000000000000000165a0bc00'
|
||||
)
|
||||
const gasPriceSpeed = null
|
||||
|
||||
const expectedResult = {
|
||||
type: dataType,
|
||||
value: gasPrice
|
||||
value: Web3Utils.hexToNumberString(gasPrice)
|
||||
}
|
||||
|
||||
// when
|
||||
|
Loading…
Reference in New Issue
Block a user