Commit 0132fd1d authored by Mark Tyneway's avatar Mark Tyneway

lint: fix

parent 122d3f14
......@@ -6,6 +6,4 @@ lib
artifacts
forge-artifacts
cache
typechain
coverage*
deployments
......@@ -85,8 +85,7 @@ contract EAS is IEAS, Semver, EIP712Verifier {
/**
* @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
......@@ -108,21 +107,30 @@ contract EAS is IEAS, Semver, EIP712Verifier {
/**
* @inheritdoc IEAS
*/
function attestByDelegation(
DelegatedAttestationRequest calldata delegatedRequest
) external payable returns (bytes32) {
function attestByDelegation(DelegatedAttestationRequest calldata delegatedRequest)
external
payable
returns (bytes32)
{
_verifyAttest(delegatedRequest);
AttestationRequestData[] memory data = new AttestationRequestData[](1);
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
*/
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
// all the returned UIDs into a single list.
bytes32[][] memory totalUids = new bytes32[][](multiRequests.length);
......@@ -132,7 +140,7 @@ contract EAS is IEAS, Semver, EIP712Verifier {
// from it to verify that there isn't any attempt to send too much ETH to resolvers. Please note that unless
// some ETH was stuck in the contract by accident (which shouldn't happen in normal conditions), it won't be
// possible to send too much ETH anyway.
uint availableValue = msg.value;
uint256 availableValue = msg.value;
for (uint256 i = 0; i < multiRequests.length; i = uncheckedInc(i)) {
// The last batch is handled slightly differently: if the total available ETH wasn't spent in full and there
......@@ -182,7 +190,7 @@ contract EAS is IEAS, Semver, EIP712Verifier {
// from it to verify that there isn't any attempt to send too much ETH to resolvers. Please note that unless
// some ETH was stuck in the contract by accident (which shouldn't happen in normal conditions), it won't be
// possible to send too much ETH anyway.
uint availableValue = msg.value;
uint256 availableValue = msg.value;
for (uint256 i = 0; i < multiDelegatedRequests.length; i = uncheckedInc(i)) {
// The last batch is handled slightly differently: if the total available ETH wasn't spent in full and there
......@@ -193,7 +201,8 @@ contract EAS is IEAS, Semver, EIP712Verifier {
last = i == multiDelegatedRequests.length - 1;
}
MultiDelegatedAttestationRequest calldata multiDelegatedRequest = multiDelegatedRequests[i];
MultiDelegatedAttestationRequest
calldata multiDelegatedRequest = multiDelegatedRequests[i];
AttestationRequestData[] calldata data = multiDelegatedRequest.data;
// Ensure that no inputs are missing.
......@@ -249,7 +258,10 @@ contract EAS is IEAS, Semver, EIP712Verifier {
/**
* @inheritdoc IEAS
*/
function revokeByDelegation(DelegatedRevocationRequest calldata delegatedRequest) external payable {
function revokeByDelegation(DelegatedRevocationRequest calldata delegatedRequest)
external
payable
{
_verifyRevoke(delegatedRequest);
RevocationRequestData[] memory data = new RevocationRequestData[](1);
......@@ -266,7 +278,7 @@ contract EAS is IEAS, Semver, EIP712Verifier {
// from it to verify that there isn't any attempt to send too much ETH to resolvers. Please note that unless
// some ETH was stuck in the contract by accident (which shouldn't happen in normal conditions), it won't be
// possible to send too much ETH anyway.
uint availableValue = msg.value;
uint256 availableValue = msg.value;
for (uint256 i = 0; i < multiRequests.length; i = uncheckedInc(i)) {
// The last batch is handled slightly differently: if the total available ETH wasn't spent in full and there
......@@ -280,7 +292,13 @@ contract EAS is IEAS, Semver, EIP712Verifier {
MultiRevocationRequest calldata multiRequest = multiRequests[i];
// Ensure to deduct the ETH that was forwarded to the resolver during the processing of this batch.
availableValue -= _revoke(multiRequest.schema, multiRequest.data, msg.sender, availableValue, last);
availableValue -= _revoke(
multiRequest.schema,
multiRequest.data,
msg.sender,
availableValue,
last
);
}
}
......@@ -294,7 +312,7 @@ contract EAS is IEAS, Semver, EIP712Verifier {
// from it to verify that there isn't any attempt to send too much ETH to resolvers. Please note that unless
// some ETH was stuck in the contract by accident (which shouldn't happen in normal conditions), it won't be
// possible to send too much ETH anyway.
uint availableValue = msg.value;
uint256 availableValue = msg.value;
for (uint256 i = 0; i < multiDelegatedRequests.length; i = uncheckedInc(i)) {
// The last batch is handled slightly differently: if the total available ETH wasn't spent in full and there
......@@ -305,7 +323,9 @@ contract EAS is IEAS, Semver, EIP712Verifier {
last = i == multiDelegatedRequests.length - 1;
}
MultiDelegatedRevocationRequest memory multiDelegatedRequest = multiDelegatedRequests[i];
MultiDelegatedRevocationRequest memory multiDelegatedRequest = multiDelegatedRequests[
i
];
RevocationRequestData[] memory data = multiDelegatedRequest.data;
// Ensure that no inputs are missing.
......@@ -438,7 +458,9 @@ contract EAS is IEAS, Semver, EIP712Verifier {
res.uids = new bytes32[](length);
// Ensure that we aren't attempting to attest to a non-existing schema.
SchemaRecord memory schemaRecord = ISchemaRegistry(Predeploys.SCHEMA_REGISTRY).getSchema(schema);
SchemaRecord memory schemaRecord = ISchemaRegistry(Predeploys.SCHEMA_REGISTRY).getSchema(
schema
);
if (schemaRecord.uid == EMPTY_UID) {
revert InvalidSchema();
}
......@@ -504,7 +526,14 @@ contract EAS is IEAS, Semver, EIP712Verifier {
emit Attested(request.recipient, attester, uid, schema);
}
res.usedValue = _resolveAttestations(schemaRecord, attestations, values, false, availableValue, last);
res.usedValue = _resolveAttestations(
schemaRecord,
attestations,
values,
false,
availableValue,
last
);
return res;
}
......@@ -528,7 +557,9 @@ contract EAS is IEAS, Semver, EIP712Verifier {
bool last
) private returns (uint256) {
// Ensure that a non-existing schema ID wasn't passed by accident.
SchemaRecord memory schemaRecord = ISchemaRegistry(Predeploys.SCHEMA_REGISTRY).getSchema(schema);
SchemaRecord memory schemaRecord = ISchemaRegistry(Predeploys.SCHEMA_REGISTRY).getSchema(
schema
);
if (schemaRecord.uid == EMPTY_UID) {
revert InvalidSchema();
}
......@@ -660,7 +691,15 @@ contract EAS is IEAS, Semver, EIP712Verifier {
) private returns (uint256) {
uint256 length = attestations.length;
if (length == 1) {
return _resolveAttestation(schemaRecord, attestations[0], values[0], isRevocation, availableValue, last);
return
_resolveAttestation(
schemaRecord,
attestations[0],
values[0],
isRevocation,
availableValue,
last
);
}
ISchemaResolver resolver = schemaRecord.resolver;
......@@ -773,7 +812,11 @@ contract EAS is IEAS, Semver, EIP712Verifier {
* @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];
if (revocations[data] != 0) {
......@@ -801,7 +844,11 @@ contract EAS is IEAS, Semver, EIP712Verifier {
*
* @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);
uint256 currentIndex = 0;
......
......@@ -108,7 +108,12 @@ interface IEAS {
* @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.
......@@ -118,7 +123,12 @@ interface IEAS {
* @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.
......@@ -194,9 +204,10 @@ interface IEAS {
*
* @return The UID of the new attestation.
*/
function attestByDelegation(
DelegatedAttestationRequest calldata delegatedRequest
) external payable returns (bytes32);
function attestByDelegation(DelegatedAttestationRequest calldata delegatedRequest)
external
payable
returns (bytes32);
/**
* @dev Attests to multiple schemas.
......@@ -239,7 +250,10 @@ interface IEAS {
*
* @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);
/**
* @dev Attests to multiple schemas using via provided EIP712 signatures.
......@@ -324,7 +338,9 @@ interface IEAS {
*
* @param delegatedRequest The arguments of the delegated revocation request.
*/
function revokeByDelegation(DelegatedRevocationRequest calldata delegatedRequest) external payable;
function revokeByDelegation(DelegatedRevocationRequest calldata delegatedRequest)
external
payable;
/**
* @dev Revokes existing attestations to multiple schemas.
......
......@@ -34,7 +34,11 @@ interface ISchemaRegistry {
*
* @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
......
......@@ -30,7 +30,11 @@ contract SchemaRegistry is ISchemaRegistry, Semver {
/**
* @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({
uid: EMPTY_UID,
schema: schema,
......@@ -66,6 +70,9 @@ contract SchemaRegistry is ISchemaRegistry, Semver {
* @return schema UID.
*/
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)
);
}
}
......@@ -14,18 +14,26 @@ import {
RevocationRequestData
} from "../IEAS.sol";
import { EIP712Signature, InvalidSignature, MAX_GAP, stringToBytes32, bytes32ToString } from "../Common.sol";
import {
EIP712Signature,
InvalidSignature,
MAX_GAP,
stringToBytes32,
bytes32ToString
} from "../Common.sol";
/// @title EIP712
/// @notice The EIP712 typed signatures verifier for EAS delegated attestations.
abstract contract EIP712Verifier is EIP712 {
// The hash of the data type used to relay calls to the attest function. It's the value of
// keccak256("Attest(bytes32 schema,address recipient,uint64 expirationTime,bool revocable,bytes32 refUID,bytes data,uint256 nonce)").
bytes32 private constant ATTEST_TYPEHASH = 0xdbfdf8dc2b135c26253e00d5b6cbe6f20457e003fd526d97cea183883570de61;
bytes32 private constant ATTEST_TYPEHASH =
0xdbfdf8dc2b135c26253e00d5b6cbe6f20457e003fd526d97cea183883570de61;
// The hash of the data type used to relay calls to the revoke function. It's the value of
// keccak256("Revoke(bytes32 schema,bytes32 uid,uint256 nonce)").
bytes32 private constant REVOKE_TYPEHASH = 0xa98d02348410c9c76735e0d0bb1396f4015ac2bb9615f9c2611d19d7a8a99650;
bytes32 private constant REVOKE_TYPEHASH =
0xa98d02348410c9c76735e0d0bb1396f4015ac2bb9615f9c2611d19d7a8a99650;
// The user readable name of the signing domain.
bytes32 private immutable _name;
......@@ -132,7 +140,9 @@ abstract contract EIP712Verifier is EIP712 {
nonce = _nonces[request.revoker]++;
}
bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(REVOKE_TYPEHASH, request.schema, data.uid, nonce)));
bytes32 digest = _hashTypedDataV4(
keccak256(abi.encode(REVOKE_TYPEHASH, request.schema, data.uid, nonce))
);
if (ECDSA.recover(digest, signature.v, signature.r, signature.s) != request.revoker) {
revert InvalidSignature();
......
......@@ -29,10 +29,10 @@ interface ISchemaResolver {
*
* @return Whether all the attestations are valid.
*/
function multiAttest(
Attestation[] calldata attestations,
uint256[] calldata values
) external payable returns (bool);
function multiAttest(Attestation[] calldata attestations, uint256[] calldata values)
external
payable
returns (bool);
/**
* @dev Processes an attestation revocation and verifies if it can be revoked.
......@@ -51,8 +51,8 @@ interface ISchemaResolver {
*
* @return Whether the attestations can be revoked.
*/
function multiRevoke(
Attestation[] calldata attestations,
uint256[] calldata values
) external payable returns (bool);
function multiRevoke(Attestation[] calldata attestations, uint256[] calldata values)
external
payable
returns (bool);
}
......@@ -67,10 +67,12 @@ abstract contract SchemaResolver is ISchemaResolver, Semver {
/**
* @inheritdoc ISchemaResolver
*/
function multiAttest(
Attestation[] calldata attestations,
uint256[] calldata values
) external payable onlyEAS returns (bool) {
function multiAttest(Attestation[] calldata attestations, uint256[] calldata values)
external
payable
onlyEAS
returns (bool)
{
uint256 length = attestations.length;
// We are keeping track of the remaining ETH amount that can be sent to resolvers and will keep deducting
......@@ -110,10 +112,12 @@ abstract contract SchemaResolver is ISchemaResolver, Semver {
/**
* @inheritdoc ISchemaResolver
*/
function multiRevoke(
Attestation[] calldata attestations,
uint256[] calldata values
) external payable onlyEAS returns (bool) {
function multiRevoke(Attestation[] calldata attestations, uint256[] calldata values)
external
payable
onlyEAS
returns (bool)
{
uint256 length = attestations.length;
// We are keeping track of the remaining ETH amount that can be sent to resolvers and will keep deducting
......@@ -154,7 +158,10 @@ abstract contract SchemaResolver is ISchemaResolver, Semver {
*
* @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);
/**
* @dev Processes an attestation revocation and verifies if it can be revoked.
......@@ -167,7 +174,10 @@ abstract contract SchemaResolver is ISchemaResolver, Semver {
*
* @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);
/**
* @dev Ensures that only the EAS contract can make this call.
......
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