Skip to content

Commit

Permalink
Merge pull request #48 from thirdweb-dev/nk/add-multicall
Browse files Browse the repository at this point in the history
Add Multicallable to core contracts
  • Loading branch information
nkrishang authored Mar 1, 2024
2 parents e7c66fa + 98ae28c commit b333948
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/core/token/ERC1155Core.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.0;

import { Initializable } from "@solady/utils/Initializable.sol";
import { Multicallable } from "@solady/utils/Multicallable.sol";

import { IERC7572 } from "../../interface/eip/IERC7572.sol";
import { IERC1155CoreCustomErrors } from "../../interface/errors/IERC1155CoreCustomErrors.sol";
Expand All @@ -16,6 +17,7 @@ import { ERC1155CoreStorage } from "../../storage/core/ERC1155CoreStorage.sol";

contract ERC1155Core is
Initializable,
Multicallable,
ERC1155Initializable,
HookInstaller,
Permission,
Expand Down
2 changes: 2 additions & 0 deletions src/core/token/ERC20Core.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.0;

import { Initializable } from "@solady/utils/Initializable.sol";
import { Multicallable } from "@solady/utils/Multicallable.sol";

import { IERC7572 } from "../../interface/eip/IERC7572.sol";
import { IERC20CoreCustomErrors } from "../../interface/errors/IERC20CoreCustomErrors.sol";
Expand All @@ -16,6 +17,7 @@ import { ERC20CoreStorage } from "../../storage/core/ERC20CoreStorage.sol";

contract ERC20Core is
Initializable,
Multicallable,
ERC20Initializable,
HookInstaller,
Permission,
Expand Down
2 changes: 2 additions & 0 deletions src/core/token/ERC721Core.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.0;

import { Initializable } from "@solady/utils/Initializable.sol";
import { Multicallable } from "@solady/utils/Multicallable.sol";

import { IERC7572 } from "../../interface/eip/IERC7572.sol";
import { IERC721CoreCustomErrors } from "../../interface/errors/IERC721CoreCustomErrors.sol";
Expand All @@ -16,6 +17,7 @@ import { ERC721CoreStorage } from "../../storage/core/ERC721CoreStorage.sol";

contract ERC721Core is
Initializable,
Multicallable,
ERC721Initializable,
HookInstaller,
Permission,
Expand Down
3 changes: 2 additions & 1 deletion src/hook/metadata/LazyMintHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
pragma solidity ^0.8.0;

import { LibString } from "@solady/utils/LibString.sol";
import { Multicallable } from "@solady/utils/Multicallable.sol";

import { ERC721Hook } from "../ERC721Hook.sol";
import { IPermission } from "../../interface/common/IPermission.sol";

import { LazyMintStorage } from "../../storage/hook/metadata/LazyMintStorage.sol";

