Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging of service events #687

Merged
merged 4 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions contracts/registry/IRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ interface IRegistry is
IERC165
{

event LogRegistration(NftId nftId, NftId parentNftId, ObjectType objectType, bool isInterceptor, address objectAddress, address initialOwner);
event LogServiceRegistration(VersionPart majorVersion, ObjectType domain);
event LogChainRegistryRegistration(NftId nftId, uint256 chainId, address chainRegistryAddress);
event LogRegistryObjectRegistered(NftId nftId, NftId parentNftId, ObjectType objectType, bool isInterceptor, address objectAddress, address initialOwner);
event LogRegistryServiceRegistered(VersionPart majorVersion, ObjectType domain);
event LogRegistryChainRegistryRegistered(NftId nftId, uint256 chainId, address chainRegistryAddress);

// initialize
error ErrorRegistryCallerNotDeployer();
Expand Down
6 changes: 3 additions & 3 deletions contracts/registry/Registry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ contract Registry is
revert ErrorRegistryChainRegistryNftIdInvalid(nftId, chainId);
}

emit LogChainRegistryRegistration(nftId, chainId, registryAddress);
emit LogRegistryChainRegistryRegistered(nftId, chainId, registryAddress);

_registerRegistryForNft(
chainId,
Expand Down Expand Up @@ -231,7 +231,7 @@ contract Registry is

_service[version][domain] = service;

emit LogServiceRegistration(version, domain);
emit LogRegistryServiceRegistered(version, domain);

nftId = _register(info);
}
Expand Down Expand Up @@ -501,7 +501,7 @@ contract Registry is
_info[nftId] = info;
_setAddressForNftId(nftId, objectAddress);

emit LogRegistration(nftId, parentNftId, objectType, isInterceptor, objectAddress, owner);
emit LogRegistryObjectRegistered(nftId, parentNftId, objectType, isInterceptor, objectAddress, owner);

// calls nft receiver(1) and interceptor(2)
uint256 mintedTokenId = CHAIN_NFT.mint(
Expand Down
1 change: 1 addition & 0 deletions contracts/shared/ComponentService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ contract ComponentService is
instance.getInstanceAdmin().setComponentLocked(
component,
locked);
emit LogComponentServiceComponentLocked(component, locked);
}


Expand Down
1 change: 1 addition & 0 deletions contracts/shared/IComponentService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ interface IComponentService is
error ErrorComponentServiceWithdrawAmountExceedsLimit(Amount withdrawnAmount, Amount withdrawLimit);
error ErrorComponentServiceWalletAllowanceTooSmall(address wallet, address spender, uint256 allowance, uint256 amount);

event LogComponentServiceComponentLocked(address component, bool locked);
event LogComponentServiceRegistered(NftId instanceNftId, NftId componentNftId, ObjectType componentType, address component, address token, address initialOwner);
event LogComponentServiceWalletAddressChanged(NftId componentNftId, address currentWallet, address newWallet);
event LogComponentServiceWalletTokensTransferred(NftId componentNftId, address currentWallet, address newWallet, uint256 currentBalance);
Expand Down
2 changes: 2 additions & 0 deletions contracts/shared/INftOwnable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ interface INftOwnable is
IERC165,
IRegistryLinked
{
event LogNftOwnableNftLinkedToAddress(NftId nftId, address owner);

error ErrorNftOwnableInitialOwnerZero();
error ErrorNftOwnableNotOwner(address account);
error ErrorNftOwnableInvalidType(NftId nftId, ObjectType expectedObjectType);
Expand Down
2 changes: 2 additions & 0 deletions contracts/shared/NftOwnable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ contract NftOwnable is

$._nftId = getRegistry().getNftIdForAddress(nftOwnableAddress);

emit LogNftOwnableNftLinkedToAddress($._nftId, getOwner());

return $._nftId;
}

Expand Down
4 changes: 2 additions & 2 deletions scripts/libs/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ export async function deployAndRegisterMasterInstance(
[InstanceService__factory.createInterface()]
);

