Validate token contract exists before group creation#112
Open
WuXieSec wants to merge 1 commit intosorosave-protocol:mainfrom
Open
Validate token contract exists before group creation#112WuXieSec wants to merge 1 commit intosorosave-protocol:mainfrom
WuXieSec wants to merge 1 commit intosorosave-protocol:mainfrom
Conversation
Changes: - Call token contract's symbol() to verify it exists - Return InvalidToken error if contract call fails - Add InvalidToken variant to ContractError enum - Add test coverage for both valid and invalid tokens 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, as requested in #62.
Changes:
symbol()to verify it existsInvalidTokenerror if contract call failsInvalidTokenvariant toContractErrorenumWhy this matters:
Without validation, groups could be created with:
This would cause failures later when trying to transfer tokens during contributions and payouts.
Implementation:
Uses
try_symbol()to safely check if the token contract exists and implements the token interface. If the call fails, we reject the group creation immediately.Test coverage:
InvalidTokenerrorCloses #62