You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.5 KiB
45 lines
1.5 KiB
// SPDX-License-Identifier: MIT
|
|
// OpenZeppelin Contracts (last updated v4.8.3) (proxy/transparent/ProxyAdmin.sol)
|
|
|
|
pragma solidity ^0.8.19;
|
|
|
|
import {ITransparentUpgradeableProxy} from "./TransparentUpgradeableProxy.sol";
|
|
import {Ownable} from "../../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 Sets the initial owner who can perform upgrades.
|
|
*/
|
|
constructor(address initialOwner) Ownable(initialOwner) {}
|
|
|
|
/**
|
|
* @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.
|
|
*
|
|
* Requirements:
|
|
*
|
|
* - This contract must be the admin of `proxy`.
|
|
*/
|
|
function upgrade(ITransparentUpgradeableProxy 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(
|
|
ITransparentUpgradeableProxy proxy,
|
|
address implementation,
|
|
bytes memory data
|
|
) public payable virtual onlyOwner {
|
|
proxy.upgradeToAndCall{value: msg.value}(implementation, data);
|
|
}
|
|
}
|
|
|