Skip to content

Commit

Permalink
graphql: fix nonce for pending accounts (ethereum#24443)
Browse files Browse the repository at this point in the history
  • Loading branch information
s1na authored and qinglin89 committed Aug 18, 2022
1 parent c1dd16f commit 7bb1463
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions graphql/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ func (a *Account) Balance(ctx context.Context) (hexutil.Big, error) {
}

func (a *Account) TransactionCount(ctx context.Context) (hexutil.Uint64, error) {
// Ask transaction pool for the nonce which includes pending transactions
if blockNr, ok := a.blockNrOrHash.Number(); ok && blockNr == rpc.PendingBlockNumber {
nonce, err := a.backend.GetPoolNonce(ctx, a.address)
if err != nil {
return 0, err
}
return hexutil.Uint64(nonce), nil
}
state, err := a.getState(ctx)
if err != nil {
return 0, err
Expand Down

0 comments on commit 7bb1463

Please sign in to comment.