ConfigRegistryAccessor_VAO_1

Description:

Smart contract deployed on Ethereum with Factory features.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "src/accessors/ConfigRegistryAccessor.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

import {Auth} from "chronicle-std/auth/Auth.sol";
import {Toll} from "chronicle-std/toll/Toll.sol";

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

/**
 * @title ConfigRegistryAccessor
 *
 * @author Chronicle Labs, Inc.
 * @custom:security-contact security@chroniclelabs.org
 */
contract ConfigRegistryAccessor is Auth, Toll {
    /// @notice Emitted when config for feeds `feedsBloom` updated.
    /// @param caller The caller's address.
    /// @param feedsBloom The feeds encoded via bloom mechanism which's config
    ///                   got updated.
    event ConfigUpdated(address indexed caller, uint indexed feedsBloom);

    /// @notice Emitted when config for feeds `feedsBloom` removed.
    /// @param caller The caller's address.
    /// @param feedsBloom The feeds encoded via bloom mechanism which's config
    ///                   got removed.
    event ConfigRemoved(address indexed caller, uint indexed feedsBloom);

    /// @notice The accessor's config registry.
    address public immutable configRegistry;

    constructor(address initialAuthed, address configRegistry_)
        Auth(initialAuthed)
    {
        configRegistry = configRegistry_;
    }

    /// @notice Updates the config's url and config's content hash for feeds
    ///         encoded in bloom filter `feedsBloom` on accessor's config
    ///         registry.
    ///
    /// @dev Only callable by toll'ed addresses.
    ///
    /// @dev Reverts if:
    ///      - Maximum number of config updates performed
    ///
    /// @param feedsBloom The bloom filter encoding the feeds to update their
    ///                   config's url and content hash.
    /// @param url The url of the new config.
    /// @param contentHash The keccak256 hash of the config's content.
    function setConfig(
        uint feedsBloom,
        string calldata url,
        bytes32 contentHash
    ) external toll {
        IConfigRegistry(configRegistry).setConfig(feedsBloom, url, contentHash);
        emit ConfigUpdated(msg.sender, feedsBloom);
    }

    /// @notice Removes the config for feeds encoded in bloom filter
    ///         `feedsBloom` on accessor's config registry.
    ///
    /// @dev Only callable by toll'ed addresses.
    ///
    /// @param feedsBloom The bloom filter encoding the feeds to remove their
    ///                   config.
    function unsetConfig(uint feedsBloom) external toll {
        IConfigRegistry(configRegistry).unsetConfig(feedsBloom);
        emit ConfigRemoved(msg.sender, feedsBloom);
    }

    /// @dev Defines authorization for IToll's authenticated functions.
    function toll_auth() internal override(Toll) auth {}
}

/**
 * @dev Contract overwrite to deploy contract instances with specific naming.
 *
 *      For more info, see docs/Deployment.md.
 */
contract ConfigRegistryAccessor_VAO_1 is ConfigRegistryAccessor {
    constructor(address initialAuthed, address configRegistry)
        ConfigRegistryAccessor(initialAuthed, configRegistry)
    {}
}
"
    },
    "lib/chronicle-std/src/auth/Auth.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

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

/**
 * @title Auth Module
 *
 * @dev The `Auth` contract module provides a basic access control mechanism,
 *      where a set of addresses are granted access to protected functions.
 *      These addresses are said to be _auth'ed_.
 *
 *      Initially, the address given as constructor argument is the only address
 *      auth'ed. Through the `rely(address)` and `deny(address)` functions,
 *      auth'ed callers are able to grant/renounce auth to/from addresses.
 *
 *      This module is used through inheritance. It will make available the
 *      modifier `auth`, which can be applied to functions to restrict their
 *      use to only auth'ed callers.
 */
