1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Use background gas price estimation method in new ui.

This commit is contained in:
Dan 2018-06-28 13:17:44 -02:30
parent 9f5ee94b69
commit de01a6f112
2 changed files with 15 additions and 8 deletions

View File

@ -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),

View File

@ -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)