-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUpgradeableProxy.sol
More file actions
38 lines (33 loc) · 941 Bytes
/
UpgradeableProxy.sol
File metadata and controls
38 lines (33 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
pragma solidity ^0.4.6;
// Proxy contract to enable contract upgrade and versioning
// Note this is a partial implementation and much is TODO
/// @title Ugradeable Contract Proxy
/// @author Adam Lemmon - <adamjlemmon@gmail.com>
contract UpgradeableProxy {
/**
* Storage
*/
address public latest;
address public owner;
bytes public data;
/// @dev Contract constructor
function UpgradeableProxy(address initialVersion) {
latest = initialVersion;
owner = msg.sender;
}
/// @dev All method requests hit this fallback and are routed
/// to latest version of contract operating in the context of
/// this proxy thus maintaining storage
function () {
if(!latest.delegatecall(msg.data)) throw;
}
/**
* Public
*/
/// @dev Update to a new version of the contract
/// @param newVersion Address of the new contract
function update(address newVersion) public {
if(msg.sender != owner) throw;
latest = newVersion;
}
}