Skip to content

fix(timestamps): localize events and reject malformed ledger dates - #38

Merged
Muyideen-js merged 2 commits into
SPaulse-Org:mainfrom
h3x-lol:agent/validate-ledger-timestamps
Jul 21, 2026
Merged

fix(timestamps): localize events and reject malformed ledger dates#38
Muyideen-js merged 2 commits into
SPaulse-Org:mainfrom
h3x-lol:agent/validate-ledger-timestamps

Conversation

@h3x-lol

@h3x-lol h3x-lol commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • format Unix-second timestamps through shared locale-aware date/time helpers
  • normalize Soroban ledgerClosedAt values to Unix seconds at the event boundary
  • reject invalid, missing, NaN, and infinite ledger timestamps with a clear RangeError
  • verify the full parser path drops malformed events before they can enter UI state

Unique correctness advantage

PR #36 adds ledgerClosedAtToUnixSeconds, but it returns NaN for malformed or non-finite inputs. That bypasses the parser's existing catch path and allows an event containing timestamp: NaN into the returned event list.

This patch validates the converted millisecond value with Number.isFinite and throws RangeError("Invalid ledger close timestamp"). The existing parser catches that error and discards the malformed event.

No seconds-versus-milliseconds heuristic is introduced: event inputs are normalized once at the service boundary, and application formatters retain a Unix-seconds contract.

Regression evidence

With the finite-value guard temporarily removed:

  • event regression suite: 3 passed, 6 failed
  • invalid string, missing value, NaN, Infinity, and -Infinity did not throw
  • the parser-level test returned an event containing timestamp: NaN instead of an empty result

With the guard present:

  • focused timestamp/event tests: 64/64 passed

Additional validation

  • full test suite: all issue-related tests pass; 3 unrelated failures remain and reproduce on unmodified main
    • 2 stale Navbar assertions expect StellarPulse while the component renders Stellar Pulse
    • 1 leaderboard assertion expects an en-US thousands separator while this environment renders the locale separator
  • TypeScript check: blocked only by the pre-existing missing Poppins weight in src/app/layout.tsx
  • production build: blocked by the same pre-existing Poppins configuration
  • lint: skipped because the repository has no ESLint configuration and next lint requires interactive setup
  • git diff --check: passed

Closes #27

@h3x-lol h3x-lol changed the title fix: reject malformed ledger timestamps fix(timestamps): localize events and reject malformed ledger dates Jul 11, 2026
@h3x-lol
h3x-lol marked this pull request as ready for review July 11, 2026 15:24
@h3x-lol

h3x-lol commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

/claim #27

@Muyideen-js

Copy link
Copy Markdown
Collaborator

@h3x-lol fix the conflict

@Muyideen-js

Copy link
Copy Markdown
Collaborator

@h3x-lol fix conflict

@Muyideen-js
Muyideen-js merged commit 06fd372 into SPaulse-Org:main Jul 21, 2026
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.

[wave] Fix inconsistent timezone display in leaderboard

2 participants