Skip to content

fix: enforce token contract whitelist in deposit methods (SC-17) - #939

Open
doctorlight0 wants to merge 1 commit into
OpenKnight-Foundation:mainfrom
doctorlight0:feat/sc-17-token-whitelist
Open

fix: enforce token contract whitelist in deposit methods (SC-17)#939
doctorlight0 wants to merge 1 commit into
OpenKnight-Foundation:mainfrom
doctorlight0:feat/sc-17-token-whitelist

Conversation

@doctorlight0

Copy link
Copy Markdown

Description

The contract previously accepted any token address in initialize_token, which could lead to users funding tournaments with worthless spoofed tokens. This change enforces an admin-maintained whitelist of permitted token contract addresses.

Changes

  • Added ALLOWED_TOKENS storage (Vec<Address>) and TokenNotWhitelisted error variant
  • Added add_whitelisted_token(admin, token) — admin-only, adds token to whitelist
  • Added remove_whitelisted_token(admin, token) — admin-only, removes token from whitelist
  • Added get_whitelisted_tokens() -> Vec<Address> — public read access
  • Modified initialize_token to reject tokens not in the whitelist
  • Modified create_game and join_game (deposit methods) to validate the token is still whitelisted at time of deposit

Related Issues

Closes #862

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

- Add ALLOWED_TOKENS storage and TokenNotWhitelisted error
- Add add_whitelisted_token / remove_whitelisted_token / get_whitelisted_tokens
- Validate token is whitelisted in initialize_token, create_game, join_game
- Update all tests to whitelist the token before initializing

Closes OpenKnight-Foundation#862
@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@doctorlight0 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

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.

SC-17: Ensure strict validation of token contract addresses in deposit methods

1 participant