EnumerableMapMock.sol 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. // SPDX-License-Identifier: MIT
  2. // This file was procedurally generated from scripts/generate/templates/EnumerableMapMock.js.
  3. pragma solidity ^0.8.0;
  4. import "../utils/structs/EnumerableMap.sol";
  5. // UintToAddressMap
  6. contract UintToAddressMapMock {
  7. using EnumerableMap for EnumerableMap.UintToAddressMap;
  8. event OperationResult(bool result);
  9. EnumerableMap.UintToAddressMap private _map;
  10. function contains(uint256 key) public view returns (bool) {
  11. return _map.contains(key);
  12. }
  13. function set(uint256 key, address value) public {
  14. bool result = _map.set(key, value);
  15. emit OperationResult(result);
  16. }
  17. function remove(uint256 key) public {
  18. bool result = _map.remove(key);
  19. emit OperationResult(result);
  20. }
  21. function length() public view returns (uint256) {
  22. return _map.length();
  23. }
  24. function at(uint256 index) public view returns (uint256 key, address value) {
  25. return _map.at(index);
  26. }
  27. function tryGet(uint256 key) public view returns (bool, address) {
  28. return _map.tryGet(key);
  29. }
  30. function get(uint256 key) public view returns (address) {
  31. return _map.get(key);
  32. }
  33. function getWithMessage(uint256 key, string calldata errorMessage) public view returns (address) {
  34. return _map.get(key, errorMessage);
  35. }
  36. }
  37. // AddressToUintMap
  38. contract AddressToUintMapMock {
  39. using EnumerableMap for EnumerableMap.AddressToUintMap;
  40. event OperationResult(bool result);
  41. EnumerableMap.AddressToUintMap private _map;
  42. function contains(address key) public view returns (bool) {
  43. return _map.contains(key);
  44. }
  45. function set(address key, uint256 value) public {
  46. bool result = _map.set(key, value);
  47. emit OperationResult(result);
  48. }
  49. function remove(address key) public {
  50. bool result = _map.remove(key);
  51. emit OperationResult(result);
  52. }
  53. function length() public view returns (uint256) {
  54. return _map.length();
  55. }
  56. function at(uint256 index) public view returns (address key, uint256 value) {
  57. return _map.at(index);
  58. }
  59. function tryGet(address key) public view returns (bool, uint256) {
  60. return _map.tryGet(key);
  61. }
  62. function get(address key) public view returns (uint256) {
  63. return _map.get(key);
  64. }
  65. function getWithMessage(address key, string calldata errorMessage) public view returns (uint256) {
  66. return _map.get(key, errorMessage);
  67. }
  68. }
  69. // Bytes32ToBytes32Map
  70. contract Bytes32ToBytes32MapMock {
  71. using EnumerableMap for EnumerableMap.Bytes32ToBytes32Map;
  72. event OperationResult(bool result);
  73. EnumerableMap.Bytes32ToBytes32Map private _map;
  74. function contains(bytes32 key) public view returns (bool) {
  75. return _map.contains(key);
  76. }
  77. function set(bytes32 key, bytes32 value) public {
  78. bool result = _map.set(key, value);
  79. emit OperationResult(result);
  80. }
  81. function remove(bytes32 key) public {
  82. bool result = _map.remove(key);
  83. emit OperationResult(result);
  84. }
  85. function length() public view returns (uint256) {
  86. return _map.length();
  87. }
  88. function at(uint256 index) public view returns (bytes32 key, bytes32 value) {
  89. return _map.at(index);
  90. }
  91. function tryGet(bytes32 key) public view returns (bool, bytes32) {
  92. return _map.tryGet(key);
  93. }
  94. function get(bytes32 key) public view returns (bytes32) {
  95. return _map.get(key);
  96. }
  97. function getWithMessage(bytes32 key, string calldata errorMessage) public view returns (bytes32) {
  98. return _map.get(key, errorMessage);
  99. }
  100. }
  101. // UintToUintMap
  102. contract UintToUintMapMock {
  103. using EnumerableMap for EnumerableMap.UintToUintMap;
  104. event OperationResult(bool result);
  105. EnumerableMap.UintToUintMap private _map;
  106. function contains(uint256 key) public view returns (bool) {
  107. return _map.contains(key);
  108. }
  109. function set(uint256 key, uint256 value) public {
  110. bool result = _map.set(key, value);
  111. emit OperationResult(result);
  112. }
  113. function remove(uint256 key) public {
  114. bool result = _map.remove(key);
  115. emit OperationResult(result);
  116. }
  117. function length() public view returns (uint256) {
  118. return _map.length();
  119. }
  120. function at(uint256 index) public view returns (uint256 key, uint256 value) {
  121. return _map.at(index);
  122. }
  123. function tryGet(uint256 key) public view returns (bool, uint256) {
  124. return _map.tryGet(key);
  125. }
  126. function get(uint256 key) public view returns (uint256) {
  127. return _map.get(key);
  128. }
  129. function getWithMessage(uint256 key, string calldata errorMessage) public view returns (uint256) {
  130. return _map.get(key, errorMessage);
  131. }
  132. }
  133. // Bytes32ToUintMap
  134. contract Bytes32ToUintMapMock {
  135. using EnumerableMap for EnumerableMap.Bytes32ToUintMap;
  136. event OperationResult(bool result);
  137. EnumerableMap.Bytes32ToUintMap private _map;
  138. function contains(bytes32 key) public view returns (bool) {
  139. return _map.contains(key);
  140. }
  141. function set(bytes32 key, uint256 value) public {
  142. bool result = _map.set(key, value);
  143. emit OperationResult(result);
  144. }
  145. function remove(bytes32 key) public {
  146. bool result = _map.remove(key);
  147. emit OperationResult(result);
  148. }
  149. function length() public view returns (uint256) {
  150. return _map.length();
  151. }
  152. function at(uint256 index) public view returns (bytes32 key, uint256 value) {
  153. return _map.at(index);
  154. }
  155. function tryGet(bytes32 key) public view returns (bool, uint256) {
  156. return _map.tryGet(key);
  157. }
  158. function get(bytes32 key) public view returns (uint256) {
  159. return _map.get(key);
  160. }
  161. function getWithMessage(bytes32 key, string calldata errorMessage) public view returns (uint256) {
  162. return _map.get(key, errorMessage);
  163. }
  164. }