SendersWhitelist

Description:

Smart contract deployed on Ethereum with Factory features.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.19;

// src/core/interfaces/ISendersWhitelist.sol

interface ISendersWhitelist {
    function enableSender(address addr) external;
    function disableSender(address addr) external;
    function isWhitelisted(address addr) external view returns (bool);
}

// src/core/OwnableGuarded.sol

abstract contract OwnableGuarded {
    // ----------------------------------------------------------------------------------------------------
    // Constants
    // ----------------------------------------------------------------------------------------------------
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    // ----------------------------------------------------------------------------------------------------
    // Errors
    // ----------------------------------------------------------------------------------------------------
    error OwnerOnly();
    error OwnerAddressRequired();
    error ReentrancyGuardReentrantCall();

    // ----------------------------------------------------------------------------------------------------
    // Storage layout
    // ----------------------------------------------------------------------------------------------------
    uint256 private _status;
    address internal _owner;

    // ----------------------------------------------------------------------------------------------------
    // Events
    // ----------------------------------------------------------------------------------------------------
    /**
     * @notice Triggers when contract ownership changes.
     * @param previousOwner The previous owner of the contract.
     * @param newOwner The new owner of the contract.
     */
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    // ----------------------------------------------------------------------------------------------------
    // Modifiers
    // ----------------------------------------------------------------------------------------------------
    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        _status = ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        if (msg.sender != _owner) revert OwnerOnly();
        _;
    }

    // ----------------------------------------------------------------------------------------------------
    // Functions
    // ----------------------------------------------------------------------------------------------------
    /**
     * @notice Transfers ownership of the contract to the account specified.
     * @param newOwner The address of the new owner.
     */
    function transferOwnership(address newOwner) external virtual nonReentrant onlyOwner {
        _transferOwnership(newOwner);
    }

    function _transferOwnership(address newOwner) internal virtual {
        if (newOwner == address(0)) revert OwnerAddressRequired();

        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }

    /**
     * @notice Gets the owner of the contract.
     * @return address The address who owns the contract.
     */
    function owner() external view virtual returns (address) {
        return _owner;
    }
}

// src/core/SendersWhitelist.sol

/**
 * @title This contract manages a whitelist of message senders.
 */
contract SendersWhitelist is ISendersWhitelist, OwnableGuarded {
    error AlreadyApproved();

    mapping (address => bool) internal _addresses;

    constructor(address ownerAddr) {
        _owner = ownerAddr;
    }

    /**
     * @notice Enables the address specified.
     * @param addr The address to enable.
     */
    function enableSender(address addr) external override onlyOwner {
        if (_addresses[addr]) revert AlreadyApproved();
        _addresses[addr] = true;
    }

    /**
     * @notice Disables the address specified.
     * @param addr The address to disable.
     */
    function disableSender(address addr) external override onlyOwner {
        _addresses[addr] = false;
    }

    /**
     * @notice Indicates if the address specified is whitelisted.
     * @param addr The address to evaluate.
     * @return bool Returns true if the address is whitelisted.
     */
    function isWhitelisted(address addr) external view override returns (bool) {
        return _addresses[addr];
    }
}

Tags:
Factory|addr:0x53e5ea0b098aeaf3898b920c9a85e0307ec63259|verified:true|block:23447822|tx:0x2571b1ce7d7653fac068afcb9f447e8049238da19e44488de90b20d755a65860|first_check:1758897938

Submitted on: 2025-09-26 16:45:41

Comments

Log in to comment.

No comments yet.