This repository has been archived by the owner on Sep 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add access control to measure + docs
- Loading branch information
Showing
8 changed files
with
1,174 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Submodule openzeppelin-contracts
deleted from
54a235
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,31 @@ | ||
// SPDX-License-Identifier: (MIT or Apache-2.0) | ||
|
||
pragma solidity ^0.8.17; | ||
import "../lib/openzeppelin-contracts/contracts/access/AccessControl.sol"; | ||
pragma solidity ^0.8.19; | ||
|
||
contract Measure { | ||
event Measurement(string data); | ||
/** | ||
* @title Measure Contract | ||
* @dev This contract submits commitments of arbitrary data on chain. | ||
*/ | ||
contract Measure is AccessControl { | ||
event Measurement(string dataCommitment); | ||
bytes32 public constant COMMITMENT_ROLE = keccak256("COMMITMENT_ROLE"); | ||
|
||
function measure(string memory data) public { | ||
emit Measurement(data); | ||
} | ||
/** | ||
* @dev Creates a measure contract with an admin | ||
* @param admin The address of the factory admin. | ||
**/ | ||
constructor(address admin) { | ||
_grantRole(DEFAULT_ADMIN_ROLE, admin); | ||
_grantRole(COMMITMENT_ROLE, admin); | ||
} | ||
|
||
/** | ||
* @dev Emmits a Measurement event with a commitment to some arbitrary data. | ||
* @param dataCommitment An arbitrary commitment to some data (eg. Merkle Root, KZG Commitment, etc.) | ||
**/ | ||
function measure(string memory dataCommitment) public { | ||
require(hasRole(COMMITMENT_ROLE, msg.sender)); | ||
emit Measurement(dataCommitment); | ||
} | ||
} |