EnumerableMapMock.sol 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity >=0.6.0 <0.8.0;
  3. import "../utils/EnumerableMap.sol";
  4. contract EnumerableMapMock {
  5. using EnumerableMap for EnumerableMap.UintToAddressMap;
  6. event OperationResult(bool result);
  7. EnumerableMap.UintToAddressMap private _map;
  8. function contains(uint256 key) public view returns (bool) {
  9. return _map.contains(key);
  10. }
  11. function set(uint256 key, address value) public {
  12. bool result = _map.set(key, value);
  13. emit OperationResult(result);
  14. }
  15. function remove(uint256 key) public {
  16. bool result = _map.remove(key);
  17. emit OperationResult(result);
  18. }
  19. function length() public view returns (uint256) {
  20. return _map.length();
  21. }
  22. function at(uint256 index) public view returns (uint256 key, address value) {
  23. return _map.at(index);
  24. }
  25. function tryGet(uint256 key) public view returns (bool, address) {
  26. return _map.tryGet(key);
  27. }
  28. function get(uint256 key) public view returns (address) {
  29. return _map.get(key);
  30. }
  31. function getWithMessage(uint256 key, string calldata errorMessage) public view returns (address) {
  32. return _map.get(key, errorMessage);
  33. }
  34. }