Skip to content

Commit

Permalink
Merge pull request #379 from poanetwork/vb-set-custom-nonce
Browse files Browse the repository at this point in the history
Ability to set custom tx nonce
  • Loading branch information
vbaranov authored May 4, 2020
2 parents ee1fece + e4fcb9f commit d1611a4
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 219 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Current Master

- [#379](https://github.com/poanetwork/nifty-wallet/pull/379) - (Feature) Ability to set custom nonce of tx
- [#377](https://github.com/poanetwork/nifty-wallet/pull/377) - (Fix) Sign message screen: do not decode message if it is not hex encoded
- [#364](https://github.com/poanetwork/nifty-wallet/pull/364) - (Fix) notifications order in batch requests

Expand Down
7 changes: 4 additions & 3 deletions app/scripts/controllers/transactions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ class TransactionController extends EventEmitter {
*/
async updateAndApproveTransaction (txMeta) {
this.txStateManager.updateTx(txMeta, 'confTx: user approved transaction')
await this.approveTransaction(txMeta.id)
const customNonce = txMeta.txParams.nonce
await this.approveTransaction(txMeta.id, customNonce)
}

/**
Expand All @@ -301,7 +302,7 @@ class TransactionController extends EventEmitter {
if any of these steps fails the tx status will be set to failed
@param txId {number} - the tx's Id
*/
async approveTransaction (txId) {
async approveTransaction (txId, customNonce) {
let nonceLock
try {
// approve
Expand All @@ -315,7 +316,7 @@ class TransactionController extends EventEmitter {
// if txMeta has lastGasPrice then it is a retry at same nonce with higher
// gas price transaction and their for the nonce should not be calculated
const nonce = txMeta.lastGasPrice ? txMeta.txParams.nonce : nonceLock.nextNonce
txMeta.txParams.nonce = ethUtil.addHexPrefix(nonce.toString(16))
txMeta.txParams.nonce = customNonce || ethUtil.addHexPrefix(nonce.toString(16))
// add nonce debugging information to txMeta
txMeta.nonceDetails = nonceLock.nonceDetails
this.txStateManager.updateTx(txMeta, 'transactions#approveTransaction')
Expand Down
Loading

0 comments on commit d1611a4

Please sign in to comment.