5 阅读USD0合约代码时,找不到写入 Usd0StorageV0 的地方?

本人初学者,在看 USD0 合约的代码:
https://etherscan.io/token/0x73a15fed60bf67631dc6cd7bc5b6e8da8190acf5#readProxyContract

这个代码中 定义了 Usd0StorageV0 的结构如下:

    struct Usd0StorageV0 {
        IRegistryAccess registryAccess;
        mapping(address => bool) isBlacklisted;
        IRegistryContract registryContract;
        ITokenMapping tokenMapping;
    }

代码有有多处 通过 以下函数读取存储的 Usd0StorageV0

    function _usd0StorageV0() internal pure returns (Usd0StorageV0 storage $) {
       bytes32 position = Usd0StorageV0Location;
       // solhint-disable-next-line no-inline-assembly
       assembly {
           $.slot := position
       }
   }

但是找不到这个存储写入的地方,我想找到这个 struct 中关于 registryAccess registryContract的实现

求解答~

请先 登录 后评论

1 个回答

0xBA

搜索registry可以发现


pragma solidity 0.8.20;

import {IRegistryAccess} from "src/interfaces/registry/IRegistryAccess.sol";

import {NotAuthorized} from "src/errors.sol";

/// @title Check Access control library
library CheckAccessControl {
    /// @dev Function to restrict to one access role.
    /// @param registryAccess The registry access contract.
    /// @param role The role being checked.
    function onlyMatchingRole(IRegistryAccess registryAccess, bytes32 role) internal view {
        if (!registryAccess.hasRole(role, msg.sender)) {
            revert NotAuthorized();
        }
    }
}

接着

// SPDX-License-Identifier: Apache-2.0

pragma solidity 0.8.20;

import {IAccessControlDefaultAdminRules} from
    "openzeppelin-contracts/access/extensions/IAccessControlDefaultAdminRules.sol";

// solhint-disable-next-line no-empty-blocks
interface IRegistryAccess is IAccessControlDefaultAdminRules {}

通过2个导入语句,可以确认是通过OpenZeppelin标准库实现的

请先 登录 后评论
  • 1 关注
  • 0 收藏,2281 浏览
  • 除刑 提出于 2024-12-23 11:17