Skip to content

Commit

Permalink
lint and fix gha workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramarti committed Mar 23, 2024
1 parent 1f300f8 commit c896aac
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 173 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ jobs:
- name: Run Forge build
run: |
forge --version
forge install OpenZeppelin/openzeppelin-foundry-upgrades --no-git
forge build --force --sizes --skip test --skip script
- name: Run Forge tests
run: |
forge test -vvv --fork-url https://gateway.tenderly.co/public/sepolia --fork-block-number 5196000 --ffi --skip build
forge test -vvv --fork-url https://gateway.tenderly.co/public/sepolia --fork-block-number 5196000
id: forge-test

- name: Run solhint
Expand Down
41 changes: 23 additions & 18 deletions contracts/modules/dispute/DisputeModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ import { ShortStringOps } from "../../utils/ShortStringOps.sol";
/// @title Dispute Module
/// @notice The dispute module acts as an enforcement layer for IP assets that allows raising and resolving disputes
/// through arbitration by judges.
contract DisputeModule is IDisputeModule, BaseModule, GovernableUpgradeable, ReentrancyGuardUpgradeable, AccessControlled, UUPSUpgradeable {
contract DisputeModule is
IDisputeModule,
BaseModule,
GovernableUpgradeable,
ReentrancyGuardUpgradeable,
AccessControlled,
UUPSUpgradeable
{
using EnumerableSet for EnumerableSet.Bytes32Set;

/// @dev Storage for DisputeModule
Expand All @@ -44,7 +51,8 @@ contract DisputeModule is IDisputeModule, BaseModule, GovernableUpgradeable, Ree
}

// keccak256(abi.encode(uint256(keccak256("story-protocol.DisputeModule")) - 1)) & ~bytes32(uint256(0xff));
bytes32 private constant DisputeModuleStorageLocation = 0x682945c2d364b4630e68ffe0854d372acb0c4ff549a1e3dbc6f878bd8da0c800;
bytes32 private constant DisputeModuleStorageLocation =
0x682945c2d364b4630e68ffe0854d372acb0c4ff549a1e3dbc6f878bd8da0c800;

string public constant override name = DISPUTE_MODULE_KEY;

Expand All @@ -59,10 +67,7 @@ contract DisputeModule is IDisputeModule, BaseModule, GovernableUpgradeable, Ree
/// @param _controller The address of the access controller
/// @param _assetRegistry The address of the asset registry
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(
address _controller,
address _assetRegistry
) AccessControlled(_controller, _assetRegistry) {
constructor(address _controller, address _assetRegistry) AccessControlled(_controller, _assetRegistry) {
IP_ASSET_REGISTRY = IIPAssetRegistry(_assetRegistry);
_disableInitializers();
}
Expand Down Expand Up @@ -289,17 +294,18 @@ contract DisputeModule is IDisputeModule, BaseModule, GovernableUpgradeable, Ree
bytes32 linkToDisputeEvidence,
bytes32 targetTag,
bytes32 currentTag
) {
DisputeModuleStorage storage $ = _getDisputeModuleStorage();
return (
$.disputes[disputeId].targetIpId,
$.disputes[disputeId].disputeInitiator,
$.disputes[disputeId].arbitrationPolicy,
$.disputes[disputeId].linkToDisputeEvidence,
$.disputes[disputeId].targetTag,
$.disputes[disputeId].currentTag
);
}
)
{
DisputeModuleStorage storage $ = _getDisputeModuleStorage();
return (
$.disputes[disputeId].targetIpId,
$.disputes[disputeId].disputeInitiator,
$.disputes[disputeId].arbitrationPolicy,
$.disputes[disputeId].linkToDisputeEvidence,
$.disputes[disputeId].targetTag,
$.disputes[disputeId].currentTag
);
}

