Conversation
WalkthroughThis PR extends the TransactionEvent type with a Changes
Sequence DiagramsequenceDiagram
participant Caller
participant TransactionAction
participant Indexer
participant Blockchain
Caller->>TransactionAction: getTransactionEvent(input)
TransactionAction->>Blockchain: Validate block height
Blockchain-->>TransactionAction: ✓ Valid
rect rgba(100, 150, 200, 0.2)
Note over TransactionAction,Indexer: New: Fetch stampMs from Indexer
TransactionAction->>TransactionAction: normalizeTransactionId(txId)
TransactionAction->>Indexer: fetchTransactionStampMs(txId)
Indexer-->>TransactionAction: stampMs (or 0 if unavailable)
end
TransactionAction->>TransactionAction: Construct TransactionEvent with stampMs
TransactionAction-->>Caller: TransactionEvent {stampMs, ...}
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–25 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (5)
tests/integration/transactionAction.test.ts (1)
69-77: stampMs assertions are aligned with the fallback contractChecking
txEvent.stampMs >= 0in these tests fits the documented behavior (real ms timestamp when available,0as sentinel when the indexer is unavailable) without making the tests brittle on indexer health.If you ever want to assert indexer correctness separately, you could add a dedicated test that expects
stampMs > 0behind a flag or env check rather than tightening these core integration tests.Also applies to: 120-130, 157-163
src/types/transaction.ts (1)
43-47: TransactionEvent.stampMs typing and docs look consistentThe
stampMs: numberfield and its doc (“millisecond timestamp… 0 when indexer unavailable”) match the implementation inTransactionAction.getTransactionEventand the API docs.You might mirror this “0 when unavailable” clarification on
LastTransaction.stampMsas well for consistency.docs/api-reference.md (1)
509-520: API docs for stampMs are accurate; minor naming consistency nitThe
stampMsdescription (“millisecond timestamp… 0 when unavailable”) and the example usage align with the public type and implementation.For consistency with the README and to make units explicit, consider changing the example log line to something like:
-console.log(`Timestamp: ${txEvent.stampMs}`); +console.log(`Timestamp (ms): ${txEvent.stampMs}`);Also applies to: 537-542
src/contracts-api/transactionAction.ts (2)
1-41: Indexer integration helper is robust; consider configurability and reuseThe indexer helper (
fetchTransactionStampMs) is defensive (handles non‑200s, malformed payloads, and network errors, all falling back to0), which fits the documentedstampMscontract.
- Make
INDEXER_BASEconfigurable (e.g., via client config or env) so non‑mainnet/local setups can point at their own indexer instead of always hitting the infra URL.normalizeTransactionIdhere is identical to the one intests/integration/utils.ts; consider centralising it in a shared utility to avoid drift.
168-182: stampMs fetch in getTransactionEvent matches the new API contractFetching
stampMsafter validatingblockHeightand returning it alongside the existing fields cleanly extendsgetTransactionEventwithout changing its error semantics; failures in the indexer path degrade tostampMs = 0as documented.Be aware this adds an extra HTTP round‑trip per
getTransactionEventcall; if clients start calling this in tight loops, you may eventually want caching or a bulk/indexer endpoint to avoid N+1 patterns.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
README.md(1 hunks)docs/api-reference.md(2 hunks)src/contracts-api/transactionAction.ts(2 hunks)src/types/transaction.ts(1 hunks)tests/integration/transactionAction.test.ts(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/contracts-api/transactionAction.ts (1)
tests/integration/utils.ts (1)
normalizeTransactionId(172-174)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test
🔇 Additional comments (1)
README.md (1)
332-339: Adding stampMs to the README example looks goodThe example now clearly surfaces the millisecond timestamp with an explicit
(ms)label, which matches the newTransactionEvent.stampMsfield.
Time Submission Status
|
|
the nitpick comments isn't necessarily important. |
related: https://github.com/trufnetwork/trufscan/issues/125
Summary by CodeRabbit
Release Notes
New Features
Documentation
Tests