Skip to content

Feat: Implement Robust On-Chain Logic for Game Settlement and Staking (#526)#681

Merged
gabito1451 merged 1 commit into
OpenKnight-Foundation:mainfrom
kryputh:feature/issue-526
Apr 25, 2026
Merged

Feat: Implement Robust On-Chain Logic for Game Settlement and Staking (#526)#681
gabito1451 merged 1 commit into
OpenKnight-Foundation:mainfrom
kryputh:feature/issue-526

Conversation

@kryputh

@kryputh kryputh commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Resolves #526

Context
This PR implements critical on-chain lifecycle management functions in contracts/game_contract/src/lib.rs to securely handle game settlement and staking withdrawals. It addresses structural gaps in how normal wins are claimed and how unmatched stakes are refunded.

Tasks Completed

  • Implemented claim_win: Normal wins (checkmates) are now processed on-chain using an ED25519 payload signature (game_id || winner_address) verified against the ADMIN_KEY to guarantee authenticity and immediately trigger the escrow payout.
  • Implemented cancel_game: Adds necessary staking logic allowing game creators to cancel a game and retrieve their staked tokens from ESCROW prior to an opponent joining (GameState::Created).
  • Secured claim_draw: Refactored the draw logic to require a backend-signed payload (game_id || "DRAW"), preventing malicious or losing players from unilaterally declaring a draw to recoup their wagers.

Acceptance Criteria Met:

  • Code is well-documented and strictly follows established design patterns (signature verification).
  • Efficient resource utilization (gas/CPU) ensuring secure state mutations in minimal passes.
  • Pushed and tested against the primary branch logic.

#526

@coderabbitai

coderabbitai Bot commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@kryputh has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 17 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 5 minutes and 17 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d0f92240-105e-4c8c-9e93-95e96d128fab

📥 Commits

Reviewing files that changed from the base of the PR and between b34033f and dbe6e12.

📒 Files selected for processing (1)
  • contracts/game_contract/src/lib.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@drips-wave

drips-wave Bot commented Apr 25, 2026

Copy link
Copy Markdown

@kryputh Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@gabito1451 gabito1451 merged commit 0e58745 into OpenKnight-Foundation:main Apr 25, 2026
2 checks passed
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.

Contract: Gas Optimization for Large-Scale Tournament Payouts

2 participants