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
_admin
function _admin() internal view 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.
fallback
function (address _implementation, address _admin, bytes _data) public payable
Contract constructor.
- Modifiers:
- Parameters:
_implementation
- address of the initial implementation._admin
- Address of the proxy administrator._data
- Data to send as msg.data to the implementation to initialize the proxied contract. It should include the signature and the parameters of the function to be called, as described in https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. This parameter is optional, if no data is given the initialization call to proxied contract will be skipped.
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 newImplementation, 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:
newImplementation
- 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/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.