Skip to content

Commit

Permalink
comments cleanup on ContractMetadataregistry
Browse files Browse the repository at this point in the history
  • Loading branch information
Krishang Nadgauda authored and Krishang Nadgauda committed May 20, 2022
1 parent b834ef9 commit dfd9dba
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
13 changes: 9 additions & 4 deletions contracts/ContractMetadataRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,37 @@ import "@openzeppelin/contracts/metatx/ERC2771Context.sol";
import { IContractMetadataRegistry } from "./interfaces/IContractMetadataRegistry.sol";

contract ContractMetadataRegistry is IContractMetadataRegistry, ERC2771Context, Multicall, AccessControlEnumerable {

/// @dev Only accounts with OPERATOR_ROLE can register metadata for contracts.
bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");

/*///////////////////////////////////////////////////////////////
State variables
Mappings
//////////////////////////////////////////////////////////////*/

/// @dev contract address deployed => metadata uri
mapping(address => string) public getMetadataUri;

/*///////////////////////////////////////////////////////////////
Constructor + modifiers
Constructor
//////////////////////////////////////////////////////////////*/

constructor(address _trustedForwarder) ERC2771Context(_trustedForwarder) {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
}

/*///////////////////////////////////////////////////////////////
External methods
External functions
//////////////////////////////////////////////////////////////*/

/// @dev Records `metadataUri` as metadata for the contract at `contractAddress`.
function registerMetadata(address contractAddress, string memory metadataUri) external {
require(hasRole(OPERATOR_ROLE, _msgSender()), "not operator.");
require(hasRole(OPERATOR_ROLE, _msgSender()), "Not operator.");
require(bytes(metadataUri).length > 0, "No metadata");
require(bytes(getMetadataUri[contractAddress]).length == 0, "Metadata already registered");

getMetadataUri[contractAddress] = metadataUri;

emit MetadataRegistered(contractAddress, metadataUri);
}

Expand Down
1 change: 1 addition & 0 deletions contracts/interfaces/IContractMetadataRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ interface IContractMetadataRegistry {
/// @dev Emitted when a contract metadata is registered
event MetadataRegistered(address indexed contractAddress, string metadataUri);

/// @dev Records `metadataUri` as metadata for the contract at `contractAddress`.
function registerMetadata(address contractAddress, string memory metadataUri) external;
}
4 changes: 2 additions & 2 deletions docs/ContractMetadataRegistry.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function OPERATOR_ROLE() external view returns (bytes32)




*Only accounts with OPERATOR_ROLE can register metadata for contracts.*


#### Returns
Expand Down Expand Up @@ -225,7 +225,7 @@ function registerMetadata(address contractAddress, string metadataUri) external




*Records `metadataUri` as metadata for the contract at `contractAddress`.*

#### Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/IContractMetadataRegistry.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function registerMetadata(address contractAddress, string metadataUri) external




*Records `metadataUri` as metadata for the contract at `contractAddress`.*

#### Parameters

Expand Down

0 comments on commit dfd9dba

Please sign in to comment.