parent
4f75159e02
commit
0ecce3094a
|
@ -6,11 +6,9 @@ import "@openzeppelin/contracts/utils/math/Math.sol";
|
||||||
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
||||||
import "./Collateral.sol";
|
import "./Collateral.sol";
|
||||||
import "./Proofs.sol";
|
import "./Proofs.sol";
|
||||||
import "./libs/Utils.sol";
|
|
||||||
|
|
||||||
contract Marketplace is Collateral, Proofs {
|
contract Marketplace is Collateral, Proofs {
|
||||||
using EnumerableSet for EnumerableSet.Bytes32Set;
|
using EnumerableSet for EnumerableSet.Bytes32Set;
|
||||||
using Utils for EnumerableSet.Bytes32Set;
|
|
||||||
|
|
||||||
type RequestId is bytes32;
|
type RequestId is bytes32;
|
||||||
type SlotId is bytes32;
|
type SlotId is bytes32;
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
pragma solidity ^0.8.8;
|
|
||||||
|
|
||||||
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
||||||
|
|
||||||
library Utils {
|
|
||||||
using EnumerableSet for EnumerableSet.Bytes32Set;
|
|
||||||
|
|
||||||
function filter(
|
|
||||||
EnumerableSet.Bytes32Set storage set,
|
|
||||||
function(bytes32) internal view returns (bool) include
|
|
||||||
) internal view returns (bytes32[] memory result) {
|
|
||||||
bytes32[] memory selected = new bytes32[](set.length());
|
|
||||||
uint256 amount = 0;
|
|
||||||
|
|
||||||
for (uint256 i = 0; i < set.length(); i++) {
|
|
||||||
if (include(set.at(i))) {
|
|
||||||
selected[amount++] = set.at(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result = new bytes32[](amount);
|
|
||||||
for (uint256 i = 0; i < result.length; i++) {
|
|
||||||
result[i] = selected[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue