Skip to content

Commit

Permalink
chore: linter and remove some test mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
adjisb committed Sep 27, 2023
1 parent 17d0f49 commit e469850
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 511 deletions.
4 changes: 3 additions & 1 deletion packages/marketplace/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
],
"compiler-version": ["error", "^0.8.0"],
"func-visibility": ["error", {"ignoreConstructors": true}],
"custom-errors": "off"
"custom-errors": "off",
"func-named-parameters": ["error", 7],
"reason-string": ["warn", {"maxLength": 64}]
}
}
1 change: 1 addition & 0 deletions packages/marketplace/contracts/exchange/Exchange.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ contract Exchange is Initializable, AccessControlUpgradeable, ExchangeCore, Tran
/// @param orderValidatorAddress address of the OrderValidator contract, that validates orders
/// @param newNativeOrder bool to indicate of the contract accepts or doesn't native tokens, i.e. ETH or Matic
/// @param newMetaNative same as =nativeOrder but for metaTransactions
// solhint-disable-next-line func-name-mixedcase
function __Exchange_init(
address admin,
address newTrustedForwarder,
Expand Down
124 changes: 66 additions & 58 deletions packages/marketplace/contracts/exchange/ExchangeCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ abstract contract ExchangeCore is Initializable, TransferExecutor, ITransferMana
/// @param newNativeOrder for orders with native token
/// @param newMetaNative for meta orders with native token
/// @dev initialize permissions for native token exchange
// solhint-disable-next-line func-name-mixedcase
function __ExchangeCoreInitialize(
bool newNativeOrder,
bool newMetaNative,
Expand Down Expand Up @@ -121,29 +122,35 @@ abstract contract ExchangeCore is Initializable, TransferExecutor, ITransferMana
/// @param direct purchase order
function _directPurchase(address from, address buyer, LibDirectTransfer.Purchase calldata direct) internal {
LibAsset.AssetType memory paymentAssetType = getPaymentAssetType(direct.paymentToken);
LibOrder.Order memory sellOrder = LibOrder.Order(
direct.sellOrderMaker,
LibAsset.Asset(LibAsset.AssetType(direct.nftAssetClass, direct.nftData), direct.sellOrderNftAmount),
address(0),
LibAsset.Asset(paymentAssetType, direct.sellOrderPaymentAmount),
direct.sellOrderSalt,
direct.sellOrderStart,
direct.sellOrderEnd,
direct.sellOrderDataType,
direct.sellOrderData
);

LibOrder.Order memory buyOrder = LibOrder.Order(
buyer,
LibAsset.Asset(paymentAssetType, direct.buyOrderPaymentAmount),
address(0),
LibAsset.Asset(LibAsset.AssetType(direct.nftAssetClass, direct.nftData), direct.buyOrderNftAmount),
0,
0,
0,
getOtherOrderType(direct.sellOrderDataType),
direct.buyOrderData
);
LibOrder.Order memory sellOrder = LibOrder.Order({
maker: direct.sellOrderMaker,
makeAsset: LibAsset.Asset(
LibAsset.AssetType(direct.nftAssetClass, direct.nftData),
direct.sellOrderNftAmount
),
taker: address(0),
takeAsset: LibAsset.Asset(paymentAssetType, direct.sellOrderPaymentAmount),
salt: direct.sellOrderSalt,
start: direct.sellOrderStart,
end: direct.sellOrderEnd,
dataType: direct.sellOrderDataType,
data: direct.sellOrderData
});

LibOrder.Order memory buyOrder = LibOrder.Order({
maker: buyer,
makeAsset: LibAsset.Asset(paymentAssetType, direct.buyOrderPaymentAmount),
taker: address(0),
takeAsset: LibAsset.Asset(
LibAsset.AssetType(direct.nftAssetClass, direct.nftData),
direct.buyOrderNftAmount
),
salt: 0,
start: 0,
end: 0,
dataType: getOtherOrderType(direct.sellOrderDataType),
data: direct.buyOrderData
});
orderValidator.verifyERC20Whitelist(direct.paymentToken);
_validateFull(from, sellOrder, direct.sellOrderSignature);
_matchAndTransfer(from, sellOrder, buyOrder);
Expand All @@ -154,30 +161,32 @@ abstract contract ExchangeCore is Initializable, TransferExecutor, ITransferMana
/// @param direct struct with parameters for accept bid operation
function _directAcceptBid(address from, LibDirectTransfer.AcceptBid calldata direct) internal {
LibAsset.AssetType memory paymentAssetType = getPaymentAssetType(direct.paymentToken);

LibOrder.Order memory buyOrder = LibOrder.Order(
direct.bidMaker,
LibAsset.Asset(paymentAssetType, direct.bidPaymentAmount),
address(0),
LibAsset.Asset(LibAsset.AssetType(direct.nftAssetClass, direct.nftData), direct.bidNftAmount),
direct.bidSalt,
direct.bidStart,
direct.bidEnd,
direct.bidDataType,
direct.bidData
);

LibOrder.Order memory sellOrder = LibOrder.Order(
address(0),
LibAsset.Asset(LibAsset.AssetType(direct.nftAssetClass, direct.nftData), direct.sellOrderNftAmount),
address(0),
LibAsset.Asset(paymentAssetType, direct.sellOrderPaymentAmount),
0,
0,
0,
getOtherOrderType(direct.bidDataType),
direct.sellOrderData
);
LibOrder.Order memory buyOrder = LibOrder.Order({
maker: direct.bidMaker,
makeAsset: LibAsset.Asset(paymentAssetType, direct.bidPaymentAmount),
taker: address(0),
takeAsset: LibAsset.Asset(LibAsset.AssetType(direct.nftAssetClass, direct.nftData), direct.bidNftAmount),
salt: direct.bidSalt,
start: direct.bidStart,
end: direct.bidEnd,
dataType: direct.bidDataType,
data: direct.bidData
});

LibOrder.Order memory sellOrder = LibOrder.Order({
maker: address(0),
makeAsset: LibAsset.Asset(
LibAsset.AssetType(direct.nftAssetClass, direct.nftData),
direct.sellOrderNftAmount
),
taker: address(0),
takeAsset: LibAsset.Asset(paymentAssetType, direct.sellOrderPaymentAmount),
salt: 0,
start: 0,
end: 0,
dataType: getOtherOrderType(direct.bidDataType),
data: direct.sellOrderData
});

_validateFull(from, buyOrder, direct.bidSignature);
_matchAndTransfer(from, sellOrder, buyOrder);
Expand Down Expand Up @@ -441,17 +450,16 @@ abstract contract ExchangeCore is Initializable, TransferExecutor, ITransferMana
}

// TODO: can we move this out so we don't need to pass from ?
emit Match(
from,
leftOrderKeyHash,
rightOrderKeyHash,
newFill,
fills[leftOrderKeyHash],
fills[rightOrderKeyHash],
orderLeft.makeAsset.value,
orderRight.makeAsset.value
);

emit Match({
from: from,
leftHash: leftOrderKeyHash,
rightHash: rightOrderKeyHash,
newFill: newFill,
totalFillLeft: fills[leftOrderKeyHash],
totalFillRight: fills[rightOrderKeyHash],
valueLeft: orderLeft.makeAsset.value,
valueRight: orderRight.makeAsset.value
});
return newFill;
}

Expand Down
69 changes: 0 additions & 69 deletions packages/marketplace/contracts/exchange/ExchangeMeta.sol

This file was deleted.

1 change: 1 addition & 0 deletions packages/marketplace/contracts/exchange/OrderValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ contract OrderValidator is IOrderValidator, Initializable, EIP712Upgradeable, Wh
/// @param newPartners boolena to indicate that partner tokens are accepted by the exchange contract
/// @param newOpen boolean to indicate that all assets are accepted by the exchange contract
/// @param newErc20 boolean to activate the white list of ERC20 tokens
// solhint-disable-next-line func-name-mixedcase
function __OrderValidator_init_unchained(
bool newTsbOnly,
bool newPartners,
Expand Down
1 change: 1 addition & 0 deletions packages/marketplace/contracts/exchange/WhiteList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ contract WhiteList is IWhiteList, OwnableUpgradeable, AccessControlUpgradeable {
/// @param newPartners allows orders with partner token
/// @param newOpen allows orders with any token
/// @param newErc20List allows to pay orders with only whitelisted token
// solhint-disable-next-line func-name-mixedcase
function __Whitelist_init(bool newTsbOnly, bool newPartners, bool newOpen, bool newErc20List) internal initializer {
__Ownable_init();
__AccessControl_init_unchained();
Expand Down

This file was deleted.

This file was deleted.

Loading

1 comment on commit e469850

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

35.56%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/marketplace/contracts/exchange
   AssetMatcher.sol78.08%73.33%100%79.49%49–50, 50, 50–51, 53, 56, 59, 73–74, 74, 74–75, 77, 80–81
   Exchange.sol57.58%54.55%56.25%60.71%103, 110–113, 128, 128–129, 135, 135–136, 141, 173–174, 174, 188, 53, 94, 94, 96–97
   ExchangeCore.sol45.02%28.75%73.68%51.79%124–125, 140, 154–156, 163–164, 176, 191–192, 210–211, 211, 211, 211, 211, 213–214, 214, 214, 214, 214, 262, 262, 262–263, 263, 263–264, 264, 264, 266–267, 267, 267–268, 268, 268–269, 269, 269, 271, 273–274, 274, 274–275, 275, 275, 277, 305–306, 308–309, 366, 375–377, 377, 377–379, 379, 379–380, 380–382, 382, 382, 384, 386, 386, 386, 388, 399, 402–403, 407–408, 411, 434, 436–438, 444–446, 470–471, 488, 505–506, 506, 506–507, 509–510, 512, 519, 519, 519–520, 522, 522, 522–523, 525, 86, 94
   OrderValidator.sol69.81%57.14%100%80.95%32, 48, 55–56, 56, 56, 66, 76–77, 82, 84, 84, 84, 84–85, 87
   WhiteList.sol97.62%93.75%100%100%51
packages/marketplace/contracts/exchange/libraries
   LibDirectTransfer.sol100%100%100%100%
   LibFill.sol55%33.33%66.67%63.64%48–49, 61, 71–72, 72, 72–73
   LibOrderDataGeneric.sol21.67%22.22%40%18.92%18–28, 30–31, 33, 46, 48, 48, 48–49, 51–52, 55, 55, 55–56, 58, 61, 61, 61–62, 64, 67, 71, 73, 73, 73–75, 78, 87, 87, 87–89
packages/marketplace/contracts/exchange/mocks
   ERC1155LazyMintTest.sol100%100%100%100%
   ERC721LazyMintTest.sol100%100%100%100%
   ExchangeTestImports.sol100%100%100%100%
   LibFillTest.sol0%100%0%0%17
   LibOrderTest.sol0%100%0%0%13, 17, 21, 25, 35, 47
   MockTrustedForwarder.sol0%0%0%0%14, 17–18, 18, 18–19
   SimpleTransferManager.sol0%100%0%0%13–16
   TestAssetMatcher.sol0%0%0%0%12, 12, 12–15, 15, 15–16, 19
   TestERC1155WithRoyaltyV2981.sol100%100%100%100%
   TestERC1271.sol0%0%0%0%24, 28, 28, 28
   TestERC20.sol100%100%100%100%
   TestERC721.sol100%100%100%100%
   TestERC721WithRoyaltyV2981.sol100%100%100%100%
   TestERC721WithRoyaltyV2981Multi.sol100%100%100%100%
   TestMinimalForwarder.sol0%0%0%0%12–15, 15, 15–16
   TestRoyaltiesRegistry.sol18%16.67%25%17.86%21–23, 23, 23–24, 24, 24–26, 28, 28, 28–29, 33, 38–39, 42–46, 50, 62–65, 65, 65–66, 66, 66–68, 70, 70, 70–71
packages/marketplace/contracts/exchange/mocks/tokens
   ERC2981.sol0%0%0%0%106, 38, 38, 38, 45, 47, 47, 47–48, 51, 53, 62, 74, 74, 74–75, 75, 75, 77, 84, 96, 96, 96–97, 97, 97, 99
   MintableERC1155.sol0%100%0%0%10, 14
   MintableERC1155WithRoyalties.sol0%0%0%0%13, 17, 21, 25, 9, 9, 9
   MintableERC20.sol0%100%0%0%10
   MintableERC721.sol0%100%0%0%10
   MintableERC721WithRoyalties.sol0%0%0%0%13, 17, 21, 25, 9, 9, 9
packages/marketplace/contracts/interfaces
   IAssetMatcher.sol100%100%100%100%
   IOrderValidator.sol100%100%100%100%
   IRoyaltiesProvider.sol100%100%100%100%
   IWhiteList.sol100%100%100%100%
packages/marketplace/contracts/lazy-mint/erc-1155
   IERC1155LazyMint.sol100%100%100%100%
   LibERC1155LazyMint.sol0%100%0%0%34–36, 38–40, 42
packages/marketplace/contracts/lazy-mint/erc-721
   IERC721LazyMint.sol100%100%100%100%
   LibERC721LazyMint.sol0%100%0%0%33–35, 37–39, 41
packages/marketplace/contracts/lazy-mint/mocks
   ERC1155LazyMintTest.sol0%0%0%0%15, 24–25, 25, 25–26, 28, 33
   ERC1155Test.sol0%0%0%0%14, 14–15, 22–24
   ERC721LazyMintTest.sol0%0%0%0%10, 14, 14, 14–15, 17, 22
   ERC721Test.sol0%0%0%0%13, 13–14, 21–23
packages/marketplace/contracts/lib-asset
   LibAsset.sol100%100%100%100%
packages/marketplace/contracts/lib-bp
   BpLibrary.sol100%100%100%100%
packages/marketplace/contracts/lib-order
   LibMath.sol27.50%18.75%50%30%100–103, 17–18,

Please sign in to comment.