Skip to content

Commit

Permalink
resolves conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
yathishram committed Feb 2, 2022
2 parents 56ee981 + 416af86 commit e05269a
Show file tree
Hide file tree
Showing 14 changed files with 477 additions and 45 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: Safient Claims CD

on:
# Trigger only for the master branch and on release
push:
branches:
- main
# Trigger only on a new release
release:
types: [created]

Expand Down
45 changes: 38 additions & 7 deletions contracts/SafientMain.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ contract SafientMain is Safes, Claims, Guardians, IArbitrable {
* @param _beneficiary Address of the safe beneficiary
* @param _safeId Id of the safe
* @param _claimType Type of the claim
* @param _signalingPeriod Signaling time window
* @param _signalingPeriod The time window in seconds within which the creator wants to signal the safe in response to a claim on the safe
* @param _DDay The timestamp in unix epoch milliseconds after which the beneficiary can directly claim the safe
* @param _metaEvidence URL of the metaevidence
*/
function createSafe(
address _beneficiary,
string memory _safeId,
Types.ClaimType _claimType,
uint256 _signalingPeriod,
uint256 _DDay,
string calldata _metaEvidence
) external payable returns (bool) {
return
Expand All @@ -56,6 +58,7 @@ contract SafientMain is Safes, Claims, Guardians, IArbitrable {
_safeId,
_claimType,
_signalingPeriod,
_DDay,
_metaEvidence
);
}
Expand All @@ -65,14 +68,16 @@ contract SafientMain is Safes, Claims, Guardians, IArbitrable {
* @param _creator Address of the safe creator
* @param _safeId Id of the safe
* @param _claimType Type of the claim
* @param _signalingPeriod Signaling time window
* @param _signalingPeriod TThe time window in seconds within which the creator wants to signal the safe in response to a claim on the safe
* @param _DDay The timestamp in unix epoch milliseconds after which the beneficiary can directly claim the safe
* @param _metaEvidence URL of the metaevidence
*/
function syncSafe(
address _creator,
string memory _safeId,
Types.ClaimType _claimType,
uint256 _signalingPeriod,
uint256 _DDay,
string calldata _metaEvidence
) external payable returns (bool) {
return
Expand All @@ -81,6 +86,7 @@ contract SafientMain is Safes, Claims, Guardians, IArbitrable {
_safeId,
_claimType,
_signalingPeriod,
_DDay,
_metaEvidence
);
}
Expand Down Expand Up @@ -130,8 +136,18 @@ contract SafientMain is Safes, Claims, Guardians, IArbitrable {

safe.claimsCount += 1;
safes[_safeId] = safe;
}
} else if (safe.claimType == Types.ClaimType.DDayBased) {
Types.DDayBasedClaimData memory data = Types.DDayBasedClaimData(
safe.currentOwner,
safe.beneficiary,
safe.dDay
);

_createDDayBasedClaim(_safeId, data);

safe.claimsCount += 1;
safes[_safeId] = safe;
}
return true;
}

Expand Down Expand Up @@ -190,17 +206,20 @@ contract SafientMain is Safes, Claims, Guardians, IArbitrable {
/**
* @notice Get the status of a claim
* @param _safeId Id of the safe
* @param _disputeID Id of the claim
* @param _claimId Id of the claim
*/
function getClaimStatus(string memory _safeId, uint256 _disputeID)
function getClaimStatus(string memory _safeId, uint256 _claimId)
external
view
returns (Types.ClaimStatus status)
{
Types.Safe memory safe = safes[_safeId];

if (safe.claimType == Types.ClaimType.ArbitrationBased) {
Types.Claim memory claim = claims[_disputeID];
if (
safe.claimType == Types.ClaimType.ArbitrationBased ||
safe.claimType == Types.ClaimType.DDayBased
) {
Types.Claim memory claim = claims[_claimId];

return claim.status;
} else if (safe.claimType == Types.ClaimType.SignalBased) {
Expand Down Expand Up @@ -267,4 +286,16 @@ contract SafientMain is Safes, Claims, Guardians, IArbitrable {
function claimRewards(uint256 _funds) external returns (bool) {
return _claimRewards(_funds);
}

/**
* @notice Update the D-Day
* @param _safeId Id of the safe
* @param _DDay The timestamp in unix epoch milliseconds after which the beneficiary can directly claim the safe
*/
function updateDDay(string memory _safeId, uint256 _DDay)
external
returns (bool)
{
return _updateDDay(_safeId, _DDay);
}
}
65 changes: 64 additions & 1 deletion contracts/components/Claims.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ contract Claims {
Types.ArbitrationBasedClaimData memory data
) {
require(data.currentOwner != address(0), "Safe does not exist");

require(
bytes(_safeId).length > 1,
"Should provide ID of the safe on threadDB"
);

require(
msg.sender == data.beneficiary,
"Only beneficiary of the safe can create the claim"
);

require(
data.funds >= data.arbitrationCost,
"Insufficient funds in the safe to pay the arbitration fee"
Expand All @@ -58,22 +61,48 @@ contract Claims {
Types.SignalBasedClaimData memory data
) {
require(data.currentOwner != address(0), "Safe does not exist");

require(
bytes(_safeId).length > 1,
"Should provide ID of the safe on threadDB"
);

require(
msg.sender == data.beneficiary,
"Only beneficiary of the safe can create the claim"
);

require(data.endSignalTime == 0, "Safe end signal time should be zero");
_;
}

modifier dDayBasedClaim(
string memory _safeId,
Types.DDayBasedClaimData memory data
) {
require(data.currentOwner != address(0), "Safe does not exist");

require(
bytes(_safeId).length > 1,
"Should provide ID of the safe on threadDB"
);

require(
msg.sender == data.beneficiary,
"Only beneficiary of the safe can create the claim"
);

require(data.dDay != 0, "D day is not set by the safe's current owner");
_;
}

modifier evidenceSubmission(uint256 _disputeID, string calldata _evidence) {
Types.Claim memory claim = claims[_disputeID];

require(_disputeID <= claimsCount, "Claim or Dispute does not exist");

require(bytes(_evidence).length > 1, "Should provide evidence URI");
Types.Claim memory claim = claims[_disputeID];

require(
msg.sender == claim.claimedBy,
"Only creator of the claim can submit the evidence"
Expand Down Expand Up @@ -199,6 +228,40 @@ contract Claims {
emit CreateClaim(msg.sender, _safeId, claimsCount);
}

/**
* @notice Create a new D-Day based claim
* @param _safeId Id of the safe
* @param data Includes safe data
*/
function _createDDayBasedClaim(
string memory _safeId,
Types.DDayBasedClaimData memory data
) internal dDayBasedClaim(_safeId, data) {
claimsCount += 1;

if (block.timestamp >= data.dDay) {
claims[claimsCount] = Types.Claim({
id: claimsCount,
claimedBy: msg.sender,
claimType: Types.ClaimType.DDayBased,
metaEvidenceId: 0,
evidenceGroupId: 0,
status: Types.ClaimStatus.Passed
});
} else if (block.timestamp < data.dDay) {
claims[claimsCount] = Types.Claim({
id: claimsCount,
claimedBy: msg.sender,
claimType: Types.ClaimType.DDayBased,
metaEvidenceId: 0,
evidenceGroupId: 0,
status: Types.ClaimStatus.Failed
});
}

emit CreateClaim(msg.sender, _safeId, claimsCount);
}

/**
* @notice Give a ruling on an arbitration based claim
* @param _disputeID Dispute id of the claim
Expand Down
1 change: 1 addition & 0 deletions contracts/components/Guardians.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ contract Guardians {

modifier withdrawRewards(uint256 _funds) {
require(guardianRewards[msg.sender] != 0, "No rewards remaining");

require(
guardianRewards[msg.sender] >= _funds,
"Funds requested exceeds the total remaining funds"
Expand Down
Loading

0 comments on commit e05269a

Please sign in to comment.