AdminUpgradeabilityProxy
contract AdminUpgradeabilityProxy
This contract combines an upgradeability proxy with an authorization mechanism for administrative tasks. All external functions in this contract must be guarded by the `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity feature proposal that would enable this to be done automatically.
Index
Reference
Events
AdminChanged
event AdminChanged(address previousAdmin, address newAdmin)
Emitted when the administration has been transferred.
- Parameters:
previousAdmin
- Address of the previous admin.newAdmin
- Address of the new admin.
Modifiers
ifAdmin
modifier ifAdmin()
Modifier to check whether the `msg.sender` is the admin. If it is, it will run the function. Otherwise, it will delegate the call to the implementation.
Functions
AdminUpgradeabilityProxy
function AdminUpgradeabilityProxy(address _implementation) public
Contract constructor. It sets the `msg.sender` as the proxy administrator.
- Modifiers:
- Parameters:
_implementation
- address of the initial implementation.
_admin
function _admin() internal returns (address)
- Returns:
- The admin slot.
_setAdmin
function _setAdmin(address newAdmin) internal
Sets the address of the proxy admin.
- Parameters:
newAdmin
- Address of the new proxy admin.
_willFallback
function _willFallback() internal
Only fall back when the sender is not the admin.
admin
function admin() external view returns (address)
- Modifiers:
- ifAdmin
- Returns:
- The address of the proxy admin.
changeAdmin
function changeAdmin(address newAdmin) external
Changes the admin of the proxy. Only the current admin can call this function.
- Modifiers:
- ifAdmin
- Parameters:
newAdmin
- Address to transfer proxy administration to.
implementation
function implementation() external view returns (address)
- Modifiers:
- ifAdmin
- Returns:
- The address of the implementation.
upgradeTo
function upgradeTo(address newImplementation) external
Upgrade the backing implementation of the proxy. Only the admin can call this function.
- Modifiers:
- ifAdmin
- Parameters:
newImplementation
- Address of the new implementation.
upgradeToAndCall
function upgradeToAndCall(address implementation, bytes data) external payable
Upgrade the backing implementation of the proxy and call a function on the new implementation. This is useful to initialize the proxied contract.
- Modifiers:
- ifAdmin
- Parameters:
implementation
- Address of the new implementation.data
- Data to send as msg.data in the low level call. It should include the signature and the parameters of the function to be called, as described in https://solidity.readthedocs.io/en/develop/abi-spec.html#function-selector-and-argument-encoding.