Skip to content

Commit

Permalink
Default retry price to recommended price if original price was 0x0
Browse files Browse the repository at this point in the history
  • Loading branch information
danjm committed Nov 30, 2018
1 parent 08b29f3 commit 1552b56
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { formatDate } from '../../util'
import {
fetchBasicGasAndTimeEstimates,
fetchGasEstimates,
setCustomGasPrice,
setCustomGasPriceForRetry,
setCustomGasLimit,
} from '../../ducks/gas.duck'

Expand All @@ -33,7 +33,7 @@ const mapDispatchToProps = dispatch => {
fetchGasEstimates: (blockTime) => dispatch(fetchGasEstimates(blockTime)),
setSelectedToken: tokenAddress => dispatch(setSelectedToken(tokenAddress)),
retryTransaction: (transaction) => {
dispatch(setCustomGasPrice(transaction.txParams.gasPrice))
dispatch(setCustomGasPriceForRetry(transaction.txParams.gasPrice))
dispatch(setCustomGasLimit(transaction.txParams.gas))
dispatch(showSidebar({
transitionName: 'sidebar-left',
Expand Down
14 changes: 14 additions & 0 deletions ui/app/ducks/gas.duck.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import {
loadLocalStorageData,
saveLocalStorageData,
} from '../../lib/local-storage-helpers'
import {
decGWEIToHexWEI,
} from '../helpers/conversions.util'

// Actions
const BASIC_GAS_ESTIMATE_LOADING_FINISHED = 'metamask/gas/BASIC_GAS_ESTIMATE_LOADING_FINISHED'
Expand Down Expand Up @@ -431,6 +434,17 @@ export function fetchGasEstimates (blockTime) {
}
}

export function setCustomGasPriceForRetry (newPrice) {
return (dispatch) => {
if (newPrice !== '0x0') {
dispatch(setCustomGasPrice(newPrice))
} else {
const { average } = loadLocalStorageData('BASIC_PRICE_ESTIMATES')
dispatch(setCustomGasPrice(decGWEIToHexWEI(average)))
}
}
}

export function setBasicGasEstimateData (basicGasEstimateData) {
return {
type: SET_BASIC_GAS_ESTIMATE_DATA,
Expand Down

0 comments on commit 1552b56

Please sign in to comment.