@@ -4,7 +4,7 @@ const sqlite = require("sqlite");
44const sqlite3 = require ( "sqlite3" ) ;
55const queue = require ( "express-queue" ) ;
66const NonceManager = require ( "./ExtendedNonceManager" ) ;
7- const { colonyIOCors, ConsoleAdapter, updateGasEstimate } = require ( "../package-utils" ) ;
7+ const { colonyIOCors, ConsoleAdapter, getFeeData } = require ( "../package-utils" ) ;
88
99const ETHEREUM_BRIDGE_ADDRESS = "0x75Df5AF045d91108662D8080fD1FEFAd6aA0bb59" ;
1010const BINANCE_BRIDGE_ADDRESS = "0x162E898bD0aacB578C8D5F8d6ca588c13d2A383F" ;
@@ -81,7 +81,7 @@ class MetatransactionBroadcaster {
8181 const colonyNetworkDef = await this . loader . load ( { contractName : "IColonyNetwork" } , { abi : true , address : false } ) ;
8282 this . colonyNetwork = new ethers . Contract ( colonyNetworkAddress , colonyNetworkDef . abi , this . wallet ) ;
8383
84- this . gasPrice = await updateGasEstimate ( "safeLow" , this . chainId , this . adapter ) ;
84+ this . feeData = await getFeeData ( "safeLow" , this . chainId , this . adapter , this . provider ) ;
8585 this . tokenLockingAddress = await this . colonyNetwork . getTokenLocking ( ) ;
8686
8787 this . metaTxDef = await this . loader . load ( { contractName : "IBasicMetaTransaction" } , { abi : true , address : false } ) ;
@@ -336,6 +336,10 @@ class MetatransactionBroadcaster {
336336
337337 try {
338338 gasEstimate = await estimateGas ( ...args ) ;
339+ if ( ethers . BigNumber . from ( args [ args . length - 1 ] . gasLimit ) . gt ( gasEstimate . mul ( 11 ) . div ( 10 ) ) ) {
340+ // eslint-disable-next-line
341+ args [ args . length - 1 ] . gasLimit = gasEstimate . mul ( 11 ) . div ( 10 ) ;
342+ }
339343 } catch ( err ) {
340344 let reason ;
341345 try {
@@ -441,14 +445,14 @@ class MetatransactionBroadcaster {
441445 try {
442446 const { target, userAddress, payload, r, s, v } = req . body ;
443447 const contract = new ethers . Contract ( target , this . metaTxDef . abi , this . nonceManager ) ;
444- this . gasPrice = await updateGasEstimate ( "safeLow" , this . chainId , this . adapter ) ;
448+ this . feeData = await getFeeData ( "safeLow" , this . chainId , this . adapter , this . provider ) ;
445449 return this . processTransactionLogic ( req , res , contract . estimateGas . executeMetaTransaction , contract . executeMetaTransaction , [
446450 userAddress ,
447451 payload ,
448452 r ,
449453 s ,
450454 v ,
451- { gasPrice : this . gasPrice , gasLimit : this . gasLimit } ,
455+ { ... this . feeData , gasLimit : this . gasLimit } ,
452456 ] ) ;
453457 } catch ( err ) {
454458 return res . status ( 500 ) . send ( {
@@ -462,7 +466,7 @@ class MetatransactionBroadcaster {
462466 try {
463467 const { target, owner, spender, value, deadline, r, s, v } = req . body ;
464468 const contract = new ethers . Contract ( target , this . metaTxTokenDef . abi , this . nonceManager ) ;
465- this . gasPrice = await updateGasEstimate ( "safeLow" , this . chainId , this . adapter ) ;
469+ this . feeData = await getFeeData ( "safeLow" , this . chainId , this . adapter , this . provider ) ;
466470 return this . processTransactionLogic ( req , res , contract . estimateGas . permit , contract . permit , [
467471 owner ,
468472 spender ,
@@ -471,7 +475,7 @@ class MetatransactionBroadcaster {
471475 v ,
472476 r ,
473477 s ,
474- { gasPrice : this . gasPrice , gasLimit : this . gasLimit } ,
478+ { ... this . feeData , gasLimit : this . gasLimit } ,
475479 ] ) ;
476480 } catch ( err ) {
477481 return res . status ( 500 ) . send ( {
0 commit comments