github.com/klaytn/klaytn@v1.12.1/contracts/system_contracts/registry/IRegistry.sol (about) 1 // Copyright 2023 The klaytn Authors 2 // This file is part of the klaytn library. 3 // 4 // The klaytn library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The klaytn library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the klaytn library. If not, see <http://www.gnu.org/licenses/>. 16 17 // SPDX-License-Identifier: LGPL-3.0-only 18 pragma solidity ^0.8.0; 19 20 abstract contract IRegistry { 21 /* ========== VARIABLES ========== */ 22 /// The following variables are baked here because their storage layouts matter in protocol consensus 23 /// when inject initial states (pre-deployed system contracts, owner) of the Registry. 24 /// @dev Mapping of system contracts 25 mapping(string => Record[]) public records; 26 27 /// @dev Array of system contract names 28 string[] public names; 29 30 /// @dev Owner of contract 31 address internal _owner; 32 33 /* ========== TYPES ========== */ 34 /// @dev Struct of system contracts 35 struct Record { 36 address addr; 37 uint256 activation; 38 } 39 40 /* ========== EVENTS ========== */ 41 /// @dev Emitted when the contract owner is updated by `transferOwnership`. 42 event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 43 44 /// @dev Emitted when a new system contract is registered. 45 event Registered(string name, address indexed addr, uint256 indexed activation); 46 47 /* ========== MUTATORS ========== */ 48 /// @dev Registers a new system contract. 49 function register(string memory name, address addr, uint256 activation) external virtual; 50 51 /// @dev Transfers ownership to newOwner. 52 function transferOwnership(address newOwner) external virtual; 53 54 /* ========== GETTERS ========== */ 55 /// @dev Returns an address for active system contracts registered as name if exists. 56 /// It returns a zero address if there's no active system contract with name. 57 function getActiveAddr(string memory name) external virtual returns (address); 58 59 /// @dev Returns all system contracts registered as name. 60 function getAllRecords(string memory name) external view virtual returns (Record[] memory); 61 62 /// @dev Returns all names of registered system contracts. 63 function getAllNames() external view virtual returns (string[] memory); 64 65 /// @dev Returns owner of contract. 66 function owner() external view virtual returns (address); 67 }