RulesEngineDiamond
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.
Parameters
Name | Type | Description |
---|---|---|
diamondCut | FacetCut[] | Array of facets to be created at deployment. |
args | RulesEngineDiamondArgs | Arguments 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.
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.
Parameters
Name | Type | Description |
---|---|---|
calls | bytes[] | An array of inputs for each call. |
revertOnFail | bool | If 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.
_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
.
Parameters
Name | Type | Description |
---|---|---|
_returnData | bytes | The returned data from the failed call. |
receive
Fallback function for empty calldata.
Allows the contract to receive Ether.