Use background gas price estimation method in new ui.

feature/default_network_editable
Dan 7 years ago
parent 9f5ee94b69
commit de01a6f112
  1. 1
      app/scripts/metamask-controller.js
  2. 22
      ui/app/actions.js

@ -338,6 +338,7 @@ module.exports = class MetamaskController extends EventEmitter {
markAccountsFound: this.markAccountsFound.bind(this),
markPasswordForgotten: this.markPasswordForgotten.bind(this),
unMarkPasswordForgotten: this.unMarkPasswordForgotten.bind(this),
getGasPrice: (cb) => cb(null, this.getGasPrice()),
// coinbase
buyEth: this.buyEth.bind(this),

@ -746,20 +746,26 @@ function updateGasData ({
}) {
return (dispatch) => {
dispatch(actions.gasLoadingStarted())
const estimatedGasPrice = estimateGasPriceFromRecentBlocks(recentBlocks)
return Promise.all([
Promise.resolve(estimatedGasPrice),
estimateGas({
let gasPrice
return (() => new Promise((resolve, reject) => {
background.getGasPrice((err, data) => {
if(err !== null) return reject(err);
return resolve(data);
})
}))()
.then(estimateGasPrice => {
gasPrice = estimateGasPrice
return estimateGas({
estimateGasMethod: background.estimateGas,
blockGasLimit,
selectedAddress,
selectedToken,
to,
value,
gasPrice: estimatedGasPrice,
}),
])
.then(([gasPrice, gas]) => {
gasPrice,
})
})
.then(gas => {
dispatch(actions.setGasPrice(gasPrice))
dispatch(actions.setGasLimit(gas))
return calcGasTotal(gas, gasPrice)

Loading…
Cancel
Save