mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #4685 from MetaMask/estimate-gasprice-background-newui
Use background gas price estimation method in new ui.
This commit is contained in:
commit
46cda26f3b
@ -338,6 +338,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
markAccountsFound: this.markAccountsFound.bind(this),
|
markAccountsFound: this.markAccountsFound.bind(this),
|
||||||
markPasswordForgotten: this.markPasswordForgotten.bind(this),
|
markPasswordForgotten: this.markPasswordForgotten.bind(this),
|
||||||
unMarkPasswordForgotten: this.unMarkPasswordForgotten.bind(this),
|
unMarkPasswordForgotten: this.unMarkPasswordForgotten.bind(this),
|
||||||
|
getGasPrice: (cb) => cb(null, this.getGasPrice()),
|
||||||
|
|
||||||
// coinbase
|
// coinbase
|
||||||
buyEth: this.buyEth.bind(this),
|
buyEth: this.buyEth.bind(this),
|
||||||
|
@ -112,19 +112,8 @@ async function runSendFlowTest (assert, done) {
|
|||||||
errorMessage = $('.send-v2__error')
|
errorMessage = $('.send-v2__error')
|
||||||
assert.equal(errorMessage.length, 0, 'send should stop rendering amount error message after amount is corrected')
|
assert.equal(errorMessage.length, 0, 'send should stop rendering amount error message after amount is corrected')
|
||||||
|
|
||||||
const sendGasField = await queryAsync($, '.send-v2__gas-fee-display')
|
|
||||||
assert.equal(
|
|
||||||
sendGasField.find('.currency-display__input-wrapper > input').val(),
|
|
||||||
'0.000021',
|
|
||||||
'send gas field should show estimated gas total'
|
|
||||||
)
|
|
||||||
assert.equal(
|
|
||||||
sendGasField.find('.currency-display__converted-value')[0].textContent,
|
|
||||||
'$0.03 USD',
|
|
||||||
'send gas field should show estimated gas total converted to USD'
|
|
||||||
)
|
|
||||||
|
|
||||||
await customizeGas(assert, 0, 21000, '0', '$0.00 USD')
|
await customizeGas(assert, 0, 21000, '0', '$0.00 USD')
|
||||||
|
await customizeGas(assert, 1, 21000, '0.000021', '$0.03 USD')
|
||||||
await customizeGas(assert, 500, 60000, '0.03', '$36.03 USD')
|
await customizeGas(assert, 500, 60000, '0.03', '$36.03 USD')
|
||||||
|
|
||||||
const sendButton = await queryAsync($, 'button.btn-primary.btn--large.page-container__footer-button')
|
const sendButton = await queryAsync($, 'button.btn-primary.btn--large.page-container__footer-button')
|
||||||
|
@ -6,7 +6,6 @@ const {
|
|||||||
calcGasTotal,
|
calcGasTotal,
|
||||||
calcTokenBalance,
|
calcTokenBalance,
|
||||||
estimateGas,
|
estimateGas,
|
||||||
estimateGasPriceFromRecentBlocks,
|
|
||||||
} = require('./components/send_/send.utils')
|
} = require('./components/send_/send.utils')
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const { fetchLocale } = require('../i18n-helper')
|
const { fetchLocale } = require('../i18n-helper')
|
||||||
@ -746,19 +745,26 @@ function updateGasData ({
|
|||||||
}) {
|
}) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(actions.gasLoadingStarted())
|
dispatch(actions.gasLoadingStarted())
|
||||||
const estimatedGasPrice = estimateGasPriceFromRecentBlocks(recentBlocks)
|
return new Promise((resolve, reject) => {
|
||||||
return Promise.all([
|
background.getGasPrice((err, data) => {
|
||||||
Promise.resolve(estimatedGasPrice),
|
if (err) return reject(err)
|
||||||
estimateGas({
|
return resolve(data)
|
||||||
estimateGasMethod: background.estimateGas,
|
})
|
||||||
blockGasLimit,
|
})
|
||||||
selectedAddress,
|
.then(estimateGasPrice => {
|
||||||
selectedToken,
|
return Promise.all([
|
||||||
to,
|
Promise.resolve(estimateGasPrice),
|
||||||
value,
|
estimateGas({
|
||||||
gasPrice: estimatedGasPrice,
|
estimateGasMethod: background.estimateGas,
|
||||||
}),
|
blockGasLimit,
|
||||||
])
|
selectedAddress,
|
||||||
|
selectedToken,
|
||||||
|
to,
|
||||||
|
value,
|
||||||
|
estimateGasPrice,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
})
|
||||||
.then(([gasPrice, gas]) => {
|
.then(([gasPrice, gas]) => {
|
||||||
dispatch(actions.setGasPrice(gasPrice))
|
dispatch(actions.setGasPrice(gasPrice))
|
||||||
dispatch(actions.setGasLimit(gas))
|
dispatch(actions.setGasLimit(gas))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user