Skip to content

Commit

Permalink
Merge pull request #86 from NethermindEth/anshu/update-eigenlayer-mock
Browse files Browse the repository at this point in the history
Update Eigenlayer Mock
  • Loading branch information
AnshuJalan authored Aug 24, 2024
2 parents 92ceda2 + 76184f9 commit f1b3872
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
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);
}

0 comments on commit f1b3872

Please sign in to comment.