Skip to content

StoreAuthorizationRegistry Contract Documentation

Overview

The StoreAuthorizationRegistry contract is responsible for managing the authorization of Minters and Trashers within the TRASH Protocol. It allows the Ecosystem Operator to authorize or revoke these roles. The contract uses OpenZeppelin's AccessControl for role management and leverages a centralized permissions system to ensure secure and modular role-based access control.

Inherited Contracts

  • AccessControl: Provides role-based access control using _grantRole and _revokeRole.
  • Authorization: Manages the authorization of Minters and Trashers within a store.
  • Permissions: Centralized access control for roles like Ecosystem Operator.
  • NoETH: Prevents the contract from accepting Ether.

Functions

initialize(address _registryAddress)

  • Description: Initializes the contract by setting the registry address. The registry is used to manage permissions and interact with other protocol components.
  • Parameters:
  • _registryAddress: The address of the registry store contract.
  • Reverts:
  • CantSetZeroAddress: If the registry address provided is the zero address.

authorizeInStore(address user)

  • Description: Authorizes a user as both a Minter and a Trasher within a store. Only the Ecosystem Operator can authorize users.
  • Parameters:
  • user: The address of the user to be authorized.
  • Modifiers:
  • onlyEcosystemOperator: Ensures only an Ecosystem Operator can call this function.
  • Emits:
  • AuthorizeMinter: Emitted when a user is authorized as a Minter.
  • AuthorizeTrasher: Emitted when a user is authorized as a Trasher.

authorizeMinter(address user)

  • Description: Grants the Minter role to the specified user. Only the Ecosystem Operator can authorize Minters.
  • Parameters:
  • user: The address of the user to be granted the Minter role.
  • Modifiers:
  • onlyEcosystemOperator: Ensures only an Ecosystem Operator can call this function.
  • Emits:
  • AuthorizeMinter: Emitted when a user is authorized as a Minter.

authorizeTrasher(address user)

  • Description: Grants the Trasher role to the specified user. Only the Ecosystem Operator can authorize Trashers.
  • Parameters:
  • user: The address of the user to be granted the Trasher role.
  • Modifiers:
  • onlyEcosystemOperator: Ensures only an Ecosystem Operator can call this function.
  • Emits:
  • AuthorizeTrasher: Emitted when a user is authorized as a Trasher.

isMinter(address user)

  • Description: Checks if a given user has the Minter role.
  • Parameters:
  • user: The address to check.
  • Returns:
  • bool: Returns true if the user has the Minter role, otherwise false.

isTrasher(address user)

  • Description: Checks if a given user has the Trasher role.
  • Parameters:
  • user: The address to check.
  • Returns:
  • bool: Returns true if the user has the Trasher role, otherwise false.

getMinters()

  • Description: Returns a list of all authorized Minters.
  • Returns:
  • address[]: Array of addresses with the Minter role.

getTrashers()

  • Description: Returns a list of all authorized Trashers.
  • Returns:
  • address[]: Array of addresses with the Trasher role.

revokeAuthorization(address user)

  • Description: Revokes both the Minter and Trasher roles from a user. Only the Ecosystem Operator can revoke authorizations.
  • Parameters:
  • user: The address of the user to have their roles revoked.
  • Modifiers:
  • onlyEcosystemOperator: Ensures only an Ecosystem Operator can call this function.
  • Emits:
  • MinterRevoked: Emitted when a user's Minter role is revoked.
  • TrasherRevoked: Emitted when a user's Trasher role is revoked.

revokeMinterAuthorization(address user)

  • Description: Revokes the Minter role from a user.
  • Parameters:
  • user: The address of the user to have their Minter role revoked.
  • Modifiers:
  • onlyEcosystemOperator: Ensures only an Ecosystem Operator can call this function.
  • Emits:
  • MinterRevoked: Emitted when a user's Minter role is revoked.

revokeTrasherAuthorization(address user)

  • Description: Revokes the Trasher role from a user.
  • Parameters:
  • user: The address of the user to have their Trasher role revoked.
  • Modifiers:
  • onlyEcosystemOperator: Ensures only an Ecosystem Operator can call this function.
  • Emits:
  • TrasherRevoked: Emitted when a user's Trasher role is revoked.

Supporting Libraries

StoreAuthKeys

  • Description: Provides constants for role keys used in the StoreAuthorizationRegistry.

Constants

  • MINTER: The bytes32 key representing the Minter role (keccak256("MINTER")).
  • TRASHER: The bytes32 key representing the Trasher role (keccak256("TRASHER")).

AuthorizationEvents

  • Description: Defines the events emitted during authorization and revocation of roles.

Events

  • AuthorizeMinter(address indexed user): Emitted when a user is authorized as a Minter.
  • AuthorizeTrasher(address indexed user): Emitted when a user is authorized as a Trasher.
  • MinterRevoked(address indexed user): Emitted when a user's Minter role is revoked.
  • TrasherRevoked(address indexed user): Emitted when a user's Trasher role is revoked.

Errors

  • CantSetZeroAddress: Thrown when a zero address is provided where a valid address is required.

Conclusion

The StoreAuthorizationRegistry contract manages the authorization of Minters and Trashers within the TRASH Protocol. It leverages AccessControl for secure role-based access control and ensures that only Ecosystem Operators can manage these roles. The contract also provides functions to check the roles of users and lists of all current Minters and Trashers.