Commit a22f52b0 authored by Andreas Bigger's avatar Andreas Bigger

Port EAS contracts to triple slash natspec styling

parent 15460387
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0; pragma solidity ^0.8.0;
// A representation of an empty/uninitialized UID. // A representation of an empty/uninitialized UID.
...@@ -14,18 +13,14 @@ error InvalidLength(); ...@@ -14,18 +13,14 @@ error InvalidLength();
error InvalidSignature(); error InvalidSignature();
error NotFound(); error NotFound();
/** /// @dev A struct representing EIP712 signature data.
* @dev A struct representing EIP712 signature data.
*/
struct EIP712Signature { struct EIP712Signature {
uint8 v; // The recovery ID. uint8 v; // The recovery ID.
bytes32 r; // The x-coordinate of the nonce R. bytes32 r; // The x-coordinate of the nonce R.
bytes32 s; // The signature data. bytes32 s; // The signature data.
} }
/** /// @dev A struct representing a single attestation.
* @dev A struct representing a single attestation.
*/
struct Attestation { struct Attestation {
bytes32 uid; // A unique identifier of the attestation. bytes32 uid; // A unique identifier of the attestation.
bytes32 schema; // The unique identifier of the schema. bytes32 schema; // The unique identifier of the schema.
...@@ -42,26 +37,18 @@ struct Attestation { ...@@ -42,26 +37,18 @@ struct Attestation {
// Maximum upgrade forward-compatibility storage gap. // Maximum upgrade forward-compatibility storage gap.
uint32 constant MAX_GAP = 50; uint32 constant MAX_GAP = 50;
/** /// @dev A helper function to work with unchecked iterators in loops.
* @dev A helper function to work with unchecked iterators in loops. /// @param i The index to increment.
* /// @return j The incremented index.
* @param i The index to increment.
*
* @return j The incremented index.
*/
function uncheckedInc(uint256 i) pure returns (uint256 j) { function uncheckedInc(uint256 i) pure returns (uint256 j) {
unchecked { unchecked {
j = i + 1; j = i + 1;
} }
} }
/** /// @dev A helper function that converts a string to a bytes32.
* @dev A helper function that converts a string to a bytes32. /// @param str The string to convert.
* /// @return The converted bytes32.
* @param str The string to convert.
*
* @return The converted bytes32.
*/
function stringToBytes32(string memory str) pure returns (bytes32) { function stringToBytes32(string memory str) pure returns (bytes32) {
bytes32 result; bytes32 result;
...@@ -72,13 +59,9 @@ function stringToBytes32(string memory str) pure returns (bytes32) { ...@@ -72,13 +59,9 @@ function stringToBytes32(string memory str) pure returns (bytes32) {
return result; return result;
} }
/** /// @dev A helper function that converts a bytes32 to a string.
* @dev A helper function that converts a bytes32 to a string. /// @param data The bytes32 data to convert.
* /// @return The converted string.
* @param data The bytes32 data to convert.
*
* @return The converted string.
*/
function bytes32ToString(bytes32 data) pure returns (string memory) { function bytes32ToString(bytes32 data) pure returns (string memory) {
bytes memory byteArray = new bytes(32); bytes memory byteArray = new bytes(32);
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.19; pragma solidity 0.8.19;
import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { Address } from "@openzeppelin/contracts/utils/Address.sol";
...@@ -85,32 +84,23 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -85,32 +84,23 @@ contract EAS is IEAS, Semver, EIP712Verifier {
// Upgrade forward-compatibility storage gap // Upgrade forward-compatibility storage gap
uint256[MAX_GAP - 3] private __gap; uint256[MAX_GAP - 3] private __gap;
/** /// @dev Creates a new EAS instance.
* @dev Creates a new EAS instance.
*/
constructor() Semver(1, 0, 0) EIP712Verifier("EAS", "1.0.0") { constructor() Semver(1, 0, 0) EIP712Verifier("EAS", "1.0.0") {
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function getSchemaRegistry() external pure returns (ISchemaRegistry) { function getSchemaRegistry() external pure returns (ISchemaRegistry) {
return _schemaRegistry; return _schemaRegistry;
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function attest(AttestationRequest calldata request) external payable returns (bytes32) { function attest(AttestationRequest calldata request) external payable returns (bytes32) {
AttestationRequestData[] memory requests = new AttestationRequestData[](1); AttestationRequestData[] memory requests = new AttestationRequestData[](1);
requests[0] = request.data; requests[0] = request.data;
return _attest(request.schema, requests, msg.sender, msg.value, true).uids[0]; return _attest(request.schema, requests, msg.sender, msg.value, true).uids[0];
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function attestByDelegation( function attestByDelegation(
DelegatedAttestationRequest calldata delegatedRequest DelegatedAttestationRequest calldata delegatedRequest
) external payable returns (bytes32) { ) external payable returns (bytes32) {
...@@ -118,13 +108,10 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -118,13 +108,10 @@ contract EAS is IEAS, Semver, EIP712Verifier {
AttestationRequestData[] memory data = new AttestationRequestData[](1); AttestationRequestData[] memory data = new AttestationRequestData[](1);
data[0] = delegatedRequest.data; data[0] = delegatedRequest.data;
return _attest(delegatedRequest.schema, data, delegatedRequest.attester, msg.value, true).uids[0]; return _attest(delegatedRequest.schema, data, delegatedRequest.attester, msg.value, true).uids[0];
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function multiAttest(MultiAttestationRequest[] calldata multiRequests) external payable returns (bytes32[] memory) { function multiAttest(MultiAttestationRequest[] calldata multiRequests) external payable returns (bytes32[] memory) {
// Since a multi-attest call is going to make multiple attestations for multiple schemas, we'd need to collect // Since a multi-attest call is going to make multiple attestations for multiple schemas, we'd need to collect
// all the returned UIDs into a single list. // all the returned UIDs into a single list.
...@@ -170,9 +157,7 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -170,9 +157,7 @@ contract EAS is IEAS, Semver, EIP712Verifier {
return _mergeUIDs(totalUids, totalUidsCount); return _mergeUIDs(totalUids, totalUidsCount);
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function multiAttestByDelegation( function multiAttestByDelegation(
MultiDelegatedAttestationRequest[] calldata multiDelegatedRequests MultiDelegatedAttestationRequest[] calldata multiDelegatedRequests
) external payable returns (bytes32[] memory) { ) external payable returns (bytes32[] memory) {
...@@ -239,9 +224,7 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -239,9 +224,7 @@ contract EAS is IEAS, Semver, EIP712Verifier {
return _mergeUIDs(totalUids, totalUidsCount); return _mergeUIDs(totalUids, totalUidsCount);
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function revoke(RevocationRequest calldata request) external payable { function revoke(RevocationRequest calldata request) external payable {
RevocationRequestData[] memory requests = new RevocationRequestData[](1); RevocationRequestData[] memory requests = new RevocationRequestData[](1);
requests[0] = request.data; requests[0] = request.data;
...@@ -249,9 +232,7 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -249,9 +232,7 @@ contract EAS is IEAS, Semver, EIP712Verifier {
_revoke(request.schema, requests, msg.sender, msg.value, true); _revoke(request.schema, requests, msg.sender, msg.value, true);
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function revokeByDelegation(DelegatedRevocationRequest calldata delegatedRequest) external payable { function revokeByDelegation(DelegatedRevocationRequest calldata delegatedRequest) external payable {
_verifyRevoke(delegatedRequest); _verifyRevoke(delegatedRequest);
...@@ -261,9 +242,7 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -261,9 +242,7 @@ contract EAS is IEAS, Semver, EIP712Verifier {
_revoke(delegatedRequest.schema, data, delegatedRequest.revoker, msg.value, true); _revoke(delegatedRequest.schema, data, delegatedRequest.revoker, msg.value, true);
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function multiRevoke(MultiRevocationRequest[] calldata multiRequests) external payable { function multiRevoke(MultiRevocationRequest[] calldata multiRequests) external payable {
// We are keeping track of the total available ETH amount that can be sent to resolvers and will keep deducting // We are keeping track of the total available ETH amount that can be sent to resolvers and will keep deducting
// from it to verify that there isn't any attempt to send too much ETH to resolvers. Please note that unless // from it to verify that there isn't any attempt to send too much ETH to resolvers. Please note that unless
...@@ -287,9 +266,7 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -287,9 +266,7 @@ contract EAS is IEAS, Semver, EIP712Verifier {
} }
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function multiRevokeByDelegation( function multiRevokeByDelegation(
MultiDelegatedRevocationRequest[] calldata multiDelegatedRequests MultiDelegatedRevocationRequest[] calldata multiDelegatedRequests
) external payable { ) external payable {
...@@ -339,31 +316,21 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -339,31 +316,21 @@ contract EAS is IEAS, Semver, EIP712Verifier {
} }
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function timestamp(bytes32 data) external returns (uint64) { function timestamp(bytes32 data) external returns (uint64) {
uint64 time = _time(); uint64 time = _time();
_timestamp(data, time); _timestamp(data, time);
return time; return time;
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function revokeOffchain(bytes32 data) external returns (uint64) { function revokeOffchain(bytes32 data) external returns (uint64) {
uint64 time = _time(); uint64 time = _time();
_revokeOffchain(msg.sender, data, time); _revokeOffchain(msg.sender, data, time);
return time; return time;
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function multiRevokeOffchain(bytes32[] calldata data) external returns (uint64) { function multiRevokeOffchain(bytes32[] calldata data) external returns (uint64) {
uint64 time = _time(); uint64 time = _time();
...@@ -375,9 +342,7 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -375,9 +342,7 @@ contract EAS is IEAS, Semver, EIP712Verifier {
return time; return time;
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function multiTimestamp(bytes32[] calldata data) external returns (uint64) { function multiTimestamp(bytes32[] calldata data) external returns (uint64) {
uint64 time = _time(); uint64 time = _time();
...@@ -389,45 +354,33 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -389,45 +354,33 @@ contract EAS is IEAS, Semver, EIP712Verifier {
return time; return time;
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function getAttestation(bytes32 uid) external view returns (Attestation memory) { function getAttestation(bytes32 uid) external view returns (Attestation memory) {
return _db[uid]; return _db[uid];
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function isAttestationValid(bytes32 uid) public view returns (bool) { function isAttestationValid(bytes32 uid) public view returns (bool) {
return _db[uid].uid != 0; return _db[uid].uid != 0;
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function getTimestamp(bytes32 data) external view returns (uint64) { function getTimestamp(bytes32 data) external view returns (uint64) {
return _timestamps[data]; return _timestamps[data];
} }
/** /// @inheritdoc IEAS
* @inheritdoc IEAS
*/
function getRevokeOffchain(address revoker, bytes32 data) external view returns (uint64) { function getRevokeOffchain(address revoker, bytes32 data) external view returns (uint64) {
return _revocationsOffchain[revoker][data]; return _revocationsOffchain[revoker][data];
} }
/** /// @dev Attests to a specific schema.
* @dev Attests to a specific schema. /// @param schema // the unique identifier of the schema to attest to.
* /// @param data The arguments of the attestation requests.
* @param schema // the unique identifier of the schema to attest to. /// @param attester The attesting account.
* @param data The arguments of the attestation requests. /// @param availableValue The total available ETH amount that can be sent to the resolver.
* @param attester The attesting account. /// @param last Whether this is the last attestations/revocations set.
* @param availableValue The total available ETH amount that can be sent to the resolver. /// @return The UID of the new attestations and the total sent ETH amount.
* @param last Whether this is the last attestations/revocations set.
*
* @return The UID of the new attestations and the total sent ETH amount.
*/
function _attest( function _attest(
bytes32 schema, bytes32 schema,
AttestationRequestData[] memory data, AttestationRequestData[] memory data,
...@@ -512,17 +465,13 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -512,17 +465,13 @@ contract EAS is IEAS, Semver, EIP712Verifier {
return res; return res;
} }
/** /// @dev Revokes an existing attestation to a specific schema.
* @dev Revokes an existing attestation to a specific schema. /// @param schema The unique identifier of the schema to attest to.
* /// @param data The arguments of the revocation requests.
* @param schema The unique identifier of the schema to attest to. /// @param revoker The revoking account.
* @param data The arguments of the revocation requests. /// @param availableValue The total available ETH amount that can be sent to the resolver.
* @param revoker The revoking account. /// @param last Whether this is the last attestations/revocations set.
* @param availableValue The total available ETH amount that can be sent to the resolver. /// @return Returns the total sent ETH amount.
* @param last Whether this is the last attestations/revocations set.
*
* @return Returns the total sent ETH amount.
*/
function _revoke( function _revoke(
bytes32 schema, bytes32 schema,
RevocationRequestData[] memory data, RevocationRequestData[] memory data,
...@@ -581,18 +530,14 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -581,18 +530,14 @@ contract EAS is IEAS, Semver, EIP712Verifier {
return _resolveAttestations(schemaRecord, attestations, values, true, availableValue, last); return _resolveAttestations(schemaRecord, attestations, values, true, availableValue, last);
} }
/** /// @dev Resolves a new attestation or a revocation of an existing attestation.
* @dev Resolves a new attestation or a revocation of an existing attestation. /// @param schemaRecord The schema of the attestation.
* /// @param attestation The data of the attestation to make/revoke.
* @param schemaRecord The schema of the attestation. /// @param value An explicit ETH amount to send to the resolver.
* @param attestation The data of the attestation to make/revoke. /// @param isRevocation Whether to resolve an attestation or its revocation.
* @param value An explicit ETH amount to send to the resolver. /// @param availableValue The total available ETH amount that can be sent to the resolver.
* @param isRevocation Whether to resolve an attestation or its revocation. /// @param last Whether this is the last attestations/revocations set.
* @param availableValue The total available ETH amount that can be sent to the resolver. /// @return Returns the total sent ETH amount.
* @param last Whether this is the last attestations/revocations set.
*
* @return Returns the total sent ETH amount.
*/
function _resolveAttestation( function _resolveAttestation(
SchemaRecord memory schemaRecord, SchemaRecord memory schemaRecord,
Attestation memory attestation, Attestation memory attestation,
...@@ -641,18 +586,14 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -641,18 +586,14 @@ contract EAS is IEAS, Semver, EIP712Verifier {
return value; return value;
} }
/** /// @dev Resolves multiple attestations or revocations of existing attestations.
* @dev Resolves multiple attestations or revocations of existing attestations. /// @param schemaRecord The schema of the attestation.
* /// @param attestations The data of the attestations to make/revoke.
* @param schemaRecord The schema of the attestation. /// @param values Explicit ETH amounts to send to the resolver.
* @param attestations The data of the attestations to make/revoke. /// @param isRevocation Whether to resolve an attestation or its revocation.
* @param values Explicit ETH amounts to send to the resolver. /// @param availableValue The total available ETH amount that can be sent to the resolver.
* @param isRevocation Whether to resolve an attestation or its revocation. /// @param last Whether this is the last attestations/revocations set.
* @param availableValue The total available ETH amount that can be sent to the resolver. /// @return Returns the total sent ETH amount.
* @param last Whether this is the last attestations/revocations set.
*
* @return Returns the total sent ETH amount.
*/
function _resolveAttestations( function _resolveAttestations(
SchemaRecord memory schemaRecord, SchemaRecord memory schemaRecord,
Attestation[] memory attestations, Attestation[] memory attestations,
...@@ -715,14 +656,10 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -715,14 +656,10 @@ contract EAS is IEAS, Semver, EIP712Verifier {
return totalUsedValue; return totalUsedValue;
} }
/** /// @dev Calculates a UID for a given attestation.
* @dev Calculates a UID for a given attestation. /// @param attestation The input attestation.
* /// @param bump A bump value to use in case of a UID conflict.
* @param attestation The input attestation. /// @return Attestation UID.
* @param bump A bump value to use in case of a UID conflict.
*
* @return Attestation UID.
*/
function _getUID(Attestation memory attestation, uint32 bump) private pure returns (bytes32) { function _getUID(Attestation memory attestation, uint32 bump) private pure returns (bytes32) {
return return
keccak256( keccak256(
...@@ -740,11 +677,8 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -740,11 +677,8 @@ contract EAS is IEAS, Semver, EIP712Verifier {
); );
} }
/** /// @dev Refunds remaining ETH amount to the attester.
* @dev Refunds remaining ETH amount to the attester. /// @param remainingValue The remaining ETH amount that was not sent to the resolver.
*
* @param remainingValue The remaining ETH amount that was not sent to the resolver.
*/
function _refund(uint256 remainingValue) private { function _refund(uint256 remainingValue) private {
if (remainingValue > 0) { if (remainingValue > 0) {
// Using a regular transfer here might revert, for some non-EOA attesters, due to exceeding of the 2300 // Using a regular transfer here might revert, for some non-EOA attesters, due to exceeding of the 2300
...@@ -754,12 +688,9 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -754,12 +688,9 @@ contract EAS is IEAS, Semver, EIP712Verifier {
} }
} }
/** /// @dev Timestamps the specified bytes32 data.
* @dev Timestamps the specified bytes32 data. /// @param data The data to timestamp.
* /// @param time The timestamp.
* @param data The data to timestamp.
* @param time The timestamp.
*/
function _timestamp(bytes32 data, uint64 time) private { function _timestamp(bytes32 data, uint64 time) private {
if (_timestamps[data] != 0) { if (_timestamps[data] != 0) {
revert AlreadyTimestamped(); revert AlreadyTimestamped();
...@@ -770,12 +701,9 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -770,12 +701,9 @@ contract EAS is IEAS, Semver, EIP712Verifier {
emit Timestamped(data, time); emit Timestamped(data, time);
} }
/** /// @dev Timestamps the specified bytes32 data.
* @dev Timestamps the specified bytes32 data. /// @param data The data to timestamp.
* /// @param time The timestamp.
* @param data The data to timestamp.
* @param time The timestamp.
*/
function _revokeOffchain(address revoker, bytes32 data, uint64 time) private { function _revokeOffchain(address revoker, bytes32 data, uint64 time) private {
mapping(bytes32 => uint64) storage revocations = _revocationsOffchain[revoker]; mapping(bytes32 => uint64) storage revocations = _revocationsOffchain[revoker];
...@@ -788,22 +716,17 @@ contract EAS is IEAS, Semver, EIP712Verifier { ...@@ -788,22 +716,17 @@ contract EAS is IEAS, Semver, EIP712Verifier {
emit RevokedOffchain(revoker, data, time); emit RevokedOffchain(revoker, data, time);
} }
/** /// @dev Returns the current's block timestamp.
* @dev Returns the current's block timestamp. This method is overridden during tests and used to simulate the /// This method is overridden during tests and
* current block time. /// used to simulate the current block time.
*/
function _time() internal view virtual returns (uint64) { function _time() internal view virtual returns (uint64) {
return uint64(block.timestamp); return uint64(block.timestamp);
} }
/** /// @dev Merges lists of UIDs.
* @dev Merges lists of UIDs. /// @param uidLists The provided lists of UIDs.
* /// @param uidsCount Total UIDs count.
* @param uidLists The provided lists of UIDs. /// @return A merged and flatten list of all the UIDs.
* @param uidsCount Total UIDs count.
*
* @return A merged and flatten list of all the UIDs.
*/
function _mergeUIDs(bytes32[][] memory uidLists, uint256 uidsCount) private pure returns (bytes32[] memory) { function _mergeUIDs(bytes32[][] memory uidLists, uint256 uidsCount) private pure returns (bytes32[] memory) {
bytes32[] memory uids = new bytes32[](uidsCount); bytes32[] memory uids = new bytes32[](uidsCount);
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0; pragma solidity ^0.8.0;
import { ISchemaRegistry } from "./ISchemaRegistry.sol"; import { ISchemaRegistry } from "./ISchemaRegistry.sol";
import { Attestation, EIP712Signature } from "./Common.sol"; import { Attestation, EIP712Signature } from "./Common.sol";
/** /// @dev A struct representing the arguments of the attestation request.
* @dev A struct representing the arguments of the attestation request.
*/
struct AttestationRequestData { struct AttestationRequestData {
address recipient; // The recipient of the attestation. address recipient; // The recipient of the attestation.
uint64 expirationTime; // The time when the attestation expires (Unix timestamp). uint64 expirationTime; // The time when the attestation expires (Unix timestamp).
...@@ -17,17 +14,13 @@ struct AttestationRequestData { ...@@ -17,17 +14,13 @@ struct AttestationRequestData {
uint256 value; // An explicit ETH amount to send to the resolver. This is important to prevent accidental user errors. uint256 value; // An explicit ETH amount to send to the resolver. This is important to prevent accidental user errors.
} }
/** /// @dev A struct representing the full arguments of the attestation request.
* @dev A struct representing the full arguments of the attestation request.
*/
struct AttestationRequest { struct AttestationRequest {
bytes32 schema; // The unique identifier of the schema. bytes32 schema; // The unique identifier of the schema.
AttestationRequestData data; // The arguments of the attestation request. AttestationRequestData data; // The arguments of the attestation request.
} }
/** /// @dev A struct representing the full arguments of the full delegated attestation request.
* @dev A struct representing the full arguments of the full delegated attestation request.
*/
struct DelegatedAttestationRequest { struct DelegatedAttestationRequest {
bytes32 schema; // The unique identifier of the schema. bytes32 schema; // The unique identifier of the schema.
AttestationRequestData data; // The arguments of the attestation request. AttestationRequestData data; // The arguments of the attestation request.
...@@ -35,17 +28,13 @@ struct DelegatedAttestationRequest { ...@@ -35,17 +28,13 @@ struct DelegatedAttestationRequest {
address attester; // The attesting account. address attester; // The attesting account.
} }
/** /// @dev A struct representing the full arguments of the multi attestation request.
* @dev A struct representing the full arguments of the multi attestation request.
*/
struct MultiAttestationRequest { struct MultiAttestationRequest {
bytes32 schema; // The unique identifier of the schema. bytes32 schema; // The unique identifier of the schema.
AttestationRequestData[] data; // The arguments of the attestation request. AttestationRequestData[] data; // The arguments of the attestation request.
} }
/** /// @dev A struct representing the full arguments of the delegated multi attestation request.
* @dev A struct representing the full arguments of the delegated multi attestation request.
*/
struct MultiDelegatedAttestationRequest { struct MultiDelegatedAttestationRequest {
bytes32 schema; // The unique identifier of the schema. bytes32 schema; // The unique identifier of the schema.
AttestationRequestData[] data; // The arguments of the attestation requests. AttestationRequestData[] data; // The arguments of the attestation requests.
...@@ -53,25 +42,19 @@ struct MultiDelegatedAttestationRequest { ...@@ -53,25 +42,19 @@ struct MultiDelegatedAttestationRequest {
address attester; // The attesting account. address attester; // The attesting account.
} }
/** /// @dev A struct representing the arguments of the revocation request.
* @dev A struct representing the arguments of the revocation request.
*/
struct RevocationRequestData { struct RevocationRequestData {
bytes32 uid; // The UID of the attestation to revoke. bytes32 uid; // The UID of the attestation to revoke.
uint256 value; // An explicit ETH amount to send to the resolver. This is important to prevent accidental user errors. uint256 value; // An explicit ETH amount to send to the resolver. This is important to prevent accidental user errors.
} }
/** /// @dev A struct representing the full arguments of the revocation request.
* @dev A struct representing the full arguments of the revocation request.
*/
struct RevocationRequest { struct RevocationRequest {
bytes32 schema; // The unique identifier of the schema. bytes32 schema; // The unique identifier of the schema.
RevocationRequestData data; // The arguments of the revocation request. RevocationRequestData data; // The arguments of the revocation request.
} }
/** /// @dev A struct representing the arguments of the full delegated revocation request.
* @dev A struct representing the arguments of the full delegated revocation request.
*/
struct DelegatedRevocationRequest { struct DelegatedRevocationRequest {
bytes32 schema; // The unique identifier of the schema. bytes32 schema; // The unique identifier of the schema.
RevocationRequestData data; // The arguments of the revocation request. RevocationRequestData data; // The arguments of the revocation request.
...@@ -79,17 +62,13 @@ struct DelegatedRevocationRequest { ...@@ -79,17 +62,13 @@ struct DelegatedRevocationRequest {
address revoker; // The revoking account. address revoker; // The revoking account.
} }
/** /// @dev A struct representing the full arguments of the multi revocation request.
* @dev A struct representing the full arguments of the multi revocation request.
*/
struct MultiRevocationRequest { struct MultiRevocationRequest {
bytes32 schema; // The unique identifier of the schema. bytes32 schema; // The unique identifier of the schema.
RevocationRequestData[] data; // The arguments of the revocation request. RevocationRequestData[] data; // The arguments of the revocation request.
} }
/** /// @dev A struct representing the full arguments of the delegated multi revocation request.
* @dev A struct representing the full arguments of the delegated multi revocation request.
*/
struct MultiDelegatedRevocationRequest { struct MultiDelegatedRevocationRequest {
bytes32 schema; // The unique identifier of the schema. bytes32 schema; // The unique identifier of the schema.
RevocationRequestData[] data; // The arguments of the revocation requests. RevocationRequestData[] data; // The arguments of the revocation requests.
...@@ -100,366 +79,298 @@ struct MultiDelegatedRevocationRequest { ...@@ -100,366 +79,298 @@ struct MultiDelegatedRevocationRequest {
/// @title IEAS /// @title IEAS
/// @notice The Ethereum Attestation Service interface. /// @notice The Ethereum Attestation Service interface.
interface IEAS { interface IEAS {
/** /// @dev Emitted when an attestation has been made.
* @dev Emitted when an attestation has been made. /// @param recipient The recipient of the attestation.
* /// @param attester The attesting account.
* @param recipient The recipient of the attestation. /// @param uid The UID the revoked attestation.
* @param attester The attesting account. /// @param schema The UID of the schema.
* @param uid The UID the revoked attestation.
* @param schema The UID of the schema.
*/
event Attested(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schema); event Attested(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schema);
/** /// @dev Emitted when an attestation has been revoked.
* @dev Emitted when an attestation has been revoked. /// @param recipient The recipient of the attestation.
* /// @param attester The attesting account.
* @param recipient The recipient of the attestation. /// @param schema The UID of the schema.
* @param attester The attesting account. /// @param uid The UID the revoked attestation.
* @param schema The UID of the schema.
* @param uid The UID the revoked attestation.
*/
event Revoked(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schema); event Revoked(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schema);
/** /// @dev Emitted when a data has been timestamped.
* @dev Emitted when a data has been timestamped. /// @param data The data.
* /// @param timestamp The timestamp.
* @param data The data.
* @param timestamp The timestamp.
*/
event Timestamped(bytes32 indexed data, uint64 indexed timestamp); event Timestamped(bytes32 indexed data, uint64 indexed timestamp);
/** /// @dev Emitted when a data has been revoked.
* @dev Emitted when a data has been revoked. /// @param revoker The address of the revoker.
* /// @param data The data.
* @param revoker The address of the revoker. /// @param timestamp The timestamp.
* @param data The data.
* @param timestamp The timestamp.
*/
event RevokedOffchain(address indexed revoker, bytes32 indexed data, uint64 indexed timestamp); event RevokedOffchain(address indexed revoker, bytes32 indexed data, uint64 indexed timestamp);
/** /// @notice Returns the address of the global schema registry.
* @dev Returns the address of the global schema registry. /// @return The address of the global schema registry.
*
* @return The address of the global schema registry.
*/
function getSchemaRegistry() external view returns (ISchemaRegistry); function getSchemaRegistry() external view returns (ISchemaRegistry);
/** /// @notice Attests to a specific schema.
* @dev Attests to a specific schema. ///
* /// Example:
* @param request The arguments of the attestation request. ///
* /// attest({
* Example: /// schema: "0facc36681cbe2456019c1b0d1e7bedd6d1d40f6f324bf3dd3a4cef2999200a0",
* /// data: {
* attest({ /// recipient: "0xdEADBeAFdeAdbEafdeadbeafDeAdbEAFdeadbeaf",
* schema: "0facc36681cbe2456019c1b0d1e7bedd6d1d40f6f324bf3dd3a4cef2999200a0", /// expirationTime: 0,
* data: { /// revocable: true,
* recipient: "0xdEADBeAFdeAdbEafdeadbeafDeAdbEAFdeadbeaf", /// refUID: "0x0000000000000000000000000000000000000000000000000000000000000000",
* expirationTime: 0, /// data: "0xF00D",
* revocable: true, /// value: 0
* refUID: "0x0000000000000000000000000000000000000000000000000000000000000000", /// }
* data: "0xF00D", /// })
* value: 0 ///
* } /// @param request The arguments of the attestation request.
* }) /// @return The UID of the new attestation.
*
* @return The UID of the new attestation.
*/
function attest(AttestationRequest calldata request) external payable returns (bytes32); function attest(AttestationRequest calldata request) external payable returns (bytes32);
/** /// @notice Attests to a specific schema via the provided EIP712 signature.
* @dev Attests to a specific schema via the provided EIP712 signature. ///
* /// Example:
* @param delegatedRequest The arguments of the delegated attestation request. ///
* /// attestByDelegation({
* Example: /// schema: '0x8e72f5bc0a8d4be6aa98360baa889040c50a0e51f32dbf0baa5199bd93472ebc',
* /// data: {
* attestByDelegation({ /// recipient: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
* schema: '0x8e72f5bc0a8d4be6aa98360baa889040c50a0e51f32dbf0baa5199bd93472ebc', /// expirationTime: 1673891048,
* data: { /// revocable: true,
* recipient: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', /// refUID: '0x0000000000000000000000000000000000000000000000000000000000000000',
* expirationTime: 1673891048, /// data: '0x1234',
* revocable: true, /// value: 0
* refUID: '0x0000000000000000000000000000000000000000000000000000000000000000', /// },
* data: '0x1234', /// signature: {
* value: 0 /// v: 28,
* }, /// r: '0x148c...b25b',
* signature: { /// s: '0x5a72...be22'
* v: 28, /// },
* r: '0x148c...b25b', /// attester: '0xc5E8740aD971409492b1A63Db8d83025e0Fc427e'
* s: '0x5a72...be22' /// })
* }, ///
* attester: '0xc5E8740aD971409492b1A63Db8d83025e0Fc427e' /// @param delegatedRequest The arguments of the delegated attestation request.
* }) /// @return The UID of the new attestation.
*
* @return The UID of the new attestation.
*/
function attestByDelegation( function attestByDelegation(
DelegatedAttestationRequest calldata delegatedRequest DelegatedAttestationRequest calldata delegatedRequest
) external payable returns (bytes32); ) external payable returns (bytes32);
/** /// @notice Attests to multiple schemas.
* @dev Attests to multiple schemas. ///
* /// Example:
* @param multiRequests The arguments of the multi attestation requests. The requests should be grouped by distinct ///
* schema ids to benefit from the best batching optimization. /// multiAttest([{
* /// schema: '0x33e9094830a5cba5554d1954310e4fbed2ef5f859ec1404619adea4207f391fd',
* Example: /// data: [{
* /// recipient: '0xdEADBeAFdeAdbEafdeadbeafDeAdbEAFdeadbeaf',
* multiAttest([{ /// expirationTime: 1673891048,
* schema: '0x33e9094830a5cba5554d1954310e4fbed2ef5f859ec1404619adea4207f391fd', /// revocable: true,
* data: [{ /// refUID: '0x0000000000000000000000000000000000000000000000000000000000000000',
* recipient: '0xdEADBeAFdeAdbEafdeadbeafDeAdbEAFdeadbeaf', /// data: '0x1234',
* expirationTime: 1673891048, /// value: 1000
* revocable: true, /// },
* refUID: '0x0000000000000000000000000000000000000000000000000000000000000000', /// {
* data: '0x1234', /// recipient: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
* value: 1000 /// expirationTime: 0,
* }, /// revocable: false,
* { /// refUID: '0x480df4a039efc31b11bfdf491b383ca138b6bde160988222a2a3509c02cee174',
* recipient: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', /// data: '0x00',
* expirationTime: 0, /// value: 0
* revocable: false, /// }],
* refUID: '0x480df4a039efc31b11bfdf491b383ca138b6bde160988222a2a3509c02cee174', /// },
* data: '0x00', /// {
* value: 0 /// schema: '0x5ac273ce41e3c8bfa383efe7c03e54c5f0bff29c9f11ef6ffa930fc84ca32425',
* }], /// data: [{
* }, /// recipient: '0xdEADBeAFdeAdbEafdeadbeafDeAdbEAFdeadbeaf',
* { /// expirationTime: 0,
* schema: '0x5ac273ce41e3c8bfa383efe7c03e54c5f0bff29c9f11ef6ffa930fc84ca32425', /// revocable: true,
* data: [{ /// refUID: '0x75bf2ed8dca25a8190c50c52db136664de25b2449535839008ccfdab469b214f',
* recipient: '0xdEADBeAFdeAdbEafdeadbeafDeAdbEAFdeadbeaf', /// data: '0x12345678',
* expirationTime: 0, /// value: 0
* revocable: true, /// },
* refUID: '0x75bf2ed8dca25a8190c50c52db136664de25b2449535839008ccfdab469b214f', /// }])
* data: '0x12345678', ///
* value: 0 /// @param multiRequests The arguments of the multi attestation requests. The requests should be grouped by distinct
* }, /// schema ids to benefit from the best batching optimization.
* }]) /// @return The UIDs of the new attestations.
*
* @return The UIDs of the new attestations.
*/
function multiAttest(MultiAttestationRequest[] calldata multiRequests) external payable returns (bytes32[] memory); function multiAttest(MultiAttestationRequest[] calldata multiRequests) external payable returns (bytes32[] memory);
/** /// @notice Attests to multiple schemas using via provided EIP712 signatures.
* @dev Attests to multiple schemas using via provided EIP712 signatures. ///
* /// Example:
* @param multiDelegatedRequests The arguments of the delegated multi attestation requests. The requests should be ///
* grouped by distinct schema ids to benefit from the best batching optimization. /// multiAttestByDelegation([{
* /// schema: '0x8e72f5bc0a8d4be6aa98360baa889040c50a0e51f32dbf0baa5199bd93472ebc',
* Example: /// data: [{
* /// recipient: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
* multiAttestByDelegation([{ /// expirationTime: 1673891048,
* schema: '0x8e72f5bc0a8d4be6aa98360baa889040c50a0e51f32dbf0baa5199bd93472ebc', /// revocable: true,
* data: [{ /// refUID: '0x0000000000000000000000000000000000000000000000000000000000000000',
* recipient: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', /// data: '0x1234',
* expirationTime: 1673891048, /// value: 0
* revocable: true, /// },
* refUID: '0x0000000000000000000000000000000000000000000000000000000000000000', /// {
* data: '0x1234', /// recipient: '0xdEADBeAFdeAdbEafdeadbeafDeAdbEAFdeadbeaf',
* value: 0 /// expirationTime: 0,
* }, /// revocable: false,
* { /// refUID: '0x0000000000000000000000000000000000000000000000000000000000000000',
* recipient: '0xdEADBeAFdeAdbEafdeadbeafDeAdbEAFdeadbeaf', /// data: '0x00',
* expirationTime: 0, /// value: 0
* revocable: false, /// }],
* refUID: '0x0000000000000000000000000000000000000000000000000000000000000000', /// signatures: [{
* data: '0x00', /// v: 28,
* value: 0 /// r: '0x148c...b25b',
* }], /// s: '0x5a72...be22'
* signatures: [{ /// },
* v: 28, /// {
* r: '0x148c...b25b', /// v: 28,
* s: '0x5a72...be22' /// r: '0x487s...67bb',
* }, /// s: '0x12ad...2366'
* { /// }],
* v: 28, /// attester: '0x1D86495b2A7B524D747d2839b3C645Bed32e8CF4'
* r: '0x487s...67bb', /// }])
* s: '0x12ad...2366' ///
* }], /// @param multiDelegatedRequests The arguments of the delegated multi attestation requests. The requests should be
* attester: '0x1D86495b2A7B524D747d2839b3C645Bed32e8CF4' /// grouped by distinct schema ids to benefit from the best batching optimization.
* }]) /// @return The UIDs of the new attestations.
*
* @return The UIDs of the new attestations.
*/
function multiAttestByDelegation( function multiAttestByDelegation(
MultiDelegatedAttestationRequest[] calldata multiDelegatedRequests MultiDelegatedAttestationRequest[] calldata multiDelegatedRequests
) external payable returns (bytes32[] memory); ) external payable returns (bytes32[] memory);
/** /// @notice Revokes an existing attestation to a specific schema.
* @dev Revokes an existing attestation to a specific schema. ///
* /// Example:
* Example: ///
* /// revoke({
* revoke({ /// schema: '0x8e72f5bc0a8d4be6aa98360baa889040c50a0e51f32dbf0baa5199bd93472ebc',
* schema: '0x8e72f5bc0a8d4be6aa98360baa889040c50a0e51f32dbf0baa5199bd93472ebc', /// data: {
* data: { /// uid: '0x101032e487642ee04ee17049f99a70590c735b8614079fc9275f9dd57c00966d',
* uid: '0x101032e487642ee04ee17049f99a70590c735b8614079fc9275f9dd57c00966d', /// value: 0
* value: 0 /// }
* } /// })
* }) ///
* /// @param request The arguments of the revocation request.
* @param request The arguments of the revocation request.
*/
function revoke(RevocationRequest calldata request) external payable; function revoke(RevocationRequest calldata request) external payable;
/** /// @notice Revokes an existing attestation to a specific schema via the provided EIP712 signature.
* @dev Revokes an existing attestation to a specific schema via the provided EIP712 signature. ///
* /// Example:
* Example: ///
* /// revokeByDelegation({
* revokeByDelegation({ /// schema: '0x8e72f5bc0a8d4be6aa98360baa889040c50a0e51f32dbf0baa5199bd93472ebc',
* schema: '0x8e72f5bc0a8d4be6aa98360baa889040c50a0e51f32dbf0baa5199bd93472ebc', /// data: {
* data: { /// uid: '0xcbbc12102578c642a0f7b34fe7111e41afa25683b6cd7b5a14caf90fa14d24ba',
* uid: '0xcbbc12102578c642a0f7b34fe7111e41afa25683b6cd7b5a14caf90fa14d24ba', /// value: 0
* value: 0 /// },
* }, /// signature: {
* signature: { /// v: 27,
* v: 27, /// r: '0xb593...7142',
* r: '0xb593...7142', /// s: '0x0f5b...2cce'
* s: '0x0f5b...2cce' /// },
* }, /// revoker: '0x244934dd3e31bE2c81f84ECf0b3E6329F5381992'
* revoker: '0x244934dd3e31bE2c81f84ECf0b3E6329F5381992' /// })
* }) ///
* /// @param delegatedRequest The arguments of the delegated revocation request.
* @param delegatedRequest The arguments of the delegated revocation request.
*/
function revokeByDelegation(DelegatedRevocationRequest calldata delegatedRequest) external payable; function revokeByDelegation(DelegatedRevocationRequest calldata delegatedRequest) external payable;
/** /// @notice Revokes existing attestations to multiple schemas.
* @dev Revokes existing attestations to multiple schemas. ///
* /// Example:
* @param multiRequests The arguments of the multi revocation requests. The requests should be grouped by distinct ///
* schema ids to benefit from the best batching optimization. /// multiRevoke([{
* /// schema: '0x8e72f5bc0a8d4be6aa98360baa889040c50a0e51f32dbf0baa5199bd93472ebc',
* Example: /// data: [{
* /// uid: '0x211296a1ca0d7f9f2cfebf0daaa575bea9b20e968d81aef4e743d699c6ac4b25',
* multiRevoke([{ /// value: 1000
* schema: '0x8e72f5bc0a8d4be6aa98360baa889040c50a0e51f32dbf0baa5199bd93472ebc', /// },
* data: [{ /// {
* uid: '0x211296a1ca0d7f9f2cfebf0daaa575bea9b20e968d81aef4e743d699c6ac4b25', /// uid: '0xe160ac1bd3606a287b4d53d5d1d6da5895f65b4b4bab6d93aaf5046e48167ade',
* value: 1000 /// value: 0
* }, /// }],
* { /// },
* uid: '0xe160ac1bd3606a287b4d53d5d1d6da5895f65b4b4bab6d93aaf5046e48167ade', /// {
* value: 0 /// schema: '0x5ac273ce41e3c8bfa383efe7c03e54c5f0bff29c9f11ef6ffa930fc84ca32425',
* }], /// data: [{
* }, /// uid: '0x053d42abce1fd7c8fcddfae21845ad34dae287b2c326220b03ba241bc5a8f019',
* { /// value: 0
* schema: '0x5ac273ce41e3c8bfa383efe7c03e54c5f0bff29c9f11ef6ffa930fc84ca32425', /// },
* data: [{ /// }])
* uid: '0x053d42abce1fd7c8fcddfae21845ad34dae287b2c326220b03ba241bc5a8f019', ///
* value: 0 /// @param multiRequests The arguments of the multi revocation requests. The requests should be grouped by distinct
* }, /// schema ids to benefit from the best batching optimization.
* }])
*/
function multiRevoke(MultiRevocationRequest[] calldata multiRequests) external payable; function multiRevoke(MultiRevocationRequest[] calldata multiRequests) external payable;
/** /// @notice Revokes existing attestations to multiple schemas via provided EIP712 signatures.
* @dev Revokes existing attestations to multiple schemas via provided EIP712 signatures. ///
* /// Example:
* @param multiDelegatedRequests The arguments of the delegated multi revocation attestation requests. The requests should be ///
* grouped by distinct schema ids to benefit from the best batching optimization. /// multiRevokeByDelegation([{
* /// schema: '0x8e72f5bc0a8d4be6aa98360baa889040c50a0e51f32dbf0baa5199bd93472ebc',
* Example: /// data: [{
* /// uid: '0x211296a1ca0d7f9f2cfebf0daaa575bea9b20e968d81aef4e743d699c6ac4b25',
* multiRevokeByDelegation([{ /// value: 1000
* schema: '0x8e72f5bc0a8d4be6aa98360baa889040c50a0e51f32dbf0baa5199bd93472ebc', /// },
* data: [{ /// {
* uid: '0x211296a1ca0d7f9f2cfebf0daaa575bea9b20e968d81aef4e743d699c6ac4b25', /// uid: '0xe160ac1bd3606a287b4d53d5d1d6da5895f65b4b4bab6d93aaf5046e48167ade',
* value: 1000 /// value: 0
* }, /// }],
* { /// signatures: [{
* uid: '0xe160ac1bd3606a287b4d53d5d1d6da5895f65b4b4bab6d93aaf5046e48167ade', /// v: 28,
* value: 0 /// r: '0x148c...b25b',
* }], /// s: '0x5a72...be22'
* signatures: [{ /// },
* v: 28, /// {
* r: '0x148c...b25b', /// v: 28,
* s: '0x5a72...be22' /// r: '0x487s...67bb',
* }, /// s: '0x12ad...2366'
* { /// }],
* v: 28, /// revoker: '0x244934dd3e31bE2c81f84ECf0b3E6329F5381992'
* r: '0x487s...67bb', /// }])
* s: '0x12ad...2366' ///
* }], /// @param multiDelegatedRequests The arguments of the delegated multi revocation attestation requests. The requests should be
* revoker: '0x244934dd3e31bE2c81f84ECf0b3E6329F5381992' /// grouped by distinct schema ids to benefit from the best batching optimization.
* }])
*
*/
function multiRevokeByDelegation( function multiRevokeByDelegation(
MultiDelegatedRevocationRequest[] calldata multiDelegatedRequests MultiDelegatedRevocationRequest[] calldata multiDelegatedRequests
) external payable; ) external payable;
/** /// @notice Timestamps the specified bytes32 data.
* @dev Timestamps the specified bytes32 data. /// @param data The data to timestamp.
* /// @return The timestamp the data was timestamped with.
* @param data The data to timestamp.
*
* @return The timestamp the data was timestamped with.
*/
function timestamp(bytes32 data) external returns (uint64); function timestamp(bytes32 data) external returns (uint64);
/** /// @notice Timestamps the specified multiple bytes32 data.
* @dev Timestamps the specified multiple bytes32 data. /// @param data The data to timestamp.
* /// @return The timestamp the data was timestamped with.
* @param data The data to timestamp.
*
* @return The timestamp the data was timestamped with.
*/
function multiTimestamp(bytes32[] calldata data) external returns (uint64); function multiTimestamp(bytes32[] calldata data) external returns (uint64);
/** /// @notice Revokes the specified bytes32 data.
* @dev Revokes the specified bytes32 data. /// @param data The data to timestamp.
* /// @return The timestamp the data was revoked with.
* @param data The data to timestamp.
*
* @return The timestamp the data was revoked with.
*/
function revokeOffchain(bytes32 data) external returns (uint64); function revokeOffchain(bytes32 data) external returns (uint64);
/** /// @notice Revokes the specified multiple bytes32 data.
* @dev Revokes the specified multiple bytes32 data. /// @param data The data to timestamp.
* /// @return The timestamp the data was revoked with.
* @param data The data to timestamp.
*
* @return The timestamp the data was revoked with.
*/
function multiRevokeOffchain(bytes32[] calldata data) external returns (uint64); function multiRevokeOffchain(bytes32[] calldata data) external returns (uint64);
/** /// @notice Returns an existing attestation by UID.
* @dev Returns an existing attestation by UID. /// @param uid The UID of the attestation to retrieve.
* /// @return The attestation data members.
* @param uid The UID of the attestation to retrieve.
*
* @return The attestation data members.
*/
function getAttestation(bytes32 uid) external view returns (Attestation memory); function getAttestation(bytes32 uid) external view returns (Attestation memory);
/** /// @notice Checks whether an attestation exists.
* @dev Checks whether an attestation exists. /// @param uid The UID of the attestation to retrieve.
* /// @return Whether an attestation exists.
* @param uid The UID of the attestation to retrieve.
*
* @return Whether an attestation exists.
*/
function isAttestationValid(bytes32 uid) external view returns (bool); function isAttestationValid(bytes32 uid) external view returns (bool);
/** /// @notice Returns the timestamp that the specified data was timestamped with.
* @dev Returns the timestamp that the specified data was timestamped with. /// @param data The data to query.
* /// @return The timestamp the data was timestamped with.
* @param data The data to query.
*
* @return The timestamp the data was timestamped with.
*/
function getTimestamp(bytes32 data) external view returns (uint64); function getTimestamp(bytes32 data) external view returns (uint64);
/** /// @notice Returns the timestamp that the specified data was timestamped with.
* @dev Returns the timestamp that the specified data was timestamped with. /// @param data The data to query.
* /// @return The timestamp the data was timestamped with.
* @param data The data to query.
*
* @return The timestamp the data was timestamped with.
*/
function getRevokeOffchain(address revoker, bytes32 data) external view returns (uint64); function getRevokeOffchain(address revoker, bytes32 data) external view returns (uint64);
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0; pragma solidity ^0.8.0;
import { ISchemaResolver } from "./resolver/ISchemaResolver.sol"; import { ISchemaResolver } from "./resolver/ISchemaResolver.sol";
/** /// @title A struct representing a record for a submitted schema.
* @title A struct representing a record for a submitted schema.
*/
struct SchemaRecord { struct SchemaRecord {
bytes32 uid; // The unique identifier of the schema. bytes32 uid; // The unique identifier of the schema.
ISchemaResolver resolver; // Optional schema resolver. ISchemaResolver resolver; // Optional schema resolver.
...@@ -17,31 +14,20 @@ struct SchemaRecord { ...@@ -17,31 +14,20 @@ struct SchemaRecord {
/// @title ISchemaRegistry /// @title ISchemaRegistry
/// @notice The interface of global attestation schemas for the Ethereum Attestation Service protocol. /// @notice The interface of global attestation schemas for the Ethereum Attestation Service protocol.
interface ISchemaRegistry { interface ISchemaRegistry {
/** /// @dev Emitted when a new schema has been registered
* @dev Emitted when a new schema has been registered /// @param uid The schema UID.
* /// @param registerer The address of the account used to register the schema.
* @param uid The schema UID.
* @param registerer The address of the account used to register the schema.
*/
event Registered(bytes32 indexed uid, address registerer); event Registered(bytes32 indexed uid, address registerer);
/** /// @dev Submits and reserves a new schema
* @dev Submits and reserves a new schema /// @param schema The schema data schema.
* /// @param resolver An optional schema resolver.
* @param schema The schema data schema. /// @param revocable Whether the schema allows revocations explicitly.
* @param resolver An optional schema resolver. /// @return The UID of the new schema.
* @param revocable Whether the schema allows revocations explicitly.
*
* @return The UID of the new schema.
*/
function register(string calldata schema, ISchemaResolver resolver, bool revocable) external returns (bytes32); function register(string calldata schema, ISchemaResolver resolver, bool revocable) external returns (bytes32);
/** /// @dev Returns an existing schema by UID
* @dev Returns an existing schema by UID /// @param uid The UID of the schema to retrieve.
* /// @return The schema data members.
* @param uid The UID of the schema to retrieve.
*
* @return The schema data members.
*/
function getSchema(bytes32 uid) external view returns (SchemaRecord memory); function getSchema(bytes32 uid) external view returns (SchemaRecord memory);
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.19; pragma solidity 0.8.19;
import { Semver } from "../universal/Semver.sol"; import { Semver } from "../universal/Semver.sol";
...@@ -22,14 +21,10 @@ contract SchemaRegistry is ISchemaRegistry, Semver { ...@@ -22,14 +21,10 @@ contract SchemaRegistry is ISchemaRegistry, Semver {
// Upgrade forward-compatibility storage gap // Upgrade forward-compatibility storage gap
uint256[MAX_GAP - 1] private __gap; uint256[MAX_GAP - 1] private __gap;
/** /// @dev Creates a new SchemaRegistry instance.
* @dev Creates a new SchemaRegistry instance.
*/
constructor() Semver(1, 0, 0) {} constructor() Semver(1, 0, 0) {}
/** /// @inheritdoc ISchemaRegistry
* @inheritdoc ISchemaRegistry
*/
function register(string calldata schema, ISchemaResolver resolver, bool revocable) external returns (bytes32) { function register(string calldata schema, ISchemaResolver resolver, bool revocable) external returns (bytes32) {
SchemaRecord memory schemaRecord = SchemaRecord({ SchemaRecord memory schemaRecord = SchemaRecord({
uid: EMPTY_UID, uid: EMPTY_UID,
...@@ -51,20 +46,14 @@ contract SchemaRegistry is ISchemaRegistry, Semver { ...@@ -51,20 +46,14 @@ contract SchemaRegistry is ISchemaRegistry, Semver {
return uid; return uid;
} }
/** /// @inheritdoc ISchemaRegistry
* @inheritdoc ISchemaRegistry
*/
function getSchema(bytes32 uid) external view returns (SchemaRecord memory) { function getSchema(bytes32 uid) external view returns (SchemaRecord memory) {
return _registry[uid]; return _registry[uid];
} }
/** /// @dev Calculates a UID for a given schema.
* @dev Calculates a UID for a given schema. /// @param schemaRecord The input schema.
* /// @return schema UID.
* @param schemaRecord The input schema.
*
* @return schema UID.
*/
function _getUID(SchemaRecord memory schemaRecord) private pure returns (bytes32) { function _getUID(SchemaRecord memory schemaRecord) private pure returns (bytes32) {
return keccak256(abi.encodePacked(schemaRecord.schema, schemaRecord.resolver, schemaRecord.revocable)); return keccak256(abi.encodePacked(schemaRecord.schema, schemaRecord.resolver, schemaRecord.revocable));
} }
......
...@@ -36,59 +36,44 @@ abstract contract EIP712Verifier is EIP712 { ...@@ -36,59 +36,44 @@ abstract contract EIP712Verifier is EIP712 {
// Upgrade forward-compatibility storage gap // Upgrade forward-compatibility storage gap
uint256[MAX_GAP - 1] private __gap; uint256[MAX_GAP - 1] private __gap;
/** /// @dev Creates a new EIP712Verifier instance.
* @dev Creates a new EIP712Verifier instance. /// @param version The current major version of the signing domain
*
* @param version The current major version of the signing domain
*/
constructor(string memory name, string memory version) EIP712(name, version) { constructor(string memory name, string memory version) EIP712(name, version) {
_name = stringToBytes32(name); _name = stringToBytes32(name);
} }
/** /// @notice Returns the domain separator used in the encoding of the signatures for attest, and revoke.
* @dev Returns the domain separator used in the encoding of the signatures for attest, and revoke.
*/
function getDomainSeparator() external view returns (bytes32) { function getDomainSeparator() external view returns (bytes32) {
return _domainSeparatorV4(); return _domainSeparatorV4();
} }
/** /// @notice Returns the current nonce per-account.
* @dev Returns the current nonce per-account. /// @param account The requested account.
* /// @return The current nonce.
* @param account The requested account.
*
* @return The current nonce.
*/
function getNonce(address account) external view returns (uint256) { function getNonce(address account) external view returns (uint256) {
return _nonces[account]; return _nonces[account];
} }
/** /// @notice Returns the EIP712 type hash for the attest function.
* Returns the EIP712 type hash for the attest function. /// @return The EIP712 attest function type hash.
*/
function getAttestTypeHash() external pure returns (bytes32) { function getAttestTypeHash() external pure returns (bytes32) {
return ATTEST_TYPEHASH; return ATTEST_TYPEHASH;
} }
/** /// @notice Returns the EIP712 type hash for the revoke function.
* Returns the EIP712 type hash for the revoke function. /// @return hash_ The EIP712 revoke function type hash.
*/
function getRevokeTypeHash() external pure returns (bytes32) { function getRevokeTypeHash() external pure returns (bytes32) {
return REVOKE_TYPEHASH; return REVOKE_TYPEHASH;
} }
/** /// @notice Returns the EIP712 name.
* Returns the EIP712 name. /// @return The EIP712 name.
*/
function getName() external view returns (string memory) { function getName() external view returns (string memory) {
return bytes32ToString(_name); return bytes32ToString(_name);
} }
/** /// @notice Verifies delegated attestation request.
* @dev Verifies delegated attestation request. /// @param request The arguments of the delegated attestation request.
*
* @param request The arguments of the delegated attestation request.
*/
function _verifyAttest(DelegatedAttestationRequest memory request) internal { function _verifyAttest(DelegatedAttestationRequest memory request) internal {
AttestationRequestData memory data = request.data; AttestationRequestData memory data = request.data;
EIP712Signature memory signature = request.signature; EIP712Signature memory signature = request.signature;
...@@ -118,11 +103,8 @@ abstract contract EIP712Verifier is EIP712 { ...@@ -118,11 +103,8 @@ abstract contract EIP712Verifier is EIP712 {
} }
} }
/** /// @notice Verifies delegated revocation request.
* @dev Verifies delegated revocation request. /// @param request The arguments of the delegated revocation request.
*
* @param request The arguments of the delegated revocation request.
*/
function _verifyRevoke(DelegatedRevocationRequest memory request) internal { function _verifyRevoke(DelegatedRevocationRequest memory request) internal {
RevocationRequestData memory data = request.data; RevocationRequestData memory data = request.data;
EIP712Signature memory signature = request.signature; EIP712Signature memory signature = request.signature;
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0; pragma solidity ^0.8.0;
import { Attestation } from "../Common.sol"; import { Attestation } from "../Common.sol";
...@@ -7,50 +6,33 @@ import { Attestation } from "../Common.sol"; ...@@ -7,50 +6,33 @@ import { Attestation } from "../Common.sol";
/// @title ISchemaResolver /// @title ISchemaResolver
/// @notice The interface of an optional schema resolver. /// @notice The interface of an optional schema resolver.
interface ISchemaResolver { interface ISchemaResolver {
/** /// @notice Checks if the resolve can be sent ETH.
* @dev Returns whether the resolver supports ETH transfers. /// @return Whether the resolver supports ETH transfers.
*/
function isPayable() external pure returns (bool); function isPayable() external pure returns (bool);
/** /// @notice Processes an attestation and verifies whether it's valid.
* @dev Processes an attestation and verifies whether it's valid. /// @param attestation The new attestation.
* /// @return Whether the attestation is valid.
* @param attestation The new attestation.
*
* @return Whether the attestation is valid.
*/
function attest(Attestation calldata attestation) external payable returns (bool); function attest(Attestation calldata attestation) external payable returns (bool);
/** /// @notice Processes multiple attestations and verifies whether they are valid.
* @dev Processes multiple attestations and verifies whether they are valid. /// @param attestations The new attestations.
* /// @param values Explicit ETH amounts which were sent with each attestation.
* @param attestations The new attestations. /// @return Whether all the attestations are valid.
* @param values Explicit ETH amounts which were sent with each attestation.
*
* @return Whether all the attestations are valid.
*/
function multiAttest( function multiAttest(
Attestation[] calldata attestations, Attestation[] calldata attestations,
uint256[] calldata values uint256[] calldata values
) external payable returns (bool); ) external payable returns (bool);
/** /// @notice Processes an attestation revocation and verifies if it can be revoked.
* @dev Processes an attestation revocation and verifies if it can be revoked. /// @param attestation The existing attestation to be revoked.
* /// @return Whether the attestation can be revoked.
* @param attestation The existing attestation to be revoked.
*
* @return Whether the attestation can be revoked.
*/
function revoke(Attestation calldata attestation) external payable returns (bool); function revoke(Attestation calldata attestation) external payable returns (bool);
/** /// @notice Processes revocation of multiple attestation and verifies they can be revoked.
* @dev Processes revocation of multiple attestation and verifies they can be revoked. /// @param attestations The existing attestations to be revoked.
* /// @param values Explicit ETH amounts which were sent with each revocation.
* @param attestations The existing attestations to be revoked. /// @return Whether the attestations can be revoked.
* @param values Explicit ETH amounts which were sent with each revocation.
*
* @return Whether the attestations can be revoked.
*/
function multiRevoke( function multiRevoke(
Attestation[] calldata attestations, Attestation[] calldata attestations,
uint256[] calldata values uint256[] calldata values
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.19; pragma solidity 0.8.19;
import { Semver } from "../../universal/Semver.sol"; import { Semver } from "../../universal/Semver.sol";
...@@ -19,11 +18,8 @@ abstract contract SchemaResolver is ISchemaResolver, Semver { ...@@ -19,11 +18,8 @@ abstract contract SchemaResolver is ISchemaResolver, Semver {
// The global EAS contract. // The global EAS contract.
IEAS internal immutable _eas; IEAS internal immutable _eas;
/** /// @dev Creates a new resolver.
* @dev Creates a new resolver. /// @param eas The address of the global EAS contract.
*
* @param eas The address of the global EAS contract.
*/
constructor(IEAS eas) Semver(1, 0, 0) { constructor(IEAS eas) Semver(1, 0, 0) {
if (address(eas) == address(0)) { if (address(eas) == address(0)) {
revert InvalidEAS(); revert InvalidEAS();
...@@ -32,41 +28,31 @@ abstract contract SchemaResolver is ISchemaResolver, Semver { ...@@ -32,41 +28,31 @@ abstract contract SchemaResolver is ISchemaResolver, Semver {
_eas = eas; _eas = eas;
} }
/** /// @dev Ensures that only the EAS contract can make this call.
* @dev Ensures that only the EAS contract can make this call.
*/
modifier onlyEAS() { modifier onlyEAS() {
_onlyEAS(); _onlyEAS();
_; _;
} }
/** /// @inheritdoc ISchemaResolver
* @inheritdoc ISchemaResolver
*/
function isPayable() public pure virtual returns (bool) { function isPayable() public pure virtual returns (bool) {
return false; return false;
} }
/** /// @dev ETH callback.
* @dev ETH callback.
*/
receive() external payable virtual { receive() external payable virtual {
if (!isPayable()) { if (!isPayable()) {
revert NotPayable(); revert NotPayable();
} }
} }
/** /// @inheritdoc ISchemaResolver
* @inheritdoc ISchemaResolver
*/
function attest(Attestation calldata attestation) external payable onlyEAS returns (bool) { function attest(Attestation calldata attestation) external payable onlyEAS returns (bool) {
return onAttest(attestation, msg.value); return onAttest(attestation, msg.value);
} }
/** /// @inheritdoc ISchemaResolver
* @inheritdoc ISchemaResolver
*/
function multiAttest( function multiAttest(
Attestation[] calldata attestations, Attestation[] calldata attestations,
uint256[] calldata values uint256[] calldata values
...@@ -100,16 +86,12 @@ abstract contract SchemaResolver is ISchemaResolver, Semver { ...@@ -100,16 +86,12 @@ abstract contract SchemaResolver is ISchemaResolver, Semver {
return true; return true;
} }
/** /// @inheritdoc ISchemaResolver
* @inheritdoc ISchemaResolver
*/
function revoke(Attestation calldata attestation) external payable onlyEAS returns (bool) { function revoke(Attestation calldata attestation) external payable onlyEAS returns (bool) {
return onRevoke(attestation, msg.value); return onRevoke(attestation, msg.value);
} }
/** /// @inheritdoc ISchemaResolver
* @inheritdoc ISchemaResolver
*/
function multiRevoke( function multiRevoke(
Attestation[] calldata attestations, Attestation[] calldata attestations,
uint256[] calldata values uint256[] calldata values
...@@ -143,35 +125,25 @@ abstract contract SchemaResolver is ISchemaResolver, Semver { ...@@ -143,35 +125,25 @@ abstract contract SchemaResolver is ISchemaResolver, Semver {
return true; return true;
} }
/** /// @notice A resolver callback that should be implemented by child contracts.
* @dev A resolver callback that should be implemented by child contracts. /// @param attestation The new attestation.
* /// @param value An explicit ETH amount that was sent to the resolver. Please note that this value is verified in
* @param attestation The new attestation. /// both attest() and multiAttest() callbacks EAS-only callbacks and that in case of multi attestations, it'll
* @param value An explicit ETH amount that was sent to the resolver. Please note that this value is verified in /// usually hold that msg.value != value, since msg.value aggregated the sent ETH amounts for all the attestations
* both attest() and multiAttest() callbacks EAS-only callbacks and that in case of multi attestations, it'll /// in the batch.
* usually hold that msg.value != value, since msg.value aggregated the sent ETH amounts for all the attestations /// @return Whether the attestation is valid.
* in the batch.
*
* @return Whether the attestation is valid.
*/
function onAttest(Attestation calldata attestation, uint256 value) internal virtual returns (bool); function onAttest(Attestation calldata attestation, uint256 value) internal virtual returns (bool);
/** /// @notice Processes an attestation revocation and verifies if it can be revoked.
* @dev Processes an attestation revocation and verifies if it can be revoked. /// @param attestation The existing attestation to be revoked.
* /// @param value An explicit ETH amount that was sent to the resolver. Please note that this value is verified in
* @param attestation The existing attestation to be revoked. /// both revoke() and multiRevoke() callbacks EAS-only callbacks and that in case of multi attestations, it'll
* @param value An explicit ETH amount that was sent to the resolver. Please note that this value is verified in /// usually hold that msg.value != value, since msg.value aggregated the sent ETH amounts for all the attestations
* both revoke() and multiRevoke() callbacks EAS-only callbacks and that in case of multi attestations, it'll /// in the batch.
* usually hold that msg.value != value, since msg.value aggregated the sent ETH amounts for all the attestations /// @return Whether the attestation can be revoked.
* in the batch.
*
* @return Whether the attestation can be revoked.
*/
function onRevoke(Attestation calldata attestation, uint256 value) internal virtual returns (bool); function onRevoke(Attestation calldata attestation, uint256 value) internal virtual returns (bool);
/** /// @notice Ensures that only the EAS contract can make this call.
* @dev Ensures that only the EAS contract can make this call.
*/
function _onlyEAS() private view { function _onlyEAS() private view {
if (msg.sender != address(_eas)) { if (msg.sender != address(_eas)) {
revert AccessDenied(); revert AccessDenied();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment