From 767675b39bb96b6206aaff9b61390de50567a81e Mon Sep 17 00:00:00 2001 From: b00ste Date: Tue, 8 Aug 2023 13:54:40 +0300 Subject: [PATCH] refactor: add LSP1 hook in `renounceOwnership(..)` --- contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol | 9 ++++++++- contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol | 8 ++++++++ contracts/LSP9Vault/LSP9VaultCore.sol | 8 ++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol b/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol index c18feddfd..50397a294 100644 --- a/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +++ b/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol @@ -668,9 +668,16 @@ abstract contract LSP0ERC725AccountCore is // Depending on the magicValue returned, a second call is done after transferring ownership bool verifyAfter = _verifyCall(_owner); - // set the pending owner + address previousOwner = owner(); LSP14Ownable2Step._renounceOwnership(); + if (owner() == address(0)) { + previousOwner.tryNotifyUniversalReceiver( + _TYPEID_LSP0_OwnershipTransferred_SenderNotification, + "" + ); + } + // If verifyAfter is true, Call {lsp20VerifyCallResult} on the owner // The transferOwnership function does not return, second parameter of {_verifyCallResult} will be empty if (verifyAfter) { diff --git a/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol b/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol index 4798a29b8..95aab9d4f 100644 --- a/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +++ b/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol @@ -109,7 +109,15 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset { override(OwnableUnset, ILSP14Ownable2Step) onlyOwner { + address previousOwner = owner(); _renounceOwnership(); + + if (owner() == address(0)) { + previousOwner.tryNotifyUniversalReceiver( + _TYPEID_LSP14_OwnershipTransferred_SenderNotification, + "" + ); + } } // --- Internal methods diff --git a/contracts/LSP9Vault/LSP9VaultCore.sol b/contracts/LSP9Vault/LSP9VaultCore.sol index 3a573f38d..a6dd13e95 100644 --- a/contracts/LSP9Vault/LSP9VaultCore.sol +++ b/contracts/LSP9Vault/LSP9VaultCore.sol @@ -526,7 +526,15 @@ contract LSP9VaultCore is override(LSP14Ownable2Step, OwnableUnset) onlyOwner { + address previousOwner = owner(); LSP14Ownable2Step._renounceOwnership(); + + if (owner() == address(0)) { + previousOwner.tryNotifyUniversalReceiver( + _TYPEID_LSP9_OwnershipTransferred_SenderNotification, + "" + ); + } } /**