contract LazyMintHook is ERC721Hook {
contract LazyMintHook is ERC721Hook, Multicallable {
using LibString for uint256;

/*//////////////////////////////////////////////////////////////
Expand Down
4 changes: 3 additions & 1 deletion src/hook/metadata/OpenEditionHookERC721.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import { Multicallable } from "@solady/utils/Multicallable.sol";

import { IPermission } from "../../interface/common/IPermission.sol";

import { ERC721Hook } from "../ERC721Hook.sol";
Expand All @@ -9,7 +11,7 @@ import { NFTMetadataRenderer } from "../../lib/NFTMetadataRenderer.sol";
import { SharedMetadataStorage } from "../../storage/hook/metadata/SharedMetadataStorage.sol";
import { ISharedMetadata } from "../../interface/common/ISharedMetadata.sol";

contract OpenEditionHookERC721 is ISharedMetadata, ERC721Hook {
contract OpenEditionHookERC721 is ISharedMetadata, ERC721Hook, Multicallable {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
Expand Down
3 changes: 2 additions & 1 deletion src/hook/metadata/SimpleMetadataHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
pragma solidity ^0.8.0;

import { LibString } from "@solady/utils/LibString.sol";
import { Multicallable } from "@solady/utils/Multicallable.sol";

import { ERC721Hook } from "../ERC721Hook.sol";
import { IPermission } from "../../interface/common/IPermission.sol";

import { SimpleMetadataStorage } from "../../storage/hook/metadata/SimpleMetadataStorage.sol";

contract SimpleMetadataHook is ERC721Hook {
contract SimpleMetadataHook is ERC721Hook, Multicallable {
using LibString for uint256;

/*//////////////////////////////////////////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion src/hook/mint/AllowlistMintHookERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ pragma solidity ^0.8.0;

import { MerkleProofLib } from "@solady/utils/MerkleProofLib.sol";
import { SafeTransferLib } from "@solady/utils/SafeTransferLib.sol";
import { Multicallable } from "@solady/utils/Multicallable.sol";

import { IFeeConfig } from "../../interface/common/IFeeConfig.sol";
import { IPermission } from "../../interface/common/IPermission.sol";
import { ERC1155Hook } from "../ERC1155Hook.sol";

import { AllowlistMintHookERC1155Storage } from "../../storage/hook/mint/AllowlistMintHookERC1155Storage.sol";

contract AllowlistMintHookERC1155 is IFeeConfig, ERC1155Hook {
contract AllowlistMintHookERC1155 is IFeeConfig, ERC1155Hook, Multicallable {
/*//////////////////////////////////////////////////////////////
STRUCTS
//////////////////////////////////////////////////////////////*/
Expand Down
3 changes: 2 additions & 1 deletion src/hook/mint/AllowlistMintHookERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ pragma solidity ^0.8.0;

import { MerkleProofLib } from "@solady/utils/MerkleProofLib.sol";
import { SafeTransferLib } from "@solady/utils/SafeTransferLib.sol";
import { Multicallable } from "@solady/utils/Multicallable.sol";

import { IFeeConfig } from "../../interface/common/IFeeConfig.sol";
import { IPermission } from "../../interface/common/IPermission.sol";
import { ERC20Hook } from "../ERC20Hook.sol";

import { AllowlistMintHookERC20Storage } from "../../storage/hook/mint/AllowlistMintHookERC20Storage.sol";

contract AllowlistMintHookERC20 is IFeeConfig, ERC20Hook {
contract AllowlistMintHookERC20 is IFeeConfig, ERC20Hook, Multicallable {
/*//////////////////////////////////////////////////////////////
STRUCTS
//////////////////////////////////////////////////////////////*/
Expand Down
3 changes: 2 additions & 1 deletion src/hook/mint/AllowlistMintHookERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ pragma solidity ^0.8.0;

import { MerkleProofLib } from "@solady/utils/MerkleProofLib.sol";
import { SafeTransferLib } from "@solady/utils/SafeTransferLib.sol";
import { Multicallable } from "@solady/utils/Multicallable.sol";

import { IFeeConfig } from "../../interface/common/IFeeConfig.sol";
import { IPermission } from "../../interface/common/IPermission.sol";
import { ERC721Hook } from "../ERC721Hook.sol";

import { AllowlistMintHookERC721Storage } from "../../storage/hook/mint/AllowlistMintHookERC721Storage.sol";

contract AllowlistMintHookERC721 is IFeeConfig, ERC721Hook {
contract AllowlistMintHookERC721 is IFeeConfig, ERC721Hook, Multicallable {
/*//////////////////////////////////////////////////////////////
STRUCTS
//////////////////////////////////////////////////////////////*/
Expand Down
3 changes: 2 additions & 1 deletion src/hook/mint/MintHookERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { EIP712 } from "@solady/utils/EIP712.sol";
import { ECDSA } from "@solady/utils/ECDSA.sol";
import { MerkleProofLib } from "@solady/utils/MerkleProofLib.sol";
import { SafeTransferLib } from "@solady/utils/SafeTransferLib.sol";
import { Multicallable } from "@solady/utils/Multicallable.sol";

import { IFeeConfig } from "../../interface/common/IFeeConfig.sol";
import { IPermission } from "../../interface/common/IPermission.sol";
Expand All @@ -15,7 +16,7 @@ import { ERC1155Hook } from "../ERC1155Hook.sol";

import { MintHookERC1155Storage } from "../../storage/hook/mint/MintHookERC1155Storage.sol";

contract MintHookERC1155 is IFeeConfig, IMintRequest, IClaimCondition, EIP712, ERC1155Hook {
contract MintHookERC1155 is IFeeConfig, IMintRequest, IClaimCondition, EIP712, ERC1155Hook, Multicallable {
using ECDSA for bytes32;

/*//////////////////////////////////////////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion src/hook/mint/MintHookERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { EIP712 } from "@solady/utils/EIP712.sol";
import { ECDSA } from "@solady/utils/ECDSA.sol";
import { MerkleProofLib } from "@solady/utils/MerkleProofLib.sol";
import { SafeTransferLib } from "@solady/utils/SafeTransferLib.sol";
import { Multicallable } from "@solady/utils/Multicallable.sol";

import { IFeeConfig } from "../../interface/common/IFeeConfig.sol";
import { IPermission } from "../../interface/common/IPermission.sol";
Expand All @@ -15,7 +16,7 @@ import { ERC20Hook } from "../ERC20Hook.sol";

import { MintHookERC20Storage } from "../../storage/hook/mint/MintHookERC20Storage.sol";

contract MintHookERC20 is IFeeConfig, IMintRequest, IClaimCondition, EIP712, ERC20Hook {
contract MintHookERC20 is IFeeConfig, IMintRequest, IClaimCondition, EIP712, ERC20Hook, Multicallable {
using ECDSA for bytes32;

/*//////////////////////////////////////////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion src/hook/mint/MintHookERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { EIP712 } from "@solady/utils/EIP712.sol";
import { ECDSA } from "@solady/utils/ECDSA.sol";
import { MerkleProofLib } from "@solady/utils/MerkleProofLib.sol";
import { SafeTransferLib } from "@solady/utils/SafeTransferLib.sol";
import { Multicallable } from "@solady/utils/Multicallable.sol";

import { IFeeConfig } from "../../interface/common/IFeeConfig.sol";
import { IPermission } from "../../interface/common/IPermission.sol";
Expand All @@ -15,7 +16,7 @@ import { ERC721Hook } from "../ERC721Hook.sol";

import { MintHookERC721Storage } from "../../storage/hook/mint/MintHookERC721Storage.sol";

contract MintHookERC721 is IFeeConfig, IMintRequest, IClaimCondition, EIP712, ERC721Hook {
contract MintHookERC721 is IFeeConfig, IMintRequest, IClaimCondition, EIP712, ERC721Hook, Multicallable {
using ECDSA for bytes32;

/*//////////////////////////////////////////////////////////////
Expand Down
4 changes: 3 additions & 1 deletion src/hook/royalty/RoyaltyHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ pragma solidity ^0.8.0;

/// @author thirdweb

import { Multicallable } from "@solady/utils/Multicallable.sol";

import { IPermission } from "../../interface/common/IPermission.sol";
import { IRoyaltyInfo } from "../../interface/common/IRoyaltyInfo.sol";
import { ERC1155Hook } from "../ERC1155Hook.sol";

import { RoyaltyHookStorage } from "../../storage/hook/royalty/RoyaltyHookStorage.sol";

contract RoyaltyHook is IRoyaltyInfo, ERC1155Hook {
contract RoyaltyHook is IRoyaltyInfo, ERC1155Hook, Multicallable {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
Expand Down
2 changes: 2 additions & 0 deletions test/core/ERC1155Core.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,8 @@ contract ERC1155CoreTest is Test, TestPlus {
}

function testSafeTransferFromSelf(uint256 id, uint256 mintAmount, uint256 transferAmount, address to) public {
vm.assume(address(0xCAFE) != to);

if (to == address(0)) to = address(0xBEEF);

if (uint256(uint160(to)) <= 18 || to.code.length > 0) return;
Expand Down

0 comments on commit b333948

Please sign in to comment.