Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces an HTTP client for the indexer's admin API and a new Indexer token provider that utilizes this client to fetch balances and total supply from pre-materialized PostgreSQL tables. Additionally, it refactors the Provider and Token interfaces to use CantonPartyID instead of user fingerprints for balance queries, ensuring consistency across the service layer. Feedback was provided regarding the normalization of the base URL in the HTTP client to prevent malformed paths, the importance of handling potential decoding errors when processing non-2xx responses, and a recommendation to defensively copy the instruments map in the Indexer provider to prevent external mutations.
sadiq1971
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces per-request gRPC ACS scans with reads from the indexer's pre-materialized PostgreSQL tables.
Problem
The only Provider implementation was Canton, which calls GetActiveContracts on every balanceOf and totalSupply request. GetTotalSupply fetches the entire ACS for CIP56Holding and filters client-side; GetBalanceByFingerprint adds a second gRPC round-trip to resolve the fingerprint to a party via GetFingerprintMapping. The indexer already materialises this data into indexer_balances and indexer_tokens via its streaming processor.
Changes
pkg/indexer/client/ — new package: HTTP client for the indexer's admin API
Clientinterface mirrorsindexer/service.Service(9 methods) so callers are agnostic to whether they talk to an in-process service or a remote indexerHTTPstruct implements all methods: token queries, balance queries, event/audit-trail queries?page=&limit=query params;EventFilter.EventTypeforwarded as?event_type=pkg/token/provider/indexer.go — new Provider implementation backed by the indexer client
tokenSymbol → InstrumentAdminfrom a configured instruments map, then delegates to the clientGetBalancemapsResourceNotFoundError(party holds zero) → "0" consistent with the Canton provider's no-holdings pathpkg/token/service.go / pkg/cantonsdk/token/client.go — eliminate double lookup
Provider.GetBalancenow acceptspartyIDinstead offingerprintservice.getBalancepassesusr.CantonPartyIDdirectly — the user record was already loaded, no reason to discard thepartyIDGetBalanceByPartyIDexposed on the CantonTokeninterface;Cantonprovider delegates to it, eliminating theGetFingerprintMappinggRPC round-trip that was happening just to undo information already knownCloses #190