Skip to content

Commit 0ddea54

Browse files
fix: applied requested changes
1 parent 36f45eb commit 0ddea54

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

contracts/disputes/DisputeManager.sol

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,15 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa
154154
_;
155155
}
156156

157+
modifier onlyPendingDispute(bytes32 _disputeID) {
158+
require(isDisputeCreated(_disputeID), "Dispute does not exist");
159+
require(
160+
disputes[_disputeID].status == IDisputeManager.DisputeStatus.Pending,
161+
"Dispute must be pending"
162+
);
163+
_;
164+
}
165+
157166
// -- Functions --
158167

159168
/**
@@ -290,7 +299,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa
290299
* @param _disputeID True if dispute already exists
291300
*/
292301
function isDisputeCreated(bytes32 _disputeID) public view override returns (bool) {
293-
return disputes[_disputeID].fisherman != address(0);
302+
return disputes[_disputeID].status != DisputeStatus.Null;
294303
}
295304

296305
/**
@@ -556,15 +565,6 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa
556565
return disputeID;
557566
}
558567

559-
modifier onlyPendingDispute(bytes32 _disputeID) {
560-
require(isDisputeCreated(_disputeID), "Dispute does not exist");
561-
require(
562-
disputes[_disputeID].status == IDisputeManager.DisputeStatus.Pending,
563-
"Dispute must be pending"
564-
);
565-
_;
566-
}
567-
568568
/**
569569
* @dev The arbitrator accepts a dispute as being valid.
570570
* This function will revert if the indexer is not slashable, whether because it does not have
@@ -647,16 +647,14 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa
647647
{
648648
Dispute storage dispute = disputes[_disputeID];
649649

650-
// store dispute status
651-
dispute.status = IDisputeManager.DisputeStatus.Drawn;
652-
653650
// Return deposit to the fisherman
654651
TokenUtils.pushTokens(graphToken(), dispute.fisherman, dispute.deposit);
655652

656-
// Resolve the conflicting dispute if any
657-
if (_isDisputeInConflict(dispute)) {
658-
drawDispute(dispute.relatedDisputeID);
659-
}
653+
// resolve related dispute if any
654+
_resolveDisputeInConflict(dispute);
655+
656+
// store dispute status
657+
dispute.status = IDisputeManager.DisputeStatus.Drawn;
660658

661659
emit DisputeDrawn(_disputeID, dispute.indexer, dispute.fisherman, dispute.deposit);
662660
}
@@ -693,15 +691,15 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa
693691
* @param _dispute Dispute
694692
* @return True if resolved
695693
*/
696-
// function _resolveDisputeInConflict(Dispute memory _dispute) private returns (bool) {
697-
// if (_isDisputeInConflict(_dispute)) {
698-
// bytes32 relatedDisputeID = _dispute.relatedDisputeID;
699-
// Dispute storage relatedDispute = disputes[relatedDisputeID];
700-
// delete disputes[relatedDisputeID];
701-
// return true;
702-
// }
703-
// return false;
704-
// }
694+
function _resolveDisputeInConflict(Dispute memory _dispute) private returns (bool) {
695+
if (_isDisputeInConflict(_dispute)) {
696+
bytes32 relatedDisputeID = _dispute.relatedDisputeID;
697+
Dispute storage relatedDispute = disputes[relatedDisputeID];
698+
relatedDispute.status = IDisputeManager.DisputeStatus.Drawn;
699+
return true;
700+
}
701+
return false;
702+
}
705703

706704
/**
707705
* @dev Pull deposit from submitter account.

contracts/disputes/IDisputeManager.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface IDisputeManager {
1313
}
1414

1515
enum DisputeStatus {
16+
Null,
1617
Accepted,
1718
Rejected,
1819
Drawn,

test/disputes/query.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ describe('DisputeManager:Query', async () => {
537537
await disputeManager.connect(arbitrator.signer).drawDispute(dID1)
538538
// Check
539539
const relatedDispute = await disputeManager.disputes(dID2)
540-
expect(relatedDispute.status).not.eq(3) // 3 = DisputeStatus.Pending
540+
expect(relatedDispute.status).not.eq(4) // 4 = DisputeStatus.Pending
541541
})
542542
})
543543
})

0 commit comments

Comments
 (0)