EnumerableSetMockUpgradeable.sol 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.0;
  3. import "../utils/structs/EnumerableSetUpgradeable.sol";
  4. import "../proxy/utils/Initializable.sol";
  5. // Bytes32Set
  6. contract EnumerableBytes32SetMockUpgradeable is Initializable {
  7. function __EnumerableBytes32SetMock_init() internal onlyInitializing {
  8. }
  9. function __EnumerableBytes32SetMock_init_unchained() internal onlyInitializing {
  10. }
  11. using EnumerableSetUpgradeable for EnumerableSetUpgradeable.Bytes32Set;
  12. event OperationResult(bool result);
  13. EnumerableSetUpgradeable.Bytes32Set private _set;
  14. function contains(bytes32 value) public view returns (bool) {
  15. return _set.contains(value);
  16. }
  17. function add(bytes32 value) public {
  18. bool result = _set.add(value);
  19. emit OperationResult(result);
  20. }
  21. function remove(bytes32 value) public {
  22. bool result = _set.remove(value);
  23. emit OperationResult(result);
  24. }
  25. function length() public view returns (uint256) {
  26. return _set.length();
  27. }
  28. function at(uint256 index) public view returns (bytes32) {
  29. return _set.at(index);
  30. }
  31. function values() public view returns (bytes32[] memory) {
  32. return _set.values();
  33. }
  34. /**
  35. * This empty reserved space is put in place to allow future versions to add new
  36. * variables without shifting down storage in the inheritance chain.
  37. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  38. */
  39. uint256[48] private __gap;
  40. }
  41. // AddressSet
  42. contract EnumerableAddressSetMockUpgradeable is Initializable {
  43. function __EnumerableAddressSetMock_init() internal onlyInitializing {
  44. }
  45. function __EnumerableAddressSetMock_init_unchained() internal onlyInitializing {
  46. }
  47. using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;
  48. event OperationResult(bool result);
  49. EnumerableSetUpgradeable.AddressSet private _set;
  50. function contains(address value) public view returns (bool) {
  51. return _set.contains(value);
  52. }
  53. function add(address value) public {
  54. bool result = _set.add(value);
  55. emit OperationResult(result);
  56. }
  57. function remove(address value) public {
  58. bool result = _set.remove(value);
  59. emit OperationResult(result);
  60. }
  61. function length() public view returns (uint256) {
  62. return _set.length();
  63. }
  64. function at(uint256 index) public view returns (address) {
  65. return _set.at(index);
  66. }
  67. function values() public view returns (address[] memory) {
  68. return _set.values();
  69. }
  70. /**
  71. * This empty reserved space is put in place to allow future versions to add new
  72. * variables without shifting down storage in the inheritance chain.
  73. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  74. */
  75. uint256[48] private __gap;
  76. }
  77. // UintSet
  78. contract EnumerableUintSetMockUpgradeable is Initializable {
  79. function __EnumerableUintSetMock_init() internal onlyInitializing {
  80. }
  81. function __EnumerableUintSetMock_init_unchained() internal onlyInitializing {
  82. }
  83. using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet;
  84. event OperationResult(bool result);
  85. EnumerableSetUpgradeable.UintSet private _set;
  86. function contains(uint256 value) public view returns (bool) {
  87. return _set.contains(value);
  88. }
  89. function add(uint256 value) public {
  90. bool result = _set.add(value);
  91. emit OperationResult(result);
  92. }
  93. function remove(uint256 value) public {
  94. bool result = _set.remove(value);
  95. emit OperationResult(result);
  96. }
  97. function length() public view returns (uint256) {
  98. return _set.length();
  99. }
  100. function at(uint256 index) public view returns (uint256) {
  101. return _set.at(index);
  102. }
  103. function values() public view returns (uint256[] memory) {
  104. return _set.values();
  105. }
  106. /**
  107. * This empty reserved space is put in place to allow future versions to add new
  108. * variables without shifting down storage in the inheritance chain.
  109. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  110. */
  111. uint256[48] private __gap;
  112. }