/// @notice Indicates if a dispute tag is whitelisted
/// @param tag The dispute tag
Expand Down Expand Up @@ -347,5 +353,4 @@ contract DisputeModule is IDisputeModule, BaseModule, GovernableUpgradeable, Ree
$.slot := DisputeModuleStorageLocation
}
}

}
6 changes: 1 addition & 5 deletions contracts/modules/dispute/policies/ArbitrationPolicySP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ contract ArbitrationPolicySP is IArbitrationPolicy, GovernableUpgradeable, UUPSU
/// @param _paymentToken The ERC20 payment token address
/// @param _arbitrationPrice The arbitration price
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(
address _disputeModule,
address _paymentToken,
uint256 _arbitrationPrice
) {
constructor(address _disputeModule, address _paymentToken, uint256 _arbitrationPrice) {
if (_disputeModule == address(0)) revert Errors.ArbitrationPolicySP__ZeroDisputeModule();
if (_paymentToken == address(0)) revert Errors.ArbitrationPolicySP__ZeroPaymentToken();

Expand Down
16 changes: 9 additions & 7 deletions contracts/modules/licensing/LicensingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ import { GovernableUpgradeable } from "../../governance/GovernableUpgradeable.so
/// - Linking IP to its parent
/// - Verifying linking parameters
/// - Verifying policy parameters
contract LicensingModule is AccessControlled, ILicensingModule, BaseModule, ReentrancyGuardUpgradeable, GovernableUpgradeable, UUPSUpgradeable {
contract LicensingModule is
AccessControlled,
ILicensingModule,
BaseModule,
ReentrancyGuardUpgradeable,
GovernableUpgradeable,
UUPSUpgradeable
{
using ERC165Checker for address;
using IPAccountChecker for IIPAccountRegistry;
using EnumerableSet for EnumerableSet.UintSet;
Expand Down Expand Up @@ -621,10 +628,5 @@ contract LicensingModule is AccessControlled, ILicensingModule, BaseModule, Reen

/// @dev Hook to authorize the upgrade according to UUPSUgradeable
/// @param newImplementation The address of the new implementation
function _authorizeUpgrade(address newImplementation)
internal
onlyProtocolAdmin
override
{}

function _authorizeUpgrade(address newImplementation) internal override onlyProtocolAdmin {}
}
16 changes: 12 additions & 4 deletions contracts/modules/royalty/RoyaltyModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ import { BaseModule } from "../BaseModule.sol";
/// @title Story Protocol Royalty Module
/// @notice The Story Protocol royalty module allows to set royalty policies an IP asset and pay royalties as a
/// derivative IP.
contract RoyaltyModule is IRoyaltyModule, GovernableUpgradeable, ReentrancyGuardUpgradeable, BaseModule, UUPSUpgradeable {
contract RoyaltyModule is
IRoyaltyModule,
GovernableUpgradeable,
ReentrancyGuardUpgradeable,
BaseModule,
UUPSUpgradeable
{
using ERC165Checker for address;

/// @dev Storage structure for the RoyaltyModule
Expand All @@ -34,8 +40,9 @@ contract RoyaltyModule is IRoyaltyModule, GovernableUpgradeable, ReentrancyGuard
}

// keccak256(abi.encode(uint256(keccak256("story-protocol.RoyaltyModule")) - 1)) & ~bytes32(uint256(0xff));
bytes32 private constant RoyaltyModuleStorageLocation = 0x98dd2c34f21d19fd1d178ed731f3db3d03e0b4e39f02dbeb040e80c9427a0300;

bytes32 private constant RoyaltyModuleStorageLocation =
0x98dd2c34f21d19fd1d178ed731f3db3d03e0b4e39f02dbeb040e80c9427a0300;

string public constant override name = ROYALTY_MODULE_KEY;

/// @notice Constructor
Expand Down Expand Up @@ -172,7 +179,8 @@ contract RoyaltyModule is IRoyaltyModule, GovernableUpgradeable, ReentrancyGuard
// if the payer does not have a royalty policy set, then the payer is not a derivative ip and does not pay
// royalties the receiver ip can have a zero royalty policy since that could mean it is an ip a root
if (payerRoyaltyPolicy == address(0)) revert Errors.RoyaltyModule__NoRoyaltyPolicySet();
if (!$.isWhitelistedRoyaltyPolicy[payerRoyaltyPolicy]) revert Errors.RoyaltyModule__NotWhitelistedRoyaltyPolicy();
if (!$.isWhitelistedRoyaltyPolicy[payerRoyaltyPolicy])
revert Errors.RoyaltyModule__NotWhitelistedRoyaltyPolicy();

IRoyaltyPolicy(payerRoyaltyPolicy).onRoyaltyPayment(msg.sender, receiverIpId, token, amount);

Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/royalty/policies/RoyaltyPolicyLAP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ contract RoyaltyPolicyLAP is
return splitClone;
}

function _getRoyaltyPolicyLAPStorage() private pure returns(RoyaltyPolicyLAPStorage storage $) {
function _getRoyaltyPolicyLAPStorage() private pure returns (RoyaltyPolicyLAPStorage storage $) {
assembly {
$.slot := RoyaltyPolicyLAPStorageLocation
}
Expand Down
4 changes: 1 addition & 3 deletions test/foundry/mocks/licensing/MockPolicyFrameworkManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ contract MockPolicyFrameworkManager is BasePolicyFrameworkManager {
event MockPolicyAdded(uint256 indexed policyId, MockPolicy policy);

/// @custom:oz-upgrades-unsafe-allow constructor
constructor(
MockPolicyFrameworkConfig memory conf
) BasePolicyFrameworkManager(conf.licensingModule) {
constructor(MockPolicyFrameworkConfig memory conf) BasePolicyFrameworkManager(conf.licensingModule) {
config = conf;
royaltyPolicy = conf.royaltyPolicy;
_getBasePolicyFrameworkManagerStorage().name = conf.name;
Expand Down
17 changes: 2 additions & 15 deletions test/foundry/modules/dispute/DisputeModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,9 @@ contract DisputeModuleTest is BaseTest {
USDC.mint(ipAccount1, 1000 * 10 ** 6);

// second arbitration policy
address impl = address(
new ArbitrationPolicySP(
getDisputeModule(),
address(USDC),
ARBITRATION_PRICE
)
);
address impl = address(new ArbitrationPolicySP(getDisputeModule(), address(USDC), ARBITRATION_PRICE));
arbitrationPolicySP2 = ArbitrationPolicySP(
TestProxyHelper.deployUUPSProxy(
impl,
abi.encodeCall(
ArbitrationPolicySP.initialize, (
getGovernance()
)
)
)
TestProxyHelper.deployUUPSProxy(impl, abi.encodeCall(ArbitrationPolicySP.initialize, (getGovernance())))
);

vm.startPrank(u.admin);
Expand Down
34 changes: 4 additions & 30 deletions test/foundry/modules/royalty/RoyaltyModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,10 @@ contract TestRoyaltyModule is BaseTest {
USDC.mint(ipAccount2, 1000 * 10 ** 6); // 1000 USDC

address impl = address(
new RoyaltyPolicyLAP(
getRoyaltyModule(),
getLicensingModule(),
LIQUID_SPLIT_FACTORY,
LIQUID_SPLIT_MAIN
)
new RoyaltyPolicyLAP(getRoyaltyModule(), getLicensingModule(), LIQUID_SPLIT_FACTORY, LIQUID_SPLIT_MAIN)
);
royaltyPolicyLAP2 = RoyaltyPolicyLAP(
TestProxyHelper.deployUUPSProxy(
impl,
abi.encodeCall(
RoyaltyPolicyLAP.initialize, (
getGovernance()
)
)
)
TestProxyHelper.deployUUPSProxy(impl, abi.encodeCall(RoyaltyPolicyLAP.initialize, (getGovernance())))
);

vm.startPrank(u.admin);
Expand Down Expand Up @@ -136,14 +124,7 @@ contract TestRoyaltyModule is BaseTest {
function test_RoyaltyModule_setLicensingModule_revert_ZeroLicensingModule() public {
address impl = address(new RoyaltyModule());
RoyaltyModule testRoyaltyModule = RoyaltyModule(
TestProxyHelper.deployUUPSProxy(
impl,
abi.encodeCall(
RoyaltyModule.initialize, (
address(getGovernance())
)
)
)
TestProxyHelper.deployUUPSProxy(impl, abi.encodeCall(RoyaltyModule.initialize, (address(getGovernance()))))
);
vm.expectRevert(Errors.RoyaltyModule__ZeroLicensingModule.selector);
vm.prank(u.admin);
Expand All @@ -154,14 +135,7 @@ contract TestRoyaltyModule is BaseTest {
vm.startPrank(u.admin);
address impl = address(new RoyaltyModule());
RoyaltyModule testRoyaltyModule = RoyaltyModule(
TestProxyHelper.deployUUPSProxy(
impl,
abi.encodeCall(
RoyaltyModule.initialize, (
address(getGovernance())
)
)
)
TestProxyHelper.deployUUPSProxy(impl, abi.encodeCall(RoyaltyModule.initialize, (address(getGovernance()))))
);
testRoyaltyModule.setLicensingModule(address(licensingModule));
assertEq(testRoyaltyModule.licensingModule(), address(licensingModule));
Expand Down
18 changes: 2 additions & 16 deletions test/foundry/modules/royalty/RoyaltyPolicyLAP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,9 @@ contract TestRoyaltyPolicyLAP is BaseTest {
}

function test_RoyaltyPolicyLAP_setAncestorsVaultImplementation() public {
address impl = address(
new RoyaltyPolicyLAP(
address(1),
address(2),
address(3),
address(4)
)
);
address impl = address(new RoyaltyPolicyLAP(address(1), address(2), address(3), address(4)));
RoyaltyPolicyLAP royaltyPolicyLAP2 = RoyaltyPolicyLAP(
TestProxyHelper.deployUUPSProxy(
impl,
abi.encodeCall(
RoyaltyPolicyLAP.initialize, (
getGovernance()
)
)
)
TestProxyHelper.deployUUPSProxy(impl, abi.encodeCall(RoyaltyPolicyLAP.initialize, (getGovernance())))
);

vm.startPrank(u.admin);
Expand Down
Loading

0 comments on commit c896aac

Please sign in to comment.