monerium / smart-contracts

ERC20 compatible e-money deployed on Ethereum
https://monerium.com
Apache License 2.0
35 stars 21 forks source link

[Merge from Private] feature: Minting allowances, Role based System R… #34

Closed KristenPire closed 7 months ago

KristenPire commented 1 year ago

This pull request significantly changes the SystemRole, StandardController and MintableController.

SystemRole

SystemRole is now the Cerberus of EURe. The new code defines three distinct roles: owner, admin, and system.

admin and system roles use openzeppelin/AccessControl.sol, while owner role relies on an older implementation with a single internal owner variable.

To improve the organization and accessibility of our roles and access code, we have shifted the inheritance of the ownable contract from StandardController to SystemRole. Additionally, we have elevated the SystemRole inheritance level to enable its inheritance by StandardController.

In addition, we have inherited SystemRole by ClaimableSystemRole to maintain our system's method of transferring ownership.

Screenshot 2023-04-07 at 11 36 37

MintAllowance

The cornerstone of this PR is MintAllowance. In regard to conciseness let's see the old and new steps to mint after upgrading the controller.

Screenshot 2023-04-07 at 11 38 02

admin will have to periodically re-set the MintAllowance of the authorized system's EOA.

Working with allowance (EMS and e-money admin)

To ensure the successful execution of a minting transaction, both the system role and valid allowances are required. If either one is missing, the transaction will fail and revert.

To avoid any disruptions to our system, we recommend querying the controller.getMintAllowance(systemAddr) returns(uint256) view function before submitting a transaction to the blockchain.

Minting big amount

To facilitate clients in transferring an amount greater than the MaxMintAllowance (i.e., the maximum minting limit set by the administrators), the following process can be implemented:

Screenshot 2023-04-07 at 11 37 26

Acess of Privilleges by Role

New Roles assignment

The table indicates that the ban function of BlacklistValidator is now protected against unauthorized access by the owner, admin, and system. To ensure this protection is effective, it's crucial to register the admin and system accounts, in addition to following the configuration steps for deploying the Controller: Screenshot 2023-04-11 at 12 11 15