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: linter and remove some test mocks #1168

Merged
merged 2 commits into from
Sep 28, 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
1 change: 0 additions & 1 deletion packages/deploy/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const importedPackages = {
'@sandbox-smart-contracts/marketplace': [
'contracts/royalties-registry/RoyaltiesRegistry.sol',
'contracts/exchange/OrderValidator.sol',
'contracts/exchange/ExchangeMeta.sol',
'contracts/exchange/Exchange.sol',
'contracts/exchange/AssetMatcher.sol',
],
Expand Down
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}]
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we plan to shorten error messages later?

}
}
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
Loading