abstract contract Auth is IAuth {
    /// @dev Mapping storing whether address is auth'ed.
    /// @custom:invariant Image of mapping is {0, 1}.
    ///                     ∀x ∊ Address: _wards[x] ∊ {0, 1}
    /// @custom:invariant Only address given as constructor argument is authenticated after deployment.
    ///                     deploy(initialAuthed) → (∀x ∊ Address: _wards[x] == 1 → x == initialAuthed)
    /// @custom:invariant Only functions `rely` and `deny` may mutate the mapping's state.
    ///                     ∀x ∊ Address: preTx(_wards[x]) != postTx(_wards[x])
    ///                                     → (msg.sig == "rely" ∨ msg.sig == "deny")
    /// @custom:invariant Mapping's state may only be mutated by authenticated caller.
    ///                     ∀x ∊ Address: preTx(_wards[x]) != postTx(_wards[x]) → _wards[msg.sender] = 1
    mapping(address => uint) private _wards;

    /// @dev List of addresses possibly being auth'ed.
    /// @dev May contain duplicates.
    /// @dev May contain addresses not being auth'ed anymore.
    /// @custom:invariant Every address being auth'ed once is element of the list.
    ///                     ∀x ∊ Address: authed(x) -> x ∊ _wardsTouched
    address[] private _wardsTouched;

    /// @dev Ensures caller is auth'ed.
    modifier auth() {
        assembly ("memory-safe") {
            // Compute slot of _wards[msg.sender].
            mstore(0x00, caller())
            mstore(0x20, _wards.slot)
            let slot := keccak256(0x00, 0x40)

            // Revert if caller not auth'ed.
            let isAuthed := sload(slot)
            if iszero(isAuthed) {
                // Store selector of `NotAuthorized(address)`.
                mstore(0x00, 0x4a0bfec1)
                // Store msg.sender.
                mstore(0x20, caller())
                // Revert with (offset, size).
                revert(0x1c, 0x24)
            }
        }
        _;
    }

    constructor(address initialAuthed) {
        _wards[initialAuthed] = 1;
        _wardsTouched.push(initialAuthed);

        // Note to use address(0) as caller to indicate address was auth'ed
        // during deployment.
        emit AuthGranted(address(0), initialAuthed);
    }

    /// @inheritdoc IAuth
    function rely(address who) external auth {
        if (_wards[who] == 1) return;

        _wards[who] = 1;
        _wardsTouched.push(who);
        emit AuthGranted(msg.sender, who);
    }

    /// @inheritdoc IAuth
    function deny(address who) external auth {
        if (_wards[who] == 0) return;

        _wards[who] = 0;
        emit AuthRenounced(msg.sender, who);
    }

    /// @inheritdoc IAuth
    function authed(address who) public view returns (bool) {
        return _wards[who] == 1;
    }

    /// @inheritdoc IAuth
    /// @custom:invariant Only contains auth'ed addresses.
    ///                     ∀x ∊ authed(): _wards[x] == 1
    /// @custom:invariant Contains all auth'ed addresses.
    ///                     ∀x ∊ Address: _wards[x] == 1 → x ∊ authed()
    function authed() public view returns (address[] memory) {
        // Initiate array with upper limit length.
        address[] memory wardsList = new address[](_wardsTouched.length);

        // Iterate through all possible auth'ed addresses.
        uint ctr;
        for (uint i; i < wardsList.length; i++) {
            // Add address only if still auth'ed.
            if (_wards[_wardsTouched[i]] == 1) {
                wardsList[ctr++] = _wardsTouched[i];
            }
        }

        // Set length of array to number of auth'ed addresses actually included.
        assembly ("memory-safe") {
            mstore(wardsList, ctr)
        }

        return wardsList;
    }

    /// @inheritdoc IAuth
    function wards(address who) public view returns (uint) {
        return _wards[who];
    }
}
"
    },
    "lib/chronicle-std/src/toll/Toll.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

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

/**
 * @title Toll Module
 *
 * @notice "Toll paid, we kiss - but dissension looms, maybe diss?"
 *
 * @dev The `Toll` contract module provides a basic access control mechanism,
 *      where a set of addresses are granted access to protected functions.
 *      These addresses are said the be _tolled_.
 *
 *      Initially, no address is tolled. Through the `kiss(address)` and
 *      `diss(address)` functions, auth'ed callers are able to toll/de-toll
 *      addresses. Authentication for these functions is defined via the
 *      downstream implemented `toll_auth()` function.
 *
 *      This module is used through inheritance. It will make available the
 *      modifier `toll`, which can be applied to functions to restrict their
 *      use to only tolled callers.
 */
