diff --git a/src/MintERC1155.sol b/src/MintERC1155.sol index 1c8369c..483fe22 100644 --- a/src/MintERC1155.sol +++ b/src/MintERC1155.sol @@ -49,36 +49,39 @@ contract MintERC1155 is ERC1155Upgradeable, OwnableUpgradeable, ERC2981Upgradeab string calldata name_, string calldata imageURI_, string calldata description_, - Edition[] calldata editions_ + Edition[] calldata editions_, + uint16 royaltyAmountBps ) external initializer { - uint256 totalPercentChance = 0; - for (uint256 i = 0; i < editions_.length; i++) { - editions.push(); - editions[i].name = editions_[i].name; - editions[i].imageURI = editions_[i].imageURI; - totalPercentChance += editions[i].percentChance = editions_[i].percentChance; - - if (editions_[i].percentChance == 0) { - revert MintERC1155_PercentChance0(); - } + { + uint256 totalPercentChance = 0; + for (uint256 i = 0; i < editions_.length; i++) { + editions.push(); + editions[i].name = editions_[i].name; + editions[i].imageURI = editions_[i].imageURI; + totalPercentChance += editions[i].percentChance = editions_[i].percentChance; + + if (editions_[i].percentChance == 0) { + revert MintERC1155_PercentChance0(); + } - for (uint256 j = 0; j < editions_[i].attributes.length; j++) { - editions[i].attributes.push(editions_[i].attributes[j]); + for (uint256 j = 0; j < editions_[i].attributes.length; j++) { + editions[i].attributes.push(editions_[i].attributes[j]); + } } - } - if (totalPercentChance != 100) { - revert MintERC1155_TotalPercentChanceNot100(); + if (totalPercentChance != 100) { + revert MintERC1155_TotalPercentChanceNot100(); + } } - __Ownable_init(owner_); name = name_; imageURI = imageURI_; description = description_; - _setDefaultRoyalty(owner_, 150); + __Ownable_init(owner_); + _setDefaultRoyalty(owner_, royaltyAmountBps); } function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts) external { diff --git a/src/NFTMint.sol b/src/NFTMint.sol index fd5f9ce..4171121 100644 --- a/src/NFTMint.sol +++ b/src/NFTMint.sol @@ -28,6 +28,7 @@ contract NFTMint is Ownable { struct MintArgs { uint96 pricePerMint; uint96 feePerMint; + uint16 royaltyAmountBps; address payable owner; address payable feeRecipient; uint40 mintExpiration; @@ -82,7 +83,7 @@ contract NFTMint is Ownable { MINT_NFT_LOGIC, keccak256(abi.encodePacked(block.chainid, msg.sender, block.timestamp)) ) ); - newMint.initialize(args.owner, args.name, args.imageURI, args.description, args.editions); + newMint.initialize(args.owner, args.name, args.imageURI, args.description, args.editions, args.royaltyAmountBps); MintInfo storage mintInfo = mints[newMint]; mintInfo.owner = args.owner; diff --git a/test/MintERC1155.t.sol b/test/MintERC1155.t.sol index 263000b..ca66c0d 100644 --- a/test/MintERC1155.t.sol +++ b/test/MintERC1155.t.sol @@ -30,7 +30,7 @@ contract MintERC1155Test is TestBase, LintJSON { }); token = MintERC1155(Clones.clone(address(impl))); - token.initialize(address(this), "My Token Name", "image here", "This is a token", editions); + token.initialize(address(this), "My Token Name", "image here", "This is a token", editions, 150); assertEq(token.name(), "My Token Name"); assertEq(token.imageURI(), "image here"); @@ -68,7 +68,7 @@ contract MintERC1155Test is TestBase, LintJSON { MintERC1155 newToken = MintERC1155(Clones.clone(address(impl))); vm.expectRevert(MintERC1155.MintERC1155_PercentChance0.selector); - newToken.initialize(address(this), "", "", "", editions); + newToken.initialize(address(this), "", "", "", editions, 150); } function test_initialize_totalPercentChanceNot100() external { @@ -84,7 +84,7 @@ contract MintERC1155Test is TestBase, LintJSON { MintERC1155 newToken = MintERC1155(Clones.clone(address(impl))); vm.expectRevert(MintERC1155.MintERC1155_TotalPercentChanceNot100.selector); - newToken.initialize(address(this), "", "", "", editions); + newToken.initialize(address(this), "", "", "", editions, 150); } function test_mintBatch_unauthorized() external { diff --git a/test/NFTMint.t.sol b/test/NFTMint.t.sol index 9d2e8d6..970c3fe 100644 --- a/test/NFTMint.t.sol +++ b/test/NFTMint.t.sol @@ -49,7 +49,8 @@ contract NFTMintTest is TestBase { feeRecipient: payable(address(this)), name: "My Token Name", imageURI: "image here", - description: "This is a description" + description: "This is a description", + royaltyAmountBps: 150 }); return nftMint.createMint(mintArgs);