Skip to content

Commit

Permalink
chore: renaming storage
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroknots committed Feb 13, 2024
1 parent fa05695 commit 974ae5c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 30 deletions.
4 changes: 1 addition & 3 deletions script/DeployRegistry.s.sol.bak
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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));

Expand Down
20 changes: 10 additions & 10 deletions src/core/AttestationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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] });
}

/**
Expand Down Expand Up @@ -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] });
}

/**
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand All @@ -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] });
}

/**
Expand All @@ -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] });
}

/**
Expand All @@ -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) {
Expand Down Expand Up @@ -261,6 +261,6 @@ abstract contract AttestationManager is IRegistry, ModuleManager, SchemaManager,
override
returns (AttestationRecord storage $attestation)
{
$attestation = _moduleToAttesterToAttestations[module][attester];
$attestation = $moduleToAttesterToAttestations[module][attester];
}
}
14 changes: 7 additions & 7 deletions src/core/ModuleManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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({
Expand All @@ -192,6 +192,6 @@ abstract contract ModuleManager is IRegistry, ResolverManager {
view
returns (ModuleRecord memory moduleRecord)
{
return _moduleAddrToRecords[moduleAddress];
return $moduleAddrToRecords[moduleAddress];
}
}
12 changes: 6 additions & 6 deletions src/core/ResolverManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ 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
*
* @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();
}
_;
Expand Down Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand All @@ -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];
}
}
8 changes: 4 additions & 4 deletions src/core/TrustManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 974ae5c

Please sign in to comment.