DummyImplementation.sol 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.19;
  3. import "../proxy/ERC1967/ERC1967Utils.sol";
  4. abstract contract Impl {
  5. function version() public pure virtual returns (string memory);
  6. }
  7. contract DummyImplementation {
  8. uint256 public value;
  9. string public text;
  10. uint256[] public values;
  11. function initializeNonPayable() public {
  12. value = 10;
  13. }
  14. function initializePayable() public payable {
  15. value = 100;
  16. }
  17. function initializeNonPayableWithValue(uint256 _value) public {
  18. value = _value;
  19. }
  20. function initializePayableWithValue(uint256 _value) public payable {
  21. value = _value;
  22. }
  23. function initialize(uint256 _value, string memory _text, uint256[] memory _values) public {
  24. value = _value;
  25. text = _text;
  26. values = _values;
  27. }
  28. function get() public pure returns (bool) {
  29. return true;
  30. }
  31. function version() public pure virtual returns (string memory) {
  32. return "V1";
  33. }
  34. function reverts() public pure {
  35. require(false, "DummyImplementation reverted");
  36. }
  37. // Use for forcing an unsafe TransparentUpgradeableProxy admin override
  38. function unsafeOverrideAdmin(address newAdmin) public {
  39. StorageSlot.getAddressSlot(ERC1967Utils.ADMIN_SLOT).value = newAdmin;
  40. }
  41. }
  42. contract DummyImplementationV2 is DummyImplementation {
  43. function migrate(uint256 newVal) public payable {
  44. value = newVal;
  45. }
  46. function version() public pure override returns (string memory) {
  47. return "V2";
  48. }
  49. }