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
Inherits:
FacetCommonImports
Author:
@mpetersoCode55, @ShaneDuncan602, @TJ-Everett, @VoR0220
This contract is a critical component of the Rules Engine, enabling secure and flexible data management.
This contract serves as the data facet for the Rules Engine Foreign Call Components. It provides functionality for managing
foreign calls. It enforces role-based access control
and ensures that only authorized users can modify or retrieve data. The contract also supports policy cementing
to prevent further modifications.
Functions
createForeignCall
Creates a foreign call and stores it in the contract’s storage.
Builds a foreign call structure and maps it to the associated policy ID.
function createForeignCall(
uint256 _policyId,
ForeignCall calldata _foreignCall,
string calldata foreignCallName,
string calldata foreignCallSignature
) external returns (uint256);
Parameters
| Name | Type | Description |
|---|
_policyId | uint256 | The policy ID the foreign call will be mapped to. |
_foreignCall | ForeignCall | The definition of the foreign call to create. |
foreignCallName | string | The name of the foreign call |
foreignCallSignature | string | |
Returns
| Name | Type | Description |
|---|
<none> | uint256 | The index of the created foreign call. |
updateForeignCall
Updates a foreign call in the contract’s storage.
function updateForeignCall(uint256 policyId, uint256 foreignCallId, ForeignCall calldata foreignCall)
external
returns (ForeignCall memory fc);
Parameters
| Name | Type | Description |
|---|
policyId | uint256 | The policy ID the foreign call is associated with. |
foreignCallId | uint256 | The ID of the foreign call to update. |
foreignCall | ForeignCall | The updated foreign call structure. |
Returns
| Name | Type | Description |
|---|
fc | ForeignCall | The updated foreign call structure. |
deleteForeignCall
Deletes a foreign call from the contract’s storage.
function deleteForeignCall(uint256 policyId, uint256 foreignCallId) external;
Parameters
| Name | Type | Description |
|---|
policyId | uint256 | The policy ID the foreign call is associated with. |
foreignCallId | uint256 | The ID of the foreign call to delete. |
getAllForeignCalls
Retrieve Foreign Call Set from storage
function getAllForeignCalls(uint256 policyId) external view returns (ForeignCall[] memory);
Parameters
| Name | Type | Description |
|---|
policyId | uint256 | the policy Id of the foreign call to retrieve |
Returns
| Name | Type | Description |
|---|
<none> | ForeignCall[] | the foreign call set structure |
getForeignCall
Retrieves a foreign call from the contract’s storage.
function getForeignCall(uint256 policyId, uint256 foreignCallId) public view returns (ForeignCall memory);
Parameters
| Name | Type | Description |
|---|
policyId | uint256 | The policy ID of the foreign call to retrieve. |
foreignCallId | uint256 | The ID of the foreign call to retrieve. |
Returns
| Name | Type | Description |
|---|
<none> | ForeignCall | The foreign call structure. |
retrieves the foreign call metadata
function getForeignCallMetadata(uint256 policyId, uint256 foreignCallId)
public
view
returns (ForeignCallMetadataStruct memory);
Parameters
| Name | Type | Description |
|---|
policyId | uint256 | The policy ID the foreign call is associated with. |
foreignCallId | uint256 | The identifier for the foreign call |
Returns
| Name | Type | Description |
|---|
<none> | ForeignCallMetadataStruct | the metadata for the foreign call |
_storeForeignCall
Stores a foreign call in the contract’s storage.
Ensures the foreign call is properly set before storing it.
function _storeForeignCall(uint256 _policyId, ForeignCall calldata _foreignCall, uint256 _foreignCallIndex) internal;
Parameters
| Name | Type | Description |
|---|
_policyId | uint256 | The policy ID the foreign call is associated with. |
_foreignCall | ForeignCall | The foreign call to store. |
_foreignCallIndex | uint256 | |
_incrementForeignCallIndex
Helper function to increment the foreign call index
Ensures the foreign call is properly set before storing it.
function _incrementForeignCallIndex(uint256 _policyId) private returns (uint256);
Parameters
| Name | Type | Description |
|---|
_policyId | uint256 | The policy ID the foreign call is associated with. |
_storeForeignCallData
Helper function to store the foreign call data
Ensures the foreign call is properly set before storing it.
function _storeForeignCallData(uint256 _policyId, ForeignCall calldata _foreignCall, uint256 _foreignCallIndex)
private;
Parameters
| Name | Type | Description |
|---|
_policyId | uint256 | The policy ID the foreign call is associated with. |
_foreignCall | ForeignCall | The foreign call to store. |
_foreignCallIndex | uint256 | The index of the foreign call. |
Helper function to store the foreign call metadata
function _storeForeignCallMetadata(
uint256 _policyId,
uint256 _foreignCallIndex,
string calldata _foreignCallName,
string memory _foreignCallSignature
) private;
Parameters
| Name | Type | Description |
|---|
_policyId | uint256 | The policy ID the foreign call is associated with. |
_foreignCallIndex | uint256 | The index of the foreign call. |
_foreignCallName | string | The name of the foreign call. |
_foreignCallSignature | string | |
_isForeignCallPermissioned
Checks if the foreign call is permissioned and if the caller is authorized.
function _isForeignCallPermissioned(address _foriegnCallAddress, bytes4 _functionSignature) internal view;
Parameters
| Name | Type | Description |
|---|
_foriegnCallAddress | address | The address of the foreign call contract. |
_functionSignature | bytes4 | The function signature of the foreign call. |
addAdminToPermissionList
Adds an admin to the permission list for a foreign call.
This function can only be called by an existing foreign call admin.
function addAdminToPermissionList(address foriegnCallAddress, address policyAdminsToAdd, bytes4 selector) external;
Parameters
| Name | Type | Description |
|---|
foriegnCallAddress | address | The address of the foreign call contract. |
policyAdminsToAdd | address | The address of the admin to add to the permission list. |
selector | bytes4 | The function selector of the foreign call to add the admin to. |
updatePermissionList
Updates the permission list for a foreign call.
This function can only be called by an existing foreign call admin.
function updatePermissionList(address foriegnCallAddress, bytes4 selector, address[] memory policyAdminsToAdd)
external;
Parameters
| Name | Type | Description |
|---|
foriegnCallAddress | address | The address of the foreign call contract. |
selector | bytes4 | The function selector of the foreign call to update the permission list for. |
policyAdminsToAdd | address[] | The addresses of the admins to add to the permission list. |
getForeignCallPermissionList
Retrieves the permission list for a foreign call.
function getForeignCallPermissionList(address foriegnCallAddress, bytes4 selector)
public
view
returns (address[] memory);
Parameters
| Name | Type | Description |
|---|
foriegnCallAddress | address | The address of the foreign call contract. |
selector | bytes4 | The function selector of the foreign call to retrieve the permission list for. |
Returns
| Name | Type | Description |
|---|
<none> | address[] | An array of addresses that are permissioned for the foreign call. |
removeAllFromPermissionList
Removes all addresses from the permission list for a foreign call.
This function resets the permission list to only include the foreign call admin.
This function can only be called by an existing foreign call admin.
function removeAllFromPermissionList(address foriegnCallAddress, bytes4 selector) external;
Parameters
| Name | Type | Description |
|---|
foriegnCallAddress | address | The address of the foreign call contract. |
selector | bytes4 | The function selector of the foreign call to remove all permissions from. |
removeFromPermissionList
Removes a specific address from the permission list for a foreign call.
This function can only be called by an existing foreign call admin.
function removeFromPermissionList(address _foriegnCallAddress, bytes4 _selector, address policyAdminToRemove)
external;
Parameters
| Name | Type | Description |
|---|
_foriegnCallAddress | address | The address of the foreign call contract. |
_selector | bytes4 | The function selector of the foreign call to remove the address from. |
policyAdminToRemove | address | The address of the admin to remove from the permission list. |
removeForeignCallPermissions
Removes foreign call permissions from the contract address and selector pair.
This function can only be called by an existing foreign call admin.
function removeForeignCallPermissions(address _foriegnCallAddress, bytes4 _selector) external;
Parameters
| Name | Type | Description |
|---|
_foriegnCallAddress | address | The address of the foreign call contract. |
_selector | bytes4 | The function selector of the foreign call to remove permissions for. |
getAllPermissionedFCs
Retrieves all permissioned foreign calls.
function getAllPermissionedFCs() external pure returns (PermissionedForeignCallStorage memory);
Returns
| Name | Type | Description |
|---|
<none> | PermissionedForeignCallStorage | The PermissionedForeignCallStorage structure containing all permissioned foreign calls. |
_notCemented
Checks that a policy is not cemented.
function _notCemented(uint256 _policyId) internal view;
Parameters
| Name | Type | Description |
|---|
_policyId | uint256 | The ID of the policy. |
_policyAdminOnly
Checks that the caller is a policy admin
function _policyAdminOnly(uint256 _policyId, address _address) internal;
Parameters
| Name | Type | Description |
|---|
_policyId | uint256 | The ID of the policy. |
_address | address | The address to check for policy admin status. |
_foreignCallAdminOnly
Checks that the caller is a policy admin
function _foreignCallAdminOnly(address _foreignCallAddr, address _address, bytes4 _functionSelector) internal;
Parameters
| Name | Type | Description |
|---|
_foreignCallAddr | address | The ID of the foreign call. |
_address | address | The address to check for policy admin status. |
_functionSelector | bytes4 | The function selector to check for policy admin status. |