Fraction Protocolhelpers

DelegateCallee

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 proxy. 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 msgSender 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, bytes4 functionSignature)

Thrown when a function should not be called by an address other than the diamond proxy itself.

OnlyExternalDelegateCall

error OnlyExternalDelegateCall(bytes4 functionSignature)

Thrown when a function should not be called by the diamond proxy 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 proxy). 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 proxy). 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 proxy). If the function is called by the diamond, the transaction will revert.

On this page