mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-15 03:33:07 +00:00
- 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.
59 lines
1.0 KiB
Solidity
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);
|
|
}
|
|
}
|