Skip to content

feat(api): include block_timestamp in /tx/<hash> detail#66

Merged
satyakwok merged 1 commit into
mainfrom
feat/tx-detail-block-timestamp
Jun 8, 2026
Merged

feat(api): include block_timestamp in /tx/<hash> detail#66
satyakwok merged 1 commit into
mainfrom
feat/tx-detail-block-timestamp

Conversation

@satyakwok
Copy link
Copy Markdown
Member

@satyakwok satyakwok commented Jun 8, 2026

Why

The transactions row has no timestamp — chain time lives on the blocks table — so the /tx/<hash> detail endpoint couldn't tell the explorer when a tx happened. The scan tx-detail page that consumes this endpoint (via the /tx fallback added in frontend #97) had to render epoch 0.

Change

detail now looks up the tx's block by height and adds block_timestamp (unix seconds, chain time) to the response, alongside tx + logs. One extra query — acceptable on a single-tx detail path (not a hot list), so the shared WireTransaction and the address-list query are untouched. Falls back to 0 only if the block row is missing (shouldn't happen for an indexed tx).

Test

Smoke asserts /tx/<fixture-cccc> (block 2 @ ts 1700086400) returns block_timestamp == 1700086400.

No version bump (repo bumps via separate chore commits per path-dep convention).

Summary by CodeRabbit

  • New Features

    • Transaction detail endpoint now includes block_timestamp in API responses. This field contains the timestamp of the block associated with the transaction and defaults to 0 if block information is unavailable.
  • Tests

    • Updated smoke tests to validate the new block_timestamp field returned in transaction detail responses.

The transactions row carries no timestamp — chain time lives on the blocks
table — so /tx/<hash> had no way to tell the explorer when a tx happened.
The tx-detail page consuming this endpoint had to show epoch 0.

Join the block's timestamp into the detail response (one extra lookup by
height; the detail path is single-tx, not a hot list). Smoke asserts the
fixture tx in block 2 returns its block timestamp.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 8, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f5b5fe1d-21a0-4a73-bd7d-f72def870ce4

📥 Commits

Reviewing files that changed from the base of the PR and between 663c9d9 and 3fca1aa.

📒 Files selected for processing (2)
  • crates/api/src/routes/tx.rs
  • scripts/smoke.sh

📝 Walkthrough

Walkthrough

This PR extends the /tx/:hash transaction detail endpoint to include a block_timestamp field in its response. The field is sourced by looking up the block associated with the transaction's block_height and extracting its timestamp, defaulting to 0 if the block row is missing. The smoke test script is updated to validate the presence and value of this new field in the endpoint response.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The pull request description covers Why, Change, and Test sections comprehensively, but does not follow the repository's required template structure with Scope and Checks sections. Consider aligning the description with the repository template by adding Scope (e.g., 'Deploy script / CI / docs only') and Checks sections to ensure consistency across pull requests.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and concisely summarizes the main change: adding block_timestamp to the /tx/ detail endpoint response.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/tx-detail-block-timestamp

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@satyakwok satyakwok merged commit d89a75d into main Jun 8, 2026
8 checks passed
@satyakwok satyakwok deleted the feat/tx-detail-block-timestamp branch June 8, 2026 10:58
satyakwok added a commit that referenced this pull request Jun 8, 2026
Lands the version bump for the v0.2.7 release (/tx block_timestamp, #66).
Bumps workspace package version + exact-pinned path-deps + indexer-* Cargo.lock entries.
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