fix: enforce token contract whitelist in deposit methods (SC-17) - #939
Open
doctorlight0 wants to merge 1 commit into
Open
fix: enforce token contract whitelist in deposit methods (SC-17)#939doctorlight0 wants to merge 1 commit into
doctorlight0 wants to merge 1 commit into
Conversation
- 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
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ALLOWED_TOKENSstorage (Vec<Address>) andTokenNotWhitelistederror variantadd_whitelisted_token(admin, token)— admin-only, adds token to whitelistremove_whitelisted_token(admin, token)— admin-only, removes token from whitelistget_whitelisted_tokens() -> Vec<Address>— public read accessinitialize_tokento reject tokens not in the whitelistcreate_gameandjoin_game(deposit methods) to validate the token is still whitelisted at time of depositRelated Issues
Closes #862
Checklist