Skip to content

Commit

Permalink
emit events in InstanceService (closes #672)
Browse files Browse the repository at this point in the history
  • Loading branch information
doerfli committed Sep 6, 2024
1 parent b9f7683 commit e0d260b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contracts/instance/IInstanceService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions contracts/instance/InstanceService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ contract InstanceService is

upgradedInstanceReaderClone.initializeWithInstance(instanceAddress);
instance.setInstanceReader(upgradedInstanceReaderClone);

emit LogInstanceServiceInstanceReaderUpgraded(
getRegistry().getNftIdForAddress(instanceAddress),
address(upgradedInstanceReaderClone));
}


Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions test/instance/InstanceReader.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit e0d260b

Please sign in to comment.