abstract contract Toll is IToll {
    /// @dev Mapping storing whether address is tolled.
    /// @custom:invariant Image of mapping is {0, 1}.
    ///                     ∀x ∊ Address: _buds[x] ∊ {0, 1}
    /// @custom:invariant Only functions `kiss` and `diss` may mutate the mapping's state.
    ///                     ∀x ∊ Address: preTx(_buds[x]) != postTx(_buds[x])
    ///                                     → (msg.sig == "kiss" ∨ msg.sig == "diss")
    /// @custom:invariant Mapping's state may only be mutated by authenticated caller.
    ///                     ∀x ∊ Address: preTx(_buds[x]) != postTx(_buds[x])
    ///                                     → toll_auth()
    mapping(address => uint) private _buds;

    /// @dev List of addresses possibly being tolled.
    /// @dev May contain duplicates.
    /// @dev May contain addresses not being tolled anymore.
    /// @custom:invariant Every address being tolled once is element of the list.
    ///                     ∀x ∊ Address: tolled(x) → x ∊ _budsTouched
    address[] private _budsTouched;

    /// @dev Ensures caller is tolled.
    modifier toll() {
        assembly ("memory-safe") {
            // Compute slot of _buds[msg.sender].
            mstore(0x00, caller())
            mstore(0x20, _buds.slot)
            let slot := keccak256(0x00, 0x40)

            // Revert if caller not tolled.
            let isTolled := sload(slot)
            if iszero(isTolled) {
                // Store selector of `NotTolled(address)`.
                mstore(0x00, 0xd957b595)
                // Store msg.sender.
                mstore(0x20, caller())
                // Revert with (offset, size).
                revert(0x1c, 0x24)
            }
        }
        _;
    }

    /// @dev Reverts if caller not allowed to access protected function.
    /// @dev Must be implemented in downstream contract.
    function toll_auth() internal virtual;

    /// @inheritdoc IToll
    function kiss(address who) external {
        toll_auth();

        if (_buds[who] == 1) return;

        _buds[who] = 1;
        _budsTouched.push(who);
        emit TollGranted(msg.sender, who);
    }

    /// @inheritdoc IToll
    function diss(address who) external {
        toll_auth();

        if (_buds[who] == 0) return;

        _buds[who] = 0;
        emit TollRenounced(msg.sender, who);
    }

    /// @inheritdoc IToll
    function tolled(address who) public view returns (bool) {
        return _buds[who] == 1;
    }

    /// @inheritdoc IToll
    /// @custom:invariant Only contains tolled addresses.
    ///                     ∀x ∊ tolled(): _tolled[x]
    /// @custom:invariant Contains all tolled addresses.
    ///                     ∀x ∊ Address: _tolled[x] == 1 → x ∊ tolled()
    function tolled() public view returns (address[] memory) {
        // Initiate array with upper limit length.
        address[] memory budsList = new address[](_budsTouched.length);

        // Iterate through all possible tolled addresses.
        uint ctr;
        for (uint i; i < budsList.length; i++) {
            // Add address only if still tolled.
            if (_buds[_budsTouched[i]] == 1) {
                budsList[ctr++] = _budsTouched[i];
            }
        }

        // Set length of array to number of tolled addresses actually included.
        assembly ("memory-safe") {
            mstore(budsList, ctr)
        }

        return budsList;
    }

    /// @inheritdoc IToll
    function bud(address who) public view returns (uint) {
        return _buds[who];
    }
}
"
    },
    "src/IConfigRegistry.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

interface IConfigRegistry {
    /// @notice Thrown if no config exists for feed with id `feedId`.
    error ConfigDoesNotExist(uint8 feedId);

    /// @notice Emitted when config for feeds `feedsBloom` updated.
    /// @param caller The caller's address.
    /// @param feedsBloom The feeds encoded via bloom mechanism which's config
    ///                   got updated.
    event ConfigUpdated(address indexed caller, uint indexed feedsBloom);

    /// @notice Emitted when config for feeds `feedsBloom` removed.
    /// @param caller The caller's address.
    /// @param feedsBloom The feeds encoded via bloom mechanism which's config
    ///                   got removed.
    event ConfigRemoved(address indexed caller, uint indexed feedsBloom);

    // -- Public Read Functions --

    /// @notice Returns the url and metadata of feed `feed`'s config.
    ///
    /// @dev Reverts if:
    ///      - Config does not exist for feed `feed`
    ///
    /// @param feed The feed address.
    /// @return url The url of the feed's config.
    /// @return contentHash The keccak256 hash of the feed config's content.
    /// @return age The age of the config.
    function configs(address feed)
        external
        view
        returns (string memory url, bytes32 contentHash, uint age);

    // -- Auth'ed Functions --

    /// @notice Updates the config's url and config's content hash for feeds
    ///         encoded in bloom filter `feedsBloom`.
    ///
    /// @dev Only callable by auth'ed addresses.
    ///
    /// @dev Reverts if:
    ///      - Maximum number of config updates performed
    ///
    /// @param feedsBloom The bloom filter encoding the feeds to update their
    ///                   config's url and content hash.
    /// @param url The url of the new config.
    /// @param contentHash The keccak256 hash of the config's content.
    function setConfig(
        uint feedsBloom,
        string calldata url,
        bytes32 contentHash
    ) external;

