Last active
October 19, 2019 00:14
-
-
Save cwhinfrey/8087cc4565054cdcd7eef82498cc8b37 to your computer and use it in GitHub Desktop.
UpgradabilityPatterns.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.5.10; | |
// V1 | |
contract AccountV1Storage { | |
uint lastInitializedVersion; | |
uint a; | |
} | |
contract AccountV1 is AccountV1Storage { | |
function initialize(uint _a) external { | |
require(lastInitializedVersion == 0); | |
lastInitializedVersion = 1; | |
a = _a; | |
} | |
/** | |
* Some functions | |
*/ | |
} | |
// V2 | |
contract AccountV2 is AccountV1 { | |
/** | |
* Some functions | |
*/ | |
} | |
// V3 | |
contract AccountV3Storage { | |
uint b; | |
} | |
contract AccountV3 is AccountV1, AccountV3Storage { | |
function initialize_v3 (uint _b) external { | |
require(lastInitializedVersion == 1); | |
lastInitializedVersion = 3; | |
b = _b; | |
} | |
/** | |
* Some functions | |
*/ | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment