EnumerableMapMockUpgradeable.sol 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.0;
  3. import "../utils/structs/EnumerableMapUpgradeable.sol";
  4. import "../proxy/utils/Initializable.sol";
  5. contract EnumerableMapMockUpgradeable is Initializable {
  6. function __EnumerableMapMock_init() internal onlyInitializing {
  7. }
  8. function __EnumerableMapMock_init_unchained() internal onlyInitializing {
  9. }
  10. using EnumerableMapUpgradeable for EnumerableMapUpgradeable.UintToAddressMap;
  11. event OperationResult(bool result);
  12. EnumerableMapUpgradeable.UintToAddressMap private _map;
  13. function contains(uint256 key) public view returns (bool) {
  14. return _map.contains(key);
  15. }
  16. function set(uint256 key, address value) public {
  17. bool result = _map.set(key, value);
  18. emit OperationResult(result);
  19. }
  20. function remove(uint256 key) public {
  21. bool result = _map.remove(key);
  22. emit OperationResult(result);
  23. }
  24. function length() public view returns (uint256) {
  25. return _map.length();
  26. }
  27. function at(uint256 index) public view returns (uint256 key, address value) {
  28. return _map.at(index);
  29. }
  30. function tryGet(uint256 key) public view returns (bool, address) {
  31. return _map.tryGet(key);
  32. }
  33. function get(uint256 key) public view returns (address) {
  34. return _map.get(key);
  35. }
  36. function getWithMessage(uint256 key, string calldata errorMessage) public view returns (address) {
  37. return _map.get(key, errorMessage);
  38. }
  39. /**
  40. * @dev This empty reserved space is put in place to allow future versions to add new
  41. * variables without shifting down storage in the inheritance chain.
  42. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  43. */
  44. uint256[47] private __gap;
  45. }