Перейти к содержимому
Проверенный контрактТочноеGPL-3.0-or-later

SenderRegistry

Адрес0x469c8a13018c02606e02ec2fb1aed602bab71db1
Баланс

0 ETH

 

Транзакций

15

 

Компилятор

solc 0.8.28

 

Тот же код

ещё 2 контракта

 

Подробности

Компилятор
solc 0.8.28+commit.7893614a
Язык
solidity
Оптимизация
Нет
Версия EVM
paris
Лицензия
GPL-3.0-or-later
Совпадение
Точноекод создания: да, код в сети: да
Проверен на Sourcify
Создан в блоке
26 479 818
Транзакция создания
0x81a2cb2d30…7ea5d19b89

src/SenderRegistry.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.27;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol";
import {ISenderRegistry} from "./interfaces/ISenderRegistry.sol";

/// @title SenderRegistry
/// @notice A registry for managing an allowlist of sender addresses
/// @dev Uses OpenZeppelin's Ownable2Step for two-step ownership transfers
contract SenderRegistry is Ownable2Step, ISenderRegistry {
    mapping(address => bool) private _allowedSenders;

    /// @notice Emitted when a sender is added to the allowlist
    /// @param sender The address that was added
    event AllowedSenderSet(address indexed sender);

    /// @notice Emitted when a sender is removed from the allowlist
    /// @param sender The address that was removed
    event AllowedSenderUnset(address indexed sender);

    /// @notice Creates a new SenderRegistry with the specified owner
    /// @param owner The address that will own this registry
    constructor(address owner) Ownable(owner) {}

    /// @notice Checks if an address is on the allowlist
    /// @param sender The address to check
    /// @return True if the address is allowed, false otherwise
    function isAllowedSender(address sender) external view returns (bool) {
        return _allowedSenders[sender];
    }

    /// @notice Adds addresses to the allowlist
    /// @dev Only callable by the owner. Skips addresses already on the allowlist.
    ///      `address(0)` is allowed: it is the `tx.origin` of an `eth_call` without `from`. Only allow it on chains
    ///      where real calls can't have that origin; Polygon PoS state sync, for example, can.
    ///      Recommended batch size: 100-200 addresses per call to avoid gas limits.
    /// @param newAllowedSenders The addresses to add
    function setAllowedSenders(address[] memory newAllowedSenders) public onlyOwner {
        for (uint256 i = 0; i < newAllowedSenders.length; i++) {
            if (!_allowedSenders[newAllowedSenders[i]]) {
                _allowedSenders[newAllowedSenders[i]] = true;
                emit AllowedSenderSet(newAllowedSenders[i]);
            }
        }
    }

    /// @notice Removes addresses from the allowlist
    /// @dev Only callable by the owner. Skips addresses not on the allowlist.
    ///      Recommended batch size: 100-200 addresses per call to avoid gas limits.
    /// @param removeAllowedSenders The addresses to remove
    function unsetAllowedSenders(address[] memory removeAllowedSenders) public onlyOwner {
        for (uint256 i = 0; i < removeAllowedSenders.length; i++) {
            if (_allowedSenders[removeAllowedSenders[i]]) {
                _allowedSenders[removeAllowedSenders[i]] = false;
                emit AllowedSenderUnset(removeAllowedSenders[i]);
            }
        }
    }
}

lib/openzeppelin-contracts/contracts/access/Ownable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

import {Ownable} from "./Ownable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * This extension of the {Ownable} contract includes a two-step mechanism to transfer
 * ownership, where the new owner must call {acceptOwnership} in order to replace the
 * old one. This can help prevent common mistakes, such as transfers of ownership to
 * incorrect accounts, or to contracts that are unable to interact with the
 * permission system.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Returns the address of the pending owner.
     */
    function pendingOwner() public view virtual returns (address) {
        return _pendingOwner;
    }

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     *
     * Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}

lib/openzeppelin-contracts/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

src/interfaces/ISenderRegistry.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.27;

/// @title ISenderRegistry
/// @notice Interface for the SenderRegistry allowlist contract
interface ISenderRegistry {
    /// @notice Checks if an address is on the allowlist
    /// @param sender The address to check
    /// @return True if the address is allowed, false otherwise
    function isAllowedSender(address sender) external view returns (bool);

    /// @notice Adds addresses to the allowlist
    /// @dev Recommended batch size: 100-200 addresses per call to avoid gas limits.
    /// @param newAllowedSenders The addresses to add
    function setAllowedSenders(address[] memory newAllowedSenders) external;

    /// @notice Removes addresses from the allowlist
    /// @dev Recommended batch size: 100-200 addresses per call to avoid gas limits.
    /// @param removeAllowedSenders The addresses to remove
    function unsetAllowedSenders(address[] memory removeAllowedSenders) external;
}
Настройки компилятораПоказать
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "evmVersion": "paris",
  "remappings": [
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
  ]
}

Исходный код и метаданные: Sourcify.

Исходный код принадлежит авторам контракта.