[Marketplace] Move `slotId()` to `Requests` library
Co-authored-by: Eric Mastro <eric.mastro@gmail.com>
This commit is contained in:
parent
07e9043b30
commit
6aa76257f8
|
@ -82,7 +82,7 @@ contract Marketplace is Collateral, Proofs, StateRetrieval {
|
|||
Request storage request = _request(requestId);
|
||||
require(slotIndex < request.ask.slots, "Invalid slot");
|
||||
|
||||
SlotId slotId = _toSlotId(requestId, slotIndex);
|
||||
SlotId slotId = Requests.slotId(requestId, slotIndex);
|
||||
Slot storage slot = slots[slotId];
|
||||
require(slot.host == address(0), "Slot already filled");
|
||||
|
||||
|
@ -399,13 +399,6 @@ contract Marketplace is Collateral, Proofs, StateRetrieval {
|
|||
return s == RequestState.New || s == RequestState.Started;
|
||||
}
|
||||
|
||||
function _toSlotId(
|
||||
RequestId requestId,
|
||||
uint256 slotIndex
|
||||
) internal pure returns (SlotId) {
|
||||
return SlotId.wrap(keccak256(abi.encode(requestId, slotIndex)));
|
||||
}
|
||||
|
||||
function _notEqual(RequestId a, uint256 b) internal pure returns (bool) {
|
||||
return RequestId.unwrap(a) != bytes32(b);
|
||||
}
|
||||
|
|
|
@ -42,6 +42,13 @@ library Requests {
|
|||
return RequestId.wrap(keccak256(abi.encode(request)));
|
||||
}
|
||||
|
||||
function slotId(
|
||||
RequestId requestId,
|
||||
uint256 slotIndex
|
||||
) internal pure returns (SlotId) {
|
||||
return SlotId.wrap(keccak256(abi.encode(requestId, slotIndex)));
|
||||
}
|
||||
|
||||
function toRequestIds(
|
||||
bytes32[] memory ids
|
||||
) internal pure returns (RequestId[] memory result) {
|
||||
|
|
Loading…
Reference in New Issue