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: add the possibility to increase and decrease frozen balance #81

Merged
merged 13 commits into from
Aug 20, 2024

Conversation

ihoroleksiienko
Copy link
Contributor

@ihoroleksiienko ihoroleksiienko commented Aug 16, 2024

Main changes

  1. A new function named freezeIncrease() has been created to increase an existing frozen balance by a certain amount.
  2. A new function named freezeDecrease() has been created to decrease an existing frozen balance by a certain amount.
  3. The existing freeze() function has been updated to prohibit the ability to use a zero address as account.
  4. The existing freeze() function has been marked as deprecated. We are going to remove it in the future.

Functions declaration

   /**
   * @notice Increases the frozen balance for an account
   *
   * Emits a {Freeze} event
   *
   * @param account The account to increase frozen balance for
   * @param amount The amount to increase the frozen balance by
   */
  function freezeIncrease(address account, uint256 amount) external;

  /**
   * @notice Decreases the frozen balance for an account
   *
   * Emits a {Freeze} event
   *
   * @param account The account to decrease frozen balance for
   * @param amount The amount to decrease the frozen balance by
   */
  function freezeDecrease(address account, uint256 amount) external;

Functions details

Emitted events

The new functions trigger the existing event Freeze:

    /**
     * @notice Emitted when token freezing has been performed for a specific account
     *
     * @param account The account for which token freezing has been performed
     * @param newFrozenBalance The updated frozen balance of the account
     * @param oldFrozenBalance The previous frozen balance of the account
     */
    event Freeze(address indexed account, uint256 newFrozenBalance, uint256 oldFrozenBalance);

Reverting Conditions

The new functions are reverted (failed) if:

  1. The contract is paused, with error message "Pausable: paused" .
  2. The caller is not blocklister, with the UnauthorizedBlocklister error.
  3. The zero address is passed to the argument of the account function, with the ZeroAddress error.
  4. Zero is passed to the argument amount, with the ZeroAmount error.
  5. The provide account did not approved freezing previously, with the FreezingNotApproved error.

Test coverage

New functionality was fully covered with tests

@EvgeniiZaitsevCW EvgeniiZaitsevCW deleted the update-freezable branch August 16, 2024 11:57
@EvgeniiZaitsevCW EvgeniiZaitsevCW restored the update-freezable branch August 16, 2024 11:58
@EvgeniiZaitsevCW
Copy link
Contributor

Reopened because I accidentally removed the remote branch instead of the local one

@EvgeniiZaitsevCW EvgeniiZaitsevCW merged commit 3e451e6 into main Aug 20, 2024
7 checks passed
@EvgeniiZaitsevCW EvgeniiZaitsevCW deleted the update-freezable branch August 20, 2024 10:10
@igorsenych-cw igorsenych-cw changed the title Adding the possibility to increase and decrease frozen balance feat: add the possibility to increase and decrease frozen balance Sep 10, 2024
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