delegation-framework
delegation-framework copied to clipboard
feat: Call Interval Enforcer
What?
- Add CallIntervalEnforcer contract to enforce a minimum interval between consecutive calls for a given delegation.
- Includes unit tests for interval enforcement logic.
Why?
- To provide a reusable enforcer that restricts the frequency of delegation usage, improving security and flexibility for delegation-based systems.
- Enables use cases such as rate-limiting actions or enforcing cooldown periods on delegated permissions.
How?
- Implements a beforeHook that checks if the required interval has passed since the last call for a (delegationManager, delegationHash) pair.
- Stores the last execution timestamp in a mapping.
- Decodes the interval from _terms (32 bytes, uint256 seconds).
- Adds comprehensive unit tests to verify correct enforcement, including edge cases and independent tracking for different managers and delegations.