83 lines
2.2 KiB
Solidity
Raw Normal View History

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./Marketplace.sol";
import "./Proofs.sol";
import "./Collateral.sol";
contract Storage is Collateral, Marketplace {
uint256 public collateralAmount;
2022-02-09 14:17:23 +01:00
uint256 public slashMisses;
uint256 public slashPercentage;
mapping(bytes32 => bool) private contractFinished;
constructor(
IERC20 token,
uint256 _proofPeriod,
uint256 _proofTimeout,
2022-03-10 10:19:21 +01:00
uint8 _proofDowntime,
uint256 _collateralAmount,
2022-02-09 14:17:23 +01:00
uint256 _slashMisses,
uint256 _slashPercentage
2022-03-10 10:19:21 +01:00
)
Marketplace(
token,
_collateralAmount,
_proofPeriod,
_proofTimeout,
_proofDowntime
)
2022-03-10 10:19:21 +01:00
{
collateralAmount = _collateralAmount;
slashMisses = _slashMisses;
slashPercentage = _slashPercentage;
2021-11-02 12:45:09 +01:00
}
function getRequest(bytes32 id) public view returns (Request memory) {
return _request(id);
}
2021-11-04 10:19:23 +01:00
function finishContract(bytes32 id) public {
require(_host(id) != address(0), "Contract not started");
require(!contractFinished[id], "Contract already finished");
require(block.timestamp > proofEnd(id), "Contract has not ended yet");
contractFinished[id] = true;
require(
token.transfer(_host(id), _request(id).ask.maxPrice),
"Payment failed"
);
}
2022-02-09 14:17:23 +01:00
function missingProofs(bytes32 contractId) public view returns (uint256) {
return _missed(contractId);
}
function isProofRequired(bytes32 contractId) public view returns (bool) {
return _isProofRequired(contractId);
}
2021-10-18 14:55:59 +02:00
function willProofBeRequired(bytes32 contractId) public view returns (bool) {
return _willProofBeRequired(contractId);
}
2022-03-10 13:04:46 +01:00
function getChallenge(bytes32 contractId) public view returns (bytes32) {
return _getChallenge(contractId);
}
function getPointer(bytes32 id) public view returns (uint8) {
return _getPointer(id);
}
function submitProof(bytes32 contractId, bytes calldata proof) public {
_submitProof(contractId, proof);
2021-10-19 09:37:03 +02:00
}
function markProofAsMissing(bytes32 contractId, uint256 period) public {
_markProofAsMissing(contractId, period);
if (_missed(contractId) % slashMisses == 0) {
_slash(_host(contractId), slashPercentage);
}
2021-10-19 09:37:03 +02:00
}
}