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

Add the possibility to update and revoke existing premints #4

Merged
merged 17 commits into from
Mar 14, 2024

Conversation

yuriicw
Copy link
Contributor

@yuriicw yuriicw commented Mar 14, 2024

Description

With the new functionality, it will be possible to revoke or update existing premints. Function cashInPremint() is reverted if the cash-in operation with the passed releaseTime already exists, so newly introduced functions should be used to modify existing premints.

New Functionality and Changes to Existing Functionality

PIX Cashier

  1. A new cashInPremintRevoke function was introduced to revoke existing premints:
function cashInPremintRevoke(bytes32 txId, uint256 releaseTime) external;

This function resets the amount of premint to zero and completely erases all the stored information about the premint, allowing the reuse of the cash-in operation ID to create new premints. It can only be executed if the premint's release time has not passed.

  1. A new cashInPremintUpdate function was introduced to update existing premints:
function cashInPremintUpdate(uint256 amount, bytes32 txId, uint256 releaseTime) external;

This function changes the amount of preminted tokens. The new amount can be less or greater than the old amount. It can only be executed if the premint's release time has not passed.

  1. The event CashInPremint event was modified; now, it emits one more parameter:
event CashInPremint(
        address indexed account, // The account that received tokens from the premint.
        uint256 newAmount,       // The new amount of preminted tokens.
        uint256 oldAmount,       // The old amount of preminted tokens.
        bytes32 indexed txId,    // The off-chain transaction identifier.
        uint256 releaseTime      // The timestamp when the minted tokens will become available for usage.
    );

In the case of a new premint, oldAmount will be equal to zero; otherwise, it would hold the previous amount of the premint.

Key Highlights

The common behavior of new functions:

  1. Each call of the new function checks for the revert conditions.
  2. If revert conditions were not met, the contract updates the stored data about the cash-in operation.
  3. Contract emits the event and makes a call to premint() function of the token contract.

The revert conditions for the functions

  1. If the passed releaseTime is zero.
  2. If the amount passed into cashInPremintUpdate is zero.
  3. If the passed txId is zero.
  4. If the account associated with the premint is blocklisted on the PixCashier contract.
  5. If the cash-in operation with the passed txId is not a premint.

Note

All the functionality regarding premints is separated between two smart contracts: PixCashier and token contract.
To check the second part, see here

Test coverage

The new functionality was fully covered by tests.
image

@igorsenych-cw igorsenych-cw merged commit 71c7d9b into main Mar 14, 2024
6 checks passed
@igorsenych-cw igorsenych-cw deleted the premint-update-feature branch March 14, 2024 14:04
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.

2 participants