diff --git a/packages/marketplace/contracts/exchange/mocks/ERC1155LazyMintTest.sol b/packages/marketplace/contracts/exchange/mocks/ERC1155LazyMintTest.sol deleted file mode 100644 index e3e1990110..0000000000 --- a/packages/marketplace/contracts/exchange/mocks/ERC1155LazyMintTest.sol +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity 0.8.21; - -// solhint-disable-next-line no-unused-import -import {ERC1155LazyMintTest} from "../../lazy-mint/mocks/ERC1155LazyMintTest.sol"; diff --git a/packages/marketplace/contracts/exchange/mocks/ERC721LazyMintTest.sol b/packages/marketplace/contracts/exchange/mocks/ERC721LazyMintTest.sol deleted file mode 100644 index 0b5548ac45..0000000000 --- a/packages/marketplace/contracts/exchange/mocks/ERC721LazyMintTest.sol +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity 0.8.21; - -// solhint-disable-next-line no-unused-import -import {ERC721LazyMintTest} from "../../lazy-mint/mocks/ERC721LazyMintTest.sol"; diff --git a/packages/marketplace/contracts/exchange/mocks/ExchangeTestImports.sol b/packages/marketplace/contracts/exchange/mocks/ExchangeTestImports.sol deleted file mode 100644 index 7ec771e775..0000000000 --- a/packages/marketplace/contracts/exchange/mocks/ExchangeTestImports.sol +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity 0.8.21; - -// solhint-disable no-unused-import -import {RoyaltiesRegistry} from "../../royalties-registry/RoyaltiesRegistry.sol"; -import {MintableERC20} from "./tokens/MintableERC20.sol"; -import {MintableERC721} from "./tokens/MintableERC721.sol"; -import {MintableERC1155} from "./tokens/MintableERC1155.sol"; -import {MintableERC721WithRoyalties} from "./tokens/MintableERC721WithRoyalties.sol"; -import {MintableERC1155WithRoyalties} from "./tokens/MintableERC1155WithRoyalties.sol"; -import {Exchange} from "../Exchange.sol"; - -// solhint-enable no-unused-import - -// solhint-disable-next-line no-empty-blocks -contract ExchangeTestImports { - -} diff --git a/packages/marketplace/contracts/exchange/mocks/MockTrustedForwarder.sol b/packages/marketplace/contracts/exchange/mocks/MockTrustedForwarder.sol deleted file mode 100644 index 9e1c0cf0e4..0000000000 --- a/packages/marketplace/contracts/exchange/mocks/MockTrustedForwarder.sol +++ /dev/null @@ -1,21 +0,0 @@ -//SPDX-License-Identifier: MIT -pragma solidity ^0.8.21; - -contract MockTrustedForwarder { - struct ForwardRequest { - address from; - address to; - uint256 value; - uint256 gasLimit; - bytes data; - } - - function execute(ForwardRequest calldata req) public payable returns (bool, bytes memory) { - (bool success, bytes memory returndata) = req.to.call{gas: req.gasLimit, value: req.value}( - abi.encodePacked(req.data, req.from) - ); - assert(gasleft() > req.gasLimit / 63); - require(success, "Call execution failed"); - return (success, returndata); - } -} diff --git a/packages/marketplace/contracts/exchange/mocks/TestERC1155WithRoyaltyV2981.sol b/packages/marketplace/contracts/exchange/mocks/TestERC1155WithRoyaltyV2981.sol deleted file mode 100644 index b3b8f8e065..0000000000 --- a/packages/marketplace/contracts/exchange/mocks/TestERC1155WithRoyaltyV2981.sol +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity 0.8.21; - -// solhint-disable-next-line no-unused-import -import {TestERC1155WithRoyaltyV2981} from "../../royalties-registry/mocks/tokens/TestERC1155WithRoyaltyV2981.sol"; diff --git a/packages/marketplace/contracts/exchange/mocks/TestERC20.sol b/packages/marketplace/contracts/exchange/mocks/TestERC20.sol deleted file mode 100644 index 759e1c1ec7..0000000000 --- a/packages/marketplace/contracts/exchange/mocks/TestERC20.sol +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity 0.8.21; - -// solhint-disable-next-line no-unused-import -import {TestERC20} from "../../test/TestERC20.sol"; diff --git a/packages/marketplace/contracts/exchange/mocks/TestERC721.sol b/packages/marketplace/contracts/exchange/mocks/TestERC721.sol deleted file mode 100644 index 71532191f4..0000000000 --- a/packages/marketplace/contracts/exchange/mocks/TestERC721.sol +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity 0.8.21; - -// solhint-disable-next-line no-unused-import -import {TestERC721} from "../../test/TestERC721.sol"; diff --git a/packages/marketplace/contracts/exchange/mocks/TestERC721WithRoyaltyV2981.sol b/packages/marketplace/contracts/exchange/mocks/TestERC721WithRoyaltyV2981.sol deleted file mode 100644 index 80a125fa48..0000000000 --- a/packages/marketplace/contracts/exchange/mocks/TestERC721WithRoyaltyV2981.sol +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity 0.8.21; - -// solhint-disable-next-line no-unused-import -import {TestERC721WithRoyaltyV2981} from "../../royalties-registry/mocks/tokens/TestERC721WithRoyaltyV2981.sol"; diff --git a/packages/marketplace/contracts/exchange/mocks/TestERC721WithRoyaltyV2981Multi.sol b/packages/marketplace/contracts/exchange/mocks/TestERC721WithRoyaltyV2981Multi.sol deleted file mode 100644 index 736bbbbc49..0000000000 --- a/packages/marketplace/contracts/exchange/mocks/TestERC721WithRoyaltyV2981Multi.sol +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity 0.8.21; - -// solhint-disable-next-line no-unused-import -import {TestERC721WithRoyaltyV2981Multi} from "../../royalties-registry/mocks/tokens/TestERC721WithRoyaltyV2981Multi.sol"; diff --git a/packages/marketplace/contracts/exchange/mocks/tokens/ERC2981.sol b/packages/marketplace/contracts/exchange/mocks/tokens/ERC2981.sol deleted file mode 100644 index be12f1534e..0000000000 --- a/packages/marketplace/contracts/exchange/mocks/tokens/ERC2981.sol +++ /dev/null @@ -1,108 +0,0 @@ -// SPDX-License-Identifier: MIT -// OpenZeppelin Contracts (last updated v4.7.0) (token/common/ERC2981.sol) -// TODO: When we move to oz > 4.5 we can use the file directly from there - -pragma solidity ^0.8.0; - -import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; -import {IERC2981} from "../../../royalties/IERC2981.sol"; - -/** - * @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information. - * - * Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for - * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first. - * - * Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the - * fee is specified in basis points by default. - * - * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See - * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to - * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported. - * - * _Available since v4.5._ - */ -abstract contract ERC2981 is IERC2981, ERC165 { - struct RoyaltyInfo { - address receiver; - uint96 royaltyFraction; - } - - RoyaltyInfo private _defaultRoyaltyInfo; - mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo; - - /** - * @dev See {IERC165-supportsInterface}. - */ - function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { - return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId); - } - - /** - * @inheritdoc IERC2981 - */ - function royaltyInfo(uint256 tokenId, uint256 salePrice) public view virtual override returns (address, uint256) { - RoyaltyInfo memory royalty = _tokenRoyaltyInfo[tokenId]; - - if (royalty.receiver == address(0)) { - royalty = _defaultRoyaltyInfo; - } - - uint256 royaltyAmount = (salePrice * royalty.royaltyFraction) / _feeDenominator(); - - return (royalty.receiver, royaltyAmount); - } - - /** - * @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a - * fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an - * override. - */ - function _feeDenominator() internal pure virtual returns (uint96) { - return 10000; - } - - /** - * @dev Sets the royalty information that all ids in this contract will default to. - * - * Requirements: - * - * - `receiver` cannot be the zero address. - * - `feeNumerator` cannot be greater than the fee denominator. - */ - function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual { - require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); - require(receiver != address(0), "ERC2981: invalid receiver"); - - _defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator); - } - - /** - * @dev Removes default royalty information. - */ - function _deleteDefaultRoyalty() internal virtual { - delete _defaultRoyaltyInfo; - } - - /** - * @dev Sets the royalty information for a specific token id, overriding the global default. - * - * Requirements: - * - * - `receiver` cannot be the zero address. - * - `feeNumerator` cannot be greater than the fee denominator. - */ - function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual { - require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); - require(receiver != address(0), "ERC2981: Invalid parameters"); - - _tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator); - } - - /** - * @dev Resets royalty information for the token id back to the global default. - */ - function _resetTokenRoyalty(uint256 tokenId) internal virtual { - delete _tokenRoyaltyInfo[tokenId]; - } -} diff --git a/packages/marketplace/contracts/royalties/mocks/AbstractRoyalties.sol b/packages/marketplace/contracts/mocks/AbstractRoyalties.sol similarity index 95% rename from packages/marketplace/contracts/royalties/mocks/AbstractRoyalties.sol rename to packages/marketplace/contracts/mocks/AbstractRoyalties.sol index f162b23126..a84d09d13f 100644 --- a/packages/marketplace/contracts/royalties/mocks/AbstractRoyalties.sol +++ b/packages/marketplace/contracts/mocks/AbstractRoyalties.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.21; -import {LibPart} from "../../lib-part/LibPart.sol"; +import {LibPart} from "../lib-part/LibPart.sol"; abstract contract AbstractRoyalties { mapping(uint256 => LibPart.Part[]) internal royalties; diff --git a/packages/marketplace/contracts/lazy-mint/mocks/ERC1155LazyMintTest.sol b/packages/marketplace/contracts/mocks/ERC1155LazyMintTest.sol similarity index 88% rename from packages/marketplace/contracts/lazy-mint/mocks/ERC1155LazyMintTest.sol rename to packages/marketplace/contracts/mocks/ERC1155LazyMintTest.sol index ac7784aa38..f90eee2278 100644 --- a/packages/marketplace/contracts/lazy-mint/mocks/ERC1155LazyMintTest.sol +++ b/packages/marketplace/contracts/mocks/ERC1155LazyMintTest.sol @@ -3,8 +3,7 @@ pragma solidity 0.8.21; import {ERC1155Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; -import {IERC1155LazyMint} from "../erc-1155/IERC1155LazyMint.sol"; -import {LibERC1155LazyMint} from "../erc-1155/LibERC1155LazyMint.sol"; +import {IERC1155LazyMint, LibERC1155LazyMint} from "../lazy-mint/erc-1155/IERC1155LazyMint.sol"; contract ERC1155LazyMintTest is IERC1155LazyMint, ERC1155Upgradeable { function mintAndTransfer( diff --git a/packages/marketplace/contracts/lazy-mint/mocks/ERC1155Test.sol b/packages/marketplace/contracts/mocks/ERC1155Test.sol similarity index 91% rename from packages/marketplace/contracts/lazy-mint/mocks/ERC1155Test.sol rename to packages/marketplace/contracts/mocks/ERC1155Test.sol index 5c14c38264..ef93b13e9c 100644 --- a/packages/marketplace/contracts/lazy-mint/mocks/ERC1155Test.sol +++ b/packages/marketplace/contracts/mocks/ERC1155Test.sol @@ -2,9 +2,9 @@ pragma solidity 0.8.21; -import {LibERC1155LazyMint} from "../erc-1155/LibERC1155LazyMint.sol"; import {ECDSAUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol"; import {EIP712Upgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol"; +import {LibERC1155LazyMint} from "../lazy-mint/erc-1155/LibERC1155LazyMint.sol"; contract ERC1155Test is EIP712Upgradeable { using ECDSAUpgradeable for bytes32; diff --git a/packages/marketplace/contracts/lazy-mint/mocks/ERC721LazyMintTest.sol b/packages/marketplace/contracts/mocks/ERC721LazyMintTest.sol similarity index 89% rename from packages/marketplace/contracts/lazy-mint/mocks/ERC721LazyMintTest.sol rename to packages/marketplace/contracts/mocks/ERC721LazyMintTest.sol index fd8ba68faa..c6b8320947 100644 --- a/packages/marketplace/contracts/lazy-mint/mocks/ERC721LazyMintTest.sol +++ b/packages/marketplace/contracts/mocks/ERC721LazyMintTest.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.21; import {ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; -import {IERC721LazyMint, LibERC721LazyMint} from "../erc-721/IERC721LazyMint.sol"; +import {IERC721LazyMint, LibERC721LazyMint} from "../lazy-mint/erc-721/IERC721LazyMint.sol"; contract ERC721LazyMintTest is IERC721LazyMint, ERC721Upgradeable { function mintAndTransfer(LibERC721LazyMint.Mint721Data memory data, address to) external override { diff --git a/packages/marketplace/contracts/lazy-mint/mocks/ERC721Test.sol b/packages/marketplace/contracts/mocks/ERC721Test.sol similarity index 91% rename from packages/marketplace/contracts/lazy-mint/mocks/ERC721Test.sol rename to packages/marketplace/contracts/mocks/ERC721Test.sol index a9073549ca..09a2efc4c3 100644 --- a/packages/marketplace/contracts/lazy-mint/mocks/ERC721Test.sol +++ b/packages/marketplace/contracts/mocks/ERC721Test.sol @@ -2,9 +2,9 @@ pragma solidity 0.8.21; -import {LibERC721LazyMint} from "../erc-721/LibERC721LazyMint.sol"; import {EIP712Upgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol"; import {ECDSAUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol"; +import {LibERC721LazyMint} from "../lazy-mint/erc-721/LibERC721LazyMint.sol"; contract ERC721Test is EIP712Upgradeable { using ECDSAUpgradeable for bytes32; diff --git a/packages/marketplace/contracts/transfer-manager/mocks/LibFeeSideTest.sol b/packages/marketplace/contracts/mocks/LibFeeSideTest.sol similarity index 78% rename from packages/marketplace/contracts/transfer-manager/mocks/LibFeeSideTest.sol rename to packages/marketplace/contracts/mocks/LibFeeSideTest.sol index 2ae2320d26..913807a498 100644 --- a/packages/marketplace/contracts/transfer-manager/mocks/LibFeeSideTest.sol +++ b/packages/marketplace/contracts/mocks/LibFeeSideTest.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.21; -import {LibFeeSide} from "../lib/LibFeeSide.sol"; +import {LibFeeSide} from "../transfer-manager/lib/LibFeeSide.sol"; contract LibFeeSideTest { function getFeeSideTest(bytes4 maker, bytes4 taker) external pure returns (LibFeeSide.FeeSide) { diff --git a/packages/marketplace/contracts/exchange/mocks/LibFillTest.sol b/packages/marketplace/contracts/mocks/LibFillTest.sol similarity index 81% rename from packages/marketplace/contracts/exchange/mocks/LibFillTest.sol rename to packages/marketplace/contracts/mocks/LibFillTest.sol index d64a65e5eb..d2d628e270 100644 --- a/packages/marketplace/contracts/exchange/mocks/LibFillTest.sol +++ b/packages/marketplace/contracts/mocks/LibFillTest.sol @@ -2,8 +2,8 @@ pragma solidity 0.8.21; -import {LibOrder} from "../../lib-order/LibOrder.sol"; -import {LibFill} from "../libraries/LibFill.sol"; +import {LibOrder} from "../lib-order/LibOrder.sol"; +import {LibFill} from "../exchange/libraries/LibFill.sol"; contract LibFillTest { function fillOrder( diff --git a/packages/marketplace/contracts/exchange/mocks/LibOrderTest.sol b/packages/marketplace/contracts/mocks/LibOrderTest.sol similarity index 95% rename from packages/marketplace/contracts/exchange/mocks/LibOrderTest.sol rename to packages/marketplace/contracts/mocks/LibOrderTest.sol index 1847810977..bf3747a482 100644 --- a/packages/marketplace/contracts/exchange/mocks/LibOrderTest.sol +++ b/packages/marketplace/contracts/mocks/LibOrderTest.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.21; -import {LibOrder, LibAsset} from "../../lib-order/LibOrder.sol"; +import {LibOrder, LibAsset} from "../lib-order/LibOrder.sol"; contract LibOrderTest { function calculateRemaining( diff --git a/packages/marketplace/contracts/royalties/mocks/Royalties2981Test.sol b/packages/marketplace/contracts/mocks/Royalties2981Test.sol similarity index 86% rename from packages/marketplace/contracts/royalties/mocks/Royalties2981Test.sol rename to packages/marketplace/contracts/mocks/Royalties2981Test.sol index 4db0aa6088..2b13dea58c 100644 --- a/packages/marketplace/contracts/royalties/mocks/Royalties2981Test.sol +++ b/packages/marketplace/contracts/mocks/Royalties2981Test.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.21; -import {IERC2981} from "../IERC2981.sol"; +import {IERC2981} from "@openzeppelin/contracts/interfaces/IERC2981.sol"; contract Royalties2981Test { IERC2981 internal immutable ROYALTIES; diff --git a/packages/marketplace/contracts/royalties/mocks/Royalties2981TestImpl.sol b/packages/marketplace/contracts/mocks/Royalties2981TestImpl.sol similarity index 67% rename from packages/marketplace/contracts/royalties/mocks/Royalties2981TestImpl.sol rename to packages/marketplace/contracts/mocks/Royalties2981TestImpl.sol index 0115279b21..45ca9a555f 100644 --- a/packages/marketplace/contracts/royalties/mocks/Royalties2981TestImpl.sol +++ b/packages/marketplace/contracts/mocks/Royalties2981TestImpl.sol @@ -2,9 +2,9 @@ pragma solidity 0.8.21; -import {IERC2981} from "../IERC2981.sol"; -import {LibRoyalties2981} from "../LibRoyalties2981.sol"; -import {LibPart} from "../../lib-part/LibPart.sol"; +import {IERC2981} from "@openzeppelin/contracts/interfaces/IERC2981.sol"; +import {LibRoyalties2981} from "../royalties/LibRoyalties2981.sol"; +import {LibPart} from "../lib-part/LibPart.sol"; contract Royalties2981TestImpl is IERC2981 { uint256 public royaltiesBasePoint; @@ -24,4 +24,8 @@ contract Royalties2981TestImpl is IERC2981 { function calculateRoyaltiesTest(address payable to, uint96 amount) external pure returns (LibPart.Part[] memory) { return LibRoyalties2981.calculateRoyalties(to, amount); } + + function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { + return interfaceId == type(IERC2981).interfaceId; + } } diff --git a/packages/marketplace/contracts/royalties-registry/mocks/royalty-registry/RoyaltiesProviderTest.sol b/packages/marketplace/contracts/mocks/RoyaltiesProviderTest.sol similarity index 83% rename from packages/marketplace/contracts/royalties-registry/mocks/royalty-registry/RoyaltiesProviderTest.sol rename to packages/marketplace/contracts/mocks/RoyaltiesProviderTest.sol index bbdb5eb4ff..88f2af2b24 100644 --- a/packages/marketplace/contracts/royalties-registry/mocks/royalty-registry/RoyaltiesProviderTest.sol +++ b/packages/marketplace/contracts/mocks/RoyaltiesProviderTest.sol @@ -2,8 +2,8 @@ pragma solidity 0.8.21; -import {IRoyaltiesProvider} from "../../../interfaces/IRoyaltiesProvider.sol"; -import {LibPart} from "../../../lib-part/LibPart.sol"; +import {IRoyaltiesProvider} from "../interfaces/IRoyaltiesProvider.sol"; +import {LibPart} from "../lib-part/LibPart.sol"; contract RoyaltiesProviderTest is IRoyaltiesProvider { mapping(address => mapping(uint256 => LibPart.Part[])) internal royaltiesTest; diff --git a/packages/marketplace/contracts/royalties-registry/mocks/royalty-registry/RoyaltiesRegistryTest.sol b/packages/marketplace/contracts/mocks/RoyaltiesRegistryTest.sol similarity index 77% rename from packages/marketplace/contracts/royalties-registry/mocks/royalty-registry/RoyaltiesRegistryTest.sol rename to packages/marketplace/contracts/mocks/RoyaltiesRegistryTest.sol index 4579e60002..91a6d8f423 100644 --- a/packages/marketplace/contracts/royalties-registry/mocks/royalty-registry/RoyaltiesRegistryTest.sol +++ b/packages/marketplace/contracts/mocks/RoyaltiesRegistryTest.sol @@ -2,8 +2,8 @@ pragma solidity 0.8.21; -import {IRoyaltiesProvider} from "../../../interfaces/IRoyaltiesProvider.sol"; -import {LibPart} from "../../../lib-part/LibPart.sol"; +import {IRoyaltiesProvider} from "../interfaces/IRoyaltiesProvider.sol"; +import {LibPart} from "../lib-part/LibPart.sol"; contract RoyaltiesRegistryTest { event GetRoyaltiesTest(LibPart.Part[] royalties); diff --git a/packages/marketplace/contracts/transfer-manager/mocks/SimpleTest.sol b/packages/marketplace/contracts/mocks/SimpleTest.sol similarity index 65% rename from packages/marketplace/contracts/transfer-manager/mocks/SimpleTest.sol rename to packages/marketplace/contracts/mocks/SimpleTest.sol index cde4320838..a006e23089 100644 --- a/packages/marketplace/contracts/transfer-manager/mocks/SimpleTest.sol +++ b/packages/marketplace/contracts/mocks/SimpleTest.sol @@ -2,10 +2,10 @@ pragma solidity 0.8.21; -import {TransferManager} from "../TransferManager.sol"; -import {LibERC721LazyMint} from "../../lazy-mint/erc-721/LibERC721LazyMint.sol"; -import {LibERC1155LazyMint, LibPart} from "../../lazy-mint/erc-1155/LibERC1155LazyMint.sol"; -import {TransferExecutor, LibAsset} from "../TransferExecutor.sol"; +import {LibERC721LazyMint} from "../lazy-mint/erc-721/LibERC721LazyMint.sol"; +import {LibERC1155LazyMint, LibPart} from "../lazy-mint/erc-1155/LibERC1155LazyMint.sol"; +import {TransferManager} from "../transfer-manager/TransferManager.sol"; +import {TransferExecutor, LibAsset} from "../transfer-manager/TransferExecutor.sol"; contract SimpleTest is TransferManager, TransferExecutor { function getRoyaltiesByAssetTest(LibAsset.AssetType memory matchNft) external returns (LibPart.Part[] memory) { diff --git a/packages/marketplace/contracts/exchange/mocks/SimpleTransferManager.sol b/packages/marketplace/contracts/mocks/SimpleTransferManager.sol similarity index 85% rename from packages/marketplace/contracts/exchange/mocks/SimpleTransferManager.sol rename to packages/marketplace/contracts/mocks/SimpleTransferManager.sol index 8e6fa3a385..ca3c7b9c1c 100644 --- a/packages/marketplace/contracts/exchange/mocks/SimpleTransferManager.sol +++ b/packages/marketplace/contracts/mocks/SimpleTransferManager.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.21; -import {ITransferManager, LibDeal} from "../../transfer-manager/interfaces/ITransferManager.sol"; +import {ITransferManager, LibDeal} from "../transfer-manager/interfaces/ITransferManager.sol"; abstract contract SimpleTransferManager is ITransferManager { function doTransfers( diff --git a/packages/marketplace/contracts/exchange/mocks/TestAssetMatcher.sol b/packages/marketplace/contracts/mocks/TestAssetMatcher.sol similarity index 90% rename from packages/marketplace/contracts/exchange/mocks/TestAssetMatcher.sol rename to packages/marketplace/contracts/mocks/TestAssetMatcher.sol index cd18ca845b..330d3e93f7 100644 --- a/packages/marketplace/contracts/exchange/mocks/TestAssetMatcher.sol +++ b/packages/marketplace/contracts/mocks/TestAssetMatcher.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.21; -import {IAssetMatcher, LibAsset} from "../../interfaces/IAssetMatcher.sol"; +import {IAssetMatcher, LibAsset} from "../interfaces/IAssetMatcher.sol"; contract TestAssetMatcher is IAssetMatcher { function matchAssets( diff --git a/packages/marketplace/contracts/test/TestERC1155.sol b/packages/marketplace/contracts/mocks/TestERC1155.sol similarity index 100% rename from packages/marketplace/contracts/test/TestERC1155.sol rename to packages/marketplace/contracts/mocks/TestERC1155.sol diff --git a/packages/marketplace/contracts/royalties-registry/mocks/tokens/TestERC1155WithRoyaltyV2981.sol b/packages/marketplace/contracts/mocks/TestERC1155WithRoyaltyV2981.sol similarity index 63% rename from packages/marketplace/contracts/royalties-registry/mocks/tokens/TestERC1155WithRoyaltyV2981.sol rename to packages/marketplace/contracts/mocks/TestERC1155WithRoyaltyV2981.sol index 06ee599a36..f6a589de46 100644 --- a/packages/marketplace/contracts/royalties-registry/mocks/tokens/TestERC1155WithRoyaltyV2981.sol +++ b/packages/marketplace/contracts/mocks/TestERC1155WithRoyaltyV2981.sol @@ -4,10 +4,10 @@ pragma solidity 0.8.21; import {ERC1155Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; -import {Royalties2981TestImpl} from "../../../royalties/mocks/Royalties2981TestImpl.sol"; -import {LibRoyalties2981} from "../../../royalties/LibRoyalties2981.sol"; -import {AbstractRoyalties, LibPart} from "../../../royalties/mocks/AbstractRoyalties.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +import {LibRoyalties2981} from "../royalties/LibRoyalties2981.sol"; +import {AbstractRoyalties, LibPart} from "./AbstractRoyalties.sol"; +import {Royalties2981TestImpl} from "./Royalties2981TestImpl.sol"; contract TestERC1155WithRoyaltyV2981 is Initializable, @@ -27,8 +27,13 @@ contract TestERC1155WithRoyaltyV2981 is _saveRoyalties(tokenId, _fees); } - function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { - return interfaceId == LibRoyalties2981._INTERFACE_ID_ROYALTIES; + function supportsInterface( + bytes4 interfaceId + ) public view virtual override(ERC1155Upgradeable, Royalties2981TestImpl) returns (bool) { + return + interfaceId == LibRoyalties2981._INTERFACE_ID_ROYALTIES || + ERC1155Upgradeable.supportsInterface(interfaceId) || + Royalties2981TestImpl.supportsInterface(interfaceId); } // solhint-disable-next-line no-empty-blocks diff --git a/packages/marketplace/contracts/exchange/mocks/TestERC1271.sol b/packages/marketplace/contracts/mocks/TestERC1271.sol similarity index 100% rename from packages/marketplace/contracts/exchange/mocks/TestERC1271.sol rename to packages/marketplace/contracts/mocks/TestERC1271.sol diff --git a/packages/marketplace/contracts/test/TestERC20.sol b/packages/marketplace/contracts/mocks/TestERC20.sol similarity index 100% rename from packages/marketplace/contracts/test/TestERC20.sol rename to packages/marketplace/contracts/mocks/TestERC20.sol diff --git a/packages/marketplace/contracts/test/TestERC20ZRX.sol b/packages/marketplace/contracts/mocks/TestERC20ZRX.sol similarity index 100% rename from packages/marketplace/contracts/test/TestERC20ZRX.sol rename to packages/marketplace/contracts/mocks/TestERC20ZRX.sol diff --git a/packages/marketplace/contracts/test/TestERC721.sol b/packages/marketplace/contracts/mocks/TestERC721.sol similarity index 100% rename from packages/marketplace/contracts/test/TestERC721.sol rename to packages/marketplace/contracts/mocks/TestERC721.sol diff --git a/packages/marketplace/contracts/royalties-registry/mocks/tokens/TestERC721WithRoyaltyV2981.sol b/packages/marketplace/contracts/mocks/TestERC721WithRoyaltyV2981.sol similarity index 61% rename from packages/marketplace/contracts/royalties-registry/mocks/tokens/TestERC721WithRoyaltyV2981.sol rename to packages/marketplace/contracts/mocks/TestERC721WithRoyaltyV2981.sol index 0ea4193553..299f5c03b4 100644 --- a/packages/marketplace/contracts/royalties-registry/mocks/tokens/TestERC721WithRoyaltyV2981.sol +++ b/packages/marketplace/contracts/mocks/TestERC721WithRoyaltyV2981.sol @@ -2,12 +2,12 @@ pragma solidity 0.8.21; +import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; -import {Royalties2981TestImpl} from "../../../royalties/mocks/Royalties2981TestImpl.sol"; -import {LibRoyalties2981} from "../../../royalties/LibRoyalties2981.sol"; -import {AbstractRoyalties, LibPart} from "../../../royalties/mocks/AbstractRoyalties.sol"; -import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +import {LibRoyalties2981} from "../royalties/LibRoyalties2981.sol"; +import {Royalties2981TestImpl} from "./Royalties2981TestImpl.sol"; +import {AbstractRoyalties, LibPart} from "./AbstractRoyalties.sol"; contract TestERC721WithRoyaltyV2981 is Initializable, @@ -25,8 +25,13 @@ contract TestERC721WithRoyaltyV2981 is _saveRoyalties(tokenId, _fees); } - function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { - return interfaceId == LibRoyalties2981._INTERFACE_ID_ROYALTIES; + function supportsInterface( + bytes4 interfaceId + ) public view virtual override(ERC721Upgradeable, Royalties2981TestImpl) returns (bool) { + return + interfaceId == LibRoyalties2981._INTERFACE_ID_ROYALTIES || + ERC721Upgradeable.supportsInterface(interfaceId) || + Royalties2981TestImpl.supportsInterface(interfaceId); } // solhint-disable-next-line no-empty-blocks diff --git a/packages/marketplace/contracts/royalties-registry/mocks/tokens/TestERC721WithRoyaltyV2981Multi.sol b/packages/marketplace/contracts/mocks/TestERC721WithRoyaltyV2981Multi.sol similarity index 75% rename from packages/marketplace/contracts/royalties-registry/mocks/tokens/TestERC721WithRoyaltyV2981Multi.sol rename to packages/marketplace/contracts/mocks/TestERC721WithRoyaltyV2981Multi.sol index 8a97044a5e..aefe610c07 100644 --- a/packages/marketplace/contracts/royalties-registry/mocks/tokens/TestERC721WithRoyaltyV2981Multi.sol +++ b/packages/marketplace/contracts/mocks/TestERC721WithRoyaltyV2981Multi.sol @@ -4,9 +4,9 @@ pragma solidity 0.8.21; import {ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; -import {Royalties2981TestImpl} from "../../../royalties/mocks/Royalties2981TestImpl.sol"; -import {LibRoyalties2981} from "../../../royalties/LibRoyalties2981.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +import {LibRoyalties2981} from "../royalties/LibRoyalties2981.sol"; +import {Royalties2981TestImpl} from "./Royalties2981TestImpl.sol"; contract TestERC721WithRoyaltyV2981Multi is Initializable, @@ -35,8 +35,14 @@ contract TestERC721WithRoyaltyV2981Multi is _setRecipients(_fees); } - function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { - return interfaceId == LibRoyalties2981._INTERFACE_ID_ROYALTIES || interfaceId == INTERFACE_ID_IROYALTYUGC; + function supportsInterface( + bytes4 interfaceId + ) public view virtual override(ERC721Upgradeable, Royalties2981TestImpl) returns (bool) { + return + interfaceId == LibRoyalties2981._INTERFACE_ID_ROYALTIES || + interfaceId == INTERFACE_ID_IROYALTYUGC || + ERC721Upgradeable.supportsInterface(interfaceId) || + Royalties2981TestImpl.supportsInterface(interfaceId); } function _setRecipients(Recipient[] memory recipients) internal { diff --git a/packages/marketplace/contracts/exchange/mocks/TestRoyaltiesRegistry.sol b/packages/marketplace/contracts/mocks/TestRoyaltiesRegistry.sol similarity index 92% rename from packages/marketplace/contracts/exchange/mocks/TestRoyaltiesRegistry.sol rename to packages/marketplace/contracts/mocks/TestRoyaltiesRegistry.sol index 2a0ef960ed..01e69d875f 100644 --- a/packages/marketplace/contracts/exchange/mocks/TestRoyaltiesRegistry.sol +++ b/packages/marketplace/contracts/mocks/TestRoyaltiesRegistry.sol @@ -2,11 +2,11 @@ pragma solidity 0.8.21; -import {IRoyaltiesProvider} from "../../interfaces/IRoyaltiesProvider.sol"; -import {LibPart} from "../../lib-part/LibPart.sol"; -import {LibRoyalties2981} from "../../royalties/LibRoyalties2981.sol"; -import {IERC2981} from "../../royalties/IERC2981.sol"; import {IERC165Upgradeable} from "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol"; +import {IRoyaltiesProvider} from "../interfaces/IRoyaltiesProvider.sol"; +import {LibPart} from "../lib-part/LibPart.sol"; +import {LibRoyalties2981} from "../royalties/LibRoyalties2981.sol"; +import {IERC2981} from "../royalties/IERC2981.sol"; contract TestRoyaltiesRegistry is IRoyaltiesProvider { struct RoyaltiesSet { diff --git a/packages/marketplace/contracts/exchange/mocks/TestMinimalForwarder.sol b/packages/marketplace/contracts/mocks/TrustedForwarderMock.sol similarity index 56% rename from packages/marketplace/contracts/exchange/mocks/TestMinimalForwarder.sol rename to packages/marketplace/contracts/mocks/TrustedForwarderMock.sol index f49e9a591e..aafe36b9c8 100644 --- a/packages/marketplace/contracts/exchange/mocks/TestMinimalForwarder.sol +++ b/packages/marketplace/contracts/mocks/TrustedForwarderMock.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.21; import {MinimalForwarder} from "@openzeppelin/contracts/metatx/MinimalForwarder.sol"; -contract TestMinimalForwarder is MinimalForwarder { +contract TrustedForwarderMock is MinimalForwarder { constructor() MinimalForwarder() {} //Expand function execute and treat error @@ -15,4 +15,13 @@ contract TestMinimalForwarder is MinimalForwarder { require(success, "meta transaction failed"); return returndata; } + + function execute(ForwardRequest calldata req) public payable returns (bool, bytes memory) { + (bool success, bytes memory returndata) = req.to.call{gas: req.gas, value: req.value}( + abi.encodePacked(req.data, req.from) + ); + assert(gasleft() > req.gas / 63); + require(success, "Call execution failed"); + return (success, returndata); + } } diff --git a/packages/marketplace/contracts/exchange/mocks/tokens/MintableERC1155.sol b/packages/marketplace/contracts/mocks/tokens/MintableERC1155.sol similarity index 100% rename from packages/marketplace/contracts/exchange/mocks/tokens/MintableERC1155.sol rename to packages/marketplace/contracts/mocks/tokens/MintableERC1155.sol diff --git a/packages/marketplace/contracts/exchange/mocks/tokens/MintableERC1155WithRoyalties.sol b/packages/marketplace/contracts/mocks/tokens/MintableERC1155WithRoyalties.sol similarity index 92% rename from packages/marketplace/contracts/exchange/mocks/tokens/MintableERC1155WithRoyalties.sol rename to packages/marketplace/contracts/mocks/tokens/MintableERC1155WithRoyalties.sol index 6a3a614f1a..d8585c0087 100644 --- a/packages/marketplace/contracts/exchange/mocks/tokens/MintableERC1155WithRoyalties.sol +++ b/packages/marketplace/contracts/mocks/tokens/MintableERC1155WithRoyalties.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; +import {ERC2981} from "@openzeppelin/contracts/token/common/ERC2981.sol"; import {MintableERC1155, ERC1155} from "./MintableERC1155.sol"; -import {ERC2981} from "./ERC2981.sol"; contract MintableERC1155WithRoyalties is MintableERC1155, ERC2981 { function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, ERC2981) returns (bool) { diff --git a/packages/marketplace/contracts/exchange/mocks/tokens/MintableERC20.sol b/packages/marketplace/contracts/mocks/tokens/MintableERC20.sol similarity index 100% rename from packages/marketplace/contracts/exchange/mocks/tokens/MintableERC20.sol rename to packages/marketplace/contracts/mocks/tokens/MintableERC20.sol diff --git a/packages/marketplace/contracts/exchange/mocks/tokens/MintableERC721.sol b/packages/marketplace/contracts/mocks/tokens/MintableERC721.sol similarity index 100% rename from packages/marketplace/contracts/exchange/mocks/tokens/MintableERC721.sol rename to packages/marketplace/contracts/mocks/tokens/MintableERC721.sol diff --git a/packages/marketplace/contracts/exchange/mocks/tokens/MintableERC721WithRoyalties.sol b/packages/marketplace/contracts/mocks/tokens/MintableERC721WithRoyalties.sol similarity index 92% rename from packages/marketplace/contracts/exchange/mocks/tokens/MintableERC721WithRoyalties.sol rename to packages/marketplace/contracts/mocks/tokens/MintableERC721WithRoyalties.sol index 77084201b3..809de1e9d8 100644 --- a/packages/marketplace/contracts/exchange/mocks/tokens/MintableERC721WithRoyalties.sol +++ b/packages/marketplace/contracts/mocks/tokens/MintableERC721WithRoyalties.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; +import {ERC2981} from "@openzeppelin/contracts/token/common/ERC2981.sol"; import {MintableERC721, ERC721} from "./MintableERC721.sol"; -import {ERC2981} from "./ERC2981.sol"; contract MintableERC721WithRoyalties is MintableERC721, ERC2981 { function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC2981) returns (bool) { diff --git a/packages/marketplace/contracts/royalties-registry/mocks/tokens/TestERC721.sol b/packages/marketplace/contracts/royalties-registry/mocks/tokens/TestERC721.sol deleted file mode 100644 index 1bbc37c83f..0000000000 --- a/packages/marketplace/contracts/royalties-registry/mocks/tokens/TestERC721.sol +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity 0.8.21; - -// solhint-disable-next-line no-unused-import -import {TestERC721} from "../../../test/TestERC721.sol"; diff --git a/packages/marketplace/contracts/test/FakeProxy.sol b/packages/marketplace/contracts/test/FakeProxy.sol deleted file mode 100644 index 8727b325fe..0000000000 --- a/packages/marketplace/contracts/test/FakeProxy.sol +++ /dev/null @@ -1,36 +0,0 @@ -//SPDX-License-Identifier: MIT -// solhint-disable-next-line compiler-version -pragma solidity 0.8.21; - -import {ERC1967UpgradeUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol"; - -/// @dev just for testing don't use this code on production !!!! -contract FakeProxy is ERC1967UpgradeUpgradeable { - constructor(address newImplementation) { - _upgradeTo(newImplementation); - } - - function _delegate(address implementation) internal virtual { - // solhint-disable-next-line no-inline-assembly - assembly { - calldatacopy(0, 0, calldatasize()) - let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) - returndatacopy(0, 0, returndatasize()) - switch result - case 0 { - revert(0, returndatasize()) - } - default { - return(0, returndatasize()) - } - } - } - - fallback() external payable { - _delegate(_getImplementation()); - } - - receive() external payable { - _delegate(_getImplementation()); - } -} diff --git a/packages/marketplace/contracts/test/TrustedForwarderMock.sol b/packages/marketplace/contracts/test/TrustedForwarderMock.sol deleted file mode 100644 index c9f85cf03c..0000000000 --- a/packages/marketplace/contracts/test/TrustedForwarderMock.sol +++ /dev/null @@ -1,22 +0,0 @@ -//SPDX-License-Identifier: MIT -// solhint-disable-next-line compiler-version -pragma solidity 0.8.21; - -contract TrustedForwarderMock { - struct ForwardRequest { - address from; - address to; - uint256 value; - uint256 gas; - uint256 nonce; - bytes data; - } - - function execute(ForwardRequest calldata req, bytes calldata) public payable returns (bool, bytes memory) { - (bool success, bytes memory returndata) = req.to.call{gas: req.gas, value: req.value}( - abi.encodePacked(req.data, req.from) - ); - assert(gasleft() > req.gas / 63); - return (success, returndata); - } -} diff --git a/packages/marketplace/contracts/transfer-manager/mocks/TestERC1155.sol b/packages/marketplace/contracts/transfer-manager/mocks/TestERC1155.sol deleted file mode 100644 index 11fcf356ce..0000000000 --- a/packages/marketplace/contracts/transfer-manager/mocks/TestERC1155.sol +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity 0.8.21; - -// solhint-disable-next-line no-unused-import -import {TestERC1155} from "../../test/TestERC1155.sol"; diff --git a/packages/marketplace/contracts/transfer-manager/mocks/TestERC20.sol b/packages/marketplace/contracts/transfer-manager/mocks/TestERC20.sol deleted file mode 100644 index 759e1c1ec7..0000000000 --- a/packages/marketplace/contracts/transfer-manager/mocks/TestERC20.sol +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity 0.8.21; - -// solhint-disable-next-line no-unused-import -import {TestERC20} from "../../test/TestERC20.sol"; diff --git a/packages/marketplace/contracts/transfer-manager/mocks/TestERC20ZRX.sol b/packages/marketplace/contracts/transfer-manager/mocks/TestERC20ZRX.sol deleted file mode 100644 index 2508a826b6..0000000000 --- a/packages/marketplace/contracts/transfer-manager/mocks/TestERC20ZRX.sol +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity 0.8.21; - -// solhint-disable-next-line no-unused-import -import {TestERC20ZRX} from "../../test/TestERC20ZRX.sol"; diff --git a/packages/marketplace/contracts/transfer-manager/mocks/TestERC721.sol b/packages/marketplace/contracts/transfer-manager/mocks/TestERC721.sol deleted file mode 100644 index 71532191f4..0000000000 --- a/packages/marketplace/contracts/transfer-manager/mocks/TestERC721.sol +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity 0.8.21; - -// solhint-disable-next-line no-unused-import -import {TestERC721} from "../../test/TestERC721.sol";