123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- // SPDX-License-Identifier: MIT
- // OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)
- pragma solidity ^0.8.0;
- import "./TransparentUpgradeableProxy.sol";
- import "../../access/Ownable.sol";
- /**
- * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
- * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
- */
- contract ProxyAdmin is Ownable {
- /**
- * @dev Changes the admin of `proxy` to `newAdmin`.
- *
- * Requirements:
- *
- * - This contract must be the current admin of `proxy`.
- */
- function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {
- proxy.changeAdmin(newAdmin);
- }
- /**
- * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.
- *
- * Requirements:
- *
- * - This contract must be the admin of `proxy`.
- */
- function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {
- proxy.upgradeTo(implementation);
- }
- /**
- * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See
- * {TransparentUpgradeableProxy-upgradeToAndCall}.
- *
- * Requirements:
- *
- * - This contract must be the admin of `proxy`.
- */
- function upgradeAndCall(
- TransparentUpgradeableProxy proxy,
- address implementation,
- bytes memory data
- ) public payable virtual onlyOwner {
- proxy.upgradeToAndCall{value: msg.value}(implementation, data);
- }
- }
|