Auth

SPDX-License-Identifier: SSPL-1.-0

State Variables

adminsCounter

uint8 adminsCounter;

operators

mapping(address => bool) public operators;

admins

mapping(address => bool) public admins;

Functions

constructor

This constructor sets the initialAdmin address as an admin and operator.

The adminsCounter is incremented unchecked.

constructor(address initialAdmin);

onlyAdmin

modifier onlyAdmin();

onlyOperator

modifier onlyOperator();

addAdmin

addAdmin() function allows an admin to add a new admin to the contract.

This function is only accessible to the existing admins and requires the address of the new admin. If the new admin is already set, the function will revert. Otherwise, the adminsCounter will be incremented and the new admin will be added to the admins mapping. An AdminAdded event will be emitted.

function addAdmin(address newAdmin) external onlyAdmin;

deleteAdmin

Deletes an admin from the list of admins.

Only admins can delete other admins. If the adminsCounter is 0, the transaction will revert.

function deleteAdmin(address oldAdmin) external onlyAdmin;

addOperator

Adds a new operator to the list of operators

Only the admin can add a new operator

function addOperator(address newOperator) external onlyAdmin;

Parameters

NameTypeDescription
newOperatoraddressThe address of the new operator

deleteOperator

function deleteOperator(address oldOperator) external onlyAdmin;

Events

AdminAdded

event AdminAdded(address indexed newAdmin);

AdminDeleted

event AdminDeleted(address indexed oldAdmin);

OperatorAdded

event OperatorAdded(address indexed newOperator);

OperatorDeleted

event OperatorDeleted(address indexed oldOperator);

Errors

Unauthorized

error Unauthorized();

AlreadySet

error AlreadySet();

NoAdmin

error NoAdmin();