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)
    external
    returns (uint256);
Parameters
NameTypeDescription
_policyIduint256The policy ID the foreign call will be mapped to.
_foreignCallForeignCallThe definition of the foreign call to create.
foreignCallNamestringThe name of the foreign call
Returns
NameTypeDescription
<none>uint256The 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
NameTypeDescription
policyIduint256The policy ID the foreign call is associated with.
foreignCallIduint256The ID of the foreign call to update.
foreignCallForeignCallThe updated foreign call structure.
Returns
NameTypeDescription
fcForeignCallThe updated foreign call structure.

deleteForeignCall

Deletes a foreign call from the contract’s storage.
function deleteForeignCall(uint256 policyId, uint256 foreignCallId) external;
Parameters
NameTypeDescription
policyIduint256The policy ID the foreign call is associated with.
foreignCallIduint256The ID of the foreign call to delete.

getAllForeignCalls

Retrieve Foreign Call Set from storage
function getAllForeignCalls(uint256 policyId) external view returns (ForeignCall[] memory);
Parameters
NameTypeDescription
policyIduint256the policy Id of the foreign call to retrieve
Returns
NameTypeDescription
<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
NameTypeDescription
policyIduint256The policy ID of the foreign call to retrieve.
foreignCallIduint256The ID of the foreign call to retrieve.
Returns
NameTypeDescription
<none>ForeignCallThe foreign call structure.

getForeignCallMetadata

retrieves the foreign call metadata
function getForeignCallMetadata(uint256 policyId, uint256 foreignCallId) public view returns (string memory);
Parameters
NameTypeDescription
policyIduint256The policy ID the foreign call is associated with.
foreignCallIduint256The identifier for the foreign call
Returns
NameTypeDescription
<none>stringthe 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
NameTypeDescription
_policyIduint256The policy ID the foreign call is associated with.
_foreignCallForeignCallThe foreign call to store.
_foreignCallIndexuint256

_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
NameTypeDescription
_policyIduint256The 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
NameTypeDescription
_policyIduint256The policy ID the foreign call is associated with.
_foreignCallForeignCallThe foreign call to store.
_foreignCallIndexuint256The index of the foreign call.

_storeForeignCallMetadata

Helper function to store the foreign call metadata
function _storeForeignCallMetadata(uint256 _policyId, uint256 _foreignCallIndex, string calldata _foreignCallName)
    private;
Parameters
NameTypeDescription
_policyIduint256The policy ID the foreign call is associated with.
_foreignCallIndexuint256The index of the foreign call.
_foreignCallNamestringThe name of the foreign call.

_isForeignCallPermissioned

Checks if the foreign call is permissioned and if the caller is authorized.
function _isForeignCallPermissioned(address _foriegnCallAddress, bytes4 _functionSignature) internal view;
Parameters
NameTypeDescription
_foriegnCallAddressaddressThe address of the foreign call contract.
_functionSignaturebytes4The 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
NameTypeDescription
foriegnCallAddressaddressThe address of the foreign call contract.
policyAdminsToAddaddressThe address of the admin to add to the permission list.
selectorbytes4The 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
NameTypeDescription
foriegnCallAddressaddressThe address of the foreign call contract.
selectorbytes4The function selector of the foreign call to update the permission list for.
policyAdminsToAddaddress[]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
NameTypeDescription
foriegnCallAddressaddressThe address of the foreign call contract.
selectorbytes4The function selector of the foreign call to retrieve the permission list for.
Returns
NameTypeDescription
<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
NameTypeDescription
foriegnCallAddressaddressThe address of the foreign call contract.
selectorbytes4The 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
NameTypeDescription
_foriegnCallAddressaddressThe address of the foreign call contract.
_selectorbytes4The function selector of the foreign call to remove the address from.
policyAdminToRemoveaddressThe 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
NameTypeDescription
_foriegnCallAddressaddressThe address of the foreign call contract.
_selectorbytes4The function selector of the foreign call to remove permissions for.

getAllPermissionedFCs

Retrieves all permissioned foreign calls.
function getAllPermissionedFCs() external pure returns (PermissionedForeignCallStorage memory);
Returns
NameTypeDescription
<none>PermissionedForeignCallStorageThe PermissionedForeignCallStorage structure containing all permissioned foreign calls.

_notCemented

Checks that a policy is not cemented.
function _notCemented(uint256 _policyId) internal view;
Parameters
NameTypeDescription
_policyIduint256The ID of the policy.

_policyAdminOnly

Checks that the caller is a policy admin
function _policyAdminOnly(uint256 _policyId, address _address) internal;
Parameters
NameTypeDescription
_policyIduint256The ID of the policy.
_addressaddressThe 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
NameTypeDescription
_foreignCallAddraddressThe ID of the foreign call.
_addressaddressThe address to check for policy admin status.
_functionSelectorbytes4The function selector to check for policy admin status.

_validateForeignCall

Validates a foreign call.
function _validateForeignCall(ForeignCall memory _foreignCall) internal pure;
Parameters
NameTypeDescription
_foreignCallForeignCallThe foreign call to validate.

_validateParamType

Validates a paramType.
function _validateParamType(ParamTypes paramType) internal pure;
Parameters
NameTypeDescription
paramTypeParamTypesThe paramType to validate.