mirror of
https://github.com/codex-storage/codex-contracts-eth.git
synced 2025-02-13 11:56:46 +00:00
add ability to get all requests
This commit is contained in:
parent
6397835635
commit
81dd4c203f
@ -41,6 +41,10 @@ contract Marketplace is Collateral, Proofs {
|
|||||||
return _toRequestIds(activeRequests[msg.sender].values());
|
return _toRequestIds(activeRequests[msg.sender].values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function allRequests() public view returns(RequestId[] memory) {
|
||||||
|
return _toRequestIds(activeSlots.keys());
|
||||||
|
}
|
||||||
|
|
||||||
function mySlots(RequestId requestId)
|
function mySlots(RequestId requestId)
|
||||||
public
|
public
|
||||||
view
|
view
|
||||||
@ -375,6 +379,17 @@ contract Marketplace is Collateral, Proofs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _toRequestIds(SetMap.Key[] memory array)
|
||||||
|
private
|
||||||
|
pure
|
||||||
|
returns (RequestId[] memory result)
|
||||||
|
{
|
||||||
|
// solhint-disable-next-line no-inline-assembly
|
||||||
|
assembly {
|
||||||
|
result := array
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function _toSlotIds(bytes32[] memory array)
|
function _toSlotIds(bytes32[] memory array)
|
||||||
private
|
private
|
||||||
pure
|
pure
|
||||||
|
@ -14,6 +14,7 @@ library SetMap {
|
|||||||
mapping(uint8 =>
|
mapping(uint8 =>
|
||||||
EnumerableSet.Bytes32Set))) _values;
|
EnumerableSet.Bytes32Set))) _values;
|
||||||
mapping(Key => uint8) _index;
|
mapping(Key => uint8) _index;
|
||||||
|
EnumerableSet.Bytes32Set _keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice Returns the EnumerableSet.Bytes32 containing the values for a key
|
/// @notice Returns the EnumerableSet.Bytes32 containing the values for a key
|
||||||
@ -50,6 +51,28 @@ library SetMap {
|
|||||||
return _set(map, key, addr).values();
|
return _set(map, key, addr).values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _toKeys(bytes32[] memory array)
|
||||||
|
private
|
||||||
|
pure
|
||||||
|
returns (Key[] memory result)
|
||||||
|
{
|
||||||
|
// solhint-disable-next-line no-inline-assembly
|
||||||
|
assembly {
|
||||||
|
result := array
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @notice Lists all keys for an AddressSetMap
|
||||||
|
/// @param map AddressSetMap to list keys
|
||||||
|
/// @return bytes32[] array of bytes32 values
|
||||||
|
function keys(AddressSetMap storage map)
|
||||||
|
internal
|
||||||
|
view
|
||||||
|
returns (Key[] memory)
|
||||||
|
{
|
||||||
|
return _toKeys(map._keys.values());
|
||||||
|
}
|
||||||
|
|
||||||
/// @notice Adds a single value to an AddressSetMap
|
/// @notice Adds a single value to an AddressSetMap
|
||||||
/// @param map AddressSetMap to add the value to
|
/// @param map AddressSetMap to add the value to
|
||||||
/// @param key key of the value to be added
|
/// @param key key of the value to be added
|
||||||
@ -64,6 +87,7 @@ library SetMap {
|
|||||||
internal
|
internal
|
||||||
returns (bool)
|
returns (bool)
|
||||||
{
|
{
|
||||||
|
map._keys.add(Key.unwrap(key));
|
||||||
return _set(map, key, addr).add(value);
|
return _set(map, key, addr).add(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +105,12 @@ library SetMap {
|
|||||||
internal
|
internal
|
||||||
returns (bool)
|
returns (bool)
|
||||||
{
|
{
|
||||||
return _set(map, key, addr).remove(value);
|
EnumerableSet.Bytes32Set storage set = _set(map, key, addr);
|
||||||
|
bool success = set.remove(value);
|
||||||
|
if (success && set.length() == 0) {
|
||||||
|
map._keys.remove(Key.unwrap(key));
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice Clears values for a key.
|
/// @notice Clears values for a key.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user