Skip to content

PSE Clearing accounts balances Query#29

Merged
TxCorpi0x merged 3 commits into
masterfrom
mehdi/pse-query-clearing-acc-balance
Nov 20, 2025
Merged

PSE Clearing accounts balances Query#29
TxCorpi0x merged 3 commits into
masterfrom
mehdi/pse-query-clearing-acc-balance

Conversation

@TxCorpi0x

@TxCorpi0x TxCorpi0x commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Description

This pull request introduces a new gRPC query endpoint to retrieve the current balances of all PSE clearing accounts. The changes span the API documentation, protobuf definitions, keeper logic, gRPC service implementation, and test coverage. The most important changes are grouped below:

API and Protobuf Enhancements:

  • Added new message types (ClearingAccountBalance, QueryClearingAccountBalancesRequest, and QueryClearingAccountBalancesResponse) and documented them in both proto/tx/pse/v1/query.proto and docs/api.md, enabling structured querying of clearing account balances.
  • Registered a new gRPC query method ClearingAccountBalances in the Query service, including REST endpoint mapping (GET /tx/pse/v1/clearing_account_balances) and updated documentation.

Keeper and Query Logic:

  • Implemented GetClearingAccountBalances in x/pse/keeper/keeper.go to fetch balances for all clearing accounts in the bond denom, handling missing accounts and zero balances gracefully.
  • Added the corresponding gRPC service handler in x/pse/keeper/grpc.go to expose this functionality via the new query endpoint.

Testing and Gateway Updates:

  • Added comprehensive tests in x/pse/keeper/grpc_query_test.go to verify the new query returns correct balances for all clearing accounts, both when balances are zero and when some are funded.
  • Updated the gRPC gateway code in x/pse/types/query.pb.gw.go to support HTTP requests for the new endpoint, including handler registration and response forwarding.

Reviewers checklist:

  • Try to write more meaningful comments with clear actions to be taken.
  • Nit-picking should be unblocking. Focus on core issues.

Authors checklist

  • Provide a concise and meaningful description
  • Review the code yourself first, before making the PR.
  • Annotate your PR in places that require explanation.
  • Think and try to split the PR to smaller PR if it is big.

This change is Reviewable

@TxCorpi0x TxCorpi0x requested review from a team, Copilot, masihyeganeh, miladz68 and ysv and removed request for a team November 17, 2025 15:06
@TxCorpi0x TxCorpi0x requested a review from a team as a code owner November 17, 2025 15:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new gRPC query endpoint ClearingAccountBalances to retrieve the current balances of all PSE clearing accounts in the bond denomination. The implementation follows established patterns within the codebase and includes comprehensive test coverage.

Key changes:

  • Added new protobuf message types for querying clearing account balances
  • Implemented keeper logic to fetch balances for all 6 clearing accounts
  • Added gRPC service handler with REST endpoint support at /tx/pse/v1/clearing_account_balances

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
proto/tx/pse/v1/query.proto Defines new RPC method, request/response messages, and ClearingAccountBalance structure for the query endpoint
x/pse/types/query.pb.go Generated protobuf code with message types, gRPC client/server interfaces, and marshaling logic
x/pse/types/query.pb.gw.go Generated gRPC-gateway code for HTTP REST endpoint routing and request/response handling
x/pse/keeper/keeper.go Implements GetClearingAccountBalances to fetch balances for all clearing accounts, handling missing accounts gracefully
x/pse/keeper/grpc.go Adds ClearingAccountBalances gRPC handler that delegates to keeper implementation
x/pse/keeper/grpc_query_test.go Comprehensive tests covering both zero-balance and funded account scenarios
docs/api.md Updated API documentation with new message types and query endpoint details

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ysv
ysv previously approved these changes Nov 17, 2025

@ysv ysv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysv reviewed 7 of 7 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @masihyeganeh and @miladz68)


proto/tx/pse/v1/query.proto line 26 at r1 (raw file):

    option (google.api.http).get = "/tx/pse/v1/score/{address}";
  }
  

nit: whitespaces


proto/tx/pse/v1/query.proto line 72 at r1 (raw file):

    (gogoproto.moretags) = "yaml:\"clearing_account\""
  ];
  

nit: whitespaces

@TxCorpi0x TxCorpi0x left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 6 of 7 files reviewed, all discussions resolved (waiting on @masihyeganeh, @miladz68, and @ysv)


proto/tx/pse/v1/query.proto line 72 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

nit: whitespaces

Done

@ysv ysv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysv reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh and @miladz68)

@miladz68 miladz68 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miladz68 reviewed 6 of 7 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)

@TxCorpi0x TxCorpi0x merged commit 4ec1d90 into master Nov 20, 2025
8 of 9 checks passed
@ysv ysv deleted the mehdi/pse-query-clearing-acc-balance branch December 19, 2025 14:40
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.

4 participants