DummyImplementation.sol 1.6 KB

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