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

chore(lint): cleanup config and affiliate flows #1140

Merged
merged 1 commit into from
Oct 27, 2023
Merged
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
10 changes: 0 additions & 10 deletions contracts/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,3 @@ parserOptions:
project: "./contracts/tsconfig.json"
plugins:
- "@typescript-eslint"
rules:
"@typescript-eslint/no-floating-promises":
- error
- ignoreIIFE: true
ignoreVoid: true
"@typescript-eslint/no-inferrable-types": "off"
"@typescript-eslint/no-unused-vars":
- error
- argsIgnorePattern: "_"
varsIgnorePattern: "_"
1 change: 1 addition & 0 deletions contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ yarn-error.log*
.DS_Store
/.idea
test*.svg
lcov.info

# broadcasts
!/broadcast
Expand Down
5 changes: 2 additions & 3 deletions contracts/.lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"*.{js,json,md,sol,ts,yml}": [
"prettier --config ./.prettierrc.yml --write"
]
"*.{js,json,md,ts,yml}": ["prettier --config ./.prettierrc.yml --write"],
"*.{sol}": ["forge fmt"]
}
2 changes: 2 additions & 0 deletions contracts/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
# files
*.env
*.log
*.sol
.pnp.*
coverage.json
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.DS_Store
23 changes: 0 additions & 23 deletions contracts/.prettierrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,3 @@ singleQuote: false
tabWidth: 2
trailingComma: "all"
useTabs: false

plugins:
- prettier-plugin-solidity

overrides:
- files: "**/*.t.sol"
rules:
max-state-count": "off"
state-visibility": "off"
max-line-length": "off"
options:
tabWidth: 4
- files: "*.sol"
rules:
compiler-version: "0.8.16"
options:
tabWidth: 4
- files: "*.ts"
options:
importOrder: ["<THIRD_PARTY_MODULES>", "^[./]"]
importOrderParserPlugins: ["importAssertions", "typescript"]
importOrderSeparation: true
importOrderSortSpecifiers: true
7 changes: 0 additions & 7 deletions contracts/.solcover.js

This file was deleted.

