@ -15,6 +15,7 @@ import { CONFIRMED_STATUS, DROPPED_STATUS } from '../../helpers/constants/transa
import UserPreferencedCurrencyDisplay from '../../components/app/user-preferenced-currency-display'
import UserPreferencedCurrencyDisplay from '../../components/app/user-preferenced-currency-display'
import { PRIMARY , SECONDARY } from '../../helpers/constants/common'
import { PRIMARY , SECONDARY } from '../../helpers/constants/common'
import AdvancedGasInputs from '../../components/app/gas-customization/advanced-gas-inputs'
import AdvancedGasInputs from '../../components/app/gas-customization/advanced-gas-inputs'
import TextField from '../../components/ui/text-field'
export default class ConfirmTransactionBase extends Component {
export default class ConfirmTransactionBase extends Component {
static contextTypes = {
static contextTypes = {
@ -50,6 +51,9 @@ export default class ConfirmTransactionBase extends Component {
isTxReprice : PropTypes . bool ,
isTxReprice : PropTypes . bool ,
methodData : PropTypes . object ,
methodData : PropTypes . object ,
nonce : PropTypes . string ,
nonce : PropTypes . string ,
useNonceField : PropTypes . bool ,
customNonceValue : PropTypes . string ,
updateCustomNonce : PropTypes . func ,
assetImage : PropTypes . string ,
assetImage : PropTypes . string ,
sendTransaction : PropTypes . func ,
sendTransaction : PropTypes . func ,
showCustomizeGasModal : PropTypes . func ,
showCustomizeGasModal : PropTypes . func ,
@ -96,11 +100,14 @@ export default class ConfirmTransactionBase extends Component {
insufficientBalance : PropTypes . bool ,
insufficientBalance : PropTypes . bool ,
hideFiatConversion : PropTypes . bool ,
hideFiatConversion : PropTypes . bool ,
transactionCategory : PropTypes . string ,
transactionCategory : PropTypes . string ,
getNextNonce : PropTypes . func ,
nextNonce : PropTypes . number ,
}
}
state = {
state = {
submitting : false ,
submitting : false ,
submitError : null ,
submitError : null ,
submitWarning : '' ,
}
}
componentDidUpdate ( prevProps ) {
componentDidUpdate ( prevProps ) {
@ -109,11 +116,21 @@ export default class ConfirmTransactionBase extends Component {
showTransactionConfirmedModal ,
showTransactionConfirmedModal ,
history ,
history ,
clearConfirmTransaction ,
clearConfirmTransaction ,
nextNonce ,
customNonceValue ,
} = this . props
} = this . props
const { transactionStatus : prevTxStatus } = prevProps
const { transactionStatus : prevTxStatus } = prevProps
const statusUpdated = transactionStatus !== prevTxStatus
const statusUpdated = transactionStatus !== prevTxStatus
const txDroppedOrConfirmed = transactionStatus === DROPPED _STATUS || transactionStatus === CONFIRMED _STATUS
const txDroppedOrConfirmed = transactionStatus === DROPPED _STATUS || transactionStatus === CONFIRMED _STATUS
if ( nextNonce !== prevProps . nextNonce || customNonceValue !== prevProps . customNonceValue ) {
if ( customNonceValue > nextNonce ) {
this . setState ( { submitWarning : this . context . t ( 'nextNonceWarning' , [ nextNonce ] ) } )
} else {
this . setState ( { submitWarning : '' } )
}
}
if ( statusUpdated && txDroppedOrConfirmed ) {
if ( statusUpdated && txDroppedOrConfirmed ) {
showTransactionConfirmedModal ( {
showTransactionConfirmedModal ( {
onSubmit : ( ) => {
onSubmit : ( ) => {
@ -204,11 +221,16 @@ export default class ConfirmTransactionBase extends Component {
hexTransactionFee ,
hexTransactionFee ,
hexTransactionTotal ,
hexTransactionTotal ,
hideDetails ,
hideDetails ,
useNonceField ,
customNonceValue ,
updateCustomNonce ,
advancedInlineGasShown ,
advancedInlineGasShown ,
customGas ,
customGas ,
insufficientBalance ,
insufficientBalance ,
updateGasAndCalculate ,
updateGasAndCalculate ,
hideFiatConversion ,
hideFiatConversion ,
nextNonce ,
getNextNonce ,
} = this . props
} = this . props
if ( hideDetails ) {
if ( hideDetails ) {
@ -240,7 +262,7 @@ export default class ConfirmTransactionBase extends Component {
: null
: null
}
}
< / d i v >
< / d i v >
< div >
< div className = { useNonceField ? 'confirm-page-container-content__gas-fee' : null } >
< ConfirmDetailRow
< ConfirmDetailRow
label = "Total"
label = "Total"
value = { hexTransactionTotal }
value = { hexTransactionTotal }
@ -251,6 +273,31 @@ export default class ConfirmTransactionBase extends Component {
primaryValueTextColor = "#2f9ae0"
primaryValueTextColor = "#2f9ae0"
/ >
/ >
< / d i v >
< / d i v >
{ useNonceField ? < div >
< div className = "confirm-detail-row" >
< div className = "confirm-detail-row__label" >
{ this . context . t ( 'nonceFieldHeading' ) }
< / d i v >
< div className = "custom-nonce-input" >
< TextField
type = "number"
min = "0"
placeholder = { this . context . t ( 'nonceFieldPlaceholder' ) }
onChange = { ( { target : { value } } ) => {
if ( ! value . length || Number ( value ) < 0 ) {
updateCustomNonce ( '' )
} else {
updateCustomNonce ( String ( Math . floor ( value ) ) )
}
getNextNonce ( )
} }
fullWidth
margin = "dense"
value = { customNonceValue || nextNonce || '' }
/ >
< / d i v >
< / d i v >
< / d i v > : n u l l }
< / d i v >
< / d i v >
)
)
)
)
@ -347,7 +394,17 @@ export default class ConfirmTransactionBase extends Component {
handleCancel ( ) {
handleCancel ( ) {
const { metricsEvent } = this . context
const { metricsEvent } = this . context
const { onCancel , txData , cancelTransaction , history , clearConfirmTransaction , actionKey , txData : { origin } , methodData = { } } = this . props
const {
onCancel ,
txData ,
cancelTransaction ,
history ,
clearConfirmTransaction ,
actionKey ,
txData : { origin } ,
methodData = { } ,
updateCustomNonce ,
} = this . props
metricsEvent ( {
metricsEvent ( {
eventOpts : {
eventOpts : {
@ -361,6 +418,7 @@ export default class ConfirmTransactionBase extends Component {
origin ,
origin ,
} ,
} ,
} )
} )
updateCustomNonce ( '' )
if ( onCancel ) {
if ( onCancel ) {
onCancel ( txData )
onCancel ( txData )
} else {
} else {
@ -374,7 +432,19 @@ export default class ConfirmTransactionBase extends Component {
handleSubmit ( ) {
handleSubmit ( ) {
const { metricsEvent } = this . context
const { metricsEvent } = this . context
const { txData : { origin } , sendTransaction , clearConfirmTransaction , txData , history , onSubmit , actionKey , metaMetricsSendCount = 0 , setMetaMetricsSendCount , methodData = { } } = this . props
const {
txData : { origin } ,
sendTransaction ,
clearConfirmTransaction ,
txData ,
history ,
onSubmit ,
actionKey ,
metaMetricsSendCount = 0 ,
setMetaMetricsSendCount ,
methodData = { } ,
updateCustomNonce ,
} = this . props
const { submitting } = this . state
const { submitting } = this . state
if ( submitting ) {
if ( submitting ) {
@ -406,6 +476,7 @@ export default class ConfirmTransactionBase extends Component {
this . setState ( {
this . setState ( {
submitting : false ,
submitting : false ,
} )
} )
updateCustomNonce ( '' )
} )
} )
} else {
} else {
sendTransaction ( txData )
sendTransaction ( txData )
@ -415,6 +486,7 @@ export default class ConfirmTransactionBase extends Component {
submitting : false ,
submitting : false ,
} , ( ) => {
} , ( ) => {
history . push ( DEFAULT _ROUTE )
history . push ( DEFAULT _ROUTE )
updateCustomNonce ( '' )
} )
} )
} )
} )
. catch ( error => {
. catch ( error => {
@ -493,7 +565,7 @@ export default class ConfirmTransactionBase extends Component {
}
}
componentDidMount ( ) {
componentDidMount ( ) {
const { txData : { origin , id } = { } , cancelTransaction } = this . props
const { txData : { origin , id } = { } , cancelTransaction , getNextNonce } = this . props
const { metricsEvent } = this . context
const { metricsEvent } = this . context
metricsEvent ( {
metricsEvent ( {
eventOpts : {
eventOpts : {
@ -521,6 +593,8 @@ export default class ConfirmTransactionBase extends Component {
cancelTransaction ( { id } )
cancelTransaction ( { id } )
}
}
}
}
getNextNonce ( )
}
}
render ( ) {
render ( ) {
@ -543,12 +617,13 @@ export default class ConfirmTransactionBase extends Component {
contentComponent ,
contentComponent ,
onEdit ,
onEdit ,
nonce ,
nonce ,
customNonceValue ,
assetImage ,
assetImage ,
warning ,
warning ,
unapprovedTxCount ,
unapprovedTxCount ,
transactionCategory ,
transactionCategory ,
} = this . props
} = this . props
const { submitting , submitError } = this . state
const { submitting , submitError , submitWarning } = this . state
const { name } = methodData
const { name } = methodData
const { valid , errorKey } = this . getErrorKey ( )
const { valid , errorKey } = this . getErrorKey ( )
@ -572,13 +647,13 @@ export default class ConfirmTransactionBase extends Component {
detailsComponent = { this . renderDetails ( ) }
detailsComponent = { this . renderDetails ( ) }
dataComponent = { this . renderData ( ) }
dataComponent = { this . renderData ( ) }
contentComponent = { contentComponent }
contentComponent = { contentComponent }
nonce = { nonce }
nonce = { customNonceValue || nonce }
unapprovedTxCount = { unapprovedTxCount }
unapprovedTxCount = { unapprovedTxCount }
assetImage = { assetImage }
assetImage = { assetImage }
identiconAddress = { identiconAddress }
identiconAddress = { identiconAddress }
errorMessage = { errorMessage || submitError }
errorMessage = { errorMessage || submitError }
errorKey = { propsErrorKey || errorKey }
errorKey = { propsErrorKey || errorKey }
warning = { warning }
warning = { warning || submitWarning }
totalTx = { totalTx }
totalTx = { totalTx }
positionOfCurrentTx = { positionOfCurrentTx }
positionOfCurrentTx = { positionOfCurrentTx }
nextTxId = { nextTxId }
nextTxId = { nextTxId }