diff --git a/src/access/OwnableAccessControl.sol b/src/access/OwnableAccessControl.sol index fc715f3..06179b7 100644 --- a/src/access/OwnableAccessControl.sol +++ b/src/access/OwnableAccessControl.sol @@ -32,7 +32,7 @@ abstract contract OwnableAccessControl is Ownable { /// @param role The bytes32 role created in the inheriting contract event RoleChange(address indexed from, address indexed user, bool indexed approved, bytes32 role); - /// @param from - address that authorized the revoke + /// @param from Address that authorized the revoke event AllRolesRevoked(address indexed from); /*////////////////////////////////////////////////////////////////////////// diff --git a/src/royalties/EIP2981TL.sol b/src/royalties/EIP2981TL.sol index bb056f8..6272197 100644 --- a/src/royalties/EIP2981TL.sol +++ b/src/royalties/EIP2981TL.sol @@ -9,7 +9,7 @@ import {IEIP2981} from "src/royalties/IEIP2981.sol"; /// while allowing for specific token overrides /// @dev Follows EIP-2981 (https://eips.ethereum.org/EIPS/eip-2981) /// @author transientlabs.xyz -/// @custom:version 3.0.0 +/// @custom:version 3.1.0 abstract contract EIP2981TL is IEIP2981, ERC165 { /*////////////////////////////////////////////////////////////////////////// Types @@ -29,6 +29,16 @@ abstract contract EIP2981TL is IEIP2981, ERC165 { uint256 private _defaultPercentage; mapping(uint256 => RoyaltySpec) private _tokenOverrides; + /*////////////////////////////////////////////////////////////////////////// + Events + //////////////////////////////////////////////////////////////////////////*/ + + /// @dev Event to emit when the default roylaty is updated + event DefaultRoyaltyUpdate(address indexed sender, address newRecipient, uint256 newPercentage); + + /// @dev Event to emit when a token royalty is overriden + event TokenRoyaltyOverride(address indexed sender, uint256 indexed tokenId, address newRecipient, uint256 newPercentage); + /*////////////////////////////////////////////////////////////////////////// Errors //////////////////////////////////////////////////////////////////////////*/ @@ -61,6 +71,7 @@ abstract contract EIP2981TL is IEIP2981, ERC165 { if (newPercentage > 10_000) revert MaxRoyaltyError(); _defaultRecipient = newRecipient; _defaultPercentage = newPercentage; + emit DefaultRoyaltyUpdate(msg.sender, newRecipient, newPercentage); } /// @notice Function to override royalty spec on a specific token @@ -72,6 +83,7 @@ abstract contract EIP2981TL is IEIP2981, ERC165 { if (newPercentage > 10_000) revert MaxRoyaltyError(); _tokenOverrides[tokenId].recipient = newRecipient; _tokenOverrides[tokenId].percentage = newPercentage; + emit TokenRoyaltyOverride(msg.sender, tokenId, newRecipient, newPercentage); } /*////////////////////////////////////////////////////////////////////////// diff --git a/src/upgradeable/royalties/EIP2981TLUpgradeable.sol b/src/upgradeable/royalties/EIP2981TLUpgradeable.sol index b8d4a6a..47df0a6 100644 --- a/src/upgradeable/royalties/EIP2981TLUpgradeable.sol +++ b/src/upgradeable/royalties/EIP2981TLUpgradeable.sol @@ -9,7 +9,7 @@ import {IEIP2981} from "src/royalties/IEIP2981.sol"; /// while allowing for specific token overrides /// @dev Follows EIP-2981 (https://eips.ethereum.org/EIPS/eip-2981) /// @author transientlabs.xyz -/// @custom:version 3.0.0 +/// @custom:version 3.1.0 abstract contract EIP2981TLUpgradeable is IEIP2981, ERC165Upgradeable { /*////////////////////////////////////////////////////////////////////////// Types @@ -47,6 +47,16 @@ abstract contract EIP2981TLUpgradeable is IEIP2981, ERC165Upgradeable { uint256 public constant BASIS = 10_000; + /*////////////////////////////////////////////////////////////////////////// + Events + //////////////////////////////////////////////////////////////////////////*/ + + /// @dev Event to emit when the default roylaty is updated + event DefaultRoyaltyUpdate(address indexed sender, address newRecipient, uint256 newPercentage); + + /// @dev Event to emit when a token royalty is overriden + event TokenRoyaltyOverride(address indexed sender, uint256 indexed tokenId, address newRecipient, uint256 newPercentage); + /*////////////////////////////////////////////////////////////////////////// Errors //////////////////////////////////////////////////////////////////////////*/ @@ -91,6 +101,7 @@ abstract contract EIP2981TLUpgradeable is IEIP2981, ERC165Upgradeable { if (newPercentage > 10_000) revert MaxRoyaltyError(); $.defaultRecipient = newRecipient; $.defaultPercentage = newPercentage; + emit DefaultRoyaltyUpdate(msg.sender, newRecipient, newPercentage); } /// @notice Function to override royalty spec on a specific token @@ -103,6 +114,7 @@ abstract contract EIP2981TLUpgradeable is IEIP2981, ERC165Upgradeable { if (newPercentage > 10_000) revert MaxRoyaltyError(); $.tokenOverrides[tokenId].recipient = newRecipient; $.tokenOverrides[tokenId].percentage = newPercentage; + emit TokenRoyaltyOverride(msg.sender, tokenId, newRecipient, newPercentage); } /*////////////////////////////////////////////////////////////////////////// diff --git a/test/royalties/EIP2981TL.t.sol b/test/royalties/EIP2981TL.t.sol index edecc05..322d7b8 100644 --- a/test/royalties/EIP2981TL.t.sol +++ b/test/royalties/EIP2981TL.t.sol @@ -15,6 +15,9 @@ contract TestEIP2981TL is Test { vm.expectRevert(EIP2981TL.ZeroAddressError.selector); } else if (percentage > 10_000) { vm.expectRevert(EIP2981TL.MaxRoyaltyError.selector); + } else { + vm.expectEmit(true, true, true, true); + emit EIP2981TL.DefaultRoyaltyUpdate(address(this), recipient, percentage); } mockContract = new MockEIP2981TL(recipient, uint256(percentage)); if (recipient != address(0) && percentage <= 10_000) { @@ -45,6 +48,9 @@ contract TestEIP2981TL is Test { vm.expectRevert(EIP2981TL.ZeroAddressError.selector); } else if (percentage > 10_000) { vm.expectRevert(EIP2981TL.MaxRoyaltyError.selector); + } else { + vm.expectEmit(true, true, true, true); + emit EIP2981TL.DefaultRoyaltyUpdate(address(this), recipient, percentage); } mockContract.setDefaultRoyalty(recipient, uint256(percentage)); if (recipient != address(0) && percentage <= 10_000) { @@ -67,6 +73,9 @@ contract TestEIP2981TL is Test { vm.expectRevert(EIP2981TL.ZeroAddressError.selector); } else if (percentage > 10_000) { vm.expectRevert(EIP2981TL.MaxRoyaltyError.selector); + } else { + vm.expectEmit(true, true, true, true); + emit EIP2981TL.TokenRoyaltyOverride(address(this), tokenId, recipient, percentage); } mockContract.setTokenRoyalty(tokenId, recipient, uint256(percentage)); if (recipient != address(0) && percentage <= 10_000) { diff --git a/test/upgradeable/royalties/EIP2981TLUpgradeable.t.sol b/test/upgradeable/royalties/EIP2981TLUpgradeable.t.sol index 41fae17..bf90da7 100644 --- a/test/upgradeable/royalties/EIP2981TLUpgradeable.t.sol +++ b/test/upgradeable/royalties/EIP2981TLUpgradeable.t.sol @@ -16,6 +16,9 @@ contract TestEIP2981TLUpgradeable is Test { vm.expectRevert(EIP2981TLUpgradeable.ZeroAddressError.selector); } else if (percentage > 10_000) { vm.expectRevert(EIP2981TLUpgradeable.MaxRoyaltyError.selector); + } else { + vm.expectEmit(true, true, true, true); + emit EIP2981TLUpgradeable.DefaultRoyaltyUpdate(address(this), recipient, percentage); } mockContract.initialize(recipient, uint256(percentage)); if (recipient != address(0) && percentage <= 10_000) { @@ -48,6 +51,9 @@ contract TestEIP2981TLUpgradeable is Test { vm.expectRevert(EIP2981TLUpgradeable.ZeroAddressError.selector); } else if (percentage > 10_000) { vm.expectRevert(EIP2981TLUpgradeable.MaxRoyaltyError.selector); + } else { + vm.expectEmit(true, true, true, true); + emit EIP2981TLUpgradeable.DefaultRoyaltyUpdate(address(this), recipient, percentage); } mockContract.setDefaultRoyalty(recipient, uint256(percentage)); if (recipient != address(0) && percentage <= 10_000) { @@ -71,6 +77,9 @@ contract TestEIP2981TLUpgradeable is Test { vm.expectRevert(EIP2981TLUpgradeable.ZeroAddressError.selector); } else if (percentage > 10_000) { vm.expectRevert(EIP2981TLUpgradeable.MaxRoyaltyError.selector); + } else { + vm.expectEmit(true, true, true, true); + emit EIP2981TLUpgradeable.TokenRoyaltyOverride(address(this), tokenId, recipient, percentage); } mockContract.setTokenRoyalty(tokenId, recipient, uint256(percentage)); if (recipient != address(0) && percentage <= 10_000) {