Repository navigation
feat(account): wrap /assets, and expose order + to on /txs - #9
Merged
Merged
Conversation
Two gaps where the client offered less than the REST API, both found while migrating cardano-shield-api off Koios (Gero-Labs/cardano-shield-api#15). getAccountAssets (#7). Nexus serves GET /api/account/{stake}/assets with the aggregation done server-side, but the client never wrapped it, so callers had to fetch every account UTxO and sum the asset lists themselves -- wire bytes proportional to the number of UTxOs for a figure the server already computes. cardano-shield does that today and can now drop its helper. order and to on getAccountTransactions (#8). The endpoint accepts both; the client exposed neither and imposed no limit, so a caller wanting a single transaction from one end of an account's history had to download the whole history to reach it. cardano-shield needs only the oldest transaction, to decide whether an address is less than a week old. The existing 3-argument getAccountTransactions overload is unchanged: it passes null for both new parameters, leaving the server defaults exactly as before. A test pins that it still sends no order parameter. Tests use MockWebServer and assert the request line, not just deserialization, so a wrong query-parameter name would fail rather than silently sending nothing. Closes #7 Closes #8 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
edridudi
pushed a commit
that referenced
this pull request
Sep 23, 2026
Skips 1.3.0 deliberately. That number was already claimed by the pom on the unreleased feat/asset-holders branch, so anyone who built from that branch has a local 1.3.0 that is not what a released 1.3.0 would contain. Reusing it would repeat the ambiguity that let main and Maven Central diverge in the first place. Contents relative to the published 1.2.0: - valid_contract and index on Transaction (#11) - getAccountAssets, plus order and to on getAccountTransactions (#9), which 1.2.0 never carried because it was released from a branch that predates it Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Closes #7, closes #8. Both are the same shape of problem — the client offering less than the REST API — and both were found while migrating cardano-shield-api off Koios (Gero-Labs/cardano-shield-api#15).
getAccountAssets(#7)Nexus serves
GET /api/account/{stake}/assetswith the aggregation done server-side. The client never wrapped it, so callers had to fetch every account UTxO and sum the asset lists themselves — wire bytes proportional to the number of UTxOs, for a figure the server already computes.cardano-shield does exactly that today, inside a synchronous user-facing transaction scan with a timeout. It can now drop its
fetchAccountAssetshelper.orderandtoongetAccountTransactions(#8)The endpoint accepts both:
The client exposed neither and imposes no limit, so a caller wanting one transaction from one end of an account's history had to download the entire history to reach it. cardano-shield needs only the oldest transaction, to decide whether an address is less than a week old — under the Koios client that was one bounded request with
Limit.of(1).Backwards compatibility
The existing 3-argument overload is unchanged. It now passes
nullfor both new parameters, which leaves the server defaults exactly as before — and a test pins that it still sends noorderparameter rather than an explicitasc, so the behaviour can't drift if the server default ever changes.Tests
Four new cases in
AccountServiceTest, using the repo's existing MockWebServer pattern. They assert the request line, not just deserialization — a mistyped query-parameter name would otherwise pass silently while sending nothing:getAccountAssets_callsTheAssetsEndpointWithPagingpage,pageSize, deserializationgetAccountAssets_passesThePolicyFilterWhenGivenpolicy=presentgetAccountTransactions_sendsOrderAndUpperBoundfrom,to,orderall presentgetAccountTransactions_shortOverloadIsUnchangedordersentWritten first; all four failed to compile against the previous interface.
Full suite: 41 tests, 0 failures.
Follow-on
cardano-shield can simplify once this is released to Maven Central — its client-side asset aggregation goes away entirely. Its address-age workaround needs the matching server-side change too, tracked as Gero-Labs/nexus#1007:
/api/addresses/{addr}/transactions/historystill has noorderparameter, which is a Nexus gap rather than a client one.🤖 Generated with Claude Code