Skip to content

Commit

Permalink
feat: event disput emit (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xShaito authored Aug 8, 2024
1 parent 438de1c commit b705027
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions solidity/contracts/Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ contract Oracle is IOracle {

IResolutionModule(_request.resolutionModule).resolveDispute(_disputeId, _request, _response, _dispute);

emit DisputeResolved(msg.sender, _disputeId, block.number);
emit DisputeResolved(_disputeId, _dispute, msg.sender, block.number);
}

/// @inheritdoc IOracle
Expand All @@ -253,7 +253,7 @@ contract Oracle is IOracle {
disputeStatus[_disputeId] = _status;
IDisputeModule(_request.disputeModule).onDisputeStatusChange(_disputeId, _request, _response, _dispute);

emit DisputeStatusUpdated(_disputeId, _status, block.number);
emit DisputeStatusUpdated(_disputeId, _dispute, _status, block.number);
}

/**
Expand Down
8 changes: 5 additions & 3 deletions solidity/interfaces/IOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,20 @@ interface IOracle {
/**
* @notice Emitted when a dispute's status changes
* @param _disputeId The id of the dispute
* @param _dispute The dispute that is being updated
* @param _status The new dispute status
* @param _blockNumber The block number of the status update
*/
event DisputeStatusUpdated(bytes32 indexed _disputeId, DisputeStatus _status, uint256 _blockNumber);
event DisputeStatusUpdated(bytes32 indexed _disputeId, Dispute _dispute, DisputeStatus _status, uint256 _blockNumber);

/**
* @notice Emitted when a dispute is resolved
* @param _caller The address of the user who resolved the dispute
* @param _disputeId The id of the dispute being resolved
* @param _dispute The dispute that is being updated
* @param _caller The address of the user who resolved the dispute
* @param _blockNumber The block number of the dispute resolution
*/
event DisputeResolved(address indexed _caller, bytes32 indexed _disputeId, uint256 _blockNumber);
event DisputeResolved(bytes32 indexed _disputeId, Dispute _dispute, address indexed _caller, uint256 _blockNumber);

/*///////////////////////////////////////////////////////////////
ERRORS
Expand Down
12 changes: 8 additions & 4 deletions solidity/test/unit/Oracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ contract BaseTest is Test, Helpers {
bytes32 indexed _requestId, bytes32 indexed _responseId, address indexed _caller, uint256 _blockNumber
);
event DisputeEscalated(address indexed _caller, bytes32 indexed _disputeId, uint256 _blockNumber);
event DisputeStatusUpdated(bytes32 indexed _disputeId, IOracle.DisputeStatus _status, uint256 _blockNumber);
event DisputeResolved(address indexed _caller, bytes32 indexed _disputeId, uint256 _blockNumber);
event DisputeStatusUpdated(
bytes32 indexed _disputeId, IOracle.Dispute _dispute, IOracle.DisputeStatus _status, uint256 _blockNumber
);
event DisputeResolved(
bytes32 indexed _disputeId, IOracle.Dispute _dispute, address indexed _caller, uint256 _blockNumber
);

function setUp() public virtual {
oracle = new MockOracle();
Expand Down Expand Up @@ -652,7 +656,7 @@ contract Oracle_Unit_UpdateDisputeStatus is BaseTest {

// Check: emits DisputeStatusUpdated event?
_expectEmit(address(oracle));
emit DisputeStatusUpdated(_disputeId, IOracle.DisputeStatus(_newStatus), block.number);
emit DisputeStatusUpdated(_disputeId, mockDispute, IOracle.DisputeStatus(_newStatus), block.number);

// Test: change the status
vm.prank(address(resolutionModule));
Expand Down Expand Up @@ -747,7 +751,7 @@ contract Oracle_Unit_ResolveDispute is BaseTest {

// Check: emits DisputeResolved event?
_expectEmit(address(oracle));
emit DisputeResolved(address(this), _disputeId, block.number);
emit DisputeResolved(_disputeId, mockDispute, address(this), block.number);

// Test: resolve the dispute
oracle.resolveDispute(mockRequest, mockResponse, mockDispute);
Expand Down

0 comments on commit b705027

Please sign in to comment.