Display value of current pending tx nonce
This commit is contained in:
parent
083c37d866
commit
a7c51f8607
|
@ -444,6 +444,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
markPasswordForgotten: this.markPasswordForgotten.bind(this),
|
markPasswordForgotten: this.markPasswordForgotten.bind(this),
|
||||||
unMarkPasswordForgotten: this.unMarkPasswordForgotten.bind(this),
|
unMarkPasswordForgotten: this.unMarkPasswordForgotten.bind(this),
|
||||||
getGasPrice: (cb) => cb(null, this.getGasPrice()),
|
getGasPrice: (cb) => cb(null, this.getGasPrice()),
|
||||||
|
getPendingNonce: nodeify(this.getPendingNonce, this),
|
||||||
|
|
||||||
// shapeshift
|
// shapeshift
|
||||||
createShapeShiftTx: this.createShapeShiftTx.bind(this),
|
createShapeShiftTx: this.createShapeShiftTx.bind(this),
|
||||||
|
|
|
@ -29,6 +29,18 @@ const optionalDataValueStyle = {
|
||||||
}
|
}
|
||||||
|
|
||||||
class SendTransactionScreen extends PersistentForm {
|
class SendTransactionScreen extends PersistentForm {
|
||||||
|
constructor (props) {
|
||||||
|
super(props)
|
||||||
|
this.state = {
|
||||||
|
pendingNonce: null,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async getPendingNonce () {
|
||||||
|
const pendingNonce = await this.props.dispatch(actions.getPendingNonce(this.props.address))
|
||||||
|
this.setState({pendingNonce: pendingNonce})
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
this.persistentFormParentId = 'send-tx-form'
|
this.persistentFormParentId = 'send-tx-form'
|
||||||
|
|
||||||
|
@ -117,12 +129,17 @@ class SendTransactionScreen extends PersistentForm {
|
||||||
dataset={{
|
dataset={{
|
||||||
persistentFormid: 'tx-custom-nonce',
|
persistentFormid: 'tx-custom-nonce',
|
||||||
}}
|
}}
|
||||||
|
defaultValue={this.state.pendingNonce}
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount () {
|
||||||
|
this.getPendingNonce()
|
||||||
|
}
|
||||||
|
|
||||||
componentWillUnmount () {
|
componentWillUnmount () {
|
||||||
this.props.dispatch(actions.displayWarning(''))
|
this.props.dispatch(actions.displayWarning(''))
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,6 +188,7 @@ const actions = {
|
||||||
signTokenTx: signTokenTx,
|
signTokenTx: signTokenTx,
|
||||||
updateTransaction,
|
updateTransaction,
|
||||||
updateAndApproveTx,
|
updateAndApproveTx,
|
||||||
|
getPendingNonce,
|
||||||
cancelTx,
|
cancelTx,
|
||||||
cancelTxs,
|
cancelTxs,
|
||||||
completedTx: completedTx,
|
completedTx: completedTx,
|
||||||
|
@ -1304,6 +1305,24 @@ function updateAndApproveTx (txData) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPendingNonce (address) {
|
||||||
|
log.info('actions: getPendingNonce')
|
||||||
|
return (dispatch) => {
|
||||||
|
log.debug(`actions calling background.getPendingNonce`)
|
||||||
|
dispatch(actions.showLoadingIndication())
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
background.getPendingNonce(address, (err, nonce) => {
|
||||||
|
if (err) {
|
||||||
|
dispatch(actions.displayWarning(err.message))
|
||||||
|
return reject(err)
|
||||||
|
}
|
||||||
|
dispatch(actions.hideLoadingIndication())
|
||||||
|
resolve(nonce)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function completedTx (id) {
|
function completedTx (id) {
|
||||||
return {
|
return {
|
||||||
type: actions.COMPLETED_TX,
|
type: actions.COMPLETED_TX,
|
||||||
|
|
Loading…
Reference in New Issue