contracts/contracts/upgradeable/UpgradeabilityProxy.sol
bumi 4d2ba2a4bf Store contract names in registry as bytes32 hashes
This allows use to call the methods with a string but still store the
name as bytes32.
I also had some issues when calling the methods from ethers.js and a
string parameter so this is easier and safer.
2018-04-03 20:23:36 +02:00

29 lines
834 B
Solidity

pragma solidity ^0.4.18;
import './Proxy.sol';
import './IRegistry.sol';
import './UpgradeabilityStorage.sol';
/**
* @title UpgradeabilityProxy
* @dev This contract represents a proxy where the implementation address to which it will delegate can be upgraded
*/
contract UpgradeabilityProxy is Proxy, UpgradeabilityStorage {
function UpgradeabilityProxy(string _name, uint _version) public {
_proxiedContractName = _name;
registry = IRegistry(msg.sender);
upgradeTo(_version);
}
/**
* @dev Upgrades the implementation to the requested version
* @param _version representing the version name of the new implementation to be set
*/
function upgradeTo(uint _version) public {
require(msg.sender == address(registry));
_implementation = registry.getVersion(_proxiedContractName, _version);
}
}