🟡 Priority: High
Difficulty: Hard
Estimated Effort: 2-3 days
Relevant Files: contracts/src/lib.rs
Labels: enhancement, priority:high, integration
Requirements
-
Event-Driven Automation
- The backend currently polls or relies on cron jobs to trigger payouts. The smart contract can emit highly specific events to tell off-chain indexers exactly when an automated action is required.
-
Rich Event Payloads
- Enhance the
contribute event to emit the current pool fullness status.
env.events().publish((symbol_short!("contrib"), member), (amount, current_cycle_contributions, is_pool_full));
- If
is_pool_full is true, this serves as a deterministic trigger for the backend to immediately construct and submit the payout() transaction, eliminating polling delays.
-
Cycle Reset Events
-
Data Minimization
- Ensure sensitive data (like the total group size or exact total balance) is only emitted if strictly necessary, to maintain some privacy on the public ledger. Use short symbols (
Symbol::short("P_FULL")) to save byte space.
-
Testing
- Unit test: Verify
is_pool_full boolean is correctly calculated and emitted in the contribution event payload.
- Unit test: Verify
cycle_done event is emitted precisely on the final payout.
- Target: >90% coverage on event emissions.
🟡 Priority: High
Difficulty: Hard
Estimated Effort: 2-3 days
Relevant Files:
contracts/src/lib.rsLabels:
enhancement,priority:high,integrationRequirements
Event-Driven Automation
Rich Event Payloads
contributeevent to emit the current pool fullness status.env.events().publish((symbol_short!("contrib"), member), (amount, current_cycle_contributions, is_pool_full));is_pool_fullis true, this serves as a deterministic trigger for the backend to immediately construct and submit thepayout()transaction, eliminating polling delays.Cycle Reset Events
payout()executes, if it was the last person in the cycle (based on Issueinitializedoes not require admin authorization — front-running attack possible #5), automatically emit acycle_completeevent.env.events().publish((symbol_short!("cycle_done"), cycle_id), ());Data Minimization
Symbol::short("P_FULL")) to save byte space.Testing
is_pool_fullboolean is correctly calculated and emitted in the contribution event payload.cycle_doneevent is emitted precisely on the final payout.