Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Eigenlayer Mock #86

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions SmartContracts/src/eigenlayer-mvp/AVSDirectory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,30 @@ pragma solidity 0.8.25;
import {IAVSDirectory} from "../interfaces/eigenlayer-mvp/IAVSDirectory.sol";

contract AVSDirectory is IAVSDirectory {
bytes32 private constant DOMAIN_TYPEHASH =
keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
bytes32 private constant OPERATOR_AVS_REGISTRATION_TYPEHASH =
keccak256("OperatorAVSRegistration(address operator,address avs,bytes32 salt,uint256 expiry)");

function registerOperatorToAVS(address operator, IAVSDirectory.SignatureWithSaltAndExpiry memory operatorSignature)
external
{}

function deregisterOperatorFromAVS(address operator) external {}

function calculateOperatorAVSRegistrationDigestHash(address operator, address avs, bytes32 salt, uint256 expiry)
public
view
returns (bytes32)
{
// calculate the struct hash
bytes32 structHash = keccak256(abi.encode(OPERATOR_AVS_REGISTRATION_TYPEHASH, operator, avs, salt, expiry));
// calculate the digest hash
bytes32 digestHash = keccak256(abi.encodePacked("\x19\x01", _calculateDomainSeparator(), structHash));
return digestHash;
}

function _calculateDomainSeparator() internal view returns (bytes32) {
return keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes("EigenLayer")), block.chainid, address(this)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@ interface IAVSDirectory {

/// @dev This function will be left without implementation in the MVP
function deregisterOperatorFromAVS(address operator) external;

/// @dev This function will have the implementation in the MVP so that the node can pull the message
/// to be signed
function calculateOperatorAVSRegistrationDigestHash(address operator, address avs, bytes32 salt, uint256 expiry)
external
view
returns (bytes32);
}