Skip to content

External contract to add supplementary check to the CMTAT

Notifications You must be signed in to change notification settings

CMTA/AuthorizationEngine

Repository files navigation

AuthorizationEngine

This project is not audited ! It is provided to show an example of a possible AuthorizationEngine as defined in the CMTAT.

If you want to use this project, perform your own verification or send an email to admin@cmta.ch.

Overview

This AuthorizationEngine adds a supplementary check on the function grantRolefrom the CMTAT

  • Enforces a 2-step process to transfer the DEFAULT_ADMIN_ROLE to another account.

  • Enforces a configurable delay between the two steps, with the ability to cancel before the transfer is accepted.

  • The delay can be changed by scheduling, see changeDefaultAdminDelay.

The behavior and the code (under MIT License) come mainly from the OpenZeppelin version AcessControlDefaultAdminRule.

Nevertheless, contrary to OpenZeppelin, these checks are NOT performed:

  • Only one account holds the DEFAULT_ADMIN_ROLE since deployment until it’s potentially renounced.

  • It is not possible to use another role to manage the DEFAULT_ADMIN_ROLE.

See https://docs.openzeppelin.com/contracts/5.x/api/access#AccessControlDefaultAdminRules

Schema

authorizationEngine.drawio

Documentation

Here a summary of the main documentation

Document Link/Files
Technical documentation doc/technical
Toolchain doc/TOOLCHAIN.md
Surya report doc/surya

Usage

Explain how it works.

Toolchain installation

The contracts are developed and tested with Foundry, a smart contract development toolchain.

To install the Foundry suite, please refer to the official instructions in the Foundry book.

Initialization

You must first initialize the submodules, with

forge install

See also the command's documentation.

Later you can update all the submodules with:

forge update

See also the command's documentation.

Compilation

The official documentation is available in the Foundry website

 forge build --contracts src/AuthorizationEngine.sol

Testing

You can run the tests with

forge test

To run a specific test, use

forge test --match-contract <contract name> --match-test <function name>

See also the test framework's official documentation, and that of the test commands.

Coverage

  • Perform a code coverage
forge coverage
  • Generate LCOV report
forge coverage --report lcov
  • Generate index.html
forge coverage --report lcov && genhtml lcov.info --branch-coverage --output-dir coverage

See Solidity Coverage in VS Code with Foundry & Foundry forge coverage