Git Source

Inherits: ERC173

Author: @mpetersoCode55, @ShaneDuncan602, @TJ-Everett, @VoR0220

The diamond inherits ERC173 for ownership management and supports batch operations for efficiency.

This contract implements the diamond proxy pattern for the Rules Engine. It is responsible for managing facets, handling token rule configurations, and facilitating communication between the application and protocol.

Functions

constructor

Constructor for the Rules Engine Diamond.

Initializes the diamond by performing a diamond cut operation to set up facets.

constructor(FacetCut[] memory diamondCut, RulesEngineDiamondArgs memory args) payable;

Parameters

NameTypeDescription
diamondCutFacetCut[]Array of facets to be created at deployment.
argsRulesEngineDiamondArgsArguments for the facets’ initialization, including the initializer address and calldata.

fallback

Fallback function to handle calls to functions not explicitly defined in the diamond.

Finds the appropriate facet for the function selector and delegates the call to it.

fallback() external payable;

batch

Allows batched call to self (this contract). Taken from BoringSolidity’s Boring Batchable and modified to not be payable.

Allows batched calls to the diamond contract. Taken from BoringSolidity’s Boring Batchable and modified to not be payable.

Executes multiple calls in a single transaction. If revertOnFail is true, the batch stops on the first failure.

function batch(bytes[] calldata calls, bool revertOnFail) external;

Parameters

NameTypeDescription
callsbytes[]An array of inputs for each call.
revertOnFailboolIf True then reverts after a failed call and stops doing further calls.

_callDiamond

Internal function to handle fallback calls.

Finds the facet for the function selector and delegates the call to it. Reverts if no facet is found or the facet has no code.

function _callDiamond() internal;

_getRevertMsg

Helper function to extract a revert message from a failed call.

If the returned data is malformed or not correctly ABI-encoded, this function reverts with a BatchError.

function _getRevertMsg(bytes memory _returnData) internal pure;

Parameters

NameTypeDescription
_returnDatabytesThe returned data from the failed call.

receive

Fallback function for empty calldata.

Allows the contract to receive Ether.

receive() external payable;

Events

EngineDeployed

event EngineDeployed();