Add token contract validation before group creation#103
Open
WuXieSec wants to merge 1 commit intosorosave-protocol:mainfrom
Open
Add token contract validation before group creation#103WuXieSec wants to merge 1 commit intosorosave-protocol:mainfrom
WuXieSec wants to merge 1 commit intosorosave-protocol:mainfrom
Conversation
Changes: - Add InvalidToken error variant to ContractError enum - Validate token contract exists by calling symbol() during create_group - Return InvalidToken error if token contract call fails - Add test coverage for invalid token scenario This prevents groups from being created with invalid or non-existent token addresses, ensuring all groups use valid Stellar asset contracts. Closes sorosave-protocol#62
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.
This PR adds validation to ensure the provided token address is a valid Stellar asset contract before creating a group, as requested in #62.
Changes:
InvalidTokenerror variant toContractErrorenumsymbol()duringcreate_groupInvalidTokenerror if the token contract call failsWhy this matters:
Without this validation, groups could be created with invalid or non-existent token addresses, leading to failures later when trying to transfer tokens during contributions.
Implementation:
Uses
try_symbol()to verify the token contract is callable. If the call fails (contract doesn't exist or doesn't implement the token interface), we returnInvalidTokenerror immediately.Closes #62