Skip to content

Commit

Permalink
feat: dispute module changes status (#223)
Browse files Browse the repository at this point in the history
* feat: emit events before external calls

* feat: allow dispute module to change the status of a dispute
  • Loading branch information
gas1cent authored Oct 16, 2023
1 parent 73ef904 commit a5f05d5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions solidity/contracts/Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ contract Oracle is IOracle {
revert Oracle_CannotTamperParticipant();
}

emit ResponseDisputed(msg.sender, _responseId, _disputeId);

if (_dispute.status != DisputeStatus.Active) {
_request.disputeModule.onDisputeStatusChange(_disputeId, _dispute);
}

emit ResponseDisputed(msg.sender, _responseId, _disputeId);
}

/// @inheritdoc IOracle
Expand All @@ -277,12 +277,12 @@ contract Oracle is IOracle {
// Notify the dispute module about the escalation
_request.disputeModule.disputeEscalated(_disputeId);

emit DisputeEscalated(msg.sender, _disputeId);

if (address(_request.resolutionModule) != address(0)) {
// Initiate the resolution
_request.resolutionModule.startResolution(_disputeId);
}

emit DisputeEscalated(msg.sender, _disputeId);
}

/// @inheritdoc IOracle
Expand All @@ -309,8 +309,8 @@ contract Oracle is IOracle {
function updateDisputeStatus(bytes32 _disputeId, DisputeStatus _status) external {
Dispute storage _dispute = _disputes[_disputeId];
Request memory _request = _requests[_dispute.requestId];
if (msg.sender != address(_request.resolutionModule)) {
revert Oracle_NotResolutionModule(msg.sender);
if (msg.sender != address(_request.disputeModule) && msg.sender != address(_request.resolutionModule)) {
revert Oracle_NotDisputeOrResolutionModule(msg.sender);
}
_dispute.status = _status;
_request.disputeModule.onDisputeStatusChange(_disputeId, _dispute);
Expand Down
2 changes: 1 addition & 1 deletion solidity/interfaces/IOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ interface IOracle {
* @notice Thrown when an unauthorized caller is trying to change a dispute's status
* @param _caller The caller of the function
*/
error Oracle_NotResolutionModule(address _caller);
error Oracle_NotDisputeOrResolutionModule(address _caller);

/**
* @notice Thrown when an unauthorized caller is trying to propose a response
Expand Down
2 changes: 1 addition & 1 deletion solidity/test/unit/Oracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ contract Unit_UpdateDisputeStatus is BaseTest {
_mockRequest();

// Check: revert?
vm.expectRevert(abi.encodeWithSelector(IOracle.Oracle_NotResolutionModule.selector, proposer));
vm.expectRevert(abi.encodeWithSelector(IOracle.Oracle_NotDisputeOrResolutionModule.selector, proposer));

// Test: try to update the status from an EOA
vm.prank(proposer);
Expand Down

0 comments on commit a5f05d5

Please sign in to comment.