// this extracts the ObjectInfo struct from the LogRegistration event
const logRegistrationInfo = getFieldFromTxRcptLogs(rcpt!, registry.registry.interface, "LogRegistration", "nftId");
// this extracts the ObjectInfo struct from the LogRegistryObjectRegistered event
const logRegistrationInfo = getFieldFromTxRcptLogs(rcpt!, registry.registry.interface, "LogRegistryObjectRegistered", "nftId");
// nftId is the first field of the ObjectInfo struct
const masterInstanceNfdId = (logRegistrationInfo as unknown);

Expand Down
6 changes: 3 additions & 3 deletions scripts/libs/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export async function deployAndRegisterServices(owner: Signer, registry: Registr
async () => await registry.releaseRegistry.registerService(registryServiceAddress, getTxOpts()),
"registerService - registryService"
);
const logRegistrationInfoRs = getFieldFromTxRcptLogs(rcptRs!, registry.registry.interface, "LogRegistration", "nftId");
const logRegistrationInfoRs = getFieldFromTxRcptLogs(rcptRs!, registry.registry.interface, "LogRegistryObjectRegistered", "nftId");
const registryServiceNfdId = (logRegistrationInfoRs as string);

// is not NftOwnable
Expand Down Expand Up @@ -249,7 +249,7 @@ export async function deployAndRegisterServices(owner: Signer, registry: Registr
async () => await registry.releaseRegistry.registerService(componentServiceAddress, getTxOpts()),
"registerService - componentService"
);
const logRegistrationInfoCmpt = getFieldFromTxRcptLogs(rcptCmpt!, registry.registry.interface, "LogRegistration", "nftId");
const logRegistrationInfoCmpt = getFieldFromTxRcptLogs(rcptCmpt!, registry.registry.interface, "LogRegistryObjectRegistered", "nftId");
const componentServiceNftId = (logRegistrationInfoCmpt as unknown);
logger.info(`componentServiceManager deployed - componentServiceAddress: ${componentServiceAddress} componentServiceManagerAddress: ${componentServiceManagerAddress} nftId: ${componentServiceNftId}`);

