mirror of
https://github.com/luxfi/uma.git
synced 2026-10-30 15:14:44 +00:00
42 lines
1.7 KiB
Solidity
42 lines
1.7 KiB
Solidity
// SPDX-License-Identifier: AGPL-3.0-only
|
|
pragma solidity ^0.8.0;
|
|
|
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
|
import "../interfaces/FinderInterface.sol";
|
|
|
|
/**
|
|
* @title Provides addresses of the live contracts implementing certain interfaces.
|
|
* @dev Examples of interfaces with implementations that Finder locates are the Oracle and Store interfaces.
|
|
*/
|
|
contract Finder is FinderInterface, Ownable {
|
|
mapping(bytes32 => address) public interfacesImplemented;
|
|
|
|
event InterfaceImplementationChanged(bytes32 indexed interfaceName, address indexed newImplementationAddress);
|
|
|
|
/**
|
|
* @notice Updates the address of the contract that implements `interfaceName`.
|
|
* @param interfaceName bytes32 of the interface name that is either changed or registered.
|
|
* @param implementationAddress address of the implementation contract.
|
|
*/
|
|
function changeImplementationAddress(bytes32 interfaceName, address implementationAddress)
|
|
external
|
|
override
|
|
onlyOwner
|
|
{
|
|
interfacesImplemented[interfaceName] = implementationAddress;
|
|
|
|
emit InterfaceImplementationChanged(interfaceName, implementationAddress);
|
|
}
|
|
|
|
/**
|
|
* @notice Gets the address of the contract that implements the given `interfaceName`.
|
|
* @param interfaceName queried interface.
|
|
* @return implementationAddress address of the defined interface.
|
|
*/
|
|
function getImplementationAddress(bytes32 interfaceName) external view override returns (address) {
|
|
address implementationAddress = interfacesImplemented[interfaceName];
|
|
require(implementationAddress != address(0x0), "Implementation not found");
|
|
return implementationAddress;
|
|
}
|
|
}
|