diff --git a/src/module/token/minting/MintableERC1155.sol b/src/module/token/minting/MintableERC1155.sol index e6c5ad95..793a7894 100644 --- a/src/module/token/minting/MintableERC1155.sol +++ b/src/module/token/minting/MintableERC1155.sol @@ -145,7 +145,10 @@ contract MintableERC1155 is override returns (bytes memory) { - if (!OwnableRoles(address(this)).hasAllRoles(msg.sender, Role._MINTER_ROLE)) { + if ( + OwnableRoles(address(this)).owner() != msg.sender + && !OwnableRoles(address(this)).hasAllRoles(msg.sender, Role._MINTER_ROLE) + ) { revert MintableRequestUnauthorized(); } } diff --git a/src/module/token/minting/MintableERC20.sol b/src/module/token/minting/MintableERC20.sol index 235cee01..d00bd703 100644 --- a/src/module/token/minting/MintableERC20.sol +++ b/src/module/token/minting/MintableERC20.sol @@ -148,7 +148,10 @@ contract MintableERC20 is override returns (bytes memory) { - if (!OwnableRoles(address(this)).hasAllRoles(msg.sender, Role._MINTER_ROLE)) { + if ( + OwnableRoles(address(this)).owner() != msg.sender + && !OwnableRoles(address(this)).hasAllRoles(msg.sender, Role._MINTER_ROLE) + ) { revert MintableRequestUnauthorized(); } } diff --git a/src/module/token/minting/MintableERC721.sol b/src/module/token/minting/MintableERC721.sol index 136394b9..9c1be9e1 100644 --- a/src/module/token/minting/MintableERC721.sol +++ b/src/module/token/minting/MintableERC721.sol @@ -150,7 +150,10 @@ contract MintableERC721 is override returns (bytes memory) { - if (!OwnableRoles(address(this)).hasAllRoles(msg.sender, Role._MINTER_ROLE)) { + if ( + OwnableRoles(address(this)).owner() != msg.sender + && !OwnableRoles(address(this)).hasAllRoles(msg.sender, Role._MINTER_ROLE) + ) { revert MintableRequestUnauthorized(); } } diff --git a/src/module/token/transferable/TransferableERC1155.sol b/src/module/token/transferable/TransferableERC1155.sol index 20423902..20b04adf 100644 --- a/src/module/token/transferable/TransferableERC1155.sol +++ b/src/module/token/transferable/TransferableERC1155.sol @@ -38,6 +38,13 @@ contract TransferableERC1155 is Module, BeforeTransferCallbackERC1155, BeforeBat /// @notice Emitted on attempt to transfer a token when transfers are disabled. error TransferDisabled(); + /*////////////////////////////////////////////////////////////// + EVENTS + //////////////////////////////////////////////////////////////*/ + + /// @notice Emitted on attempt to transfer a token when transfers are disabled. + event TransferEnableFor(address indexed target, bool enabled); + /*////////////////////////////////////////////////////////////// MODULE CONFIG //////////////////////////////////////////////////////////////*/ @@ -60,8 +67,18 @@ contract TransferableERC1155 is Module, BeforeTransferCallbackERC1155, BeforeBat config.requiredInterfaces = new bytes4[](1); config.requiredInterfaces[0] = 0xd9b67a26; // ERC1155 + + config.registerInstallationCallback = true; + } + + /// @dev Called by a Core into an Module during the installation of the Module. + function onInstall(bytes calldata data) external { + _transferableStorage().transferEnabled = true; } + /// @dev Called by a Core into an Module during the uninstallation of the Module. + function onUninstall(bytes calldata data) external {} + /*////////////////////////////////////////////////////////////// CALLBACK FUNCTIONS //////////////////////////////////////////////////////////////*/ @@ -120,6 +137,7 @@ contract TransferableERC1155 is Module, BeforeTransferCallbackERC1155, BeforeBat /// @notice Set transferability for an operator for a token. function setTransferableFor(address target, bool enableTransfer) external { _transferableStorage().transferEnabledFor[target] = enableTransfer; + emit TransferEnableFor(target, enableTransfer); } /*////////////////////////////////////////////////////////////// diff --git a/src/module/token/transferable/TransferableERC20.sol b/src/module/token/transferable/TransferableERC20.sol index 9dd747b0..163a68f0 100644 --- a/src/module/token/transferable/TransferableERC20.sol +++ b/src/module/token/transferable/TransferableERC20.sol @@ -36,6 +36,13 @@ contract TransferableERC20 is Module, BeforeTransferCallbackERC20 { /// @notice Emitted on attempt to transfer a token when transfers are disabled. error TransferDisabled(); + /*////////////////////////////////////////////////////////////// + EVENTS + //////////////////////////////////////////////////////////////*/ + + /// @notice Emitted on attempt to transfer a token when transfers are disabled. + event TransferEnableFor(address indexed target, bool enabled); + /*////////////////////////////////////////////////////////////// MODULE CONFIG //////////////////////////////////////////////////////////////*/ @@ -54,8 +61,18 @@ contract TransferableERC20 is Module, BeforeTransferCallbackERC20 { FallbackFunction({selector: this.setTransferable.selector, permissionBits: Role._MANAGER_ROLE}); config.fallbackFunctions[3] = FallbackFunction({selector: this.setTransferableFor.selector, permissionBits: Role._MANAGER_ROLE}); + + config.registerInstallationCallback = true; + } + + /// @dev Called by a Core into an Module during the installation of the Module. + function onInstall(bytes calldata data) external { + _transferableStorage().transferEnabled = true; } + /// @dev Called by a Core into an Module during the uninstallation of the Module. + function onUninstall(bytes calldata data) external {} + /*////////////////////////////////////////////////////////////// CALLBACK FUNCTIONS //////////////////////////////////////////////////////////////*/ @@ -93,6 +110,7 @@ contract TransferableERC20 is Module, BeforeTransferCallbackERC20 { /// @notice Set transferability for an address for a token. function setTransferableFor(address target, bool enableTransfer) external { _transferableStorage().transferEnabledFor[target] = enableTransfer; + emit TransferEnableFor(target, enableTransfer); } /*////////////////////////////////////////////////////////////// diff --git a/src/module/token/transferable/TransferableERC721.sol b/src/module/token/transferable/TransferableERC721.sol index d43aad29..e1b1b6d0 100644 --- a/src/module/token/transferable/TransferableERC721.sol +++ b/src/module/token/transferable/TransferableERC721.sol @@ -36,6 +36,13 @@ contract TransferableERC721 is Module, BeforeTransferCallbackERC721 { /// @notice Emitted on attempt to transfer a token when transfers are disabled. error TransferDisabled(); + /*////////////////////////////////////////////////////////////// + EVENTS + //////////////////////////////////////////////////////////////*/ + + /// @notice Emitted on attempt to transfer a token when transfers are disabled. + event TransferEnableFor(address indexed target, bool enabled); + /*////////////////////////////////////////////////////////////// MODULE CONFIG //////////////////////////////////////////////////////////////*/ @@ -57,8 +64,18 @@ contract TransferableERC721 is Module, BeforeTransferCallbackERC721 { config.requiredInterfaces = new bytes4[](1); config.requiredInterfaces[0] = 0x80ac58cd; // ERC721. + + config.registerInstallationCallback = true; + } + + /// @dev Called by a Core into an Module during the installation of the Module. + function onInstall(bytes calldata data) external { + _transferableStorage().transferEnabled = true; } + /// @dev Called by a Core into an Module during the uninstallation of the Module. + function onUninstall(bytes calldata data) external {} + /*////////////////////////////////////////////////////////////// CALLBACK FUNCTIONS //////////////////////////////////////////////////////////////*/ @@ -96,6 +113,7 @@ contract TransferableERC721 is Module, BeforeTransferCallbackERC721 { /// @notice Set transferability for an address for a token. function setTransferableFor(address target, bool enableTransfer) external { _transferableStorage().transferEnabledFor[target] = enableTransfer; + emit TransferEnableFor(target, enableTransfer); } /*////////////////////////////////////////////////////////////// diff --git a/test/module/minting/MintableERC1155.t.sol b/test/module/minting/MintableERC1155.t.sol index 522daf03..8d2de48a 100644 --- a/test/module/minting/MintableERC1155.t.sol +++ b/test/module/minting/MintableERC1155.t.sol @@ -188,7 +188,7 @@ contract MintableERC1155Test is Test { ); // Check minted balance - assertEq(core.balanceOf(address(0x123), tokenId), amount); + assertEq(core.balanceOf(tokenRecipient, tokenId), amount); uint256 salePrice = (amount * mintRequest.pricePerUnit); (uint256 primarySaleAmount, uint256 platformFeeAmount) = @@ -198,6 +198,18 @@ contract MintableERC1155Test is Test { assertEq(feeRecipient.balance, platformFeeAmount, "feeRecipient balance"); } + function test_simple_mint() public { + vm.prank(owner); + core.mint(owner, tokenId, amount, "", ""); + + assertEq(core.balanceOf(owner, tokenId), amount); + + vm.prank(permissionedActor); + core.mint(permissionedActor, tokenId, amount, "", ""); + + assertEq(core.balanceOf(permissionedActor, tokenId), amount); + } + function test_mint_revert_unableToDecodeArgs() public { vm.deal(tokenRecipient, 100 ether); diff --git a/test/module/minting/MintableERC20.t.sol b/test/module/minting/MintableERC20.t.sol index 4a2fc009..bc69726c 100644 --- a/test/module/minting/MintableERC20.t.sol +++ b/test/module/minting/MintableERC20.t.sol @@ -186,6 +186,18 @@ contract MintableERC20Test is Test { assertEq(feeRecipient.balance, platformFeeAmount, "feeRecipient balance"); } + function test_simple_mint() public { + vm.prank(owner); + core.mint(owner, amount, ""); + + assertEq(core.balanceOf(owner), amount); + + vm.prank(permissionedActor); + core.mint(permissionedActor, amount, ""); + + assertEq(core.balanceOf(permissionedActor), amount); + } + function test_mint_revert_unableToDecodeArgs() public { vm.deal(tokenRecipient, 100 ether); diff --git a/test/module/minting/MintableERC721.t.sol b/test/module/minting/MintableERC721.t.sol index 5fd4c52c..f0fc1fb0 100644 --- a/test/module/minting/MintableERC721.t.sol +++ b/test/module/minting/MintableERC721.t.sol @@ -186,7 +186,7 @@ contract MintableERC721Test is Test { ); // Check minted balance - assertEq(core.balanceOf(address(0x123)), amount); + assertEq(core.balanceOf(tokenRecipient), amount); uint256 salePrice = (amount * mintRequest.pricePerUnit); (uint256 primarySaleAmount, uint256 platformFeeAmount) = @@ -196,6 +196,18 @@ contract MintableERC721Test is Test { assertEq(feeRecipient.balance, platformFeeAmount, "feeRecipient balance"); } + function test_simple_mint() public { + vm.prank(owner); + core.mint(owner, amount, "", ""); + + assertEq(core.balanceOf(owner), amount); + + vm.prank(permissionedActor); + core.mint(permissionedActor, amount, "", ""); + + assertEq(core.balanceOf(permissionedActor), amount); + } + function test_mint_revert_unableToDecodeArgs() public { vm.deal(tokenRecipient, 100 ether);