Skip to content

Commit

Permalink
Enforcing Lints to Enhance Code Standard (storyprotocol#86)
Browse files Browse the repository at this point in the history
* fix: makefile fork url

* fix: test utils import

* fix: pkg dep and bumps

* config: lint, pkg, husky changes

* lint: prettier lint run

* nit: config fix

* lint: solhint/prettier linting fixes

* fix: pkg installs
  • Loading branch information
jdubpark authored Feb 8, 2024
1 parent 8e229ec commit 8925a5d
Show file tree
Hide file tree
Showing 97 changed files with 1,162 additions and 2,011 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = false
max_line_length = 120

[*.sol]
indent_size = 4

[*.{js,ts}]
indent_size = 2

[*.{adoc,md}]
max_line_length = 0
6 changes: 6 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint:sol:fix
# recheck
yarn lint:sol
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"plugins": ["prettier-plugin-solidity"],
"useTabs": false,
"printWidth": 120,
"trailingComma": "es5",
Expand All @@ -12,6 +13,12 @@
"options": {
"tabWidth": 2
}
},
{
"files": "*.sol",
"options": {
"singleQuote": false
}
}
]
}
13 changes: 13 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
norpc: true,
testCommand: 'npm test',
compileCommand: 'npm run compile',
skipFiles: ['mocks'],
providerOptions: {
default_balance_ether: '10000000000000000000000000',
},
mocha: {
fgrep: '[skip-on-coverage]',
invert: true,
},
};
8 changes: 5 additions & 3 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
"plugins": ["prettier"],
"rules": {
"code-complexity": ["error", 8],
"compiler-version": ["error", ">=0.8.19"],
"compiler-version": ["error", ">=0.8.23"],
"const-name-snakecase": "off",
"no-empty-blocks": "off",
"constructor-syntax": "error",
"func-visibility": ["error", { "ignoreConstructors": true }],
"modifier-name-mixedcase": "error",
"max-line-length": ["error", 120],
"not-rely-on-time": "off",
"reason-string": ["warn", { "maxLength": 64 }],
Expand All @@ -18,6 +17,9 @@
"avoid-low-level-calls": "off",
"no-global-import": "error",
"prettier/prettier": "error",
"private-vars-leading-underscore": "off"
"private-vars-leading-underscore": "off",
"func-name-mixedcase": "off",
"var-name-mixedcase": "off",
"modifier-name-mixedcase": "off"
}
}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ format:
# generate html report from lcov.info (ignore "line ... has branchcov but no linecov data" error)
coverage:
mkdir -p coverage
forge coverage --report lcov --fork-url https://rpc.ankr.com/eth --fork-block-number 19042069
lcov --remove lcov.info -o coverage/lcov.info 'test/*' 'script/*' 'contracts/mocks/*' --rc branch_coverage=1
forge coverage --report lcov --fork-url https://rpc.ankr.com/eth_sepolia --fork-block-number 5196000
lcov --remove lcov.info -o coverage/lcov.info 'test/*' 'script/*' --rc branch_coverage=1
genhtml coverage/lcov.info -o coverage --rc branch_coverage=1 --ignore-errors category

abi:
Expand Down
2 changes: 1 addition & 1 deletion contracts/AccessController.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
// See https://github.com/storyprotocol/protocol-contracts/blob/main/StoryProtocol-AlphaTestingAgreement-17942166.3.pdf
pragma solidity ^0.8.21;
pragma solidity ^0.8.23;

import { IModuleRegistry } from "./interfaces/registries/IModuleRegistry.sol";
import { IAccessController } from "./interfaces/IAccessController.sol";
Expand Down
3 changes: 1 addition & 2 deletions contracts/interfaces/governance/IGovernable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// See https://github.com/storyprotocol/protocol-contracts/blob/main/StoryProtocol-AlphaTestingAgreement-17942166.3.pdf
pragma solidity ^0.8.23;


