Skip to content

feat(transaction): expose valid_contract and index - #11

Merged
edridudi merged 1 commit into
mainfrom
feat/tx-valid-contract-and-index
Sep 23, 2026
Merged

edridudi merged 1 commit into
mainfrom
feat/tx-valid-contract-and-index

Conversation

@edridudi

Copy link
Copy Markdown
Member

What

Adds valid_contract and index to the Transaction model.

@JsonProperty("valid_contract")
private Boolean validContract;

private Integer index;   // wire name is "index", not snake_case

Why now

Nexus began serving both fields on GET /api/transactions/{hash} in Gero-Labs/nexus#1081, which is merged and deployed to production.

Verified live on mainnet rather than assumed — tx 4847714e...c6710d25:

"valid_contract": true
"index": 5

Both appear before plutus_contracts in the payload, which is what confirms they are the transaction-level fields rather than the per-script TxPlutusContract.validContract that shares a name. A naive grep matches that nested field ten times on this transaction and would have been misleading.

Two details worth knowing

valid_contract needs its @JsonProperty; index does not. This client sets no global naming strategy, because the server emits mixed naming — txHash camelCase alongside block_hash snake_case. So the annotation is load-bearing here, not decoration.

Both are boxed. A provider that does not report them leaves null rather than defaulting to false/0. That matters for index in particular: it rides Nexus's best-effort enrichment path, so a network without the yaci datasource wired legitimately returns no value, and 0 is a real index (the first transaction in a block) rather than an absence.

Tests

3 added, written before the fields existed and confirmed failing for the right reason (cannot find symbol: getValidContract):

  • values map from a payload carrying both
  • index: 0 is preserved, not read as absent
  • both stay null when the payload omits them

44 tests pass, BUILD SUCCESS, javadoc clean.

What this unblocks

Upstream cardano-client-lib's NexusTransactionService currently hardcodes:

// Nexus has no per-block tx index or Plutus valid-contract flag in this model; leave unmapped.
tc.setIndex(null);
tc.setValidContract(null);

That comment stops being true once this ships. Replacing those two lines is the last step in making the CCL REST fallback shape 1:1 with the direct path — a PR to bloxbean/cardano-client-lib, which needs a released version of this client to depend on.

Release note

main sits at 1.3.0 after #10 reconciled it with the branch 1.2.0 was actually released from. Publishing is tag-triggered (v*) and reads the pom version, so whichever number is chosen, this needs a tag to reach Maven Central before CCL can consume it.

🤖 Generated with Claude Code

Nexus began serving both fields on GET /api/transactions/{hash} in
Gero-Labs/nexus#1081, verified live on mainnet against tx 4847714e...c6710d25
("valid_contract": true, "index": 5, both top-level).

valid_contract needs an explicit @JsonProperty because the client sets no global
naming strategy - the server emits mixed naming (txHash camelCase, block_hash
snake_case) - while index binds by field name.

valid_contract is transaction-level and distinct from
TxPlutusContract.validContract, which is per-script-execution. Both are boxed, so
a provider that does not report them leaves null rather than defaulting to
false/0.

These are what let upstream cardano-client-lib's NexusTransactionService replace
its two hardcoded nulls (tc.setIndex(null) / tc.setValidContract(null)).

3 tests: value mapping, index 0 not read as absent, and both staying null when
the payload omits them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@edridudi
edridudi merged commit 9e8d47d into main Sep 23, 2026
1 check passed
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>
@edridudi
edridudi deleted the feat/tx-valid-contract-and-index branch September 24, 2026 09: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.

1 participant