Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispute modifications #51

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions contracts/interfaces/modules/dispute/IDisputeModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ interface IDisputeModule {
function cancelDispute(uint256 disputeId, bytes calldata data) external;

/// @notice Resolves a dispute after it has been judged
/// @param disputeId The dispute id
function resolveDispute(uint256 disputeId) external;
/// @param disputeId The dispute
/// @param data The data to resolve the dispute
function resolveDispute(uint256 disputeId, bytes calldata data) external;

/// @notice Returns true if the ipId is tagged with any tag (meaning at least one dispute went through)
/// @param ipId The ipId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ interface IArbitrationPolicy {
/// @param data The arbitrary data used to cancel the dispute
function onDisputeCancel(address caller, uint256 disputeId, bytes calldata data) external;

/// @notice Executes custom logic on resolving dispute
/// @dev Enforced to be only callable by the DisputeModule
/// @param caller Address of the caller
/// @param disputeId The dispute id
/// @param data The arbitrary data used to resolve the dispute
function onResolveDispute(address caller, uint256 disputeId, bytes calldata data) external;

/// @notice Allows governance address to withdraw
/// @dev Enforced to be only callable by the governance protocol admin.
function governanceWithdraw() external;
Expand Down
5 changes: 4 additions & 1 deletion contracts/modules/dispute/DisputeModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ contract DisputeModule is

/// @notice Resolves a dispute after it has been judged
/// @param disputeId The dispute id
function resolveDispute(uint256 disputeId) external {
/// @param data The data to resolve the dispute
function resolveDispute(uint256 disputeId, bytes calldata data) external {
DisputeModuleStorage storage $ = _getDisputeModuleStorage();
Dispute memory dispute = $.disputes[disputeId];

Expand All @@ -251,6 +252,8 @@ contract DisputeModule is
$.successfulDisputesPerIp[dispute.targetIpId]--;
$.disputes[disputeId].currentTag = bytes32(0);

IArbitrationPolicy(dispute.arbitrationPolicy).onResolveDispute(msg.sender, disputeId, data);

emit DisputeResolved(disputeId);
}

Expand Down
19 changes: 13 additions & 6 deletions contracts/modules/dispute/policies/ArbitrationPolicySP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ contract ArbitrationPolicySP is IArbitrationPolicy, GovernableUpgradeable, UUPSU
__UUPSUpgradeable_init();
}

/// @notice Executes custom logic on raising dispute.
/// @dev Enforced to be only callable by the DisputeModule.
/// @notice Executes custom logic on raising dispute
/// @dev Enforced to be only callable by the DisputeModule
/// @param caller Address of the caller
/// @param data The arbitrary data used to raise the dispute
function onRaiseDispute(address caller, bytes calldata data) external onlyDisputeModule {
// requires that the caller has given approve() to this contract
IERC20(PAYMENT_TOKEN).safeTransferFrom(caller, address(this), ARBITRATION_PRICE);
}

/// @notice Executes custom logic on disputing judgement.
/// @dev Enforced to be only callable by the DisputeModule.
/// @notice Executes custom logic on disputing judgement
/// @dev Enforced to be only callable by the DisputeModule
/// @param disputeId The dispute id
/// @param decision The decision of the dispute
/// @param data The arbitrary data used to set the dispute judgement
Expand All @@ -74,13 +74,20 @@ contract ArbitrationPolicySP is IArbitrationPolicy, GovernableUpgradeable, UUPSU
}
}

/// @notice Executes custom logic on disputing cancel.
/// @dev Enforced to be only callable by the DisputeModule.
/// @notice Executes custom logic on disputing cancel
/// @dev Enforced to be only callable by the DisputeModule
/// @param caller Address of the caller
/// @param disputeId The dispute id
/// @param data The arbitrary data used to cancel the dispute
function onDisputeCancel(address caller, uint256 disputeId, bytes calldata data) external onlyDisputeModule {}

/// @notice Executes custom logic on resolving dispute
/// @dev Enforced to be only callable by the DisputeModule
/// @param caller Address of the caller
/// @param disputeId The dispute id
/// @param data The arbitrary data used to resolve the dispute
function onResolveDispute(address caller, uint256 disputeId, bytes calldata data) external onlyDisputeModule {}

/// @notice Allows governance address to withdraw
/// @dev Enforced to be only callable by the governance protocol admin.
function governanceWithdraw() external onlyProtocolAdmin {
Expand Down
2 changes: 1 addition & 1 deletion test/foundry/integration/flows/disputes/Disputes.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ contract Flows_Integration_Disputes is BaseIntegration {
uint256 disputeId = _disputeIp(u.bob, ipAcct[1]);

vm.prank(u.bob);
disputeModule.resolveDispute(disputeId);
disputeModule.resolveDispute(disputeId, "");

assertEq(licenseToken.balanceOf(u.carl), 0);

Expand Down
2 changes: 1 addition & 1 deletion test/foundry/mocks/module/MockDisputeModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ contract MockDisputeModule is BaseModule, IDisputeModule {
IArbitrationPolicy(dispute.arbitrationPolicy).onDisputeCancel(msg.sender, _disputeId, _data);
}

function resolveDispute(uint256 _disputeId) external {
function resolveDispute(uint256 _disputeId, bytes calldata _data) external {
disputes[_disputeId].currentTag = bytes32(0);
}

Expand Down
2 changes: 2 additions & 0 deletions test/foundry/mocks/policy/MockArbitrationPolicy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ contract MockArbitrationPolicy is IArbitrationPolicy {

function onDisputeCancel(address caller, uint256 disputeId, bytes calldata data) external {}

function onResolveDispute(address caller, uint256 disputeId, bytes calldata data) external {}

function governanceWithdraw() external {
uint256 balance = IERC20(PAYMENT_TOKEN).balanceOf(address(this));
IERC20(PAYMENT_TOKEN).transfer(msg.sender, balance);
Expand Down
8 changes: 4 additions & 4 deletions test/foundry/modules/dispute/DisputeModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ contract DisputeModuleTest is BaseTest {

function test_DisputeModule_resolveDispute_revert_NotDisputeInitiator() public {
vm.expectRevert(Errors.DisputeModule__NotDisputeInitiator.selector);
disputeModule.resolveDispute(1);
disputeModule.resolveDispute(1, "");
}

function test_DisputeModule_resolveDispute_revert_NotAbleToResolve() public {
Expand All @@ -432,7 +432,7 @@ contract DisputeModuleTest is BaseTest {

vm.startPrank(ipAccount1);
vm.expectRevert(Errors.DisputeModule__NotAbleToResolve.selector);
disputeModule.resolveDispute(1);
disputeModule.resolveDispute(1, "");
}

function test_DisputeModule_resolveDispute() public {
Expand All @@ -454,7 +454,7 @@ contract DisputeModuleTest is BaseTest {
vm.expectEmit(true, true, true, true, address(disputeModule));
emit DisputeResolved(1);

disputeModule.resolveDispute(1);
disputeModule.resolveDispute(1, "");

(, , , , , bytes32 currentTagAfterResolve) = disputeModule.disputes(1);

Expand All @@ -464,7 +464,7 @@ contract DisputeModuleTest is BaseTest {

// Cant resolve again
vm.expectRevert(Errors.DisputeModule__NotAbleToResolve.selector);
disputeModule.resolveDispute(1);
disputeModule.resolveDispute(1, "");
vm.stopPrank();
}

Expand Down
Loading
Loading