Skip to content

Commit

Permalink
Update EnumerableMapMock.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed May 20, 2022
1 parent 51463b0 commit b9bc2c3
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions contracts/mocks/EnumerableMapMock.sol
Expand Up @@ -4,19 +4,19 @@ pragma solidity ^0.8.0;

import "../utils/structs/EnumerableMap.sol";

// UintToUintMap
contract UintToUintMapMock {
using EnumerableMap for EnumerableMap.UintToUintMap;
// UintToAddressMap
contract UintToAddressMapMock {
using EnumerableMap for EnumerableMap.UintToAddressMap;

event OperationResult(bool result);

EnumerableMap.UintToUintMap private _map;
EnumerableMap.UintToAddressMap private _map;

function contains(uint256 key) public view returns (bool) {
return _map.contains(key);
}

function set(uint256 key, uint256 value) public {
function set(uint256 key, address value) public {
bool result = _map.set(key, value);
emit OperationResult(result);
}
Expand All @@ -30,41 +30,41 @@ contract UintToUintMapMock {
return _map.length();
}

function at(uint256 index) public view returns (uint256 key, uint256 value) {
function at(uint256 index) public view returns (uint256 key, address value) {
return _map.at(index);
}

function tryGet(uint256 key) public view returns (bool, uint256) {
function tryGet(uint256 key) public view returns (bool, address) {
return _map.tryGet(key);
}

function get(uint256 key) public view returns (uint256) {
function get(uint256 key) public view returns (address) {
return _map.get(key);
}

function getWithMessage(uint256 key, string calldata errorMessage) public view returns (uint256) {
function getWithMessage(uint256 key, string calldata errorMessage) public view returns (address) {
return _map.get(key, errorMessage);
}
}

// UintToAddressMap
contract UintToAddressMapMock {
using EnumerableMap for EnumerableMap.UintToAddressMap;
// AddressToUintMap
contract AddressToUintMapMock {
using EnumerableMap for EnumerableMap.AddressToUintMap;

event OperationResult(bool result);

EnumerableMap.UintToAddressMap private _map;
EnumerableMap.AddressToUintMap private _map;

function contains(uint256 key) public view returns (bool) {
function contains(address key) public view returns (bool) {
return _map.contains(key);
}

function set(uint256 key, address value) public {
function set(address key, uint256 value) public {
bool result = _map.set(key, value);
emit OperationResult(result);
}

function remove(uint256 key) public {
function remove(address key) public {
bool result = _map.remove(key);
emit OperationResult(result);
}
Expand All @@ -73,41 +73,40 @@ contract UintToAddressMapMock {
return _map.length();
}

function at(uint256 index) public view returns (uint256 key, address value) {
function at(uint256 index) public view returns (address key, uint256 value) {
return _map.at(index);
}

function tryGet(uint256 key) public view returns (bool, address) {
function tryGet(address key) public view returns (bool, uint256) {
return _map.tryGet(key);
}

function get(uint256 key) public view returns (address) {
function get(address key) public view returns (uint256) {
return _map.get(key);
}

function getWithMessage(uint256 key, string calldata errorMessage) public view returns (address) {
function getWithMessage(address key, string calldata errorMessage) public view returns (uint256) {
return _map.get(key, errorMessage);
}
}

// AddressToUintMap
contract AddressToUintMapMock {
using EnumerableMap for EnumerableMap.AddressToUintMap;
contract Bytes32ToBytes32MapMock {
using EnumerableMap for EnumerableMap.Bytes32ToBytes32Map;

event OperationResult(bool result);

EnumerableMap.AddressToUintMap private _map;
EnumerableMap.Bytes32ToBytes32Map private _map;

function contains(address key) public view returns (bool) {
function contains(bytes32 key) public view returns (bool) {
return _map.contains(key);
}

function set(address key, uint256 value) public {
function set(bytes32 key, bytes32 value) public {
bool result = _map.set(key, value);
emit OperationResult(result);
}

function remove(address key) public {
function remove(bytes32 key) public {
bool result = _map.remove(key);
emit OperationResult(result);
}
Expand All @@ -116,40 +115,41 @@ contract AddressToUintMapMock {
return _map.length();
}

function at(uint256 index) public view returns (address key, uint256 value) {
function at(uint256 index) public view returns (bytes32 key, bytes32 value) {
return _map.at(index);
}

function tryGet(address key) public view returns (bool, uint256) {
function tryGet(bytes32 key) public view returns (bool, bytes32) {
return _map.tryGet(key);
}

function get(address key) public view returns (uint256) {
function get(bytes32 key) public view returns (bytes32) {
return _map.get(key);
}

function getWithMessage(address key, string calldata errorMessage) public view returns (uint256) {
function getWithMessage(bytes32 key, string calldata errorMessage) public view returns (bytes32) {
return _map.get(key, errorMessage);
}
}

contract Bytes32ToBytes32MapMock {
using EnumerableMap for EnumerableMap.Bytes32ToBytes32Map;
// UintToUintMap
contract UintToUintMapMock {
using EnumerableMap for EnumerableMap.UintToUintMap;

event OperationResult(bool result);

EnumerableMap.Bytes32ToBytes32Map private _map;
EnumerableMap.UintToUintMap private _map;

function contains(bytes32 key) public view returns (bool) {
function contains(uint256 key) public view returns (bool) {
return _map.contains(key);
}

function set(bytes32 key, bytes32 value) public {
function set(uint256 key, uint256 value) public {
bool result = _map.set(key, value);
emit OperationResult(result);
}

function remove(bytes32 key) public {
function remove(uint256 key) public {
bool result = _map.remove(key);
emit OperationResult(result);
}
Expand All @@ -158,19 +158,19 @@ contract Bytes32ToBytes32MapMock {
return _map.length();
}

function at(uint256 index) public view returns (bytes32 key, bytes32 value) {
function at(uint256 index) public view returns (uint256 key, uint256 value) {
return _map.at(index);
}

function tryGet(bytes32 key) public view returns (bool, bytes32) {
function tryGet(uint256 key) public view returns (bool, uint256) {
return _map.tryGet(key);
}

function get(bytes32 key) public view returns (bytes32) {
function get(uint256 key) public view returns (uint256) {
return _map.get(key);
}

function getWithMessage(bytes32 key, string calldata errorMessage) public view returns (bytes32) {
function getWithMessage(uint256 key, string calldata errorMessage) public view returns (uint256) {
return _map.get(key, errorMessage);
}
}

0 comments on commit b9bc2c3

Please sign in to comment.