Skip to content

feat(account): wrap /assets, and expose order + to on /txs - #9

Merged
edridudi merged 1 commit into
mainfrom
feat/account-assets-and-tx-ordering
Sep 22, 2026
Merged

edridudi merged 1 commit into
mainfrom
feat/account-assets-and-tx-ordering

Conversation

@edridudi

Copy link
Copy Markdown
Member

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}/assets with 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 fetchAccountAssets helper.

Result<List<AccountAsset>> getAccountAssets(Network network, String stakeAddress, int page, int pageSize);
Result<List<AccountAsset>> getAccountAssets(Network network, String stakeAddress, String policyId, int page, int pageSize);

order and to on getAccountTransactions (#8)

The endpoint accepts both:

from   (required, @Min(1))
to     (optional)
order  (asc | desc, default asc)

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).

Result<List<AccountTransaction>> getAccountTransactions(
        Network network, String stakeAddress, int fromBlockHeight, Integer toBlockHeight, String order);

Backwards compatibility

The existing 3-argument overload is unchanged. It now passes null for both new parameters, which leaves the server defaults exactly as before — and a test pins that it still sends no order parameter rather than an explicit asc, 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:

test asserts
getAccountAssets_callsTheAssetsEndpointWithPaging path, page, pageSize, deserialization
getAccountAssets_passesThePolicyFilterWhenGiven policy= present
getAccountTransactions_sendsOrderAndUpperBound from, to, order all present
getAccountTransactions_shortOverloadIsUnchanged no order sent

Written 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/history still has no order parameter, which is a Nexus gap rather than a client one.

🤖 Generated with Claude Code

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
edridudi merged commit d81da7f into main Sep 22, 2026
1 check passed
@edridudi
edridudi deleted the feat/account-assets-and-tx-ordering branch September 22, 2026 09:53
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant