Skip to content

Commit e05269a

Browse files
committed
resolves conflicts
2 parents 56ee981 + 416af86 commit e05269a

14 files changed

Lines changed: 477 additions & 45 deletions

File tree

.github/workflows/publish.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
name: Safient Claims CD
22

33
on:
4-
# Trigger only for the master branch and on release
5-
push:
6-
branches:
7-
- main
4+
# Trigger only on a new release
85
release:
96
types: [created]
107

contracts/SafientMain.sol

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ contract SafientMain is Safes, Claims, Guardians, IArbitrable {
4040
* @param _beneficiary Address of the safe beneficiary
4141
* @param _safeId Id of the safe
4242
* @param _claimType Type of the claim
43-
* @param _signalingPeriod Signaling time window
43+
* @param _signalingPeriod The time window in seconds within which the creator wants to signal the safe in response to a claim on the safe
44+
* @param _DDay The timestamp in unix epoch milliseconds after which the beneficiary can directly claim the safe
4445
* @param _metaEvidence URL of the metaevidence
4546
*/
4647
function createSafe(
4748
address _beneficiary,
4849
string memory _safeId,
4950
Types.ClaimType _claimType,
5051
uint256 _signalingPeriod,
52+
uint256 _DDay,
5153
string calldata _metaEvidence
5254
) external payable returns (bool) {
5355
return
@@ -56,6 +58,7 @@ contract SafientMain is Safes, Claims, Guardians, IArbitrable {
5658
_safeId,
5759
_claimType,
5860
_signalingPeriod,
61+
_DDay,
5962
_metaEvidence
6063
);
6164
}
@@ -65,14 +68,16 @@ contract SafientMain is Safes, Claims, Guardians, IArbitrable {
6568
* @param _creator Address of the safe creator
6669
* @param _safeId Id of the safe
6770
* @param _claimType Type of the claim
68-
* @param _signalingPeriod Signaling time window
71+
* @param _signalingPeriod TThe time window in seconds within which the creator wants to signal the safe in response to a claim on the safe
72+
* @param _DDay The timestamp in unix epoch milliseconds after which the beneficiary can directly claim the safe
6973
* @param _metaEvidence URL of the metaevidence
7074
*/
7175
function syncSafe(
7276
address _creator,
7377
string memory _safeId,
7478
Types.ClaimType _claimType,
7579
uint256 _signalingPeriod,
80+
uint256 _DDay,
7681
string calldata _metaEvidence
7782
) external payable returns (bool) {
7883
return
@@ -81,6 +86,7 @@ contract SafientMain is Safes, Claims, Guardians, IArbitrable {
8186
_safeId,
8287
_claimType,
8388
_signalingPeriod,
89+
_DDay,
8490
_metaEvidence
8591
);
8692
}
@@ -130,8 +136,18 @@ contract SafientMain is Safes, Claims, Guardians, IArbitrable {
130136

131137
safe.claimsCount += 1;
132138
safes[_safeId] = safe;
133-
}
139+
} else if (safe.claimType == Types.ClaimType.DDayBased) {
140+
Types.DDayBasedClaimData memory data = Types.DDayBasedClaimData(
141+
safe.currentOwner,
142+
safe.beneficiary,
143+
safe.dDay
144+
);
145+
146+
_createDDayBasedClaim(_safeId, data);
134147

148+
safe.claimsCount += 1;
149+
safes[_safeId] = safe;
150+
}
135151
return true;
136152
}
137153

