The Registry contract is a fundamental component of the Allo ecosystem, enabling the creation and management of profiles. Profiles serve as essential entities for decentralized applications, offering identity management, access control, and interaction capabilities. This contract is equipped with mechanisms for creating profiles, updating metadata, managing ownership, and handling fund recovery. It leverages external libraries, interfaces, and internal functions to provide robust functionality while adhering to security and transparency.
sequenceDiagram
participant Alice
participant Registry
participant Anchor
Alice ->>+ Registry: createProfile
Registry ->>+ Anchor: CREATE3 deploy (using anchor)
Anchor -->>- Registry: Returns reference to deployed contract
Registry -->>- Alice: profileId : 1
sequenceDiagram
participant Alice
participant Registry
Alice ->>+ Registry: updateProfileMetadata(profileId, newMetadata)
Registry -->> Registry: Update metadata for profileId
Registry -->>- Alice: Metadata updated successfully
sequenceDiagram
participant Alice
participant Registry
participant Anchor
Alice ->>+ Registry: updateProfileName(profileId, newName)
Registry ->>+ Anchor: CREATE3 deploy (using new anchor)
Anchor -->>- Registry: Returns reference to deployed contract
Registry -->> Registry: Update anchor and profile name for profileId
Registry -->>- Alice: Profile name and anchor updated successfully
sequenceDiagram
participant Alice
participant Bob
participant Registry
Alice ->>+ Registry: addMembers(profileId, [Bob])
Registry -->>- Alice: Bob added as a member to profileId
Alice ->>+ Registry: removeMembers(profileId, [Bob])
Registry -->>- Alice: Bob removed from members of profileId
sequenceDiagram
participant Alice
participant Bob
participant Registry
Alice ->>+ Registry: updateProfilePendingOwner(profileId, Bob)
Registry -->>- Alice: Pending owner updated for profileId
Bob ->>+ Registry: acceptProfileOwnership(profileId)
Registry -->>- Bob: Ownership transferred for profileId
- License: The
Registrycontract adheres to the MIT License, promoting permissive open-source usage. - Solidity Version: Developed using Solidity version 0.8.19, harnessing the latest advancements in Ethereum smart contract technology.
- External Libraries: The contract incorporates the
AccessControlandCREATE3external libraries, enhancing access control and facilitating contract deployment. - Interfaces: The contract utilizes the
IRegistryinterface for communication with external components.
anchorToProfileId(Public Mapping): This mapping correlates anchor addresses to corresponding profile IDs, providing efficient lookup capabilities.profilesById(Public Mapping): A mapping associating profile IDs with instances of theProfilestruct. This struct encapsulates profile-specific information.profileIdToPendingOwner(Public Mapping): This mapping links profile IDs to addresses representing pending owners, enabling controlled ownership transfer.ALLO_OWNER(Public Constant): A constant representing the role of the Allo owner for fund recovery.
onlyProfileOwner(bytes32 _profileId): A modifier ensuring that only the owner of a specific profile can access a function.
The contract constructor initializes the Allo owner role and assigns the provided initial owner address.
getProfileById: Retrieve profile details using the profile ID.getProfileByAnchor: Retrieve profile details using the profile's anchor address.createProfile: Create a new profile, assigning owners and members along with profile-specific attributes.updateProfileName: Update a profile's name and generate a new anchor.updateProfileMetadata: Update a profile's metadata, accessible only to the owner.isOwnerOrMemberOfProfile: Check if an address is either an owner or a member of a profile.isOwnerOfProfile: Check if an address is the owner of a profile.isMemberOfProfile: Check if an address is a member of a profile.updateProfilePendingOwner: Update the pending owner of a profile, restricted to the current owner.acceptProfileOwnership: Transfer profile ownership to the pending owner, initiated by the pending owner.addMembers: Add members to a profile, restricted to the profile's owner.removeMembers: Remove members from a profile, restricted to the profile's owner.
_generateAnchor: Generate and deploy an anchor for a given profile ID and name._generateProfileId: Generate a profile ID based on the provided nonce and the caller's address._isOwnerOfProfile: Check if an address is the owner of a profile._isMemberOfProfile: Check if an address is a member of a profile.
- Allo Owner: The Allo owner possesses the ability to recover funds, perform upgrades, and manage the contract's overarching aspects.
- Profile Owner: A user who owns a profile can perform actions such as updating profile attributes, managing members, and transferring ownership.
- Profile Member: Members of a profile have specific access rights as defined by the profile's owner.
- Pending Owner: The address designated as the pending owner can assume ownership of the profile once the current owner confirms the transfer.
In summary, the Registry smart contract provides a comprehensive system for creating and managing profiles within the Allo ecosystem. It offers functionalities such as profile creation, metadata updates, ownership management, and fund recovery. By leveraging a combination of storage variables, modifiers, external functions, and internal functions, the contract contributes to establishing decentralized identity management and access control mechanisms. The Registry contract is designed to facilitate the seamless integration of profiles within Ethereum-based decentralized applications, promoting efficiency and security in user interactions and data management.
- User initiates a transaction to the
createProfilefunction with the required parameters:_nonce,_name,_metadata,_owner, and_members. - The contract generates a unique
profileIdbased on_nonceand the caller's address using the_generateProfileIdfunction. - The contract creates a new
Profileobject containing the provided data and assigns it to theprofilesByIdmapping using the generatedprofileId. - Roles are granted to the
_membersof the profile using the_grantRolefunction. - The contract emits the
ProfileCreatedevent to indicate the successful creation of the profile.
- The profile owner initiates a transaction to the
updateProfileNamefunction with the_profileIdand the new_name. - The contract generates a new anchor using
_generateAnchorfunction and the_profileIdand_name. - The contract updates the anchor mapping to remove the old anchor and assigns the new anchor to the profile.
- The contract emits the
ProfileNameUpdatedevent to indicate the successful update of the profile name and anchor.
- The profile owner initiates a transaction to the
updateProfileMetadatafunction with the_profileIdand the new_metadata. - The contract updates the metadata of the profile identified by
_profileId. - The contract emits the
ProfileMetadataUpdatedevent to indicate the successful update of the profile metadata.
- The profile owner initiates a transaction to the
addMembersfunction with the_profileIdand an array of_members. - The contract grants roles to the new members using the
_grantRolefunction. - The contract emits events to indicate the successful addition of members.
- The profile owner initiates a transaction to the
removeMembersfunction with the_profileIdand an array of_members. - The contract revokes roles from the members using the
_revokeRolefunction. - The contract emits events to indicate the successful removal of members.
- The profile owner initiates a transaction to the
updateProfilePendingOwnerfunction with the_profileIdand the new_pendingOwner. - The contract updates the pending owner for the profile identified by
_profileId. - The contract emits the
ProfilePendingOwnerUpdatedevent to indicate the successful update of the pending owner.
- The pending owner initiates a transaction to the
acceptProfileOwnershipfunction with the_profileId. - The contract checks if the caller is the pending owner of the profile.
- If the caller is the pending owner, the contract updates the owner of the profile and clears the pending owner.
- The contract emits the
ProfileOwnerUpdatedevent to indicate the successful transfer of ownership.
- Users can query profile information using the
getProfileByIdandgetProfileByAnchorfunctions by providing the_profileIdor_anchor.
- Users can check if an address is the owner or member of a profile using the
isOwnerOrMemberOfProfile,isOwnerOfProfile, andisMemberOfProfilefunctions.
- The allo owner (an address with the ALLO_OWNER role) initiates a transaction to the
recoverFundsfunction with the_tokenand_recipientaddresses. - The contract transfers the remaining funds from the contract to the recipient.