Documentation Index
Fetch the complete documentation index at: https://docs.forterulesengine.io/llms.txt
Use this file to discover all available pages before exploring further.
Git Source
Author:
@mpetersoCode55, @ShaneDuncan602, @TJ-Everett, @VoR0220
This contract is intended to be used internally by facets in the Rules Engine to streamline cross-facet interactions.
This contract provides utility functions for interacting with other facets in the Rules Engine.
It includes functionality for performing delegate calls to other facets using their function selectors.
State Variables
FLAG_FOREIGN_CALL
uint8 constant FLAG_FOREIGN_CALL = 0x01;
FLAG_TRACKER_VALUE
uint8 constant FLAG_TRACKER_VALUE = 0x02;
MASK_GLOBAL_VAR
uint8 constant MASK_GLOBAL_VAR = 0x1C;
SHIFT_GLOBAL_VAR
uint8 constant SHIFT_GLOBAL_VAR = 2;
Functions
_callAnotherFacet
Performs a delegate call to another facet in the Rules Engine.
Uses the function selector to locate the target facet and executes the provided call data.
Reverts with the returned error message if the delegate call fails.
function _callAnotherFacet(bytes4 _functionSelector, bytes memory _callData)
internal
returns (bool _success, bytes memory _res);
Parameters
| Name | Type | Description |
|---|
_functionSelector | bytes4 | The function selector of the target function in the other facet. |
_callData | bytes | The encoded call data to pass to the target function. |
Returns
| Name | Type | Description |
|---|
_success | bool | A boolean indicating whether the delegate call was successful. |
_res | bytes | The returned data from the delegate call. |
_isForeignCall
Checks if the foreign call flag is set in a Placeholder using assembly
Uses optimized assembly to extract the flag bit directly from memory
function _isForeignCall(Placeholder memory placeholder) internal pure returns (bool result);
Parameters
| Name | Type | Description |
|---|
placeholder | Placeholder | The Placeholder struct to check |
Returns
| Name | Type | Description |
|---|
result | bool | True if the foreign call flag is set, false otherwise |
_isTrackerValue
Checks if the tracker value flag is set in a Placeholder using assembly
Uses optimized assembly to extract the flag bit directly from memory
function _isTrackerValue(Placeholder memory placeholder) internal pure returns (bool result);
Parameters
| Name | Type | Description |
|---|
placeholder | Placeholder | The Placeholder struct to check |
Returns
| Name | Type | Description |
|---|
result | bool | True if the tracker value flag is set, false otherwise |
Helper function to extract flags from a placeholder
function _extractFlags(Placeholder memory placeholder)
internal
pure
returns (bool isTrackerValue, bool isForeignCall, uint8 globalVarType);
Parameters
| Name | Type | Description |
|---|
placeholder | Placeholder | The placeholder to extract flags from |
Returns
| Name | Type | Description |
|---|
isTrackerValue | bool | Whether the tracker value flag is set |
isForeignCall | bool | Whether the foreign call flag is set |
globalVarType | uint8 | The global variable type |
_isThereDuplicatesInCalldataValueTypeArray
this is only useful for an array passed as an argument to an external/public function and the function explicitely uses
the calldata keyword. This won’t work if the array is stored in memory.
this is a type-agnostic solution for determining if an array of value types from calldata contains duplicates in it
function _isThereDuplicatesInCalldataValueTypeArray(uint256 len, uint256 start)
internal
pure
returns (bool duplicatesFound);
Parameters
| Name | Type | Description |
|---|
len | uint256 | the length of the array. Can be easily retrieved in Solidity by using array.length; |
start | uint256 | the location in the calldata of the first element of the array. Can be retrieved with Yul by doing array.offset |
Returns
| Name | Type | Description |
|---|
duplicatesFound | bool | true if at least one element is repeated in the array. False otherwise |