    /// @notice Removes the config for feeds encoded in bloom filter
    ///         `feedsBloom`.
    ///
    /// @dev Only callable by auth'ed addresses.
    ///
    /// @param feedsBloom The bloom filter encoding the feeds to remove their
    ///                   config.
    function unsetConfig(uint feedsBloom) external;
}
"
    },
    "lib/chronicle-std/src/auth/IAuth.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

interface IAuth {
    /// @notice Thrown by protected function if caller not auth'ed.
    /// @param caller The caller's address.
    error NotAuthorized(address caller);

    /// @notice Emitted when auth granted to address.
    /// @param caller The caller's address.
    /// @param who The address auth got granted to.
    event AuthGranted(address indexed caller, address indexed who);

    /// @notice Emitted when auth renounced from address.
    /// @param caller The caller's address.
    /// @param who The address auth got renounced from.
    event AuthRenounced(address indexed caller, address indexed who);

    /// @notice Grants address `who` auth.
    /// @dev Only callable by auth'ed address.
    /// @param who The address to grant auth.
    function rely(address who) external;

    /// @notice Renounces address `who`'s auth.
    /// @dev Only callable by auth'ed address.
    /// @param who The address to renounce auth.
    function deny(address who) external;

    /// @notice Returns whether address `who` is auth'ed.
    /// @param who The address to check.
    /// @return True if `who` is auth'ed, false otherwise.
    function authed(address who) external view returns (bool);

    /// @notice Returns full list of addresses granted auth.
    /// @dev May contain duplicates.
    /// @return List of addresses granted auth.
    function authed() external view returns (address[] memory);

    /// @notice Returns whether address `who` is auth'ed.
    /// @custom:deprecated Use `authed(address)(bool)` instead.
    /// @param who The address to check.
    /// @return 1 if `who` is auth'ed, 0 otherwise.
    function wards(address who) external view returns (uint);
}
"
    },
    "lib/chronicle-std/src/toll/IToll.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

interface IToll {
    /// @notice Thrown by protected function if caller not tolled.
    /// @param caller The caller's address.
    error NotTolled(address caller);

    /// @notice Emitted when toll granted to address.
    /// @param caller The caller's address.
    /// @param who The address toll got granted to.
    event TollGranted(address indexed caller, address indexed who);

    /// @notice Emitted when toll renounced from address.
    /// @param caller The caller's address.
    /// @param who The address toll got renounced from.
    event TollRenounced(address indexed caller, address indexed who);

    /// @notice Grants address `who` toll.
    /// @dev Only callable by auth'ed address.
    /// @param who The address to grant toll.
    function kiss(address who) external;

    /// @notice Renounces address `who`'s toll.
    /// @dev Only callable by auth'ed address.
    /// @param who The address to renounce toll.
    function diss(address who) external;

    /// @notice Returns whether address `who` is tolled.
    /// @param who The address to check.
    /// @return True if `who` is tolled, false otherwise.
    function tolled(address who) external view returns (bool);

    /// @notice Returns full list of addresses tolled.
    /// @dev May contain duplicates.
    /// @return List of addresses tolled.
    function tolled() external view returns (address[] memory);

    /// @notice Returns whether address `who` is tolled.
    /// @custom:deprecated Use `tolled(address)(bool)` instead.
    /// @param who The address to check.
    /// @return 1 if `who` is tolled, 0 otherwise.
    function bud(address who) external view returns (uint);
}
"
    }
  },
  "settings": {
    "remappings": [
      "ds-test/=lib/forge-std/lib/ds-test/src/",
      "forge-std/=lib/forge-std/src/",
      "chronicle-std/=lib/chronicle-std/src/",
      "@script/chronicle-std/=lib/chronicle-std/script/"
    ],
    "optimizer": {
      "enabled": true,
      "runs": 10000
    },
    "metadata": {
      "useLiteralContent": false,
      "bytecodeHash": "ipfs"
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "evmVersion": "london",
    "viaIR": true
  }
}}

Tags:
Factory|addr:0x87761a445c732db158093065c5f5b6d161f3a511|verified:true|block:23396820|tx:0xede8b71609bae1c51eac5ab43c760cd57f1e548a91c50f045cbb52410b8a02bc|first_check:1758284842

Submitted on: 2025-09-19 14:27:24

Comments

Log in to comment.

No comments yet.