Contract 0xa19713ae9d07134448735f2643c1b27e42ee6b3f

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x9e2d7d975115fc125dc02a5583a486e2fb7972fe75ec8a9dedfa088c1f7294b20x6080604014627772022-02-09 14:19:48358 days 4 hrs agoLido: Deployer IN  Create: AuthManager0 MOVR0.001297203
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
AuthManager

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 3 : AuthManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "Initializable.sol";

import "IAuthManager.sol";


contract AuthManager is IAuthManager, Initializable {
    // mapping which contains roles for address
    mapping(address => bytes32[])  internal members;

    // constant for showing that element not found in array
    uint256 internal constant NOT_FOUND = type(uint256).max;

    // hash for SUPER role
    bytes32 public constant SUPER_ROLE = keccak256("SUPER_ROLE");

    // event emitted when new member for role added
    event AddMember(address member, bytes32 role);

    // event emitted when member removed from role
    event RemoveMember(address member, bytes32 role);

    /**
    * @notice Initialize contract after deploying
    * @param superior - address of member which granted with super role
    */
    function initialize(address superior) external initializer {
        if (superior == address(0)) {
            members[msg.sender] = [SUPER_ROLE];
            emit AddMember(msg.sender, SUPER_ROLE);
        } else {
            members[superior] = [SUPER_ROLE];
            emit AddMember(superior, SUPER_ROLE);
        }
    }

    /**
    * @notice Function returns roles array for member
    * @param _member - address of member
    */
    function roles(address _member) external view returns (bytes32[] memory) {
        return members[_member];
    }

    /**
    * @notice Check if member has a specific role
    * @param role - hash of role string
    * @param _member - address of member
    */
    function has(bytes32 role, address _member) external override view returns (bool) {
        return _find(members[_member], role) != NOT_FOUND;
    }

    /**
    * @notice Add new role for member. Only SUPER_ROLE can add new roles
    * @param role - hash of a role string
    * @param member - address of member
    */
    function add(bytes32 role, address member) external override {
        require(_find(members[msg.sender], SUPER_ROLE) != NOT_FOUND, "FORBIDDEN");

        bytes32[] storage _roles = members[member];

        require(_find(_roles, role) == NOT_FOUND, "ALREADY_MEMBER");
        _roles.push(role);
        emit AddMember(member, role);
    }

    /**
    * @notice Add new role for member by string. Only SUPER_ROLE can add new roles
    * @param roleString - role string
    * @param member - address of member
    */
    function addByString(string calldata roleString, address member) external {
        require(_find(members[msg.sender], SUPER_ROLE) != NOT_FOUND, "FORBIDDEN");

        bytes32[] storage _roles = members[member];
        bytes32 role = keccak256(bytes(roleString));

        require(_find(_roles, role) == NOT_FOUND, "ALREADY_MEMBER");
        _roles.push(role);
        emit AddMember(member, role);
    }

    /**
    * @notice Remove role from member. Only SUPER_ROLE can add new roles
    * @param role - hash of a role string
    * @param member - address of member
    */
    function remove(bytes32 role, address member) external override {
        require(_find(members[msg.sender], SUPER_ROLE) != NOT_FOUND, "FORBIDDEN");
        require(msg.sender != member || role != SUPER_ROLE, "INVALID");

        bytes32[] storage _roles = members[member];

        uint256 i = _find(_roles, role);
        require(i != NOT_FOUND, "MEMBER_NOT_FOUND");
        if (_roles.length == 1) {
            delete members[member];
        } else {
            if (i < _roles.length - 1) {
                _roles[i] = _roles[_roles.length - 1];
            }
            _roles.pop();
        }

        emit RemoveMember(member, role);
    }

    /**
    * @notice Search _role index in _roles array
    * @param _roles - array of roles hashes
    * @param _role - hash of role string
    */
    function _find(bytes32[] storage _roles, bytes32 _role) internal view returns (uint256) {
        for (uint256 i = 0; i < _roles.length; ++i) {
            if (_role == _roles[i]) {
                return i;
            }
        }
        return NOT_FOUND;
    }

}

File 2 of 3 : Initializable.sol
// SPDX-License-Identifier: MIT

// solhint-disable-next-line compiler-version
pragma solidity ^0.8.0;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {

    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}

File 3 of 3 : IAuthManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IAuthManager {
    function has(bytes32 role, address member) external view returns (bool);

    function add(bytes32 role, address member) external;

    function remove(bytes32 role, address member) external;
}

