From 0424bffdb61b18390b83dd44577a74fc2b4cba3f Mon Sep 17 00:00:00 2001 From: TuDo1403 Date: Tue, 25 Jun 2024 13:44:46 +0700 Subject: [PATCH] fix(RONRegistrarController): emit TreasuryUpdated event when setTreasury --- src/RONRegistrarController.sol | 17 +++++++++++++++-- src/interfaces/IRONRegistrarController.sol | 5 +++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/RONRegistrarController.sol b/src/RONRegistrarController.sol index 8f982469..9bb061c1 100644 --- a/src/RONRegistrarController.sol +++ b/src/RONRegistrarController.sol @@ -92,8 +92,8 @@ contract RONRegistrarController is _setPriceOracle(priceOracle); _setMinRegistrationDuration(minRegistrationDuration); _setCommitmentAge(minCommitmentAge, maxCommitmentAge); + _setTreasury(treasury); - _treasury = treasury; _rnsUnified = rnsUnified; _nameChecker = nameChecker; _reverseRegistrar = reverseRegistrar; @@ -281,7 +281,7 @@ contract RONRegistrarController is * @inheritdoc IRONRegistrarController */ function setTreasury(address payable addr) external onlyRole(DEFAULT_ADMIN_ROLE) { - _treasury = addr; + _setTreasury(addr); } /** @@ -452,6 +452,19 @@ contract RONRegistrarController is emit DomainPriceUpdated(_msgSender(), priceOracle); } + /** + * @dev Helper method to update treasury address. + * + * Emits an event {TreasuryUpdated}. + */ + function _setTreasury(address payable addr) internal { + if (addr == address(0x0)) revert NullAddress(); + + _treasury = addr; + + emit TreasuryUpdated(addr); + } + /** * @dev Helper method to check if a domain name is available for register. */ diff --git a/src/interfaces/IRONRegistrarController.sol b/src/interfaces/IRONRegistrarController.sol index 22914bda..a4355f48 100644 --- a/src/interfaces/IRONRegistrarController.sol +++ b/src/interfaces/IRONRegistrarController.sol @@ -38,6 +38,8 @@ interface IRONRegistrarController { error ErrInvalidRegisterProtectedName(string name, address requestOwner, bool nameProtected, bool ownerWhitelisted); /// @dev Thrown when received invalid array length error InvalidArrayLength(); + /// @dev Thrown when treasury address is set to null + error NullAddress(); /** * @dev Emitted when the min registration duration is updated. @@ -46,6 +48,9 @@ interface IRONRegistrarController { */ event MinRegistrationDurationUpdated(address indexed operator, uint256 duration); + /// @dev Emitted when the treasury is updated. + event TreasuryUpdated(address indexed addr); + /** * @dev Emitted when RNSDomainPrice contract is updated. * @param operator The address of the operator who triggered the update.