RulesEngineComponentFacet
Inherits: [FacetCommonImports](/v2(/v2/reference/engine/facets/FacetCommonImports.sol/abstract.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 subcomponents. It provides functionality for managing foreign calls, trackers, function signatures, and policy subscriptions. 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.
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. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The index of the created foreign call. |
_storeForeignCall
Stores a foreign call in the contract’s storage.
Ensures the foreign call is properly set before storing it.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The policy ID the foreign call is associated with. |
_foreignCall | ForeignCall | The foreign call to store. |
deleteForeignCall
Deletes a foreign call from the contract’s storage.
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. |
updateForeignCall
Updates a foreign call in the contract’s storage.
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. |
getForeignCall
Retrieves a foreign call from the contract’s storage.
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 |
---|---|---|
fc | ForeignCall | The foreign call structure. |
getAllForeignCalls
Retrieve Foreign Call Set from storage
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | the policy Id of the foreign call to retrieve |
Returns
Name | Type | Description |
---|---|---|
fc | ForeignCall[] | the foreign call set structure |
createTracker
Adds a tracker to the tracker storage mapping.
Creates a new tracker and associates it with the specified policy ID.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The policy ID the tracker is associated with. |
_tracker | Trackers | The tracker to add. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | trackerIndex The index of the created tracker. |
updateTracker
Updates an existing tracker in the tracker storage mapping.
Modifies the tracker associated with the specified policy ID and tracker index.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The policy ID the tracker is associated with. |
_trackerIndex | uint256 | The index of the tracker to update. |
_tracker | Trackers | The updated tracker data. |
_storeTracker
Stores a tracker in the tracker storage mapping.
Sets the tracker data and marks it as active.
Parameters
Name | Type | Description |
---|---|---|
_data | TrackerS | The tracker storage structure. |
_policyId | uint256 | The policy ID the tracker is associated with. |
_trackerIndex | uint256 | The index of the tracker to store. |
_tracker | Trackers | The tracker data to store. |
getTracker
Retrieves a tracker from the tracker storage mapping.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The policy ID the tracker is associated with. |
_index | uint256 | The index of the tracker to retrieve. |
Returns
Name | Type | Description |
---|---|---|
tracker | Trackers | The tracker data. |
getAllTrackers
Retrieves all trackers associated with a specific policy ID.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The policy ID the trackers are associated with. |
Returns
Name | Type | Description |
---|---|---|
<none> | Trackers[] | trackers An array of tracker data. |
deleteTracker
Deletes a tracker from the tracker storage mapping.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The policy ID the tracker is associated with. |
_trackerIndex | uint256 | The index of the tracker to delete. |
createFunctionSignature
Creates a new function signature and stores it in the function signature storage mapping.
Associates the function signature with the specified policy ID and parameter types.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The policy ID the function signature is associated with. |
_functionSignature | bytes4 | The function signature to create. |
_pTypes | PT[] | The parameter types for the function signature. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | functionId The index of the created function signature. |
updateFunctionSignature
Updates an existing function signature by appending new parameter types.
Ensures that the new parameter types are compatible with the existing ones.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The policy ID the function signature is associated with. |
_functionSignatureId | uint256 | The ID of the function signature to update. |
_functionSignature | bytes4 | The function signature to update. |
_pTypes | PT[] | The new parameter types to append. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | functionId The updated function signature ID. |
deleteFunctionSignature
Deletes a function signature from storage.
Removes the function signature and its associated rules and mappings.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The policy ID the function signature is associated with. |
_functionSignatureId | uint256 | The ID of the function signature to delete. |
getFunctionSignature
Retrieves a function signature from storage.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The policy ID the function signature is associated with. |
_functionSignatureId | uint256 | The ID of the function signature to retrieve. |
Returns
Name | Type | Description |
---|---|---|
<none> | FunctionSignatureStorageSet | functionSignatureSet The function signature data. |
getAllFunctionSignatures
Retrieves all function signatures associated with a specific policy ID.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The policy ID the function signatures are associated with. |
Returns
Name | Type | Description |
---|---|---|
<none> | FunctionSignatureStorageSet[] | functionSignatureStorageSets An array of function signature data. |
addClosedPolicySubscriber
Adds an address to the subscriber list of a specified policy.
Only callable by a policy admin. The policy must not be cemented.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The ID of the policy. |
_subscriber | address | The address to add to the policy subscription. |
isClosedPolicySubscriber
Checks if an address is a subscriber of the specified policy.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The ID of the policy. |
_subscriber | address | The address to check for policy subscription. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool True if the address is a subscriber, false otherwise. |
removeClosedPolicySubscriber
Removes an address from the subscriber list of a specified policy.
Only callable by a policy admin. The policy must not be cemented.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The ID of the policy. |
_subscriber | address | The address to remove from the policy subscription. |
isCemented
Checks if a policy is cemented.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The ID of the policy. |
Returns
Name | Type | Description |
---|---|---|
_cemented | bool | True if the policy is cemented, false otherwise. |
notCemented
Modifier to ensure that cemented policies cannot be modified.
Parameters
Name | Type | Description |
---|---|---|
_policyId | uint256 | The ID of the policy. |