Skip to content

Add token contract validation before group creation#103

Open
WuXieSec wants to merge 1 commit intosorosave-protocol:mainfrom
WuXieSec:feat/validate-token-contract
Open

Add token contract validation before group creation#103
WuXieSec wants to merge 1 commit intosorosave-protocol:mainfrom
WuXieSec:feat/validate-token-contract

Conversation

@WuXieSec
Copy link
Copy Markdown

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:

  • Add InvalidToken error variant to ContractError enum
  • Validate token contract exists by calling symbol() during create_group
  • Return InvalidToken error if the token contract call fails
  • Add test coverage for invalid token scenario

Why 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 return InvalidToken error immediately.

Closes #62

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
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.

Validate token contract exists before group creation

1 participant