1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +02:00

Merge pull request #5917 from MetaMask/correct-gas-limit-from-external-tx

Ensures that advanced tab gas limit reflects tx gas limit
This commit is contained in:
Dan J Miller 2018-12-12 12:19:31 -03:30 committed by GitHub
commit 7c60414075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 11 deletions

View File

@ -769,6 +769,22 @@ describe('MetaMask', function () {
await driver.switchTo().window(popup)
await delay(regularDelayMs)
const configureGas = await driver.wait(until.elementLocated(By.css('.confirm-detail-row__header-text--edit')), 10000)
await configureGas.click()
await delay(regularDelayMs)
const advancedTabButton = await driver.wait(until.elementLocated(By.xpath(`//li[contains(text(), 'Advanced')]`)), 10000)
await advancedTabButton.click()
await delay(tinyDelayMs)
const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-tab__gas-edit-row__input'))
assert(gasPriceInput.getAttribute('value'), 20)
assert(gasLimitInput.getAttribute('value'), 4700000)
const saveButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`))
await saveButton.click()
await delay(regularDelayMs)
const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`))
await confirmButton.click()
await delay(regularDelayMs)

View File

@ -76,7 +76,7 @@ const mapStateToProps = (state, ownProps) => {
const customGasTotal = calcGasTotal(customModalGasLimitInHex, customModalGasPriceInHex)
const gasButtonInfo = getRenderableBasicEstimateData(state)
const gasButtonInfo = getRenderableBasicEstimateData(state, customModalGasLimitInHex)
const currentCurrency = getCurrentCurrency(state)
const conversionRate = getConversionRate(state)
@ -235,7 +235,7 @@ function getTxParams (state, transactionId) {
const { txParams: pendingTxParams } = pendingTransaction || {}
return txData.txParams || pendingTxParams || {
from: send.from,
gas: send.gasLimit,
gas: send.gasLimit || '0x5208',
gasPrice: send.gasPrice || getFastPriceEstimateInHexWEI(state, true),
to: send.to,
value: getSelectedToken(state) ? '0x0' : send.amount,

View File

@ -29,7 +29,7 @@ const SET_BASIC_PRICE_ESTIMATES_LAST_RETRIEVED = 'metamask/gas/SET_BASIC_PRICE_E
const initState = {
customData: {
price: null,
limit: '0x5208',
limit: null,
},
basicEstimates: {
average: null,

View File

@ -98,7 +98,7 @@ describe('Gas Duck', () => {
const initState = {
customData: {
price: null,
limit: '0x5208',
limit: null,
},
basicEstimates: {
average: null,

View File

@ -221,11 +221,10 @@ function getGasPriceInHexWei (price) {
)(price)
}
function getRenderableBasicEstimateData (state) {
function getRenderableBasicEstimateData (state, gasLimit) {
if (getBasicGasEstimateLoadingStatus(state)) {
return []
}
const gasLimit = state.metamask.send.gasLimit || getCustomGasLimit(state)
const conversionRate = state.metamask.conversionRate
const currentCurrency = getCurrentCurrency(state)
const {
@ -270,7 +269,7 @@ function getRenderableEstimateDataForSmallButtonsFromGWEI (state) {
if (getBasicGasEstimateLoadingStatus(state)) {
return []
}
const gasLimit = state.metamask.send.gasLimit || getCustomGasLimit(state)
const gasLimit = state.metamask.send.gasLimit || getCustomGasLimit(state) || '0x5208'
const conversionRate = state.metamask.conversionRate
const currentCurrency = getCurrentCurrency(state)
const {

View File

@ -102,9 +102,6 @@ describe('custom-gas selectors', () => {
metamask: {
conversionRate: 255.71,
currentCurrency: 'usd',
send: {
gasLimit: '0x5208',
},
},
gas: {
basicEstimates: {
@ -168,7 +165,7 @@ describe('custom-gas selectors', () => {
it('should return renderable data about basic estimates', () => {
tests.forEach(test => {
assert.deepEqual(
getRenderableBasicEstimateData(test.mockState),
getRenderableBasicEstimateData(test.mockState, '0x5208'),
test.expectedResult
)
})