Description
create_market does not pre-flight check that the caller has paid sufficient rent for the persistent-tier keys it will allocate. Add a pre-flight estimate and reject if insufficient.
Requirements and Context
- Compute rent estimate from
StorageConfig constants and number of keys allocated
- Compare to
env.storage().instance().get_ttl() headroom
- Reject with
Error::InsufficientStorageRent
- Must be secure, tested, and documented
- Should be efficient and easy to review
Suggested Execution
- Fork the repo and create a branch
git checkout -b feat/create-market-rent-preflight
- Implement changes
contracts/predictify-hybrid/src/markets.rs
contracts/predictify-hybrid/src/storage.rs
contracts/predictify-hybrid/src/err.rs
- Test and commit
cargo test -p predictify-hybrid market_creation_validation_tests -- --nocapture
- Cover edge cases: ample headroom, just-enough, insufficient
- Include test output and notes in the PR
Example commit message
feat: pre-flight storage-rent check in create_market
Acceptance Criteria
Guidelines
- Avoid double-counting persistent-key bumps
- Minimum 95% coverage
- Clear documentation and inline comments
- Timeframe: 96 hours
Description
create_marketdoes not pre-flight check that the caller has paid sufficient rent for the persistent-tier keys it will allocate. Add a pre-flight estimate and reject if insufficient.Requirements and Context
StorageConfigconstants and number of keys allocatedenv.storage().instance().get_ttl()headroomError::InsufficientStorageRentSuggested Execution
contracts/predictify-hybrid/src/markets.rscontracts/predictify-hybrid/src/storage.rscontracts/predictify-hybrid/src/err.rscargo test -p predictify-hybrid market_creation_validation_tests -- --nocaptureExample commit message
Acceptance Criteria
unwrap()introducedGuidelines