From 974ae5ca727643d44c102101d0d456d552aad60b Mon Sep 17 00:00:00 2001 From: zeroknots Date: Tue, 13 Feb 2024 14:37:21 +0700 Subject: [PATCH] chore: renaming storage --- script/DeployRegistry.s.sol.bak | 4 +--- src/core/AttestationManager.sol | 20 ++++++++++---------- src/core/ModuleManager.sol | 14 +++++++------- src/core/ResolverManager.sol | 12 ++++++------ src/core/TrustManager.sol | 8 ++++---- 5 files changed, 28 insertions(+), 30 deletions(-) diff --git a/script/DeployRegistry.s.sol.bak b/script/DeployRegistry.s.sol.bak index 8b8fc4bd..30f5f4de 100644 --- a/script/DeployRegistry.s.sol.bak +++ b/script/DeployRegistry.s.sol.bak @@ -2,8 +2,6 @@ pragma solidity ^0.8.24; import { Script } from "forge-std/Script.sol"; -import { RegistryTestTools, RegistryInstance } from "../test/utils/BaseUtils.sol"; -import { DebugResolver } from "../src/external/examples/DebugResolver.sol"; import { IExternalResolver } from "../src/external/IExternalResolver.sol"; import { ResolverUID } from "../src/DataTypes.sol"; import { console2 } from "forge-std/console2.sol"; @@ -12,7 +10,7 @@ import { console2 } from "forge-std/console2.sol"; * @title DeployRegistryScript * @author zeroknots */ -contract DeployRegistryScript is Script, RegistryTestTools { +contract DeployRegistryScript is Script { function run() public { bytes32 salt = bytes32(uint256(2)); diff --git a/src/core/AttestationManager.sol b/src/core/AttestationManager.sol index da3e1473..14c50e42 100644 --- a/src/core/AttestationManager.sol +++ b/src/core/AttestationManager.sol @@ -33,7 +33,7 @@ abstract contract AttestationManager is IRegistry, ModuleManager, SchemaManager, using ModuleTypeLib for ModuleType[]; mapping(address module => mapping(address attester => AttestationRecord attestation)) internal - _moduleToAttesterToAttestations; + $moduleToAttesterToAttestations; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* Attestation */ @@ -58,7 +58,7 @@ abstract contract AttestationManager is IRegistry, ModuleManager, SchemaManager, _storeAttestation({ schemaUID: schemaUID, attester: attester, request: request }); record.requireExternalSchemaValidation({ $schema: schemas[schemaUID] }); - record.requireExternalResolverOnAttestation({ $resolver: resolvers[resolverUID] }); + record.requireExternalResolverOnAttestation({ $resolver: $resolvers[resolverUID] }); } /** @@ -97,7 +97,7 @@ abstract contract AttestationManager is IRegistry, ModuleManager, SchemaManager, // Use StubLib to call schema Validation and resolver if needed records.requireExternalSchemaValidation({ $schema: schemas[schemaUID] }); - records.requireExternalResolverOnAttestation({ $resolver: resolvers[resolverUID] }); + records.requireExternalResolverOnAttestation({ $resolver: $resolvers[resolverUID] }); } /** @@ -135,7 +135,7 @@ abstract contract AttestationManager is IRegistry, ModuleManager, SchemaManager, // caching module address. address module = request.moduleAddr; // SLOAD the resolverUID from the moduleRecord - resolverUID = _moduleAddrToRecords[module].resolverUID; + resolverUID = $moduleAddrToRecords[module].resolverUID; // Ensure that attestation is for module that was registered. if (resolverUID == EMPTY_RESOLVER_UID) { revert ModuleNotFoundInRegistry(module); @@ -158,7 +158,7 @@ abstract contract AttestationManager is IRegistry, ModuleManager, SchemaManager, dataPointer: sstore2Pointer }); // SSTORE attestation to registry storage - _moduleToAttesterToAttestations[request.moduleAddr][attester] = record; + $moduleToAttesterToAttestations[request.moduleAddr][attester] = record; emit Attested({ moduleAddr: module, @@ -180,7 +180,7 @@ abstract contract AttestationManager is IRegistry, ModuleManager, SchemaManager, function _revoke(address attester, RevocationRequest calldata request) internal { (AttestationRecord memory record, ResolverUID resolverUID) = _storeRevocation(attester, request); - record.tryExternalResolverOnRevocation({ $resolver: resolvers[resolverUID] }); + record.tryExternalResolverOnRevocation({ $resolver: $resolvers[resolverUID] }); } /** @@ -203,7 +203,7 @@ abstract contract AttestationManager is IRegistry, ModuleManager, SchemaManager, } // No schema validation required during revocation. the attestation data was already checked against - records.tryExternalResolverOnRevocation({ $resolver: resolvers[resolverUID] }); + records.tryExternalResolverOnRevocation({ $resolver: $resolvers[resolverUID] }); } /** @@ -221,11 +221,11 @@ abstract contract AttestationManager is IRegistry, ModuleManager, SchemaManager, returns (AttestationRecord memory record, ResolverUID resolverUID) { AttestationRecord storage $attestation = - _moduleToAttesterToAttestations[request.moduleAddr][revoker]; + $moduleToAttesterToAttestations[request.moduleAddr][revoker]; // SLOAD entire record. This will later be passed to the resolver record = $attestation; - resolverUID = _moduleAddrToRecords[request.moduleAddr].resolverUID; + resolverUID = $moduleAddrToRecords[request.moduleAddr].resolverUID; // Ensure that we aren't attempting to revoke a non-existing attestation. if (record.dataPointer == EMPTY_ATTESTATION_REF) { @@ -261,6 +261,6 @@ abstract contract AttestationManager is IRegistry, ModuleManager, SchemaManager, override returns (AttestationRecord storage $attestation) { - $attestation = _moduleToAttesterToAttestations[module][attester]; + $attestation = $moduleToAttesterToAttestations[module][attester]; } } diff --git a/src/core/ModuleManager.sol b/src/core/ModuleManager.sol index 5745ea19..78bd6927 100644 --- a/src/core/ModuleManager.sol +++ b/src/core/ModuleManager.sol @@ -33,7 +33,7 @@ abstract contract ModuleManager is IRegistry, ResolverManager { using ModuleDeploymentLib for address; using StubLib for *; - mapping(address moduleAddress => ModuleRecord moduleRecord) internal _moduleAddrToRecords; + mapping(address moduleAddress => ModuleRecord moduleRecord) internal $moduleAddrToRecords; /** * @inheritdoc IRegistry @@ -48,7 +48,7 @@ abstract contract ModuleManager is IRegistry, ResolverManager { payable returns (address moduleAddress) { - ResolverRecord storage $resolver = resolvers[resolverUID]; + ResolverRecord storage $resolver = $resolvers[resolverUID]; if ($resolver.resolverOwner == ZERO_ADDRESS) revert InvalidResolver($resolver.resolver); moduleAddress = initCode.deploy(salt); @@ -91,7 +91,7 @@ abstract contract ModuleManager is IRegistry, ResolverManager { ) external { - ResolverRecord storage $resolver = resolvers[resolverUID]; + ResolverRecord storage $resolver = $resolvers[resolverUID]; // ensure that non-zero resolverUID was provided if ($resolver.resolverOwner == ZERO_ADDRESS) revert InvalidResolver($resolver.resolver); @@ -123,7 +123,7 @@ abstract contract ModuleManager is IRegistry, ResolverManager { payable returns (address moduleAddress) { - ResolverRecord storage $resolver = resolvers[resolverUID]; + ResolverRecord storage $resolver = $resolvers[resolverUID]; if ($resolver.resolverOwner == ZERO_ADDRESS) revert InvalidResolverUID(resolverUID); // prevent someone from calling a registry function pretending its a factory if (factory == address(this)) revert FactoryCallFailed(factory); @@ -162,7 +162,7 @@ abstract contract ModuleManager is IRegistry, ResolverManager { // ensure that non-zero resolverUID was provided if (resolverUID == EMPTY_RESOLVER_UID) revert InvalidDeployment(); // ensure moduleAddress is not already registered - if (_moduleAddrToRecords[moduleAddress].resolverUID != EMPTY_RESOLVER_UID) { + if ($moduleAddrToRecords[moduleAddress].resolverUID != EMPTY_RESOLVER_UID) { revert AlreadyRegistered(moduleAddress); } // revert if moduleAddress is NOT a contract @@ -174,7 +174,7 @@ abstract contract ModuleManager is IRegistry, ResolverManager { ModuleRecord({ resolverUID: resolverUID, sender: sender, metadata: metadata }); // Store module record in _modules mapping - _moduleAddrToRecords[moduleAddress] = moduleRegistration; + $moduleAddrToRecords[moduleAddress] = moduleRegistration; // Emit ModuleRegistration event emit ModuleRegistration({ @@ -192,6 +192,6 @@ abstract contract ModuleManager is IRegistry, ResolverManager { view returns (ModuleRecord memory moduleRecord) { - return _moduleAddrToRecords[moduleAddress]; + return $moduleAddrToRecords[moduleAddress]; } } diff --git a/src/core/ResolverManager.sol b/src/core/ResolverManager.sol index 3bd19011..e4a76393 100644 --- a/src/core/ResolverManager.sol +++ b/src/core/ResolverManager.sol @@ -10,7 +10,7 @@ import { IRegistry } from "../IRegistry.sol"; abstract contract ResolverManager is IRegistry { using UIDLib for ResolverRecord; - mapping(ResolverUID uid => ResolverRecord resolver) internal resolvers; + mapping(ResolverUID uid => ResolverRecord resolver) internal $resolvers; /** * @dev Modifier to require that the caller is the owner of a resolver @@ -18,7 +18,7 @@ abstract contract ResolverManager is IRegistry { * @param uid The UID of the resolver. */ modifier onlyResolverOwner(ResolverUID uid) { - if (resolvers[uid].resolverOwner != msg.sender) { + if ($resolvers[uid].resolverOwner != msg.sender) { revert AccessDenied(); } _; @@ -53,12 +53,12 @@ abstract contract ResolverManager is IRegistry { uid = resolverRecord.getUID(); // Checking if a schema with this UID already exists -> resolver can never be ZERO_ADDRESS - if (address(resolvers[uid].resolver) != ZERO_ADDRESS) { + if (address($resolvers[uid].resolver) != ZERO_ADDRESS) { revert ResolverAlreadyExists(); } // SSTORE schema in the resolvers mapping - resolvers[uid] = resolverRecord; + $resolvers[uid] = resolverRecord; emit NewResolver(uid, address(resolver)); } @@ -74,7 +74,7 @@ abstract contract ResolverManager is IRegistry { onlyResolver(resolver) onlyResolverOwner(uid) // authorization control { - ResolverRecord storage referrer = resolvers[uid]; + ResolverRecord storage referrer = $resolvers[uid]; referrer.resolver = resolver; emit NewResolver(uid, address(resolver)); } @@ -83,6 +83,6 @@ abstract contract ResolverManager is IRegistry { * @inheritdoc IRegistry */ function findResolver(ResolverUID uid) external view returns (ResolverRecord memory) { - return resolvers[uid]; + return $resolvers[uid]; } } diff --git a/src/core/TrustManager.sol b/src/core/TrustManager.sol index 3bd1cccc..3e56a41f 100644 --- a/src/core/TrustManager.sol +++ b/src/core/TrustManager.sol @@ -28,7 +28,7 @@ abstract contract TrustManager is IRegistry, TrustManagerExternalAttesterList { using ModuleTypeLib for PackedModuleTypes; using LibSort for address[]; - mapping(address account => TrustedAttesterRecord attesters) internal _accountToAttester; + mapping(address account => TrustedAttesterRecord attesters) internal $accountToAttester; /** * @inheritdoc IRegistry @@ -42,7 +42,7 @@ abstract contract TrustManager is IRegistry, TrustManagerExternalAttesterList { if (attestersLength == 0) revert InvalidTrustedAttesterInput(); if (attesters.length != attestersLength) revert InvalidTrustedAttesterInput(); - TrustedAttesterRecord storage $trustedAttester = _accountToAttester[msg.sender]; + TrustedAttesterRecord storage $trustedAttester = $accountToAttester[msg.sender]; // threshold cannot be greater than the number of attesters if (threshold > attestersLength) { threshold = uint8(attestersLength); @@ -104,7 +104,7 @@ abstract contract TrustManager is IRegistry, TrustManagerExternalAttesterList { * @param moduleType (optional param), setting moduleType = 0, will ignore moduleTypes in attestations */ function _check(address smartAccount, address module, ModuleType moduleType) internal view { - TrustedAttesterRecord storage $trustedAttesters = _accountToAttester[smartAccount]; + TrustedAttesterRecord storage $trustedAttesters = $accountToAttester[smartAccount]; // SLOAD from one slot uint256 attesterCount = $trustedAttesters.attesterCount; uint256 threshold = $trustedAttesters.threshold; @@ -208,7 +208,7 @@ abstract contract TrustManager is IRegistry, TrustManagerExternalAttesterList { view returns (address[] memory attesters) { - TrustedAttesterRecord storage $trustedAttesters = _accountToAttester[smartAccount]; + TrustedAttesterRecord storage $trustedAttesters = $accountToAttester[smartAccount]; uint256 count = $trustedAttesters.attesterCount; address attester0 = $trustedAttesters.attester; attesters = new address[](count);