Documentation Index
Fetch the complete documentation index at: https://thrackle.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Git Source
Author:
@mpetersoCode55, @ShaneDuncan602, @TJ-Everett, @VoR0220
This library is a critical component of the Rules Engine, enabling dynamic and modular functionality through
the diamond proxy pattern.
This library implements the core functionality for managing facets in the diamond proxy pattern. It provides
functions for adding, replacing, and removing facets, as well as initializing diamond cuts. The library also
enforces rules for facet management and ensures that only valid operations are performed.
State Variables
DIAMOND_CUT_STORAGE
bytes32 constant DIAMOND_CUT_STORAGE = bytes32(uint256(keccak256("diamond-cut.storage")) - 1);
Functions
Function for position of rules. Every rule has its own storage.
function s() internal pure returns (RulesEngineDiamondStorage storage ds);
Returns
| Name | Type | Description |
|---|
ds | RulesEngineDiamondStorage | Data storage for Rule Processor Storage |
diamondCut
Internal function version of _diamondCut
function diamondCut(FacetCut[] memory _diamondCut, address init, bytes memory data) internal;
Parameters
| Name | Type | Description |
|---|
_diamondCut | FacetCut[] | Facets Array |
init | address | Address of the contract or facet to execute “data” |
data | bytes | A function call, including function selector and arguments calldata is executed with delegatecall on “init” |
addFunctions
Add Function to Diamond
function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal;
Parameters
| Name | Type | Description |
|---|
_facetAddress | address | Address of Facet |
_functionSelectors | bytes4[] | Signature array of function selectors |
replaceFunctions
Replace Function from Diamond
function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal;
Parameters
| Name | Type | Description |
|---|
_facetAddress | address | Address of Facet |
_functionSelectors | bytes4[] | Signature array of function selectors |
removeFunctions
can’t replace immutable functions — functions defined directly in the diamond in this case
replace old facet address
Remove Function from Diamond
function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal;
Parameters
| Name | Type | Description |
|---|
_facetAddress | address | Address of Facet |
_functionSelectors | bytes4[] | Signature array of function selectors |
initializeDiamondCut
can’t remove immutable functions — functions defined directly in the diamond
replace selector with last selector
delete last selector
Initialize Diamond Cut of new Facet
function initializeDiamondCut(address init, bytes memory data) internal;
Parameters
| Name | Type | Description |
|---|
init | address | The address of the contract or facet to execute “data” |
data | bytes | A function call, including function selector and arguments calldata is executed with delegatecall on “init” |
enforceHasContractCode
Internal function to enforce contract has code
function enforceHasContractCode(address _contract, string memory _errorMessage) internal view;
Parameters
| Name | Type | Description |
|---|
_contract | address | The address of the contract be checked or enforced |
_errorMessage | string | Error for contract with non matching co |
Events
DiamondCut
event DiamondCut(FacetCut[] _diamondCut, address init, bytes data);