// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.12; import "openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol"; /** * @title Abstract contract that implements minimal signature-related storage & functionality for upgradeable contracts. * @author Layr Labs, Inc. * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service */ abstract contract UpgradeableSignatureCheckingUtils is Initializable { /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); // chain id at the time of contract deployment uint256 internal immutable ORIGINAL_CHAIN_ID; /** * @notice Original EIP-712 Domain separator for this contract. * @dev The domain separator may change in the event of a fork that modifies the ChainID. * Use the getter function `domainSeparator` to get the current domain separator for this contract. */ bytes32 internal _DOMAIN_SEPARATOR; // INITIALIZING FUNCTIONS constructor() { ORIGINAL_CHAIN_ID = block.chainid; } function _initializeSignatureCheckingUtils() internal onlyInitializing { _DOMAIN_SEPARATOR = _calculateDomainSeparator(); } // VIEW FUNCTIONS /** * @notice Getter function for the current EIP-712 domain separator for this contract. * @dev The domain separator will change in the event of a fork that changes the ChainID. */ function domainSeparator() public view returns (bytes32) { if (block.chainid == ORIGINAL_CHAIN_ID) { return _DOMAIN_SEPARATOR; } else { return _calculateDomainSeparator(); } } // @notice Internal function for calculating the current domain separator of this contract function _calculateDomainSeparator() internal view returns (bytes32) { return keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes("EigenLayer")), block.chainid, address(this))); } }