5 changes: 3 additions & 2 deletions contracts/.solhint.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"plugins": ["prettier"],
"extends": "solhint:recommended",
"rules": {
"avoid-low-level-calls": "off",
"code-complexity": ["error", 12],
"compiler-version": ["error", ">=0.8.16"],
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["warn", 200],
"no-console": "off",
"no-empty-blocks": "off",
"not-rely-on-time": "off",
"private-vars-leading-underscore": "warn",
"reason-string": ["warn", { "maxLength": 64 }],
"one-contract-per-file": "off"
}
Expand Down
2 changes: 0 additions & 2 deletions contracts/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"editor.formatOnSave": true,
"solidity.formatter": "prettier",
"solidity.packageDefaultDependenciesContractsDirectory": "src",
"solidity.packageDefaultDependenciesDirectory": "lib",
"solidity.remappings": ["./remappings.txt"],
"solidity.defaultCompiler": "remoteFile",
"files.exclude": {
"**/.git": true,
"**/.svn": true,
Expand Down
8 changes: 6 additions & 2 deletions contracts/foundry.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Full reference https://github.com/foundry-rs/foundry/tree/master/config

[profile.default]
auto_detect_solc = true
auto_detect_solc = true
allow_paths = ["../node_modules", "lib"]
bytecode_hash = "none"
force = false
Expand All @@ -23,4 +23,8 @@ verbosity = 1
[rpc_endpoints]
mainnet = "${MAINNET_RPC_URL}"
goerli = "${GOERLI_RPC_URL}"
optimism = "${OPTIMISM_RPC_URL}"
optimism = "${OPTIMISM_RPC_URL}"

[fmt]
number_underscore = "thousands"
wrap_comments = true
9 changes: 4 additions & 5 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
"shx": "^0.3.4",
"solhint": "^3.6.2",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.8.2",
"solmate": "^6.2.0",
"ts-node": "^10.9.1",
"typechain": "^8.3.1",
Expand All @@ -104,14 +103,14 @@
"build": "hardhat compile && pnpm tsc -p tsconfig.build.json && rollup -c && pnpm copy:contracts",
"build:forge": "forge build",
"clean": "rimraf cache out dist src/typechain src/abi",
"copy:contracts": "copyfiles -u 1 ./src/**/*.sol ./src/*.sol ./contracts",
"copy:contracts": "copyfiles -u 1 ./src/**/*.sol ./src/*.sol ./contracts",
"docs": "hardhat dodoc",
"lint": "pnpm lint:sol && pnpm prettier:check",
"lint:sol": "solhint -w 60 \"./{src,test/protocol,test/marketplace}/**/*.sol\"",
"lint:sol": "forge fmt --check && solhint \"./{src,test/protocol,test/marketplace}/**/*.sol\"",
"prebuild": "pnpm clean",
"prepublish": "pnpm build",
"prettier": "prettier --config \"./.prettierrc.yml\" --write \"**/*.{json,md,sol,yml}\"",
"prettier:check": "prettier --config \"./.prettierrc.yml\" --check \"**/*.{json,md,sol,yml}\"",
"prettier": "prettier --config \"./.prettierrc.yml\" --write \"**/*.{json,md,ts,yml}\"",
"prettier:check": "prettier --config \"./.prettierrc.yml\" --check \"**/*.{json,md,ts,yml}\"",
"slither": "slither ./src",
"test": "pnpm test:hardhat && pnpm test:forge",
"test:forge": "forge test",
Expand Down
16 changes: 12 additions & 4 deletions contracts/src/marketplace/BatchOrderTypehashRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.8.17;

// Shared errors
import { MerkleProofTooLarge } from "./errors/SharedErrors.sol";
import {MerkleProofTooLarge} from "./errors/SharedErrors.sol";

/**
* @title BatchOrderTypehashRegistry
Expand All @@ -22,9 +22,17 @@ contract BatchOrderTypehashRegistry {

/**
* @dev It looks like this for each height
* height == 1: BatchOrder(Maker[2] tree)Maker(uint8 quoteType,uint256 globalNonce,uint256 subsetNonce,uint256 orderNonce,uint256 strategyId,uint8 collectionType,address collection,address currency,address signer,uint256 startTime,uint256 endTime,uint256 price,uint256[] itemIds,uint256[] amounts,bytes additionalParameters)
* height == 2: BatchOrder(Maker[2][2] tree)Maker(uint8 quoteType,uint256 globalNonce,uint256 subsetNonce,uint256 orderNonce,uint256 strategyId,uint8 collectionType,address collection,address currency,address signer,uint256 startTime,uint256 endTime,uint256 price,uint256[] itemIds,uint256[] amounts,bytes additionalParameters)
* height == n: BatchOrder(Maker[2]...[2] tree)Maker(uint8 quoteType,uint256 globalNonce,uint256 subsetNonce,uint256 orderNonce,uint256 strategyId,uint8 collectionType,address collection,address currency,address signer,uint256 startTime,uint256 endTime,uint256 price,uint256[] itemIds,uint256[] amounts,bytes additionalParameters)
* height == 1: BatchOrder(Maker[2] tree)Maker(uint8 quoteType,uint256 globalNonce,uint256 subsetNonce,uint256
* orderNonce,uint256 strategyId,uint8 collectionType,address collection,address currency,address signer,uint256
* startTime,uint256 endTime,uint256 price,uint256[] itemIds,uint256[] amounts,bytes additionalParameters)
* height == 2: BatchOrder(Maker[2][2] tree)Maker(uint8 quoteType,uint256 globalNonce,uint256
* subsetNonce,uint256 orderNonce,uint256 strategyId,uint8 collectionType,address collection,address
* currency,address signer,uint256 startTime,uint256 endTime,uint256 price,uint256[] itemIds,uint256[] amounts,bytes
* additionalParameters)
* height == n: BatchOrder(Maker[2]...[2] tree)Maker(uint8 quoteType,uint256 globalNonce,uint256
* subsetNonce,uint256 orderNonce,uint256 strategyId,uint8 collectionType,address collection,address
* currency,address signer,uint256 startTime,uint256 endTime,uint256 price,uint256[] itemIds,uint256[] amounts,bytes
* additionalParameters)
*/
function _getBatchOrderTypehash(uint256 height) internal pure returns (bytes32 typehash) {
if (height == 1) {
Expand Down
25 changes: 12 additions & 13 deletions contracts/src/marketplace/CreatorFeeManagerWithRebates.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
pragma solidity 0.8.17;

// LooksRare unopinionated libraries
import { IERC2981 } from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC2981.sol";
import {IERC2981} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC2981.sol";

// Interfaces
import { ICreatorFeeManager } from "./interfaces/ICreatorFeeManager.sol";
import { IRoyaltyFeeRegistry } from "./interfaces/IRoyaltyFeeRegistry.sol";
import {ICreatorFeeManager} from "./interfaces/ICreatorFeeManager.sol";
import {IRoyaltyFeeRegistry} from "./interfaces/IRoyaltyFeeRegistry.sol";

// Constants
import { ONE_HUNDRED_PERCENT_IN_BP } from "./constants/NumericConstants.sol";
import {ONE_HUNDRED_PERCENT_IN_BP} from "./constants/NumericConstants.sol";

/**
* @title CreatorFeeManagerWithRebates
Expand Down Expand Up @@ -38,22 +38,21 @@ contract CreatorFeeManagerWithRebates is ICreatorFeeManager {
/**
* @inheritdoc ICreatorFeeManager
*/
function viewCreatorFeeInfo(
address collection,
uint256 price,
uint256[] memory itemIds
) external view returns (address creator, uint256 creatorFeeAmount) {
function viewCreatorFeeInfo(address collection, uint256 price, uint256[] memory itemIds)
external
view
returns (address creator, uint256 creatorFeeAmount)
{
// Check if there is a royalty info in the system
(creator, ) = royaltyFeeRegistry.royaltyInfo(collection, price);
(creator,) = royaltyFeeRegistry.royaltyInfo(collection, price);

if (creator == address(0)) {
if (IERC2981(collection).supportsInterface(IERC2981.royaltyInfo.selector)) {
uint256 length = itemIds.length;

for (uint256 i; i < length; ) {
for (uint256 i; i < length;) {
try IERC2981(collection).royaltyInfo(itemIds[i], price) returns (
address newCreator,
uint256 /* newCreatorFeeAmount */
address newCreator, uint256 /* newCreatorFeeAmount */
) {
if (i == 0) {
creator = newCreator;
Expand Down
21 changes: 10 additions & 11 deletions contracts/src/marketplace/CreatorFeeManagerWithRoyalties.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
pragma solidity 0.8.17;

// LooksRare unopinionated libraries
import { IERC2981 } from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC2981.sol";
import {IERC2981} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC2981.sol";

// Interfaces
import { ICreatorFeeManager } from "./interfaces/ICreatorFeeManager.sol";
import { IRoyaltyFeeRegistry } from "./interfaces/IRoyaltyFeeRegistry.sol";
import {ICreatorFeeManager} from "./interfaces/ICreatorFeeManager.sol";
import {IRoyaltyFeeRegistry} from "./interfaces/IRoyaltyFeeRegistry.sol";

/**
* @title CreatorFeeManagerWithRoyalties
Expand Down Expand Up @@ -44,22 +44,21 @@ contract CreatorFeeManagerWithRoyalties is ICreatorFeeManager {
* (1) high royalties
* (2) potential unexpected royalty changes that can occur after the creation of the order.
*/
function viewCreatorFeeInfo(
address collection,
uint256 price,
uint256[] memory itemIds
) external view returns (address creator, uint256 creatorFeeAmount) {
function viewCreatorFeeInfo(address collection, uint256 price, uint256[] memory itemIds)
external
view
returns (address creator, uint256 creatorFeeAmount)
{
// Check if there is a royalty info in the system
(creator, creatorFeeAmount) = royaltyFeeRegistry.royaltyInfo(collection, price);

if (creator == address(0)) {
if (IERC2981(collection).supportsInterface(IERC2981.royaltyInfo.selector)) {
uint256 length = itemIds.length;

for (uint256 i; i < length; ) {
for (uint256 i; i < length;) {
try IERC2981(collection).royaltyInfo(itemIds[i], price) returns (
address newCreator,
uint256 newCreatorFeeAmount
address newCreator, uint256 newCreatorFeeAmount
) {
if (i == 0) {
creator = newCreator;
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/marketplace/CurrencyManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
pragma solidity 0.8.17;

// LooksRare unopinionated libraries
import { OwnableTwoSteps } from "@looksrare/contracts-libs/contracts/OwnableTwoSteps.sol";
import {OwnableTwoSteps} from "@looksrare/contracts-libs/contracts/OwnableTwoSteps.sol";

// Interfaces
import { ICurrencyManager } from "./interfaces/ICurrencyManager.sol";
import {ICurrencyManager} from "./interfaces/ICurrencyManager.sol";

/**
* @title CurrencyManager
Expand Down
51 changes: 25 additions & 26 deletions contracts/src/marketplace/ExecutionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,31 @@
pragma solidity 0.8.17;

// Libraries
import { OrderStructs } from "./libraries/OrderStructs.sol";
import {OrderStructs} from "./libraries/OrderStructs.sol";

// Interfaces
import { IExecutionManager } from "./interfaces/IExecutionManager.sol";
import { ICreatorFeeManager } from "./interfaces/ICreatorFeeManager.sol";
import {IExecutionManager} from "./interfaces/IExecutionManager.sol";
import {ICreatorFeeManager} from "./interfaces/ICreatorFeeManager.sol";

// Direct dependencies
import { InheritedStrategy } from "./InheritedStrategy.sol";
import { NonceManager } from "./NonceManager.sol";
import { StrategyManager } from "./StrategyManager.sol";
import {InheritedStrategy} from "./InheritedStrategy.sol";
import {NonceManager} from "./NonceManager.sol";
import {StrategyManager} from "./StrategyManager.sol";

// Assembly
import { NoSelectorForStrategy_error_selector, NoSelectorForStrategy_error_length, OutsideOfTimeRange_error_selector, OutsideOfTimeRange_error_length, Error_selector_offset } from "./constants/AssemblyConstants.sol";
import {
NoSelectorForStrategy_error_selector,
NoSelectorForStrategy_error_length,
OutsideOfTimeRange_error_selector,
OutsideOfTimeRange_error_length,
Error_selector_offset
} from "./constants/AssemblyConstants.sol";

// Constants
import { ONE_HUNDRED_PERCENT_IN_BP } from "./constants/NumericConstants.sol";
import {ONE_HUNDRED_PERCENT_IN_BP} from "./constants/NumericConstants.sol";

// Enums
import { QuoteType } from "./enums/QuoteType.sol";
import {QuoteType} from "./enums/QuoteType.sol";

/**
* @title ExecutionManager
Expand All @@ -39,7 +45,7 @@ contract ExecutionManager is InheritedStrategy, NonceManager, StrategyManager, I
* @notice Maximum creator fee (in basis point).
*/
// TODO do we need a max? Is 1% max fair?
uint16 public maxCreatorFeeBp = 1_000;
uint16 public maxCreatorFeeBp = 1000;

/**
* @notice Creator fee manager.
Expand Down Expand Up @@ -72,7 +78,7 @@ contract ExecutionManager is InheritedStrategy, NonceManager, StrategyManager, I
* Only callable by owner.
*/
function updateMaxCreatorFeeBp(uint16 newMaxCreatorFeeBp) external onlyOwner {
if (newMaxCreatorFeeBp > 2_500) {
if (newMaxCreatorFeeBp > 2500) {
revert CreatorFeeBpTooHigh();
}

Expand Down Expand Up @@ -172,11 +178,8 @@ contract ExecutionManager is InheritedStrategy, NonceManager, StrategyManager, I
}

// Creator fee and adjustment of protocol fee
(recipients[1], feeAmounts[1]) = _getCreatorRecipientAndCalculateFeeAmount(
makerOrder.collection,
price,
itemIds
);
(recipients[1], feeAmounts[1]) =
_getCreatorRecipientAndCalculateFeeAmount(makerOrder.collection, price, itemIds);
if (makerOrder.quoteType == QuoteType.Bid) {
_setTheRestOfFeeAmountsAndRecipients(
makerOrder.strategyId,
Expand All @@ -187,11 +190,7 @@ contract ExecutionManager is InheritedStrategy, NonceManager, StrategyManager, I
);
} else {
_setTheRestOfFeeAmountsAndRecipients(
makerOrder.strategyId,
price,
makerOrder.signer,
feeAmounts,
recipients
makerOrder.strategyId, price, makerOrder.signer, feeAmounts, recipients
);
}
}
Expand Down Expand Up @@ -240,11 +239,11 @@ contract ExecutionManager is InheritedStrategy, NonceManager, StrategyManager, I
* @return creator Creator recipient
* @return creatorFeeAmount Creator fee amount
*/
function _getCreatorRecipientAndCalculateFeeAmount(
address collection,
uint256 price,
uint256[] memory itemIds
) private view returns (address creator, uint256 creatorFeeAmount) {
function _getCreatorRecipientAndCalculateFeeAmount(address collection, uint256 price, uint256[] memory itemIds)
private
view
returns (address creator, uint256 creatorFeeAmount)
{
if (address(creatorFeeManager) != address(0)) {
(creator, creatorFeeAmount) = creatorFeeManager.viewCreatorFeeInfo(collection, price, itemIds);

Expand Down
Loading