DummyImplementationUpgradeable.sol 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.0;
  3. import "../proxy/utils/Initializable.sol";
  4. abstract contract ImplUpgradeable is Initializable {
  5. function __Impl_init() internal onlyInitializing {
  6. }
  7. function __Impl_init_unchained() internal onlyInitializing {
  8. }
  9. function version() public pure virtual returns (string memory);
  10. /**
  11. * This empty reserved space is put in place to allow future versions to add new
  12. * variables without shifting down storage in the inheritance chain.
  13. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  14. */
  15. uint256[50] private __gap;
  16. }
  17. contract DummyImplementationUpgradeable is Initializable {
  18. function __DummyImplementation_init() internal onlyInitializing {
  19. }
  20. function __DummyImplementation_init_unchained() internal onlyInitializing {
  21. }
  22. uint256 public value;
  23. string public text;
  24. uint256[] public values;
  25. function initializeNonPayable() public {
  26. value = 10;
  27. }
  28. function initializePayable() public payable {
  29. value = 100;
  30. }
  31. function initializeNonPayableWithValue(uint256 _value) public {
  32. value = _value;
  33. }
  34. function initializePayableWithValue(uint256 _value) public payable {
  35. value = _value;
  36. }
  37. function initialize(
  38. uint256 _value,
  39. string memory _text,
  40. uint256[] memory _values
  41. ) public {
  42. value = _value;
  43. text = _text;
  44. values = _values;
  45. }
  46. function get() public pure returns (bool) {
  47. return true;
  48. }
  49. function version() public pure virtual returns (string memory) {
  50. return "V1";
  51. }
  52. function reverts() public pure {
  53. require(false, "DummyImplementation reverted");
  54. }
  55. /**
  56. * This empty reserved space is put in place to allow future versions to add new
  57. * variables without shifting down storage in the inheritance chain.
  58. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  59. */
  60. uint256[47] private __gap;
  61. }
  62. contract DummyImplementationV2Upgradeable is Initializable, DummyImplementationUpgradeable {
  63. function __DummyImplementationV2_init() internal onlyInitializing {
  64. }
  65. function __DummyImplementationV2_init_unchained() internal onlyInitializing {
  66. }
  67. function migrate(uint256 newVal) public payable {
  68. value = newVal;
  69. }
  70. function version() public pure override returns (string memory) {
  71. return "V2";
  72. }
  73. /**
  74. * This empty reserved space is put in place to allow future versions to add new
  75. * variables without shifting down storage in the inheritance chain.
  76. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  77. */
  78. uint256[50] private __gap;
  79. }