Skip to content

rpc: implement pending resolver and GetPendingTransactions GraphQL#21593

Draft
lupin012 wants to merge 2 commits into
mainfrom
lupin012/impl_pending_grphQL
Draft

rpc: implement pending resolver and GetPendingTransactions GraphQL#21593
lupin012 wants to merge 2 commits into
mainfrom
lupin012/impl_pending_grphQL

Conversation

@lupin012
Copy link
Copy Markdown
Contributor

@lupin012 lupin012 commented Jun 2, 2026

The GraphQL server had three pending field resolvers and the query.pending field itself all implemented with panic("not implemented") — any GraphQL call on pending would crash.


Changes

rpc/jsonrpc/graphql_api.go

  • Added txPool txpoolproto.TxpoolClient as a dependency of GraphQLAPIImpl
  • Added GetPendingTransactions(ctx) to the GraphQLAPI interface and its implementation: calls txPool.Pending() via gRPC, decodes RLP-encoded transactions, and returns them as []types.Transaction
  • Nil-safe: if txPool is nil, returns an empty list without error

rpc/jsonrpc/daemon.go

  • Updated the NewGraphQLAPI(...) call to pass txPool as the new parameter

cmd/rpcdaemon/graphql/graph/schema.resolvers.go

  • queryResolver.Pending: fetches pending txs and populates model.Pending with TransactionCount and the Transactions list (nonce, gas, hash)
  • pendingResolver.Account: resolves the account at pending state via GetAccountInfo(..., PendingBlockNumber)
  • pendingResolver.Call: executes an eth call at pending state via PendingBlockNumber
  • pendingResolver.EstimateGas: estimates gas at pending state via PendingBlockNumber

cmd/rpcdaemon/graphql/graph/schema_resolvers_test.go

  • Added GetPendingTransactions to the mockGraphQLAPI mock
  • 6 new tests: empty pool, one pending tx, error propagation, invalid address, PendingBlockNumber forwarding for Call and EstimateGas

lupin012 and others added 2 commits June 2, 2026 21:12
Wire txPool into GraphQLAPI and implement GetPendingTransactions, which
fetches pending txs via the txpool gRPC Pending call. Resolve the previously
panic-stubbed pendingResolver methods (Account, Call, EstimateGas) and the
Pending query using PendingBlockNumber. Add unit tests for all new paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant