diff --git a/test/foundry/mocks/access/MockAccessController.sol b/test/foundry/mocks/access/MockAccessController.sol deleted file mode 100644 index 06cbd515..00000000 --- a/test/foundry/mocks/access/MockAccessController.sol +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.23; - -import { IAccessController } from "contracts/interfaces/access/IAccessController.sol"; -import { IIPAccount } from "contracts/interfaces/IIPAccount.sol"; -import { Errors } from "contracts/lib/Errors.sol"; -import { AccessPermission } from "contracts/lib/AccessPermission.sol"; - -contract MockAccessController is IAccessController { - bool public isAllowed = true; - - function setAddresses(address ipAccountRegistry, address moduleRegistry) external {} - - function setAllowed(bool _isAllowed) external { - isAllowed = _isAllowed; - } - - function setGlobalPermission(address signer_, address to_, bytes4 func_, uint8 permission_) external {} - - function setPermission(address, address, address, bytes4, uint8) external pure {} - - function getPermission(address, address, address, bytes4) external pure returns (uint8) { - return 1; - } - - function checkPermission(address ipAccount, address signer, address to, bytes4 func) external view { - if (IIPAccount(payable(ipAccount)).owner() != signer || !isAllowed) { - revert Errors.AccessController__PermissionDenied(ipAccount, signer, to, func); - } - } - - function setBatchPermissions(AccessPermission.Permission[] memory permissions) external {} -} diff --git a/test/foundry/mocks/governance/MockGovernance.sol b/test/foundry/mocks/governance/MockGovernance.sol deleted file mode 100644 index 8ccd0901..00000000 --- a/test/foundry/mocks/governance/MockGovernance.sol +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.23; - -import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol"; - -import { IGovernance } from "../../../../contracts/interfaces/governance/IGovernance.sol"; -import { GovernanceLib } from "../../../../contracts/lib/GovernanceLib.sol"; - -contract MockGovernance is AccessControl, IGovernance { - GovernanceLib.ProtocolState internal state; - - constructor(address admin) { - _grantRole(GovernanceLib.PROTOCOL_ADMIN, admin); - } - - function setState(GovernanceLib.ProtocolState newState) external { - state = newState; - } - - function getState() external view returns (GovernanceLib.ProtocolState) { - return state; - } - - function supportsInterface(bytes4) public pure override returns (bool) { - return true; - } -} diff --git a/test/foundry/mocks/module/MockDisputeModule.sol b/test/foundry/mocks/module/MockDisputeModule.sol deleted file mode 100644 index af37bec7..00000000 --- a/test/foundry/mocks/module/MockDisputeModule.sol +++ /dev/null @@ -1,120 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.23; - -import { IDisputeModule } from "../../../../contracts/interfaces/modules/dispute/IDisputeModule.sol"; -import { IArbitrationPolicy } from "../../../../contracts/interfaces/modules/dispute/policies/IArbitrationPolicy.sol"; -import { BaseModule } from "../../../../contracts/modules/BaseModule.sol"; -import { ShortStringOps } from "../../../../contracts/utils/ShortStringOps.sol"; - -contract MockDisputeModule is BaseModule, IDisputeModule { - bytes32 public constant IN_DISPUTE = bytes32("IN_DISPUTE"); - - string public constant override name = "DISPUTE_MODULE"; - uint256 public disputeCounter; - address public baseArbitrationPolicy; - - mapping(uint256 disputeId => Dispute dispute) public disputes; - mapping(bytes32 tag => bool allowed) public isWhitelistedDisputeTag; - mapping(address arbitrationPolicy => bool allowed) public isWhitelistedArbitrationPolicy; - mapping(address arbitrationPolicy => mapping(address arbitrationRelayer => bool allowed)) - public isWhitelistedArbitrationRelayer; - mapping(address ipId => address arbitrationPolicy) public arbitrationPolicies; - - function whitelistDisputeTag(bytes32 _tag, bool _allowed) external { - isWhitelistedDisputeTag[_tag] = _allowed; - } - - function whitelistArbitrationPolicy(address _arbitrationPolicy, bool _allowed) external { - isWhitelistedArbitrationPolicy[_arbitrationPolicy] = _allowed; - } - - function whitelistArbitrationRelayer( - address _arbitrationPolicy, - address _arbPolicyRelayer, - bool _allowed - ) external { - isWhitelistedArbitrationRelayer[_arbitrationPolicy][_arbPolicyRelayer] = _allowed; - } - - function setBaseArbitrationPolicy(address _arbitrationPolicy) external { - baseArbitrationPolicy = _arbitrationPolicy; - } - - function setArbitrationPolicy(address _ipId, address _arbitrationPolicy) external { - arbitrationPolicies[_ipId] = _arbitrationPolicy; - } - - function raiseDispute( - address _targetIpId, - string memory _linkToDisputeEvidence, - bytes32 _targetTag, - bytes calldata - ) public returns (uint256) { - bytes32 linkToDisputeEvidence = ShortStringOps.stringToBytes32(_linkToDisputeEvidence); - address arbitrationPolicy = arbitrationPolicies[_targetIpId]; - if (!isWhitelistedArbitrationPolicy[arbitrationPolicy]) arbitrationPolicy = baseArbitrationPolicy; - - uint256 disputeId_ = ++disputeCounter; - - disputes[disputeId_] = Dispute({ - targetIpId: _targetIpId, - disputeInitiator: msg.sender, - arbitrationPolicy: arbitrationPolicy, - linkToDisputeEvidence: linkToDisputeEvidence, - targetTag: _targetTag, - currentTag: IN_DISPUTE - }); - - return disputeId_; - } - - function raiseDisputeWithCallback( - address _targetIpId, - string memory _linkToDisputeEvidence, - bytes32 _targetTag, - bytes calldata _data - ) external returns (uint256 disputeId_) { - disputeId_ = raiseDispute(_targetIpId, _linkToDisputeEvidence, _targetTag, _data); - - address arbitrationPolicy = arbitrationPolicies[_targetIpId]; - if (!isWhitelistedArbitrationPolicy[arbitrationPolicy]) arbitrationPolicy = baseArbitrationPolicy; - IArbitrationPolicy(arbitrationPolicy).onRaiseDispute(msg.sender, _data); - } - - function setDisputeJudgement(uint256 _disputeId, bool _decision, bytes calldata) public { - Dispute memory dispute = disputes[_disputeId]; - disputes[_disputeId].currentTag = _decision ? dispute.targetTag : bytes32(0); - } - - function setDisputeJudgementWithCallback(uint256 _disputeId, bool _decision, bytes calldata _data) external { - setDisputeJudgement(_disputeId, _decision, _data); - - Dispute memory dispute = disputes[_disputeId]; - IArbitrationPolicy(dispute.arbitrationPolicy).onDisputeJudgement(_disputeId, _decision, _data); - } - - function cancelDispute(uint256 _disputeId, bytes calldata) public { - disputes[_disputeId].currentTag = bytes32(0); - } - - function cancelDisputeWithCallback(uint256 _disputeId, bytes calldata _data) external { - cancelDispute(_disputeId, _data); - - Dispute memory dispute = disputes[_disputeId]; - IArbitrationPolicy(dispute.arbitrationPolicy).onDisputeCancel(msg.sender, _disputeId, _data); - } - - function resolveDispute(uint256 _disputeId) external { - disputes[_disputeId].currentTag = bytes32(0); - } - - function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { - return interfaceId == type(IDisputeModule).interfaceId || super.supportsInterface(interfaceId); - } - - // These methods are not really used in the mock. They are just here to satisfy the interface. - - function isIpTagged(address) external pure returns (bool) { - return false; - } -} diff --git a/test/foundry/mocks/module/MockRoyaltyModule.sol b/test/foundry/mocks/module/MockRoyaltyModule.sol deleted file mode 100644 index ef8d3474..00000000 --- a/test/foundry/mocks/module/MockRoyaltyModule.sol +++ /dev/null @@ -1,87 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.23; - -import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; - -import { IRoyaltyModule } from "../../../../contracts/interfaces/modules/royalty/IRoyaltyModule.sol"; -import { BaseModule } from "../../../../contracts/modules/BaseModule.sol"; - -contract MockRoyaltyModule is BaseModule, IRoyaltyModule { - string public constant override name = "ROYALTY_MODULE"; - - address public LICENSING_MODULE; - - address public DISPUTE_MODULE; - - mapping(address royaltyPolicy => bool allowed) public isWhitelistedRoyaltyPolicy; - - mapping(address token => bool) public isWhitelistedRoyaltyToken; - - mapping(address ipId => address royaltyPolicy) public royaltyPolicies; - - constructor() {} - - function setDisputeModule(address _disputeModule) external { - DISPUTE_MODULE = _disputeModule; - } - - function setLicensingModule(address _licensingModule) external { - LICENSING_MODULE = _licensingModule; - } - - function licensingModule() external view override returns (address) { - return LICENSING_MODULE; - } - - function disputeModule() external view override returns (address) { - return DISPUTE_MODULE; - } - - function whitelistRoyaltyPolicy(address _royaltyPolicy, bool _allowed) external { - isWhitelistedRoyaltyPolicy[_royaltyPolicy] = _allowed; - } - - function whitelistRoyaltyToken(address _token, bool _allowed) external { - isWhitelistedRoyaltyToken[_token] = _allowed; - } - - function onLicenseMinting( - address _ipId, - address _royaltyPolicy, - bytes calldata _licenseData, - bytes calldata _externalData - ) external { - // address royaltyPolicyIpId = royaltyPolicies[_ipId]; - // IRoyaltyPolicy(_royaltyPolicy).onLicenseMinting(_ipId, _licenseData, _externalData); - } - - function onLinkToParents( - address _ipId, - address _royaltyPolicy, - address[] calldata _parentIpIds, - bytes[] memory _licenseData, - bytes calldata _externalData - ) external { - royaltyPolicies[_ipId] = _royaltyPolicy; - // IRoyaltyPolicy(_royaltyPolicy).onLinkToParents(_ipId, _parentIpIds, _licenseData, _externalData); - } - - function payRoyaltyOnBehalf(address _receiverIpId, address _payerIpId, address _token, uint256 _amount) external { - address payerRoyaltyPolicy = royaltyPolicies[_payerIpId]; - // IRoyaltyPolicy(payerRoyaltyPolicy).onRoyaltyPayment(msg.sender, _receiverIpId, _token, _amount); - } - - function payLicenseMintingFee(address receiverIpId, address payerAddress, address token, uint256 amount) external {} - - function payLicenseMintingFee( - address receiverIpId, - address payerAddress, - address licenseRoyaltyPolicy, - address token, - uint256 amount - ) external {} - - function supportsInterface(bytes4 interfaceId) public view virtual override(BaseModule, IERC165) returns (bool) { - return interfaceId == type(IRoyaltyModule).interfaceId || super.supportsInterface(interfaceId); - } -} diff --git a/test/foundry/mocks/policy/MockArbitrationPolicy.sol b/test/foundry/mocks/policy/MockArbitrationPolicy.sol deleted file mode 100644 index c79e3ed7..00000000 --- a/test/foundry/mocks/policy/MockArbitrationPolicy.sol +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.23; - -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 { - address public DISPUTE_MODULE; - address public PAYMENT_TOKEN; - uint256 public ARBITRATION_PRICE; - - constructor(address disputeModule, address paymentToken, uint256 arbitrationPrice) { - DISPUTE_MODULE = disputeModule; - PAYMENT_TOKEN = paymentToken; - ARBITRATION_PRICE = arbitrationPrice; - } - - function setDisputeModule(address disputeModule) external { - DISPUTE_MODULE = disputeModule; - } - - function setPaymentToken(address paymentToken) external { - PAYMENT_TOKEN = paymentToken; - } - - function setArbitrationPrice(uint256 arbitrationPrice) external { - ARBITRATION_PRICE = arbitrationPrice; - } - - function onRaiseDispute(address _caller, bytes calldata) external { - IERC20(PAYMENT_TOKEN).transferFrom(_caller, address(this), ARBITRATION_PRICE); - } - - function onDisputeJudgement(uint256 _disputeId, bool _decision, bytes calldata) external { - if (_decision) { - (, address disputeInitiator, , , , ) = IDisputeModule(DISPUTE_MODULE).disputes(_disputeId); - IERC20(PAYMENT_TOKEN).transfer(disputeInitiator, ARBITRATION_PRICE); - } - } - - function onDisputeCancel(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); - } -} diff --git a/test/foundry/mocks/registry/MockModuleRegistry.sol b/test/foundry/mocks/registry/MockModuleRegistry.sol deleted file mode 100644 index 9ce3929e..00000000 --- a/test/foundry/mocks/registry/MockModuleRegistry.sol +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-License-Identifier: BUSDL-1.1 -pragma solidity 0.8.23; - -import { IModuleRegistry } from "../../../../contracts/interfaces/registries/IModuleRegistry.sol"; -import { MODULE_TYPE_DEFAULT } from "../../../../contracts/lib/modules/Module.sol"; - -contract MockModuleRegistry is IModuleRegistry { - mapping(string => address) public modules; - mapping(address => string) public moduleTypes; - mapping(string => bytes4) public allModuleTypes; - - function registerModuleType(string memory name, bytes4 interfaceId) external override { - allModuleTypes[name] = interfaceId; - } - - function removeModuleType(string memory name) external override { - delete allModuleTypes[name]; - } - - function registerModule(string memory name, address moduleAddress) external { - _registerModule(name, moduleAddress, MODULE_TYPE_DEFAULT); - } - - function registerModule(string memory name, address moduleAddress, string memory moduleType) external { - _registerModule(name, moduleAddress, moduleType); - } - - function removeModule(string memory name) external { - address module = modules[name]; - delete modules[name]; - delete moduleTypes[module]; - - emit ModuleRemoved(name, module); - } - - function getModule(string memory name) external view returns (address) { - return modules[name]; - } - - function isRegistered(address moduleAddress) external view returns (bool) { - return bytes(moduleTypes[moduleAddress]).length > 0; - } - - function getModuleType(address moduleAddress) external view returns (string memory) { - return moduleTypes[moduleAddress]; - } - - function getModuleTypeInterfaceId(string memory moduleType) external view returns (bytes4) { - return allModuleTypes[moduleType]; - } - - function _registerModule(string memory name, address moduleAddress, string memory moduleType) internal { - modules[name] = moduleAddress; - moduleTypes[moduleAddress] = moduleType; - } -} diff --git a/test/foundry/mocks/token/MockUSDC.sol b/test/foundry/mocks/token/MockUSDC.sol deleted file mode 100644 index 331e095f..00000000 --- a/test/foundry/mocks/token/MockUSDC.sol +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.23; - -import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; - -contract MockUSDC is ERC20 { - constructor() ERC20("MockUSDC", "MUSDC") {} - - function decimals() public view virtual override returns (uint8) { - return 6; - } - - function mint(address to, uint256 amount) external { - _mint(to, amount); - } - - function burn(address from, uint256 amount) external { - _burn(from, amount); - } -}