Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding freezer role #82

Merged
merged 27 commits into from
Aug 30, 2024
Merged

feat: adding freezer role #82

merged 27 commits into from
Aug 30, 2024

Conversation

ihoroleksiienko
Copy link
Contributor

@ihoroleksiienko ihoroleksiienko commented Aug 21, 2024

Main changes

  1. The new freezer role has been added to the contract. That role must be assigned to accounts that are executed the frozen balance related functions, like: freezeIncrease(), freezeDecrease(), transferFrozen().
  2. A new function named configureFreezerBatch() has been created to configure the freezer role for a batch of accounts.
  3. A new modifier named onlyFreezer has been added to substitute onlyBlockclister modifier and checks if caller is freezer for the related functions.

Function declaration

  /**
   * @notice Configures a batch of freezers
   *
   * Emits a {FreezerAssigned} event for each assigned freezer
   *
   * Emits a {FreezerRemoved} event for each removed freezer
   *
   * @param freezers The array of freezer addresses to configure
   * @param status The new status of the freezers: `true` is to assign freezers, `false` is to remove freezers
   */
  function configureFreezerBatch(address[] calldata freezers, bool status) external;

Function details

Emitted events

The new function triggers new events FreezerAssigned and FreezerRemoved:

    /**
     * @notice Emitted when a freezer account is assigned
     *
     * @param freezer The address of the assigned freezer
     */
    event FreezerAssigned(address indexed freezer);

    /**
     * @notice Emitted when a freezer account is removed
     *
     * @param freezer The address of the removed freezer
     */
    event FreezerRemoved(address indexed freezer);

Reverting Conditions

The new function is reverted (failed) if:

  1. The contract is paused, with error message "Pausable: paused" .
  2. The caller is not owner, with error message Ownable: caller is not the owner.
  3. The freezer status is the same as previously set for one of the provided accounts, with AlreadyConfigured error.

Test coverage

New functionality was fully covered with tests

@EvgeniiZaitsevCW EvgeniiZaitsevCW merged commit cf22410 into main Aug 30, 2024
7 checks passed
@EvgeniiZaitsevCW EvgeniiZaitsevCW deleted the add-freezer-role-v2 branch August 30, 2024 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants