2020-05-29 16:45:37 +00:00
|
|
|
// SPDX-License-Identifier: agpl-3.0
|
2020-11-20 10:45:20 +00:00
|
|
|
pragma solidity 0.6.12;
|
2020-05-29 16:45:37 +00:00
|
|
|
|
2020-07-13 08:54:08 +00:00
|
|
|
import './BaseAdminUpgradeabilityProxy.sol';
|
|
|
|
import './InitializableUpgradeabilityProxy.sol';
|
2020-05-29 16:45:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @title InitializableAdminUpgradeabilityProxy
|
2020-07-13 08:54:08 +00:00
|
|
|
* @dev Extends from BaseAdminUpgradeabilityProxy with an initializer for
|
2020-05-29 16:45:37 +00:00
|
|
|
* initializing the implementation, admin, and init data.
|
|
|
|
*/
|
2020-07-13 08:54:08 +00:00
|
|
|
contract InitializableAdminUpgradeabilityProxy is
|
|
|
|
BaseAdminUpgradeabilityProxy,
|
|
|
|
InitializableUpgradeabilityProxy
|
|
|
|
{
|
|
|
|
/**
|
2020-05-29 16:45:37 +00:00
|
|
|
* Contract initializer.
|
2020-08-21 16:18:12 +00:00
|
|
|
* @param logic address of the initial implementation.
|
|
|
|
* @param admin Address of the proxy administrator.
|
|
|
|
* @param data Data to send as msg.data to the implementation to initialize the proxied contract.
|
2020-05-29 16:45:37 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
2020-07-13 08:54:08 +00:00
|
|
|
function initialize(
|
2020-08-21 16:18:12 +00:00
|
|
|
address logic,
|
|
|
|
address admin,
|
|
|
|
bytes memory data
|
2020-07-13 08:54:08 +00:00
|
|
|
) public payable {
|
|
|
|
require(_implementation() == address(0));
|
2020-08-21 16:18:12 +00:00
|
|
|
InitializableUpgradeabilityProxy.initialize(logic, data);
|
2020-07-13 08:54:08 +00:00
|
|
|
assert(ADMIN_SLOT == bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1));
|
2020-08-21 16:18:12 +00:00
|
|
|
_setAdmin(admin);
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
2020-05-29 16:45:37 +00:00
|
|
|
|
2020-07-13 08:54:08 +00:00
|
|
|
/**
|
|
|
|
* @dev Only fall back when the sender is not the admin.
|
|
|
|
*/
|
|
|
|
function _willFallback() internal override(BaseAdminUpgradeabilityProxy, Proxy) {
|
|
|
|
BaseAdminUpgradeabilityProxy._willFallback();
|
|
|
|
}
|
2020-05-29 16:45:37 +00:00
|
|
|
}
|