Skip to content
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
39 changes: 1 addition & 38 deletions src/core/token/ERC1155Core.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {Multicallable} from "@solady/utils/Multicallable.sol";
import {ModularCore} from "../../ModularCore.sol";

import {BeforeApproveForAllCallback} from "../../callback/BeforeApproveForAllCallback.sol";
import {BeforeBatchMintCallbackERC1155} from "../../callback/BeforeBatchMintCallbackERC1155.sol";
import {BeforeBatchTransferCallbackERC1155} from "../../callback/BeforeBatchTransferCallbackERC1155.sol";
import {BeforeBurnCallbackERC1155} from "../../callback/BeforeBurnCallbackERC1155.sol";
import {BeforeMintCallbackERC1155} from "../../callback/BeforeMintCallbackERC1155.sol";
Expand Down Expand Up @@ -124,7 +123,7 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
override
returns (SupportedCallbackFunction[] memory supportedCallbackFunctions)
{
supportedCallbackFunctions = new SupportedCallbackFunction[](7);
supportedCallbackFunctions = new SupportedCallbackFunction[](6);
supportedCallbackFunctions[0] = SupportedCallbackFunction({
selector: BeforeMintCallbackERC1155.beforeMintERC1155.selector,
mode: CallbackMode.REQUIRED
Expand All @@ -147,10 +146,6 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
});
supportedCallbackFunctions[5] =
Copy link
Member

Choose a reason for hiding this comment

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

is this intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mistake on my end, updated to add this back in

SupportedCallbackFunction({selector: OnTokenURICallback.onTokenURI.selector, mode: CallbackMode.REQUIRED});
supportedCallbackFunctions[6] = SupportedCallbackFunction({
selector: BeforeBatchMintCallbackERC1155.beforeBatchMintERC1155.selector,
mode: CallbackMode.REQUIRED
});
}

/*//////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -181,27 +176,6 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
_mint(to, tokenId, value, "");
}

/**
* @notice Batch mints tokens. Calls the beforeBatchMint hook.
* @dev Reverts if beforeBatchMint hook is absent or unsuccessful.
* @param to The address to mint the token to.
* @param ids The tokenIds to mint.
* @param amounts The amounts of tokens to mint.
* @param data ABI encoded data to pass to the beforeBatchMint hook.
*/
function batchMint(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
external
payable
{
_beforeBatchMint(to, ids, amounts, data);

for (uint256 i = 0; i < ids.length; i++) {
_totalSupply[ids[i]] += amounts[i];
}

_batchMint(to, ids, amounts, "");
}

/**
* @notice Burns given amount of tokens.
* @dev Calls the beforeBurn hook. Skips calling the hook if it doesn't exist.
Expand Down Expand Up @@ -285,17 +259,6 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
);
}

/// @dev Calls the beforeBatchMint hook.
function _beforeBatchMint(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
internal
virtual
{
_executeCallbackFunction(
BeforeBatchMintCallbackERC1155.beforeBatchMintERC1155.selector,
abi.encodeCall(BeforeBatchMintCallbackERC1155.beforeBatchMintERC1155, (to, ids, amounts, data))
);
}

/// @dev Calls the beforeTransfer hook, if installed.
function _beforeTransfer(address from, address to, uint256 tokenId, uint256 value) internal virtual {
_executeCallbackFunction(
Expand Down
39 changes: 1 addition & 38 deletions src/core/token/ERC1155CoreInitializable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {Multicallable} from "@solady/utils/Multicallable.sol";
import {ModularCore} from "../../ModularCore.sol";

import {BeforeApproveForAllCallback} from "../../callback/BeforeApproveForAllCallback.sol";
import {BeforeBatchMintCallbackERC1155} from "../../callback/BeforeBatchMintCallbackERC1155.sol";
import {BeforeBatchTransferCallbackERC1155} from "../../callback/BeforeBatchTransferCallbackERC1155.sol";
import {BeforeBurnCallbackERC1155} from "../../callback/BeforeBurnCallbackERC1155.sol";
import {BeforeMintCallbackERC1155} from "../../callback/BeforeMintCallbackERC1155.sol";
Expand Down Expand Up @@ -129,7 +128,7 @@ contract ERC1155CoreInitializable is ERC1155, ModularCore, Multicallable, Initia
override
returns (SupportedCallbackFunction[] memory supportedCallbackFunctions)
{
supportedCallbackFunctions = new SupportedCallbackFunction[](7);
supportedCallbackFunctions = new SupportedCallbackFunction[](6);
supportedCallbackFunctions[0] = SupportedCallbackFunction({
selector: BeforeMintCallbackERC1155.beforeMintERC1155.selector,
mode: CallbackMode.REQUIRED
Expand All @@ -152,10 +151,6 @@ contract ERC1155CoreInitializable is ERC1155, ModularCore, Multicallable, Initia
});
supportedCallbackFunctions[5] =
SupportedCallbackFunction({selector: OnTokenURICallback.onTokenURI.selector, mode: CallbackMode.REQUIRED});
supportedCallbackFunctions[6] = SupportedCallbackFunction({
selector: BeforeBatchMintCallbackERC1155.beforeBatchMintERC1155.selector,
mode: CallbackMode.REQUIRED
});
}

/*//////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -186,27 +181,6 @@ contract ERC1155CoreInitializable is ERC1155, ModularCore, Multicallable, Initia
_mint(to, tokenId, value, "");
}

/**
* @notice Batch mints tokens. Calls the beforeBatchMint hook.
* @dev Reverts if beforeBatchMint hook is absent or unsuccessful.
* @param to The address to mint the token to.
* @param ids The tokenIds to mint.
* @param amounts The amounts of tokens to mint.
* @param data ABI encoded data to pass to the beforeBatchMint hook.
*/
function batchMint(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
external
payable
{
_beforeBatchMint(to, ids, amounts, data);

for (uint256 i = 0; i < ids.length; i++) {
_totalSupply[ids[i]] += amounts[i];
}

_batchMint(to, ids, amounts, "");
}

/**
* @notice Burns given amount of tokens.
* @dev Calls the beforeBurn hook. Skips calling the hook if it doesn't exist.
Expand Down Expand Up @@ -290,17 +264,6 @@ contract ERC1155CoreInitializable is ERC1155, ModularCore, Multicallable, Initia
);
}

/// @dev Calls the beforeBatchMint hook.
function _beforeBatchMint(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
internal
virtual
{
_executeCallbackFunction(
BeforeBatchMintCallbackERC1155.beforeBatchMintERC1155.selector,
abi.encodeCall(BeforeBatchMintCallbackERC1155.beforeBatchMintERC1155, (to, ids, amounts, data))
);
}

/// @dev Calls the beforeTransfer hook, if installed.
function _beforeTransfer(address from, address to, uint256 tokenId, uint256 value) internal virtual {
_executeCallbackFunction(
Expand Down