@@ -190,17 +206,20 @@ contract SafientMain is Safes, Claims, Guardians, IArbitrable {
190206
/**
191207
* @notice Get the status of a claim
192208
* @param _safeId Id of the safe
193-
* @param _disputeID Id of the claim
209+
* @param _claimId Id of the claim
194210
*/
195-
function getClaimStatus(string memory _safeId, uint256 _disputeID)
211+
function getClaimStatus(string memory _safeId, uint256 _claimId)
196212
external
197213
view
198214
returns (Types.ClaimStatus status)
199215
{
200216
Types.Safe memory safe = safes[_safeId];
201217

202-
if (safe.claimType == Types.ClaimType.ArbitrationBased) {
203-
Types.Claim memory claim = claims[_disputeID];
218+
if (
219+
safe.claimType == Types.ClaimType.ArbitrationBased ||
220+
safe.claimType == Types.ClaimType.DDayBased
221+
) {
222+
Types.Claim memory claim = claims[_claimId];
204223

205224
return claim.status;
206225
} else if (safe.claimType == Types.ClaimType.SignalBased) {
@@ -267,4 +286,16 @@ contract SafientMain is Safes, Claims, Guardians, IArbitrable {
267286
function claimRewards(uint256 _funds) external returns (bool) {
268287
return _claimRewards(_funds);
269288
}
289+
290+
/**
291+
* @notice Update the D-Day
292+
* @param _safeId Id of the safe
293+
* @param _DDay The timestamp in unix epoch milliseconds after which the beneficiary can directly claim the safe
294+
*/
295+
function updateDDay(string memory _safeId, uint256 _DDay)
296+
external
297+
returns (bool)
298+
{
299+
return _updateDDay(_safeId, _DDay);
300+
}
270301
}

contracts/components/Claims.sol

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@ contract Claims {
3838
Types.ArbitrationBasedClaimData memory data
3939
) {
4040
require(data.currentOwner != address(0), "Safe does not exist");
41+
4142
require(
4243
bytes(_safeId).length > 1,
4344
"Should provide ID of the safe on threadDB"
4445
);
46+
4547
require(
4648
msg.sender == data.beneficiary,
4749
"Only beneficiary of the safe can create the claim"
4850
);
51+
4952
require(
5053
data.funds >= data.arbitrationCost,
5154
"Insufficient funds in the safe to pay the arbitration fee"
@@ -58,22 +61,48 @@ contract Claims {
5861
Types.SignalBasedClaimData memory data
5962
) {
6063
require(data.currentOwner != address(0), "Safe does not exist");
64+
6165
require(
6266
bytes(_safeId).length > 1,
6367
"Should provide ID of the safe on threadDB"
6468
);
69+
6570
require(
6671
msg.sender == data.beneficiary,
6772
"Only beneficiary of the safe can create the claim"
6873
);
74+
6975
require(data.endSignalTime == 0, "Safe end signal time should be zero");
7076
_;
7177
}
7278

79+
modifier dDayBasedClaim(
80+
string memory _safeId,
81+
Types.DDayBasedClaimData memory data
82+
) {
83+
require(data.currentOwner != address(0), "Safe does not exist");
84+
85+
require(
86+
bytes(_safeId).length > 1,
87+
"Should provide ID of the safe on threadDB"
88+
);
89+
90+
require(
91+
msg.sender == data.beneficiary,
92+
"Only beneficiary of the safe can create the claim"
93+
);
94+
95+
require(data.dDay != 0, "D day is not set by the safe's current owner");
96+
_;
97+
}
98+
7399
modifier evidenceSubmission(uint256 _disputeID, string calldata _evidence) {
100+
Types.Claim memory claim = claims[_disputeID];
101+
74102
require(_disputeID <= claimsCount, "Claim or Dispute does not exist");
103+
75104
require(bytes(_evidence).length > 1, "Should provide evidence URI");
76-
Types.Claim memory claim = claims[_disputeID];
105+
77106
require(
78107
msg.sender == claim.claimedBy,
79108
"Only creator of the claim can submit the evidence"
@@ -199,6 +228,40 @@ contract Claims {
199228
emit CreateClaim(msg.sender, _safeId, claimsCount);
200229
}
201230

231+
/**
232+
* @notice Create a new D-Day based claim
233+
* @param _safeId Id of the safe
234+
* @param data Includes safe data
235+
*/
236+
function _createDDayBasedClaim(
237+
string memory _safeId,
238+
Types.DDayBasedClaimData memory data
239+
) internal dDayBasedClaim(_safeId, data) {
240+
claimsCount += 1;
241+
242+
if (block.timestamp >= data.dDay) {
243+
claims[claimsCount] = Types.Claim({
244+
id: claimsCount,
245+
claimedBy: msg.sender,
246+
claimType: Types.ClaimType.DDayBased,
247+
metaEvidenceId: 0,
248+
evidenceGroupId: 0,
249+
status: Types.ClaimStatus.Passed
250+
});
251+
} else if (block.timestamp < data.dDay) {
252+
claims[claimsCount] = Types.Claim({
253+
id: claimsCount,
254+
claimedBy: msg.sender,
255+
claimType: Types.ClaimType.DDayBased,
256+
metaEvidenceId: 0,
257+
evidenceGroupId: 0,
258+
status: Types.ClaimStatus.Failed
259+
});
260+
}
261+
262+
emit CreateClaim(msg.sender, _safeId, claimsCount);
263+
}
264+
202265
/**
203266
* @notice Give a ruling on an arbitration based claim
204267
* @param _disputeID Dispute id of the claim

contracts/components/Guardians.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ contract Guardians {
1515

1616
modifier withdrawRewards(uint256 _funds) {
1717
require(guardianRewards[msg.sender] != 0, "No rewards remaining");
18+
1819
require(
1920
guardianRewards[msg.sender] >= _funds,
2021
"Funds requested exceeds the total remaining funds"

0 commit comments

Comments
 (0)