/// @title IGovernable
/// @notice This is the interface for the Lens Protocol main governance functions.
interface IGovernable {
Expand All @@ -13,6 +12,6 @@ interface IGovernable {
/// @param newGovernance The address of the new governance
function setGovernance(address newGovernance) external;
/// @notice Returns the current governance address
/// @return The address of the current governance
/// @return The address of the current governance
function getGovernance() external view returns (address);
}
1 change: 0 additions & 1 deletion contracts/interfaces/modules/base/IModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity ^0.8.23;

/// @notice Module Interface
interface IModule {

/// @notice Returns the string identifier associated with the module.
function name() external returns (string memory);
}
8 changes: 5 additions & 3 deletions contracts/interfaces/modules/dispute/IDisputeModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface IDisputeModule {
/// @notice Event emitted when the base arbitration policy is set
/// @param arbitrationPolicy The address of the arbitration policy
event DefaultArbitrationPolicyUpdated(address arbitrationPolicy);

/// @notice Event emitted when an arbitration policy is set for an ipId
/// @param ipId The ipId address
/// @param arbitrationPolicy The address of the arbitration policy
Expand Down Expand Up @@ -107,7 +107,9 @@ interface IDisputeModule {

/// @notice Gets the dispute struct characteristics
/// @param disputeId The dispute id
function disputes(uint256 disputeId)
function disputes(
uint256 disputeId
)
external
view
returns (
Expand All @@ -118,4 +120,4 @@ interface IDisputeModule {
bytes32 targetTag, // The target tag of the dispute
bytes32 currentTag // The current tag of the dispute
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ interface IArbitrationPolicy {
event GovernanceWithdrew(uint256 amount);

/// @notice Executes custom logic on raise dispute
/// @param caller Address of the caller
/// @param data The data to raise the dispute
/// @param caller Address of the caller
/// @param data The data to raise the dispute
function onRaiseDispute(address caller, bytes calldata data) external;

/// @notice Executes custom logic on dispute judgement
Expand Down
6 changes: 1 addition & 5 deletions contracts/interfaces/modules/licensing/ILicensingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ interface ILicensingModule is IModule {
/// @param childIpId The id of the child IP to be linked
/// @param minRoyalty The minimum derivative rev share that the child wants from its descendants. The value is
/// overriden by the `derivativesRevShare` value of the linking licenses.
function linkIpToParents(
uint256[] calldata licenseIds,
address childIpId,
uint32 minRoyalty
) external;
function linkIpToParents(uint256[] calldata licenseIds, address childIpId, uint32 minRoyalty) external;

///
/// Getters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.23;

import { IERC165 } from "@openzeppelin/contracts/interfaces/IERC165.sol";

import { Licensing } from "../../../lib/Licensing.sol";

/// @title IPolicyFrameworkManager
/// @notice Interface to define a policy framework contract, that will
/// register itself into the LicenseRegistry to format policy into the LicenseRegistry
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.23;

import { Licensing } from "../../../lib/Licensing.sol";
import { IPolicyFrameworkManager } from "../../../interfaces/modules/licensing/IPolicyFrameworkManager.sol";

/// @notice Licensing parameters for the UML standard
Expand Down Expand Up @@ -44,7 +42,8 @@ struct UMLPolicy {
/// so we can verify compatibility when inheriting new policies
/// @param commercial Whether or not there is a policy that allows commercial use
/// @param derivatives Whether or not there is a policy that allows derivatives
/// @param derivativesReciprocal Whether or not there is a policy that requires derivatives to be licensed under the same terms
/// @param derivativesReciprocal Whether or not there is a policy that requires derivatives
/// to be licensed under the same terms
/// @param lastPolicyId The last policy ID that was added to the IP
/// @param territoriesAcc The last hash of the territories array
/// @param distributionChannelsAcc The last hash of the distributionChannels array
Expand All @@ -70,7 +69,7 @@ interface IUMLPolicyFrameworkManager is IPolicyFrameworkManager {
/// @param policyId The ID of the policy to fetch
/// @return policy The UMLPolicy struct
function getPolicy(uint256 policyId) external view returns (UMLPolicy memory policy);

/// @notice gets the aggregation data for inherited policies.
function getAggregator(address ipId) external view returns (UMLAggregator memory rights);
}
9 changes: 7 additions & 2 deletions contracts/interfaces/modules/royalty/IRoyaltyModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,17 @@ interface IRoyaltyModule is IModule {
/// @param royaltyPolicy The address of the royalty policy
/// @param parentIpIds The parent ipIds
/// @param data The data to initialize the policy
function setRoyaltyPolicy(address ipId, address royaltyPolicy, address[] calldata parentIpIds, bytes calldata data) external;
function setRoyaltyPolicy(
address ipId,
address royaltyPolicy,
address[] calldata parentIpIds,
bytes calldata data
) external;

/// @notice Allows a sender to to pay royalties on behalf of an ipId
/// @param receiverIpId The ipId that receives the royalties
/// @param payerIpId The ipId that pays the royalties
/// @param token The token to use to pay the royalties
/// @param amount The amount to pay
function payRoyaltyOnBehalf(address receiverIpId, address payerIpId, address token, uint256 amount) external;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ interface ILSClaimer {
/// @param withdrawETH Indicates if the claimer wants to withdraw ETH
/// @param tokens The ERC20 tokens to withdraw
function claim(address[] calldata path, address claimerIpId, bool withdrawETH, ERC20[] calldata tokens) external;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface ILiquidSplitClone {
/// @notice Distributes funds to the accounts in the LiquidSplitClone contract
/// @param token The token to distribute
/// @param accounts The accounts to distribute to
/// @param distributorAddress The distributor address
/// @param distributorAddress The distributor address
function distributeFunds(address token, address[] calldata accounts, address distributorAddress) external;

/// @notice Transfers rnft tokens
Expand All @@ -15,13 +15,7 @@ interface ILiquidSplitClone {
/// @param id The token id
/// @param amount The amount to transfer
/// @param data Custom data
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;

function balanceOf(address account, uint256 id) external view returns (uint256);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ pragma solidity ^0.8.23;
interface ILiquidSplitFactory {
/// @notice Creates a new LiquidSplitClone contract
/// @param accounts The accounts to initialize the LiquidSplitClone contract with
/// @param initAllocations The initial allocations
/// @param initAllocations The initial allocations
/// @param _distributorFee The distributor fee
/// @param owner The owner of the LiquidSplitClone contract
/// @param owner The owner of the LiquidSplitClone contract
function createLiquidSplitClone(
address[] calldata accounts,
uint32[] calldata initAllocations,
uint32 _distributorFee,
address owner
) external returns (address);
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;

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

/// @title LiquidSplitMain interface
interface ILiquidSplitMain {
/// @notice Allows an account to withdraw their accrued and distributed pending amount
/// @param account The account to withdraw from
/// @param withdrawETH The amount of ETH to withdraw
/// @param tokens The tokens to withdraw
function withdraw(
address account,
uint256 withdrawETH,
ERC20[] calldata tokens
) external;
function withdraw(address account, uint256 withdrawETH, ERC20[] calldata tokens) external;

/// @notice Gets the ETH balance of an account
/// @param account The account to get the ETH balance of
Expand All @@ -23,4 +19,4 @@ interface ILiquidSplitMain {
/// @param account The account to get the ERC20 balance of
/// @param token The token to get the balance of
function getERC20Balance(address account, ERC20 token) external view returns (uint256);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.23;

/// @title RoyaltyPolicy interface
interface IRoyaltyPolicy {
interface IRoyaltyPolicy {
/// @notice Initializes the royalty policy
/// @param ipId The ipId
/// @param parentsIpIds The parent ipIds
Expand All @@ -19,4 +19,4 @@ interface IRoyaltyPolicy {
/// @notice Returns the minimum royalty the IPAccount expects from descendants
/// @param ipId The ipId
function minRoyaltyFromDescendants(address ipId) external view returns (uint32);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ interface IRoyaltyPolicyLS is IRoyaltyPolicy {
/// claimer The claimer address
/// royaltyStack The royalty stack
/// minRoyalty The min royalty
function royaltyData(address ipId) external view returns (address splitClone, address claimer, uint32 royaltyStack, uint32 minRoyalty);
function royaltyData(
address ipId
) external view returns (address splitClone, address claimer, uint32 royaltyStack, uint32 minRoyalty);

/// @notice Distributes funds to the accounts in the LiquidSplitClone contract
/// @param ipId The ipId
Expand Down
15 changes: 3 additions & 12 deletions contracts/interfaces/registries/IIPAccountRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,15 @@ interface IIPAccountRegistry {
/// @param chainId_ The chain ID where the token contract deployed
/// @param tokenContract_ The address of the token contract to be associated with the IP Account
/// @param tokenId_ The ID of the token to be associated with the IP Account
/// @return The address of the newly created IP Account
function registerIpAccount(
uint256 chainId_,
address tokenContract_,
uint256 tokenId_
) external returns (address);
/// @return The address of the newly created IP Account
function registerIpAccount(uint256 chainId_, address tokenContract_, uint256 tokenId_) external returns (address);

/// @notice Returns the IPAccount address for the given NFT token
/// @param chainId_ The chain ID where the token contract deployed
/// @param tokenContract_ The address of the token contract associated with the IP Account
/// @param tokenId_ The ID of the token associated with the IP Account
/// @return The address of the IP Account associated with the given NFT token
function ipAccount(
uint256 chainId_,
address tokenContract_,
uint256 tokenId_
) external view returns (address);

function ipAccount(uint256 chainId_, address tokenContract_, uint256 tokenId_) external view returns (address);

/// @notice Returns the IPAccount implementation address
/// @return The address of the IPAccount implementation
Expand Down
Loading

0 comments on commit 8925a5d

Please sign in to comment.