Contract 0x75d3fce9fca94afa2b130e5900bd0fee103b3a3d

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x7ae393f7a8f4c0f086a52195222c19fffbe426c162b1def367e432f316ecd4ec0x608060409066052022-04-27 6:39:48402 days 1 hr agoLido Staked Polkadot: Deployer IN  Create: AuthManager0 GLMR0.0639999
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
AuthManager

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 10 runs

Other Settings:
default evmVersion, MIT license
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": 10
  },
  "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"}]

608060405234801561001057600080fd5b50610a9f806100206000396000f3fe608060405234801561001057600080fd5b506004361061006d5760003560e01c80632874528e14610072578063470284291461008757806361641bdc1461009a57806399374642146100ad578063aeab4c23146100d6578063c4d66de8146100f9578063eff11b2c1461010c575b600080fd5b61008561008036600461082f565b61012f565b005b61008561009536600461085b565b61033c565b6100856100a836600461082f565b610428565b6100c06100bb3660046108db565b6104f5565b6040516100cd91906108fd565b60405180910390f35b6100eb600080516020610a4a83398151915281565b6040519081526020016100cd565b6100856101073660046108db565b610561565b61011f61011a36600461082f565b61070e565b60405190151581526020016100cd565b3360009081526001602052604090206000199061015a90600080516020610a4a83398151915261073f565b14156101815760405162461bcd60e51b815260040161017890610941565b60405180910390fd5b336001600160a01b0382161415806101a75750600080516020610a4a8339815191528214155b6101dd5760405162461bcd60e51b81526020600482015260076024820152661253959053125160ca1b6044820152606401610178565b6001600160a01b038116600090815260016020526040812090610200828561073f565b90506000198114156102475760405162461bcd60e51b815260206004820152601060248201526f13515350915497d393d517d193d5539160821b6044820152606401610178565b815460011415610277576001600160a01b038316600090815260016020526040812061027291610792565b6102fd565b81546102859060019061097a565b8110156102d6578154829061029c9060019061097a565b815481106102ac576102ac610991565b90600052602060002001548282815481106102c9576102c9610991565b6000918252602090912001555b818054806102e6576102e66109a7565b600190038181906000526020600020016000905590555b7f4e828dd00a0a7cb7b59473c940c050d8e84183a0471c02c3ade980fccc0c1446838560405161032e9291906109bd565b60405180910390a150505050565b3360009081526001602052604090206000199061036790600080516020610a4a83398151915261073f565b14156103855760405162461bcd60e51b815260040161017890610941565b6001600160a01b03811660009081526001602052604080822090519091906103b090869086906109d6565b604051809103902090506000196103c7838361073f565b146103e45760405162461bcd60e51b8152600401610178906109e6565b815460018101835560008381526020902001819055604051600080516020610a2a8339815191529061041990859084906109bd565b60405180910390a15050505050565b3360009081526001602052604090206000199061045390600080516020610a4a83398151915261073f565b14156104715760405162461bcd60e51b815260040161017890610941565b6001600160a01b0381166000908152600160205260409020600019610496828561073f565b146104b35760405162461bcd60e51b8152600401610178906109e6565b805460018101825560008281526020902001839055604051600080516020610a2a833981519152906104e890849086906109bd565b60405180910390a1505050565b6001600160a01b03811660009081526001602090815260409182902080548351818402810184019094528084526060939283018282801561055557602002820191906000526020600020905b815481526020019060010190808311610541575b50505050509050919050565b600054610100900460ff168061057a575060005460ff16155b6105dd5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610178565b600054610100900460ff161580156105ff576000805461ffff19166101011790555b6001600160a01b038216610680576040805160208082018352600080516020610a4a833981519152825233600090815260019182905292909220610645929091906107b3565b50600080516020610a2a83398151915233600080516020610a4a8339815191526040516106739291906109bd565b60405180910390a16106f8565b6040805160208082018352600080516020610a4a83398151915282526001600160a01b0385166000908152600191829052929092206106c1929091906107b3565b50600080516020610a2a83398151915282600080516020610a4a8339815191526040516106ef9291906109bd565b60405180910390a15b801561070a576000805461ff00191690555b5050565b6001600160a01b038116600090815260016020526040812060001990610734908561073f565b141590505b92915050565b6000805b83548110156107875783818154811061075e5761075e610991565b9060005260206000200154831415610777579050610739565b61078081610a0e565b9050610743565b506000199392505050565b50805460008255906000526020600020908101906107b091906107fe565b50565b8280548282559060005260206000209081019282156107ee579160200282015b828111156107ee5782518255916020019190600101906107d3565b506107fa9291506107fe565b5090565b5b808211156107fa57600081556001016107ff565b80356001600160a01b038116811461082a57600080fd5b919050565b6000806040838503121561084257600080fd5b8235915061085260208401610813565b90509250929050565b60008060006040848603121561087057600080fd5b83356001600160401b038082111561088757600080fd5b818601915086601f83011261089b57600080fd5b8135818111156108aa57600080fd5b8760208285010111156108bc57600080fd5b6020928301955093506108d29186019050610813565b90509250925092565b6000602082840312156108ed57600080fd5b6108f682610813565b9392505050565b6020808252825182820181905260009190848201906040850190845b8181101561093557835183529284019291840191600101610919565b50909695505050505050565b6020808252600990820152682327a92124a22222a760b91b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60008282101561098c5761098c610964565b500390565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b6001600160a01b03929092168252602082015260400190565b8183823760009101908152919050565b6020808252600e908201526d20a62922a0a22cafa6a2a6a122a960911b604082015260600190565b6000600019821415610a2257610a22610964565b506001019056fe5a07c30e620eed977ed2fac9e80c246cc34d926fdc1e39b799e148685f00da707387a36ac025b2ab41ebea0cf5ffe0f06a3c79b46a1c1fd59ffadefcd6d2b791a2646970667358221220b9b4852e6edb5918ec9ff0f167f58fa680b140462a0e8c41f7c57794639a7f2f64736f6c634300080a0033

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