-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version 6.7.2 gas limit fix #6786
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ebc1a69
Introduce delay for eth_estimateGas calls with in test
danjm dc18467
Add test that fails when gas estimates of contract method calls witho…
danjm 0d5858f
Get transaction gas data from unApprovedTxs instead of confirmTransac…
danjm 7d0afd0
Fix selection of gas data in gas-modal-page-container.container
danjm 8e967aa
Lint changes related to Version-6.7.2-gasLimitFix
danjm 9f8703e
Fix e2e tests on Version-6.7.2-gasLimitFix
danjm 64d428f
Fix unit and integration tests for changes from Version-6.7.2-gasLimi…
danjm 1b7f62f
more e2e fixes
danjm f7cbb5a
Add assertions for transaction values on confirm screen
danjm 4330341
Fix display of transaction amount on confirm screen.
danjm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,21 @@ export default class AdvancedTabContent extends Component { | |
t: PropTypes.func, | ||
} | ||
|
||
constructor (props) { | ||
super(props) | ||
this.state = { | ||
gasPrice: this.props.customGasPrice, | ||
gasLimit: this.props.customGasLimit, | ||
} | ||
this.changeGasPrice = debounce(this.changeGasPrice, 500) | ||
this.changeGasLimit = debounce(this.changeGasLimit, 500) | ||
const tempSetState = this.setState.bind(this) | ||
this.setState = (...args) => { | ||
return tempSetState(...args) | ||
} | ||
} | ||
|
||
|
||
static propTypes = { | ||
updateCustomGasPrice: PropTypes.func, | ||
updateCustomGasLimit: PropTypes.func, | ||
|
@@ -20,15 +35,40 @@ export default class AdvancedTabContent extends Component { | |
showGasLimitInfoModal: PropTypes.func, | ||
} | ||
|
||
debouncedGasLimitReset = debounce((dVal) => { | ||
if (dVal < 21000) { | ||
componentDidUpdate (prevProps) { | ||
const { customGasPrice: prevCustomGasPrice, customGasLimit: prevCustomGasLimit } = prevProps | ||
const { customGasPrice, customGasLimit } = this.props | ||
const { gasPrice, gasLimit } = this.state | ||
|
||
if (customGasPrice !== prevCustomGasPrice && customGasPrice !== gasPrice) { | ||
this.setState({ gasPrice: customGasPrice }) | ||
} | ||
if (customGasLimit !== prevCustomGasLimit && customGasLimit !== gasLimit) { | ||
this.setState({ gasLimit: customGasLimit }) | ||
} | ||
} | ||
|
||
onChangeGasLimit = (e) => { | ||
this.setState({ gasLimit: e.target.value }) | ||
this.changeGasLimit({ target: { value: e.target.value } }) | ||
} | ||
|
||
changeGasLimit = (e) => { | ||
if (e.target.value < 21000) { | ||
this.setState({ gasLimit: 21000 }) | ||
this.props.updateCustomGasLimit(21000) | ||
} else { | ||
this.props.updateCustomGasLimit(Number(e.target.value)) | ||
} | ||
}, 1000, { trailing: true }) | ||
} | ||
|
||
onChangeGasPrice = (e) => { | ||
this.setState({ gasPrice: e.target.value }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should Edit: Likewise for |
||
this.changeGasPrice({ target: { value: e.target.value } }) | ||
} | ||
|
||
onChangeGasLimit = (val) => { | ||
this.props.updateCustomGasLimit(val) | ||
this.debouncedGasLimitReset(val) | ||
changeGasPrice = (e) => { | ||
this.props.updateCustomGasPrice(Number(e.target.value)) | ||
} | ||
|
||
gasInputError ({ labelKey, insufficientBalance, customPriceIsSafe, isSpeedUp, value }) { | ||
|
@@ -74,7 +114,7 @@ export default class AdvancedTabContent extends Component { | |
})} | ||
type="number" | ||
value={value} | ||
onChange={event => onChange(Number(event.target.value))} | ||
onChange={onChange} | ||
/> | ||
<div className={classnames('advanced-gas-inputs__gas-edit-row__input-arrows', { | ||
'advanced-gas-inputs__gas-edit-row__input--error': isInError && errorType === 'error', | ||
|
@@ -120,9 +160,6 @@ export default class AdvancedTabContent extends Component { | |
|
||
render () { | ||
const { | ||
customGasPrice, | ||
updateCustomGasPrice, | ||
customGasLimit, | ||
insufficientBalance, | ||
customPriceIsSafe, | ||
isSpeedUp, | ||
|
@@ -134,8 +171,8 @@ export default class AdvancedTabContent extends Component { | |
<div className="advanced-gas-inputs__gas-edit-rows"> | ||
{ this.renderGasEditRow({ | ||
labelKey: 'gasPrice', | ||
value: customGasPrice, | ||
onChange: updateCustomGasPrice, | ||
value: this.state.gasPrice, | ||
onChange: this.onChangeGasPrice, | ||
insufficientBalance, | ||
customPriceIsSafe, | ||
showGWEI: true, | ||
|
@@ -144,7 +181,7 @@ export default class AdvancedTabContent extends Component { | |
}) } | ||
{ this.renderGasEditRow({ | ||
labelKey: 'gasLimit', | ||
value: customGasLimit, | ||
value: this.state.gasLimit, | ||
onChange: this.onChangeGasLimit, | ||
insufficientBalance, | ||
customPriceIsSafe, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import { connect } from 'react-redux' | ||
import { compose } from 'recompose' | ||
import { withRouter } from 'react-router-dom' | ||
import ConfirmTokenTransactionBase from './confirm-token-transaction-base.component' | ||
import { | ||
contractExchangeRateSelector, | ||
transactionFeeSelector, | ||
} from '../../selectors/confirm-transaction' | ||
import { tokenSelector } from '../../selectors/tokens' | ||
import { | ||
|
@@ -14,15 +17,21 @@ import { | |
} from '../../helpers/utils/token-util' | ||
|
||
|
||
const mapStateToProps = (state) => { | ||
const { confirmTransaction, metamask: { currentCurrency, conversionRate } } = state | ||
const mapStateToProps = (state, ownProps) => { | ||
const { match: { params = {} } } = ownProps | ||
const { id: paramsTransactionId } = params | ||
const { confirmTransaction, metamask: { currentCurrency, conversionRate, selectedAddressTxList } } = state | ||
|
||
const { | ||
txData: { txParams: { to: tokenAddress, data } = {} } = {}, | ||
fiatTransactionTotal, | ||
ethTransactionTotal, | ||
txData: { id: transactionId, txParams: { to: tokenAddress, data } = {} } = {}, | ||
} = confirmTransaction | ||
|
||
|
||
const transaction = selectedAddressTxList.find(({ id }) => id === (Number(paramsTransactionId) || transactionId)) | ||
console.log('!!! * transaction', transaction) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: console log |
||
const { | ||
ethTransactionTotal, | ||
fiatTransactionTotal, | ||
} = transactionFeeSelector(state, transaction) | ||
const tokens = tokenSelector(state) | ||
const currentToken = tokens && tokens.find(({ address }) => tokenAddress === address) | ||
const { decimals, symbol: tokenSymbol } = currentToken || {} | ||
|
@@ -46,4 +55,7 @@ const mapStateToProps = (state) => { | |
} | ||
} | ||
|
||
export default connect(mapStateToProps)(ConfirmTokenTransactionBase) | ||
export default compose( | ||
withRouter, | ||
connect(mapStateToProps) | ||
)(ConfirmTokenTransactionBase) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the property syntax for the debounce? That is, wrap the property value in the debounce call directly. If we can remove theses lines we can move the state to a property as well and remove the constructor.