Skip to content

Commit

Permalink
Remove arbitration policy SP (storyprotocol#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spablob authored Sep 26, 2024
1 parent 541d33b commit 3b44a0b
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 534 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ abi:
@$(call generate_abi,"LicenseToken",".")
@$(call generate_abi,"AccessController","./access")
@$(call generate_abi,"DisputeModule","./modules/dispute")
@$(call generate_abi,"ArbitrationPolicySP","./modules/dispute/policies")
@$(call generate_abi,"LicensingModule","./modules/licensing")
@$(call generate_abi,"PILicenseTemplate","./modules/licensing")
@$(call generate_abi,"CoreMetadataModule","./modules/metadata")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ pragma solidity 0.8.26;

/// @title Arbitration Policy Interface
interface IArbitrationPolicy {
/// @notice Allows governance set the treasury address
/// @dev Enforced to be only callable by the governance protocol admin
/// @param newTreasury The new address of the treasury
function setTreasury(address newTreasury) external;

/// @notice Executes custom logic on raising dispute.
/// @dev Enforced to be only callable by the DisputeModule.
/// @param caller Address of the caller
Expand All @@ -34,7 +29,4 @@ interface IArbitrationPolicy {
/// @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 Returns the treasury address
function treasury() external view returns (address);
}
19 changes: 0 additions & 19 deletions contracts/lib/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -414,25 +414,6 @@ library Errors {
/// @notice Provided parent dispute has not been resolved.
error DisputeModule__ParentDisputeNotResolved();

////////////////////////////////////////////////////////////////////////////
// ArbitrationPolicy SP //
////////////////////////////////////////////////////////////////////////////

/// @notice Zero address provided for Access Manager in initializer.
error ArbitrationPolicySP__ZeroAccessManager();

/// @notice Zero address provided for Dispute Module.
error ArbitrationPolicySP__ZeroDisputeModule();

/// @notice Zero address provided for Treasury.
error ArbitrationPolicySP__ZeroTreasury();

/// @notice Zero address provided for Payment Token.
error ArbitrationPolicySP__ZeroPaymentToken();

/// @notice Caller is not the Dispute Module.
error ArbitrationPolicySP__NotDisputeModule();

////////////////////////////////////////////////////////////////////////////
// Royalty Module //
////////////////////////////////////////////////////////////////////////////
Expand Down
141 changes: 0 additions & 141 deletions contracts/modules/dispute/policies/ArbitrationPolicySP.sol

This file was deleted.

32 changes: 0 additions & 32 deletions script/foundry/utils/DeployHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { RoyaltyPolicyLAP } from "contracts/modules/royalty/policies/LAP/Royalty
import { RoyaltyPolicyLRP } from "contracts/modules/royalty/policies/LRP/RoyaltyPolicyLRP.sol";
import { VaultController } from "contracts/modules/royalty/policies/VaultController.sol";
import { DisputeModule } from "contracts/modules/dispute/DisputeModule.sol";
import { ArbitrationPolicySP } from "contracts/modules/dispute/policies/ArbitrationPolicySP.sol";
import { MODULE_TYPE_HOOK } from "contracts/lib/modules/Module.sol";
import { IModule } from "contracts/interfaces/modules/base/IModule.sol";
import { IHookModule } from "contracts/interfaces/modules/base/IHookModule.sol";
Expand Down Expand Up @@ -90,7 +89,6 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
CoreMetadataViewModule internal coreMetadataViewModule;

// Policy
ArbitrationPolicySP internal arbitrationPolicySP;
RoyaltyPolicyLAP internal royaltyPolicyLAP;
RoyaltyPolicyLRP internal royaltyPolicyLRP;
UpgradeableBeacon internal ipRoyaltyVaultBeacon;
Expand Down Expand Up @@ -511,27 +509,6 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
// Story-specific Non-Core Contracts
//

_predeploy("ArbitrationPolicySP");
impl = address(new ArbitrationPolicySP(address(disputeModule), address(erc20), ARBITRATION_PRICE));
arbitrationPolicySP = ArbitrationPolicySP(
TestProxyHelper.deployUUPSProxy(
create3Deployer,
_getSalt(type(ArbitrationPolicySP).name),
impl,
abi.encodeCall(ArbitrationPolicySP.initialize, (address(protocolAccessManager), TREASURY_ADDRESS))
)
);
require(
_getDeployedAddress(type(ArbitrationPolicySP).name) == address(arbitrationPolicySP),
"Deploy: Arbitration Policy Address Mismatch"
);
require(
_loadProxyImpl(address(arbitrationPolicySP)) == impl,
"ArbitrationPolicySP Proxy Implementation Mismatch"
);
impl = address(0);
_postdeploy("ArbitrationPolicySP", address(arbitrationPolicySP));

_predeploy("RoyaltyPolicyLAP");
impl = address(new RoyaltyPolicyLAP(
address(royaltyModule),
Expand Down Expand Up @@ -718,11 +695,7 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
ipRoyaltyVaultBeacon.transferOwnership(address(royaltyModule));

// Dispute Module and SP Dispute Policy
address arbitrationRelayer = relayer;
disputeModule.whitelistDisputeTag("PLAGIARISM", true);
disputeModule.whitelistArbitrationPolicy(address(arbitrationPolicySP), true);
disputeModule.whitelistArbitrationRelayer(address(arbitrationPolicySP), arbitrationRelayer, true);
disputeModule.setBaseArbitrationPolicy(address(arbitrationPolicySP));

// Core Metadata Module
coreMetadataViewModule.updateCoreMetadataModule();
Expand Down Expand Up @@ -754,11 +727,6 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
protocolAccessManager.setTargetFunctionRole(address(licenseToken), selectors, ProtocolAdmin.UPGRADER_ROLE);
protocolAccessManager.setTargetFunctionRole(address(accessController), selectors, ProtocolAdmin.UPGRADER_ROLE);
protocolAccessManager.setTargetFunctionRole(address(disputeModule), selectors, ProtocolAdmin.UPGRADER_ROLE);
protocolAccessManager.setTargetFunctionRole(
address(arbitrationPolicySP),
selectors,
ProtocolAdmin.UPGRADER_ROLE
);
protocolAccessManager.setTargetFunctionRole(address(licensingModule), selectors, ProtocolAdmin.UPGRADER_ROLE);
protocolAccessManager.setTargetFunctionRole(address(royaltyPolicyLAP), selectors, ProtocolAdmin.UPGRADER_ROLE);
protocolAccessManager.setTargetFunctionRole(address(royaltyPolicyLRP), selectors, ProtocolAdmin.UPGRADER_ROLE);
Expand Down
2 changes: 1 addition & 1 deletion test/foundry/invariants/DisputeModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ contract DisputeInvariants is BaseTest {

mockToken.mint(address(harness), 1000 ether);
vm.startPrank(address(harness));
mockToken.approve(address(arbitrationPolicySP), type(uint256).max);
mockToken.approve(address(mockArbitrationPolicy), type(uint256).max);
vm.stopPrank();
mockNFT.transferFrom(address(this), address(harness), 300);
mockNFT.transferFrom(address(this), address(harness), 301);
Expand Down
53 changes: 53 additions & 0 deletions test/foundry/mocks/dispute/MockArbitrationPolicy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.26;

import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import { IDisputeModule } from "../../../../contracts/interfaces/modules/dispute/IDisputeModule.sol";
import { IArbitrationPolicy } from "../../../../contracts/interfaces/modules/dispute/policies/IArbitrationPolicy.sol";

contract MockArbitrationPolicy is IArbitrationPolicy {
using SafeERC20 for IERC20;

address public immutable DISPUTE_MODULE;
address public immutable PAYMENT_TOKEN;
uint256 public immutable ARBITRATION_PRICE;

address treasury;

error MockArbitrationPolicy__NotDisputeModule();

/// @notice Restricts the calls to the DisputeModule
modifier onlyDisputeModule() {
if (msg.sender != DISPUTE_MODULE) revert MockArbitrationPolicy__NotDisputeModule();
_;
}

constructor(address disputeModule, address paymentToken, uint256 arbitrationPrice) {
DISPUTE_MODULE = disputeModule;
PAYMENT_TOKEN = paymentToken;
ARBITRATION_PRICE = arbitrationPrice;
}

function setTreasury(address newTreasury) external {
treasury = newTreasury;
}

function onRaiseDispute(address caller, bytes calldata data) external onlyDisputeModule {
IERC20(PAYMENT_TOKEN).safeTransferFrom(caller, address(this), ARBITRATION_PRICE);
}

function onDisputeJudgement(uint256 disputeId, bool decision, bytes calldata data) external onlyDisputeModule {
if (decision) {
(, address disputeInitiator, , , , , ) = IDisputeModule(DISPUTE_MODULE).disputes(disputeId);
IERC20(PAYMENT_TOKEN).safeTransfer(disputeInitiator, ARBITRATION_PRICE);
} else {
IERC20(PAYMENT_TOKEN).safeTransfer(treasury, ARBITRATION_PRICE);
}
}

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

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

0 comments on commit 3b44a0b

Please sign in to comment.