Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QoL changes for dashboard + crosschain modules #185

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions src/module/token/minting/ClaimableERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ contract ClaimableERC1155 is
/// @dev Called by a Core into an Module during the uninstallation of the Module.
function onUninstall(bytes calldata data) external {}

/// @dev Returns bytes encoded for installing modules on cross-chain
function crosschainBytesOnInstall() external view returns (bytes memory) {
return abi.encode(_claimableStorage().saleConfig.primarySaleRecipient);
}

/*//////////////////////////////////////////////////////////////
Encode install / uninstall data
//////////////////////////////////////////////////////////////*/
Expand Down
5 changes: 5 additions & 0 deletions src/module/token/minting/ClaimableERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ contract ClaimableERC20 is
/// @dev Called by a Core into an Module during the uninstallation of the Module.
function onUninstall(bytes calldata data) external {}

/// @dev Returns bytes encoded for installing modules on cross-chain
function crosschainBytesOnInstall() external view returns (bytes memory) {
return abi.encode(_claimableStorage().saleConfig.primarySaleRecipient);
}

/*//////////////////////////////////////////////////////////////
Encode install / uninstall data
//////////////////////////////////////////////////////////////*/
Expand Down
5 changes: 5 additions & 0 deletions src/module/token/minting/ClaimableERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ contract ClaimableERC721 is
/// @dev Called by a Core into an Module during the uninstallation of the Module.
function onUninstall(bytes calldata data) external {}

/// @dev Returns bytes encoded for installing modules on cross-chain
function crosschainBytesOnInstall() external view returns (bytes memory) {
return abi.encode(_claimableStorage().saleConfig.primarySaleRecipient);
}

/*//////////////////////////////////////////////////////////////
Encode install / uninstall data
//////////////////////////////////////////////////////////////*/
Expand Down
10 changes: 9 additions & 1 deletion src/module/token/minting/MintableERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -190,6 +193,11 @@ contract MintableERC1155 is
return "";
}

/// @dev Returns bytes encoded for installing modules on cross-chain
function crosschainBytesOnInstall() external view returns (bytes memory) {
return abi.encode(_mintableStorage().saleConfig.primarySaleRecipient);
}

/*//////////////////////////////////////////////////////////////
Encode mint params
//////////////////////////////////////////////////////////////*/
Expand Down
10 changes: 9 additions & 1 deletion src/module/token/minting/MintableERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -196,6 +199,11 @@ contract MintableERC20 is
return "";
}

/// @dev Returns bytes encoded for installing modules on cross-chain
function crosschainBytesOnInstall() external view returns (bytes memory) {
return abi.encode(_mintableStorage().saleConfig.primarySaleRecipient);
}

/*//////////////////////////////////////////////////////////////
Encode mint params
//////////////////////////////////////////////////////////////*/
Expand Down
10 changes: 9 additions & 1 deletion src/module/token/minting/MintableERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -182,6 +185,11 @@ contract MintableERC721 is
/// @dev Called by a Core into an Module during the uninstallation of the Module.
function onUninstall(bytes calldata data) external {}

/// @dev Returns bytes encoded for installing modules on cross-chain
function crosschainBytesOnInstall() external view returns (bytes memory) {
return abi.encode(_mintableStorage().saleConfig.primarySaleRecipient);
}

/*//////////////////////////////////////////////////////////////
Encode install / uninstall data
//////////////////////////////////////////////////////////////*/
Expand Down
9 changes: 9 additions & 0 deletions src/module/token/royalty/RoyaltyERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ contract RoyaltyERC1155 is
return "";
}

/// @dev Returns bytes encoded for installing modules on cross-chain
function crosschainBytesOnInstall() external view returns (bytes memory) {
return abi.encode(
_royaltyStorage().defaultRoyaltyInfo.recipient,
_royaltyStorage().defaultRoyaltyInfo.bps,
_royaltyStorage().transferValidator
);
}

/*//////////////////////////////////////////////////////////////
CALLBACK FUNCTIONS
//////////////////////////////////////////////////////////////*/
Expand Down
9 changes: 9 additions & 0 deletions src/module/token/royalty/RoyaltyERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ contract RoyaltyERC721 is Module, IInstallationCallback, BeforeTransferCallbackE
return "";
}

/// @dev Returns bytes encoded for installing modules on cross-chain
function crosschainBytesOnInstall() external view returns (bytes memory) {
return abi.encode(
_royaltyStorage().defaultRoyaltyInfo.recipient,
_royaltyStorage().defaultRoyaltyInfo.bps,
_royaltyStorage().transferValidator
);
}

/*//////////////////////////////////////////////////////////////
CALLBACK FUNCTIONS
//////////////////////////////////////////////////////////////*/
Expand Down
10 changes: 10 additions & 0 deletions src/module/token/transferable/TransferableERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,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
//////////////////////////////////////////////////////////////*/
Expand Down
10 changes: 10 additions & 0 deletions src/module/token/transferable/TransferableERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,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
//////////////////////////////////////////////////////////////*/
Expand Down
10 changes: 10 additions & 0 deletions src/module/token/transferable/TransferableERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,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
//////////////////////////////////////////////////////////////*/
Expand Down
14 changes: 13 additions & 1 deletion test/module/minting/MintableERC1155.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand All @@ -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);

Expand Down
12 changes: 12 additions & 0 deletions test/module/minting/MintableERC20.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
14 changes: 13 additions & 1 deletion test/module/minting/MintableERC721.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand All @@ -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);

Expand Down