arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
Merge pull request #405 from hermeznetwork/fix/api-nonce

Fix API nonces
Eduard S eduard@iden3.io
Tue, 22 Dec 2020 17:43:24 +0100
commit

cd1a193dcd3e6c11376594ae5f48fe6256035055

parent

c61c4f337666db5abe1deeeb3cde749fed9adc74

2 files changed, 6 insertions(+), 1 deletions(-)

jump to
M api/account.go → api/account.go

@@ -29,6 +29,7 @@ return

} apiAccount.Balance = apitypes.NewBigIntStr(account.Balance) + apiAccount.Nonce = account.Nonce c.JSON(http.StatusOK, apiAccount) }

@@ -67,6 +68,7 @@ retSQLErr(err, c)

return } apiAccounts[x].Balance = apitypes.NewBigIntStr(account.Balance) + apiAccounts[x].Nonce = account.Nonce } // Build succesfull response
M api/api_test.go → api/api_test.go

@@ -330,7 +330,10 @@ // Set USD value for tokens in DB

commonL1Txs = append(commonL1Txs, block.Rollup.L1UserTxs...) for _, batch := range block.Rollup.Batches { commonL2Txs = append(commonL2Txs, batch.L2Txs...) - commonAccounts = append(commonAccounts, batch.CreatedAccounts...) + for i := range batch.CreatedAccounts { + batch.CreatedAccounts[i].Nonce = common.Nonce(i) + commonAccounts = append(commonAccounts, batch.CreatedAccounts[i]) + } commonBatches = append(commonBatches, batch.Batch) commonExitTree = append(commonExitTree, batch.ExitTree...) commonL1Txs = append(commonL1Txs, batch.L1CoordinatorTxs...)