From e0d260bc55683f812dbd954836499abd7bb1bf23 Mon Sep 17 00:00:00 2001 From: Marc Doerflinger Date: Fri, 6 Sep 2024 08:50:08 +0000 Subject: [PATCH] emit events in InstanceService (closes #672) --- contracts/instance/IInstanceService.sol | 2 ++ contracts/instance/InstanceService.sol | 8 ++++++++ test/instance/InstanceReader.t.sol | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/contracts/instance/IInstanceService.sol b/contracts/instance/IInstanceService.sol index be038cfc5..2717d7d91 100644 --- a/contracts/instance/IInstanceService.sol +++ b/contracts/instance/IInstanceService.sol @@ -56,6 +56,8 @@ interface IInstanceService is IService { event LogInstanceServiceInstanceLocked(NftId instanceNftId, bool locked); event LogInstanceServiceInstanceCreated(NftId instanceNftId, address instance); + event LogInstanceServiceMasterInstanceReaderUpgraded(NftId instanceNfId, address newInstanceReader); + event LogInstanceServiceInstanceReaderUpgraded(NftId instanceNfId, address newInstanceReader); /// @dev Creates a new custom role for the calling instance. function createRole(string memory roleName, RoleId adminRoleId, uint32 maxMemberCount) external returns (RoleId roleId); diff --git a/contracts/instance/InstanceService.sol b/contracts/instance/InstanceService.sol index 5e74b9150..9f2f1f987 100644 --- a/contracts/instance/InstanceService.sol +++ b/contracts/instance/InstanceService.sol @@ -303,6 +303,10 @@ contract InstanceService is upgradedInstanceReaderClone.initializeWithInstance(instanceAddress); instance.setInstanceReader(upgradedInstanceReaderClone); + + emit LogInstanceServiceInstanceReaderUpgraded( + getRegistry().getNftIdForAddress(instanceAddress), + address(upgradedInstanceReaderClone)); } @@ -373,6 +377,10 @@ contract InstanceService is if(instanceReader.getInstance() != IInstance(_masterInstance)) { revert ErrorInstanceServiceInstanceReaderInstanceMismatch(); } _masterInstanceReader = instanceReaderAddress; + + emit LogInstanceServiceMasterInstanceReaderUpgraded( + getRegistry().getNftIdForAddress(_masterInstance), + instanceReaderAddress); } function getMasterInstanceReader() external virtual view returns (address) { diff --git a/test/instance/InstanceReader.t.sol b/test/instance/InstanceReader.t.sol index 91658007e..a51519cb8 100644 --- a/test/instance/InstanceReader.t.sol +++ b/test/instance/InstanceReader.t.sol @@ -22,7 +22,11 @@ contract InstanceReaderTest is GifTest { // GIVEN vm.startPrank(registryOwner); InstanceReader newMasterInstanceReader = _createNewMasterInstanceReader(); + // address newMasterInstanceReaderAddress = address(newMasterInstanceReader); + vm.expectEmit(); + emit IInstanceService.LogInstanceServiceMasterInstanceReaderUpgraded(masterInstanceNftId, address(newMasterInstanceReader)); + // WHEN instanceService.upgradeMasterInstanceReader(address(newMasterInstanceReader)); @@ -72,6 +76,10 @@ contract InstanceReaderTest is GifTest { // WHEN vm.startPrank(instanceOwner); + + vm.expectEmit(true, false, false, false); + emit IInstanceService.LogInstanceServiceInstanceReaderUpgraded(instanceNftId, address(newMasterInstanceReader)); + instance.upgradeInstanceReader(); vm.stopPrank();