logos-storage-contracts-eth/contracts/libs/TestEnumerableSetExtensions.sol
Eric Mastro 8fde295b73
refactor Mappings.Mapping, add ClearableBytes32Set
- refactor Mappings.Mapping to use a ClearableBytes32Set and multiple EnumerableSet.Bytes32Sets instead of implementing that code directly in Mappings.Mapping.
- update the api for better readability and reasoning.

This should be much cleaner now.
2022-11-28 14:39:11 +11:00

59 lines
1.0 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./EnumerableSetExtensions.sol";
// exposes public functions for testing
contract TestClearableBytes32Set {
using EnumerableSet for EnumerableSet.Bytes32Set;
using EnumerableSetExtensions for EnumerableSetExtensions.ClearableBytes32Set;
event OperationResult(bool result);
EnumerableSetExtensions.ClearableBytes32Set private _set;
function values()
public
view
returns (bytes32[] memory)
{
return _set.values();
}
function add(bytes32 value)
public
{
bool result = _set.add(value);
emit OperationResult(result);
}
function remove(bytes32 value)
public
{
bool result = _set.remove(value);
emit OperationResult(result);
}
function clear()
public
{
_set.clear();
}
function length()
public
view
returns (uint256)
{
return _set.length();
}
function contains(bytes32 value)
public
view
returns (bool)
{
return _set.contains(value);
}
}