Add uint to uint enumerable map (#3338)

This commit is contained in:
ashhanai
2022-05-20 14:31:53 +01:00
committed by GitHub
parent 6339027a7a
commit c4f76cfa15
4 changed files with 151 additions and 2 deletions

View File

@ -131,3 +131,46 @@ contract Bytes32ToBytes32MapMock {
return _map.get(key, errorMessage);
}
}
// UintToUintMap
contract UintToUintMapMock {
using EnumerableMap for EnumerableMap.UintToUintMap;
event OperationResult(bool result);
EnumerableMap.UintToUintMap private _map;
function contains(uint256 key) public view returns (bool) {
return _map.contains(key);
}
function set(uint256 key, uint256 value) public {
bool result = _map.set(key, value);
emit OperationResult(result);
}
function remove(uint256 key) public {
bool result = _map.remove(key);
emit OperationResult(result);
}
function length() public view returns (uint256) {
return _map.length();
}
function at(uint256 index) public view returns (uint256 key, uint256 value) {
return _map.at(index);
}
function tryGet(uint256 key) public view returns (bool, uint256) {
return _map.tryGet(key);
}
function get(uint256 key) public view returns (uint256) {
return _map.get(key);
}
function getWithMessage(uint256 key, string calldata errorMessage) public view returns (uint256) {
return _map.get(key, errorMessage);
}
}