Complexity: High (200 points)
Description
subscribe() accepts any Address as token. If a non-contract address is passed, the token::Client::new() call will succeed but allowance() will fail at runtime with an opaque error.
Requirements and context
- Validate that the token address is a contract (not an account) before storing the subscription
- Use
env.deployer().get_contract_id() or similar Soroban API
- Add
ContractError::InvalidTokenAddress variant
- Add test: non-contract address as token panics with typed error
Suggested execution
git checkout -b fix/token-address-validation
- Edit
contract/src/lib.rs → subscribe()
- Edit
contract/src/errors.rs
- Add test
Acceptance criteria
Complexity: High (200 points)
Description
subscribe()accepts anyAddressastoken. If a non-contract address is passed, thetoken::Client::new()call will succeed butallowance()will fail at runtime with an opaque error.Requirements and context
env.deployer().get_contract_id()or similar Soroban APIContractError::InvalidTokenAddressvariantSuggested execution
contract/src/lib.rs→subscribe()contract/src/errors.rsAcceptance criteria
cargo testpasses