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:
parent
9f5ee94b69
commit
de01a6f112
@ -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…
Reference in New Issue
Block a user