Skip to content

Go Fish Midnight Contract Placeholder - #1

Merged
Lambdanaut merged 1 commit into
mainfrom
feature/midnight-go-fish-contract-demo
Jan 14, 2026
Merged

Lambdanaut merged 1 commit into
mainfrom
feature/midnight-go-fish-contract-demo

Conversation

@acedward

Copy link
Copy Markdown
Contributor
deno task -f @go-fish/midnight-contract-go-fish compile

deno task -f @go-fish/midnight-contracts test

Output

Task test (@go-fish/midnight-contracts) deno run -A example.test.ts
🎴 Go Fish Contract Test Suite & Simulator
==========================================


======================================================================
🧪 CONTRACT TEST SUITE
======================================================================
Testing each function from game.compact individually...

Game ID: 0d05e714ec964d06

--- TEST 1: applyMask (Player 1) - creates game ---
  ✅ PASS: applyMask (Player 1) (mask applied, game created)

--- TEST 2: get_deck_size ---
  ✅ PASS: get_deck_size (deck has 52 cards)

--- TEST 3: get_top_card_index (initial) ---
  ✅ PASS: get_top_card_index (initial) (top card index is 0)
...

@Lambdanaut
Lambdanaut merged commit 4f4c699 into main Jan 14, 2026
acedward added a commit that referenced this pull request Apr 20, 2026
…arden witnesses

Phase 0 (EVM lobby alignment):
- Remove maxPlayers from GoFishGameState type and in-memory state
  (DB column dropped per EVM_UPDATE.md; game is always 2 players)

Phase 1 (critical fixes):
- Fix callAfterGoFish: remove stale drewRequestedCard param (4→3 args).
  Contract v3 decrypts the drawn card internally (game.compact:451-510).
  Updated across all 6 files in the call chain (GoFishContractService,
  MidnightService, MidnightOnChainService, midnightBridge, GameScreen,
  GameScene).
- Delete callGoFish / goFish: no goFish circuit exists in the compiled
  contract. respondToAsk handles the draw internally. Turn flow is now:
  askForCard → respondToAsk → (if WaitForDrawCheck) afterGoFish.
- Allow empty-hand asks: contract rule-5 relaxation permits asking for
  any rank when hand is empty. GameScreen now shows an "Ask for a card"
  button instead of the old passive "Drawing will happen automatically"
  message that stalled the game.

Phase 2 (book scoring — without this, games never end):
- Add callCheckAndScoreBook to GoFishContractService (batcher delegation)
- Add onChainCheckAndScoreBook to MidnightOnChainService
- Add checkAndScoreBook routing to MidnightService
- Add autoScoreBooks() to GameScreen: after respondToAsk and afterGoFish,
  scans the player's hand for ranks with ≥3 cards and submits
  checkAndScoreBook for each. The contract's addScore checks ≥4 books
  and sets phase=GameOver + winner.

Phase 3 (winner display):
- Update renderGameOverPanel to use ≥4 threshold for winner determination
  (matches the contract's early-win rule). Added TODO for reading
  getWinner from the contract once direct indexer access is available.

Phase 5 (witness hardening):
- Remove silent Math.random() fallback from witnesses.ts getSecretKey
  and getShuffleSeed. Both now throw immediately on a miss with a
  descriptive error naming the game+player that's missing. Delete the
  static `keys` object that powered the fallback (20-bit random values
  that produced wrong ec_mul results). See BACKEND_ISSUES.md #1.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants