feat(api): include block_timestamp in /tx/<hash> detail#66
Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR extends the Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
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.
Why
The
transactionsrow has no timestamp — chain time lives on theblockstable — 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/txfallback added in frontend #97) had to render epoch 0.Change
detailnow looks up the tx's block by height and addsblock_timestamp(unix seconds, chain time) to the response, alongsidetx+logs. One extra query — acceptable on a single-tx detail path (not a hot list), so the sharedWireTransactionand 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) returnsblock_timestamp == 1700086400.No version bump (repo bumps via separate chore commits per path-dep convention).
Summary by CodeRabbit
New Features
block_timestampin API responses. This field contains the timestamp of the block associated with the transaction and defaults to 0 if block information is unavailable.Tests
block_timestampfield returned in transaction detail responses.