mirror of
https://github.com/status-im/dagger-contracts.git
synced 2025-01-14 08:37:19 +00:00
add back proof end mappings
This commit is contained in:
parent
cfb70897f8
commit
2478e36aba
@ -75,7 +75,7 @@ contract Marketplace is Collateral, Proofs {
|
|||||||
ProofId proofId = _toProofId(slotId);
|
ProofId proofId = _toProofId(slotId);
|
||||||
_expectProofs(
|
_expectProofs(
|
||||||
proofId,
|
proofId,
|
||||||
requestId,
|
_toEndId(requestId),
|
||||||
request.ask.proofProbability);
|
request.ask.proofProbability);
|
||||||
_submitProof(proofId, proof);
|
_submitProof(proofId, proof);
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ contract Marketplace is Collateral, Proofs {
|
|||||||
context.state == RequestState.Started) {
|
context.state == RequestState.Started) {
|
||||||
|
|
||||||
context.state = RequestState.Failed;
|
context.state = RequestState.Failed;
|
||||||
_setProofEnd(requestId, block.timestamp - 1);
|
_setProofEnd(_toEndId(requestId), block.timestamp - 1);
|
||||||
context.endsAt = block.timestamp - 1;
|
context.endsAt = block.timestamp - 1;
|
||||||
emit RequestFailed(requestId);
|
emit RequestFailed(requestId);
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ contract Marketplace is Collateral, Proofs {
|
|||||||
return _timeout();
|
return _timeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
function proofEnd(bytes32 slotId) public view returns (uint256) {
|
function proofEnd(SlotId slotId) public view returns (uint256) {
|
||||||
Slot memory slot = _slot(slotId);
|
Slot memory slot = _slot(slotId);
|
||||||
uint256 end = _end(_toEndId(slot.requestId));
|
uint256 end = _end(_toEndId(slot.requestId));
|
||||||
if (_slotAcceptsProofs(slotId)) {
|
if (_slotAcceptsProofs(slotId)) {
|
||||||
@ -337,12 +337,14 @@ contract Marketplace is Collateral, Proofs {
|
|||||||
return ProofId.wrap(SlotId.unwrap(slotId));
|
return ProofId.wrap(SlotId.unwrap(slotId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _toEndId(RequestId requestId) internal pure returns (EndId) {
|
||||||
|
return EndId.wrap(RequestId.unwrap(requestId));
|
||||||
|
}
|
||||||
|
|
||||||
function _notEqual(RequestId a, uint256 b) internal pure returns (bool) {
|
function _notEqual(RequestId a, uint256 b) internal pure returns (bool) {
|
||||||
return RequestId.unwrap(a) != bytes32(b);
|
return RequestId.unwrap(a) != bytes32(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct Request {
|
struct Request {
|
||||||
address client;
|
address client;
|
||||||
Ask ask;
|
Ask ask;
|
||||||
|
@ -3,6 +3,7 @@ pragma solidity ^0.8.8;
|
|||||||
|
|
||||||
contract Proofs {
|
contract Proofs {
|
||||||
type ProofId is bytes32;
|
type ProofId is bytes32;
|
||||||
|
type EndId is bytes32;
|
||||||
|
|
||||||
uint256 private immutable period;
|
uint256 private immutable period;
|
||||||
uint256 private immutable timeout;
|
uint256 private immutable timeout;
|
||||||
@ -37,7 +38,7 @@ contract Proofs {
|
|||||||
return timeout;
|
return timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _end(ProofId id) internal view returns (uint256) {
|
function _end(EndId endId) internal view returns (uint256) {
|
||||||
uint256 end = ends[endId];
|
uint256 end = ends[endId];
|
||||||
require(end > 0, "Proof ending doesn't exist");
|
require(end > 0, "Proof ending doesn't exist");
|
||||||
return ends[endId];
|
return ends[endId];
|
||||||
@ -45,7 +46,7 @@ contract Proofs {
|
|||||||
|
|
||||||
function _endId(ProofId id) internal view returns (EndId) {
|
function _endId(ProofId id) internal view returns (EndId) {
|
||||||
EndId endId = idEnds[id];
|
EndId endId = idEnds[id];
|
||||||
require(endId > 0, "endId for given id doesn't exist");
|
require(EndId.unwrap(endId) > 0, "endId for given id doesn't exist");
|
||||||
return endId;
|
return endId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +188,7 @@ contract Proofs {
|
|||||||
/// @dev Can only be set once
|
/// @dev Can only be set once
|
||||||
/// @param endId the endId of the proofs to extend (typically a request id).
|
/// @param endId the endId of the proofs to extend (typically a request id).
|
||||||
/// @param ending the new end time (in seconds)
|
/// @param ending the new end time (in seconds)
|
||||||
function _setProofEnd(bytes32 endId, uint256 ending) internal {
|
function _setProofEnd(EndId endId, uint256 ending) internal {
|
||||||
// TODO: create type aliases for id and endId so that _end() can return
|
// TODO: create type aliases for id and endId so that _end() can return
|
||||||
// EndId storage and we don't need to replicate the below require here
|
// EndId storage and we don't need to replicate the below require here
|
||||||
require (ends[endId] == 0 || ending < block.timestamp, "End exists or must be past");
|
require (ends[endId] == 0 || ending < block.timestamp, "End exists or must be past");
|
||||||
|
@ -24,7 +24,7 @@ contract TestProofs is Proofs {
|
|||||||
return _timeout();
|
return _timeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
function end(ProofId id) public view returns (uint256) {
|
function end(EndId id) public view returns (uint256) {
|
||||||
return _end(id);
|
return _end(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ contract TestProofs is Proofs {
|
|||||||
_markProofAsMissing(id, _period);
|
_markProofAsMissing(id, _period);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setProofEnd(bytes32 id, uint256 ending) public {
|
function setProofEnd(EndId id, uint256 ending) public {
|
||||||
_setProofEnd(id, ending);
|
_setProofEnd(id, ending);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user