Staking Protocolhelpers

StakingDelegateCallee

This abstract contract provides modifiers to enforce specific call contexts for functions of facets in a diamond architecture (see EIP-2535). It ensures proper function execution by restricting access based on the caller's address.

_Functions of facets must always be called via delegate calls from the diamond. If there is no delegate call, the function is not in the context of the diamond, therby eliminating the risk of unintended behavior and storage access.

When using delegatecall, the msg.sender within the context of the called contract is the address of the original caller that invoked the function, not the address of the contract executing the delegate call. This distinction allows us to differentiate between "internal" and "external" delegate calls in the context of the diamond architecture._

OnlyInternalDelegateCall

error OnlyInternalDelegateCall(address invalidCaller, address expectedCaller)

Thrown when a function is called by an address other than the diamond (contract) itself.

OnlyExternalDelegateCall

error OnlyExternalDelegateCall(address invalidCaller)

Thrown when a function is called by the diamond (contract) itself.

onlyInternalDelegateCall

modifier onlyInternalDelegateCall()

Restricts access to functions that should only be invoked via "internal" delegate calls from the diamond contract. This ensures that certain operations are executed in the correct context and prevents unauthorized access or unexpected behavior.

This modifier verifies that the caller is the contract itself (i.e., the diamond). If the function is called from outside the diamond, the transaction will revert.

onlyExternalDelegateCall

modifier onlyExternalDelegateCall()

Restricts access to functions that should only be invoked via "external" delegate calls (calls originating from an admin or other external caller targeting the diamond). This modifier is mainly used to ensure that initialization operations cannot be executed directly by the diamond contract itself.

This modifier checks that the caller is not the contract itself (i.e., the diamond). If the function is called by the diamond, the transaction will revert.

On this page