Settings
{
  "evmVersion": "istanbul",
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "libraries": {
    "AuthManager.sol": {}
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"member","type":"address"},{"indexed":false,"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"AddMember","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"member","type":"address"},{"indexed":false,"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"RemoveMember","type":"event"},{"inputs":[],"name":"SUPER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"member","type":"address"}],"name":"add","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"roleString","type":"string"},{"internalType":"address","name":"member","type":"address"}],"name":"addByString","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"_member","type":"address"}],"name":"has","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"superior","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"member","type":"address"}],"name":"remove","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_member","type":"address"}],"name":"roles","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50610ad7806100206000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c8063993746421161005b57806399374642146100bd578063aeab4c23146100e6578063c4d66de814610109578063eff11b2c1461011c57600080fd5b80632874528e14610082578063470284291461009757806361641bdc146100aa575b600080fd5b6100956100903660046108a7565b61013f565b005b6100956100a53660046108d3565b610355565b6100956100b83660046108a7565b61046d565b6100d06100cb366004610954565b610566565b6040516100dd9190610976565b60405180910390f35b6100fb600080516020610a8283398151915281565b6040519081526020016100dd565b610095610117366004610954565b6105d2565b61012f61012a3660046108a7565b610786565b60405190151581526020016100dd565b3360009081526001602052604090206000199061016a90600080516020610a828339815191526107b7565b14156101915760405162461bcd60e51b8152600401610188906109ba565b60405180910390fd5b336001600160a01b0382161415806101b75750600080516020610a828339815191528214155b6101ed5760405162461bcd60e51b81526020600482015260076024820152661253959053125160ca1b6044820152606401610188565b6001600160a01b03811660009081526001602052604081209061021082856107b7565b90506000198114156102575760405162461bcd60e51b815260206004820152601060248201526f13515350915497d393d517d193d5539160821b6044820152606401610188565b815460011415610287576001600160a01b03831660009081526001602052604081206102829161080a565b61030d565b8154610295906001906109f3565b8110156102e657815482906102ac906001906109f3565b815481106102bc576102bc610a0a565b90600052602060002001548282815481106102d9576102d9610a0a565b6000918252602090912001555b818054806102f6576102f6610a20565b600190038181906000526020600020016000905590555b604080516001600160a01b0385168152602081018690527f4e828dd00a0a7cb7b59473c940c050d8e84183a0471c02c3ade980fccc0c1446910160405180910390a150505050565b3360009081526001602052604090206000199061038090600080516020610a828339815191526107b7565b141561039e5760405162461bcd60e51b8152600401610188906109ba565b6001600160a01b03811660009081526001602052604080822090519091906103c99086908690610a36565b604051809103902090506000196103e083836107b7565b1461041e5760405162461bcd60e51b815260206004820152600e60248201526d20a62922a0a22cafa6a2a6a122a960911b6044820152606401610188565b81546001810183556000838152602090819020909101829055604080516001600160a01b0386168152918201839052600080516020610a62833981519152910160405180910390a15050505050565b3360009081526001602052604090206000199061049890600080516020610a828339815191526107b7565b14156104b65760405162461bcd60e51b8152600401610188906109ba565b6001600160a01b03811660009081526001602052604090206000196104db82856107b7565b146105195760405162461bcd60e51b815260206004820152600e60248201526d20a62922a0a22cafa6a2a6a122a960911b6044820152606401610188565b80546001810182556000828152602090819020909101849055604080516001600160a01b0385168152918201859052600080516020610a62833981519152910160405180910390a1505050565b6001600160a01b0381166000908152600160209081526040918290208054835181840281018401909452808452606093928301828280156105c657602002820191906000526020600020905b8154815260200190600101908083116105b2575b50505050509050919050565b600054610100900460ff16806105eb575060005460ff16155b61064e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610188565b600054610100900460ff16158015610670576000805461ffff19166101011790555b6001600160a01b0382166106f0576040805160208082018352600080516020610a828339815191528252336000908152600191829052929092206106b69290919061082b565b5060408051338152600080516020610a828339815191526020820152600080516020610a62833981519152910160405180910390a1610770565b6040805160208082018352600080516020610a8283398151915282526001600160a01b0385166000908152600191829052929092206107319290919061082b565b50604080516001600160a01b0384168152600080516020610a828339815191526020820152600080516020610a62833981519152910160405180910390a15b8015610782576000805461ff00191690555b5050565b6001600160a01b0381166000908152600160205260408120600019906107ac90856107b7565b141590505b92915050565b6000805b83548110156107ff578381815481106107d6576107d6610a0a565b90600052602060002001548314156107ef5790506107b1565b6107f881610a46565b90506107bb565b506000199392505050565b50805460008255906000526020600020908101906108289190610876565b50565b828054828255906000526020600020908101928215610866579160200282015b8281111561086657825182559160200191906001019061084b565b50610872929150610876565b5090565b5b808211156108725760008155600101610877565b80356001600160a01b03811681146108a257600080fd5b919050565b600080604083850312156108ba57600080fd5b823591506108ca6020840161088b565b90509250929050565b6000806000604084860312156108e857600080fd5b833567ffffffffffffffff8082111561090057600080fd5b818601915086601f83011261091457600080fd5b81358181111561092357600080fd5b87602082850101111561093557600080fd5b60209283019550935061094b918601905061088b565b90509250925092565b60006020828403121561096657600080fd5b61096f8261088b565b9392505050565b6020808252825182820181905260009190848201906040850190845b818110156109ae57835183529284019291840191600101610992565b50909695505050505050565b6020808252600990820152682327a92124a22222a760b91b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600082821015610a0557610a056109dd565b500390565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b8183823760009101908152919050565b6000600019821415610a5a57610a5a6109dd565b506001019056fe5a07c30e620eed977ed2fac9e80c246cc34d926fdc1e39b799e148685f00da707387a36ac025b2ab41ebea0cf5ffe0f06a3c79b46a1c1fd59ffadefcd6d2b791a2646970667358221220421d5a596c82ea8213383054cccd359d651339d4e60ae6111ea103564131e2e164736f6c63430008090033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.