State Variables
version
Functions
updatePolicy
Updates a policy in storage. Updates the policy type, calling functions, and associated rules.Name | Type | Description |
---|---|---|
policyId | uint256 | The ID of the policy to update. |
callingFunctions | bytes4[] | The function signatures of the calling functions in the policy. |
ruleIds | uint256[][] | A two-dimensional array of rule IDs associated with the policy. |
policyType | PolicyType | The type of the policy (CLOSED_POLICY or OPEN_POLICY). |
policyName | string | |
policyDescription | string |
Name | Type | Description |
---|---|---|
<none> | uint256 | policyId The updated policy ID. |
closePolicy
Closes a policy by changing its type to CLOSED_POLICY. This function ensures that only policy admins can close a policy and that the policy is not cemented.Name | Type | Description |
---|---|---|
policyId | uint256 | The ID of the policy to close. |
openPolicy
Opens a policy by changing its type to OPEN_POLICY. This function ensures that only policy admins can open a policy and that the policy is not cemented.Name | Type | Description |
---|---|---|
policyId | uint256 | The ID of the policy to open. |
cementPolicy
Marks a policy as cemented, preventing further modifications.Name | Type | Description |
---|---|---|
policyId | uint256 | The ID of the policy to cement. |
disablePolicy
Marks a policy as disabled. A policy will not be checked against if it is in a disabled state.Name | Type | Description |
---|---|---|
policyId | uint256 | The ID of the policy to disable. |
deletePolicy
Deletes a policy from storage. Removes the policy and all associated rules, trackers, and foreign calls. Ensures the policy is not cemented.Name | Type | Description |
---|---|---|
policyId | uint256 | The ID of the policy to delete. |
applyPolicy
Applies policies to a specified contract. Ensures that only calling contract admins can apply policies and validates policy types.Name | Type | Description |
---|---|---|
contractAddress | address | The address of the contract to apply policies to. |
policyIds | uint256[] | The IDs of the policies to apply. |
unapplyPolicy
Unapplies policies from a specified contract. Ensures that only calling contract admins can unapply policies. Removes associations between the contract and the specified policies.Name | Type | Description |
---|---|---|
_contractAddress | address | The address of the contract from which policies will be unapplied. |
_policyIds | uint256[] | The IDs of the policies to unapply. |
createPolicy
Creates a new policy and assigns a policy admin. Generates a policy ID and initializes the policy with the specified type.Name | Type | Description |
---|---|---|
policyType | PolicyType | The type of the policy (CLOSED_POLICY or OPEN_POLICY). |
policyName | string | The name of the policy. |
policyDescription | string | A description of the policy. |
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 The generated policy ID. |
_storePolicyMetadata
Internal function to store policy metadata. This function is a placeholder for storing policy metadata such as name and description.Name | Type | Description |
---|---|---|
_policyId | uint256 | The ID of the policy. |
_policyName | string | The name of the policy. |
_policyDescription | string | A description of the policy. |
getPolicyMetadata
Retrieves the metadata of a policy.Name | Type | Description |
---|---|---|
_policyId | uint256 | The ID of the policy to retrieve metadata for. |
Name | Type | Description |
---|---|---|
<none> | PolicyMetadata | PolicyMetadata The metadata of the policy. |
getAppliedPolicyIds
Retrieves the IDs of policies applied to a specific contract.Name | Type | Description |
---|---|---|
contractAddress | address | The address of the contract. |
Name | Type | Description |
---|---|---|
<none> | uint256[] | uint256[] An array of applied policy IDs. |
isClosedPolicy
Checks if a policy is closed.Name | Type | Description |
---|---|---|
policyId | uint256 | The ID of the policy to check. |
Name | Type | Description |
---|---|---|
<none> | bool | bool True if the policy is closed, false otherwise. |
isDisabledPolicy
Checks if a policy is disabled.Name | Type | Description |
---|---|---|
policyId | uint256 | The ID of the policy to check. |
Name | Type | Description |
---|---|---|
<none> | bool | bool True if the policy is disabled, false otherwise. |
getPolicy
Retrieves a policy from storage. SincePolicy
contains nested mappings, the data is broken into arrays for external return.
Name | Type | Description |
---|---|---|
policyId | uint256 | The ID of the policy. |
Name | Type | Description |
---|---|---|
callingFunctions | bytes4[] | The calling functions within the policy. |
ruleIds | uint256[][] | The rule IDs corresponding to each calling function. |
_storePolicyData
Internal helper function for creating and updating policy data. This function processes and stores policy data, including calling functions, rules, and policy type. The parameters are complex because nested structs are not allowed for externally facing functions.Name | Type | Description |
---|---|---|
_policyId | uint256 | The ID of the policy. |
_callingFunctions | bytes4[] | All callingFunctions in the policy. |
_ruleIds | uint256[][] | A two-dimensional array of rule IDs. The first level represents calling functions, and the second level contains rule IDs for each calling function. |
_policyType | PolicyType | The type of the policy (OPEN or CLOSED). |
_policyName | string | |
_policyDescription | string |
Name | Type | Description |
---|---|---|
<none> | uint256 | policyId The updated policy ID. |
_processCallingFunctionsWithRules
Internal helper function to process calling functions with associated rules. This function validates calling functions, maps them to their IDs, and processes rules for each calling function.Name | Type | Description |
---|---|---|
_policyId | uint256 | The ID of the policy. |
_callingFunctions | bytes4[] | The function signatures of the calling functions in the policy. |
_ruleIds | uint256[][] | A two-dimensional array of rule IDs associated with the policy. |
data | Policy | The policy data storage structure. |
_processCallingFunctionsWithoutRules
Internal helper function to process calling functions without associated rules. This function validates calling functions and maps them to their IDs.Name | Type | Description |
---|---|---|
_policyId | uint256 | The ID of the policy. |
_callingFunctions | bytes4[] | The function signatures of the calling functions in the policy. |
data | Policy | The policy data storage structure. |
_processRulesForCallingFunction
Internal helper function to process rules for a calling function. This function validates placeholders in the rule and maps rules to the calling function.Name | Type | Description |
---|---|---|
_policyId | uint256 | The ID of the policy. |
_callingFunction | bytes4 | The function signature of the calling function. |
_ruleIds | uint256[] | The IDs of the rules associated with the calling function. |
data | Policy | The policy data storage structure. |
_validatePlaceholders
Internal helper function to validate placeholders in a policy. This function checks if the placeholders are set correctly and if foreign calls or trackers are valid.Name | Type | Description |
---|---|---|
_policyId | uint256 | The ID of the policy. |
placeholders | Placeholder[] | The array of placeholders to validate. |
_validateNoIdenticalFunctionSigs
_processPolicyTypeChange
Internal helper function to handle data cleanup during policy type changes. This function removes applied contract associations when transitioning to a CLOSED policy.Name | Type | Description |
---|---|---|
_policyId | uint256 | The ID of the policy. |
_policyType | PolicyType | The new type of the policy (OPEN or CLOSED). |
isCementedPolicy
Checks if a policy is cemented.Name | Type | Description |
---|---|---|
_policyId | uint256 | The ID of the policy to check. |
Name | Type | Description |
---|---|---|
<none> | bool | bool True if the policy is cemented, false otherwise. |
_policyAdminOnly
Checks that the caller is a policy adminName | Type | Description |
---|---|---|
_policyId | uint256 | The ID of the policy. |
_address | address | The address to check for policy admin status. |