set_code_hash.sol 528 B

12345678910111213141516171819202122232425262728293031
  1. import "polkadot";
  2. abstract contract Upgradeable {
  3. function set_code(uint8[32] code) external {
  4. require(set_code_hash(code) == 0);
  5. }
  6. }
  7. contract SetCodeCounterV1 is Upgradeable {
  8. uint public count;
  9. constructor(uint _count) {
  10. count = _count;
  11. }
  12. function inc() external {
  13. count += 1;
  14. }
  15. }
  16. contract SetCodeCounterV2 is Upgradeable {
  17. uint public count;
  18. constructor(uint _count) {
  19. count = _count;
  20. }
  21. function inc() external {
  22. count -= 1;
  23. }
  24. }