Expand Down Expand Up @@ -577,7 +577,7 @@ async function registerAndLinkService(releaseRegistry: ReleaseRegistry, serviceA
async () => await releaseRegistry.registerService(serviceAddress, getTxOpts()),
`registerService - ${serviceAddress}`
);
const logRegistrationInfo = getFieldFromTxRcptLogs(rcptBdl!, IRegistry__factory.createInterface(), "LogRegistration", "nftId");
const logRegistrationInfo = getFieldFromTxRcptLogs(rcptBdl!, IRegistry__factory.createInterface(), "LogRegistryObjectRegistered", "nftId");
const serviceNftId = (logRegistrationInfo as unknown);
await executeTx(
async () => await proxyManager.linkToProxy(getTxOpts()),
Expand Down
15 changes: 5 additions & 10 deletions test/registry/RegistryTestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ import {GifDeployer} from "../base/GifDeployer.sol";

contract RegistryTestBase is GifDeployer, FoundryRandom {

// keep indentical to IRegistry events
event LogRegistration(NftId nftId, NftId parentNftId, ObjectType objectType, bool isInterceptor, address objectAddress, address initialOwner);
event LogServiceRegistration(VersionPart majorVersion, ObjectType domain);
event LogChainRegistryRegistration(NftId nftId, uint256 chainId, address registry);

// keep identical to ChainNft events
event LogTokenInterceptorAddress(uint256 tokenId, address interceptor);

Expand Down Expand Up @@ -1077,7 +1072,7 @@ contract RegistryTestBase is GifDeployer, FoundryRandom {
NftId expectedNftId = NftIdLib.toNftId(expectedId);

vm.expectEmit(address(registry));
emit LogChainRegistryRegistration(expectedNftId, chainId, registryAddress);
emit IRegistry.LogRegistryChainRegistryRegistered(expectedNftId, chainId, registryAddress);

vm.expectEmit(address(chainNft));
emit Transfer(address(0), registryInfo.initialOwner, expectedId);
Expand Down Expand Up @@ -1276,10 +1271,10 @@ contract RegistryTestBase is GifDeployer, FoundryRandom {
);

vm.expectEmit(address(registry));
emit LogServiceRegistration(version, domain);
emit IRegistry.LogRegistryServiceRegistered(version, domain);

vm.expectEmit(address(registry));
emit LogRegistration(
emit IRegistry.LogRegistryObjectRegistered(
expectedNftId,
info.parentNftId,
info.objectType,
Expand Down Expand Up @@ -1468,7 +1463,7 @@ contract RegistryTestBase is GifDeployer, FoundryRandom {
);

vm.expectEmit(address(registry));
emit LogRegistration(
emit IRegistry.LogRegistryObjectRegistered(
expectedNftId,
info.parentNftId,
info.objectType,
Expand Down Expand Up @@ -1633,7 +1628,7 @@ contract RegistryTestBase is GifDeployer, FoundryRandom {
);

vm.expectEmit(address(registry));
emit LogRegistration(
emit IRegistry.LogRegistryObjectRegistered(
expectedNftId,
info.parentNftId,
info.objectType,
Expand Down
12 changes: 5 additions & 7 deletions test/release/ReleaseRegistryConcrete.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {console} from "../../lib/forge-std/src/Test.sol";

import {IAccessAdmin} from "../../contracts/authorization/IAccessAdmin.sol";
import {ILifecycle} from "../../contracts/shared/Lifecycle.sol";
import {IRegistry} from "../../contracts/registry/IRegistry.sol";
import {IRelease} from "../../contracts/registry/IRelease.sol";
import {IService} from "../../contracts/shared/IService.sol";
import {IServiceAuthorization} from "../../contracts/authorization/IServiceAuthorization.sol";
Expand Down Expand Up @@ -37,9 +38,6 @@ contract ReleaseRegistryConcreteTest is GifDeployer, FoundryRandom {
event LogReleaseDisabled(VersionPart version);
event LogReleaseEnabled(VersionPart version);

// keep identical to IRegistry events
event LogServiceRegistration(VersionPart majorVersion, ObjectType serviceDomain);

address public outsider = makeAddr("outsider");

function setUp() public virtual
Expand Down Expand Up @@ -419,7 +417,7 @@ contract ReleaseRegistryConcreteTest is GifDeployer, FoundryRandom {

// TODO add AccessAdmin logs
vm.expectEmit(address(registry));
emit LogServiceRegistration(nextVersion, REGISTRY());
emit IRegistry.LogRegistryServiceRegistered(nextVersion, REGISTRY());

vm.prank(gifManager);
NftId serviceNftId = releaseRegistry.registerService(service);
Expand Down Expand Up @@ -565,7 +563,7 @@ console.log("block 3b, i:", i);

// TODO add AccessAdmin logs
vm.expectEmit(address(registry));
emit LogServiceRegistration(nextVersion, REGISTRY());
emit IRegistry.LogRegistryServiceRegistered(nextVersion, REGISTRY());

vm.prank(gifManager);
NftId serviceNftId = releaseRegistry.registerService(service);
Expand Down Expand Up @@ -730,7 +728,7 @@ console.log("block 3g, i:", i);

// TODO add AccessAdmin logs
vm.expectEmit(address(registry));
emit LogServiceRegistration(nextVersion, REGISTRY());
emit IRegistry.LogRegistryServiceRegistered(nextVersion, REGISTRY());

vm.prank(gifManager);
NftId serviceNftId = releaseRegistry.registerService(service);
Expand Down Expand Up @@ -896,7 +894,7 @@ console.log("block 3g, i:", i);

// TODO add AccessAdmin logs
vm.expectEmit(address(registry));
emit LogServiceRegistration(nextVersion, REGISTRY());
emit IRegistry.LogRegistryServiceRegistered(nextVersion, REGISTRY());

vm.prank(gifManager);
NftId serviceNftId = releaseRegistry.registerService(service);
Expand Down
3 changes: 0 additions & 3 deletions test/release/ReleaseRegistryFuzz.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ contract ReleaseRegistryTest is GifDeployer, FoundryRandom {
event LogReleaseDisabled(VersionPart version);
event LogReleaseEnabled(VersionPart version);

// keep identical to IRegistry events
event LogServiceRegistration(VersionPart majorVersion, ObjectType serviceDomain);

address public outsider = makeAddr("outsider");
mapping(VersionPart version => IService) public serviceByVersion;

Expand Down
Loading