Description
The reentrancy_guard module exposes with_external_call/before_external_call/after_external_call, but it must actually wrap every cross-contract token transfer. withdraw, claim_winnings, distribute_payouts, and withdraw_collected_fees perform SAC transfer calls that should follow checks-effects-interactions and be guarded so a malicious token cannot re-enter mid-payout.
Requirements and Context
- Identify all external
transfer calls in contracts/predictify-hybrid/src/lib.rs / bets.rs / fees.rs.
- Apply state mutation before the transfer and wrap the transfer in
ReentrancyGuard::with_external_call.
- Ensure guard state is restored on transfer failure.
- 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 task/reentrancy-guard-transfers
- Implement changes
contracts/predictify-hybrid/src/lib.rs, contracts/predictify-hybrid/src/bets.rs, contracts/predictify-hybrid/src/fees.rs, contracts/predictify-hybrid/src/reentrancy_guard.rs
- Test and commit
cargo test -p predictify-hybrid -- reentrancy
- Cover edge cases: re-entrant token mock, transfer failure rollback
- Include test output and notes in the PR
Example commit message
task: guard external token transfers against reentrancy
Acceptance Criteria
Guidelines
- Minimum 95% coverage on touched code, validate reentrancy-equivalent assumptions
- Clear documentation and inline comments
- Timeframe: 96 hours
Description
The
reentrancy_guardmodule exposeswith_external_call/before_external_call/after_external_call, but it must actually wrap every cross-contract token transfer.withdraw,claim_winnings,distribute_payouts, andwithdraw_collected_feesperform SACtransfercalls that should follow checks-effects-interactions and be guarded so a malicious token cannot re-enter mid-payout.Requirements and Context
transfercalls incontracts/predictify-hybrid/src/lib.rs/bets.rs/fees.rs.ReentrancyGuard::with_external_call.Suggested Execution
contracts/predictify-hybrid/src/lib.rs,contracts/predictify-hybrid/src/bets.rs,contracts/predictify-hybrid/src/fees.rs,contracts/predictify-hybrid/src/reentrancy_guard.rscargo test -p predictify-hybrid -- reentrancyExample commit message
Acceptance Criteria
Guidelines