diff options
author | Dan J Miller <danjm.com@gmail.com> | 2018-07-05 18:31:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-05 18:31:03 +0800 |
commit | 46cda26f3b982fb7ff26c29d2137540a5dc49457 (patch) | |
tree | 212cdcad5a11c77098905743ee06d1279fd94261 | |
parent | fd218142acb6dab0b2f921b9729f17ff90cffc2d (diff) | |
parent | 7d7662191af708621549cfd67592375436263eb3 (diff) | |
download | tangerine-wallet-browser-46cda26f3b982fb7ff26c29d2137540a5dc49457.tar tangerine-wallet-browser-46cda26f3b982fb7ff26c29d2137540a5dc49457.tar.gz tangerine-wallet-browser-46cda26f3b982fb7ff26c29d2137540a5dc49457.tar.bz2 tangerine-wallet-browser-46cda26f3b982fb7ff26c29d2137540a5dc49457.tar.lz tangerine-wallet-browser-46cda26f3b982fb7ff26c29d2137540a5dc49457.tar.xz tangerine-wallet-browser-46cda26f3b982fb7ff26c29d2137540a5dc49457.tar.zst tangerine-wallet-browser-46cda26f3b982fb7ff26c29d2137540a5dc49457.zip |
Merge pull request #4685 from MetaMask/estimate-gasprice-background-newui
Use background gas price estimation method in new ui.
-rw-r--r-- | app/scripts/metamask-controller.js | 1 | ||||
-rw-r--r-- | test/integration/lib/send-new-ui.js | 13 | ||||
-rw-r--r-- | ui/app/actions.js | 34 |
3 files changed, 22 insertions, 26 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index b4d39031a..450113acf 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.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), diff --git a/test/integration/lib/send-new-ui.js b/test/integration/lib/send-new-ui.js index 241358135..d5e80151c 100644 --- a/test/integration/lib/send-new-ui.js +++ b/test/integration/lib/send-new-ui.js @@ -112,19 +112,8 @@ async function runSendFlowTest (assert, done) { errorMessage = $('.send-v2__error') 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, 1, 21000, '0.000021', '$0.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') diff --git a/ui/app/actions.js b/ui/app/actions.js index 41fc3c504..ad890f565 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -6,7 +6,6 @@ const { calcGasTotal, calcTokenBalance, estimateGas, - estimateGasPriceFromRecentBlocks, } = require('./components/send_/send.utils') const ethUtil = require('ethereumjs-util') const { fetchLocale } = require('../i18n-helper') @@ -746,19 +745,26 @@ function updateGasData ({ }) { return (dispatch) => { dispatch(actions.gasLoadingStarted()) - const estimatedGasPrice = estimateGasPriceFromRecentBlocks(recentBlocks) - return Promise.all([ - Promise.resolve(estimatedGasPrice), - estimateGas({ - estimateGasMethod: background.estimateGas, - blockGasLimit, - selectedAddress, - selectedToken, - to, - value, - gasPrice: estimatedGasPrice, - }), - ]) + return new Promise((resolve, reject) => { + background.getGasPrice((err, data) => { + if (err) return reject(err) + return resolve(data) + }) + }) + .then(estimateGasPrice => { + return Promise.all([ + Promise.resolve(estimateGasPrice), + estimateGas({ + estimateGasMethod: background.estimateGas, + blockGasLimit, + selectedAddress, + selectedToken, + to, + value, + estimateGasPrice, + }), + ]) + }) .then(([gasPrice, gas]) => { dispatch(actions.setGasPrice(gasPrice)) dispatch(actions.setGasLimit(gas)) |