Skip to content

feat(stats): wire history and round detail to the real round ledger#52

Merged
netqo merged 1 commit into
devfrom
feat/stats-layer
Jun 23, 2026
Merged

feat(stats): wire history and round detail to the real round ledger#52
netqo merged 1 commit into
devfrom
feat/stats-layer

Conversation

@netqo

@netqo netqo commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

Phase 1 of the stats layer: connects the persisted game_round ledger (added with Coinflip) into the two screens that were still rendering preview data. History (CU-10) now lists the rounds actually played with a live aggregate summary, and Round Detail (CU-11) resolves a round by id and shows its real, verifiable provably-fair seeds.

Rationale

The round ledger existed but had no readers. Wiring History + Round Detail first delivers the marquee defense feature (real provably-fair verification) and is self-contained:

  • HistoryViewModel maps GameRepository.rounds into the existing HistoryData (rows + summary: rounds, win rate, net). Search/filter stay screen-local. A "no rounds yet" empty state is distinguished from the filtered-out "no rounds match".
  • RoundDetailViewModel reads the nav-arg id, resolves the round via the new GameRepository.getRound, and exposes Loading / Success / NotFound; RoundDetailScreen is now stateless over that state (matching the Wallet/News pattern). The provably-fair block carries the round's real serverSeed / clientSeed / nonce / HMAC hash.
  • The round -> RoundDetailData mapping is coinflip-shaped for now (no crash bar) and branches on GameRound.game, so the other games slot in as they land.

Profile P&L is intentionally left on preview data; it is the next slice (kept out to keep this PR scoped and avoid destabilizing the Profile tests).

Also fixes CoinflipScreenTest, which still called the pre-stateless CoinflipScreen signature from the Coinflip PR. The "assemble and unit tests" CI job does not compile the instrumented sources, so it was not caught; this PR compiles them locally.

Verification

  • ./gradlew testDebugUnitTest detekt ktlintCheck assembleDebug compileDebugAndroidTestKotlin green locally (JDK 17).
  • New tests: HistoryViewModelTest, RoundDetailViewModelTest, getRound cases in GameRepositoryImplTest.
  • Installed the debug APK on a physical device: played coinflip rounds, saw them list in History with a correct summary, opened a round and expanded Provably Fair to confirm the real seeds/nonce/hash render.

Test plan

  • History lists played rounds newest-first with Bet/Payout/Prediction.
  • The summary strip (rounds, win rate, net) reflects the real rounds.
  • Game/Result filters and search work over the rounds.
  • An empty ledger shows "No rounds yet".
  • Tapping a round opens Round Detail with the real outcome.
  • Provably Fair expands to the round's real seeds / nonce / hash.
  • Back returns to History.

Related issues

Refs the stats-layer work for the final entrega (phase 1 of 2; profile P&L is phase 2).

Checklist

  • Commit messages follow Conventional Commits (see CONTRIBUTING.md).
  • Branch name follows the naming convention (feat/, fix/, chore/, etc.).
  • The change is scoped: no unrelated edits sneaked into this PR.
  • If user-visible behavior changed, CHANGELOG.md has been updated under [Unreleased].
  • If a new dependency was added, it is justified in the PR description. (No new dependencies.)

Connect the persisted game_round ledger (added with Coinflip) into the
two screens that were still on preview data.

HistoryViewModel maps GameRepository.rounds into the list rows plus the
aggregate summary (rounds, win rate, net); search and filtering stay
screen-local, and a dedicated "no rounds yet" empty state distinguishes
an empty ledger from a filtered-out one.

RoundDetailViewModel resolves a round by the nav-arg id via
GameRepository.getRound and exposes Loading / Success / NotFound; the
RoundDetailScreen is now stateless over that state. The provably-fair
block renders the round's real serverSeed / clientSeed / nonce / HMAC
hash, so the outcome is independently verifiable.

Adds GameRepository.getRound. Also fixes CoinflipScreenTest, which still
referenced the pre-stateless CoinflipScreen signature (the assemble/unit
CI job does not compile the instrumented sources, so it went unnoticed).

Covered by HistoryViewModelTest, RoundDetailViewModelTest and the new
getRound cases in GameRepositoryImplTest.
@netqo netqo merged commit f56c847 into dev Jun 23, 2026
3 checks passed
@netqo netqo deleted the feat/stats-layer branch June 23, 2026 20:19
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