Git Source

Author: @mpetersoCode55, @ShaneDuncan602, @TJ-Everett, @VoR0220

This library is a critical component of the Rules Engine, enabling modular and efficient storage management.

This library provides functions to access and manage storage positions for various components of the Rules Engine. It defines fixed storage slots for initialized flags, foreign calls, trackers, calling functions, rules, policies, and policy associations. These storage slots are used to ensure consistent and conflict-free storage management across the diamond proxy pattern.

State Variables

DIAMOND_CUT_STORAGE_ENGINE_POS

bytes32 constant DIAMOND_CUT_STORAGE_ENGINE_POS = bytes32(uint256(keccak256("diamond-cut.storage-engine")) - 1);

INITIALIZED_POSITION

bytes32 constant INITIALIZED_POSITION = bytes32(uint256(keccak256("initialized-position")) - 1);

FOREIGN_CALL_POSITION

bytes32 constant FOREIGN_CALL_POSITION = bytes32(uint256(keccak256("foreign-call-position")) - 1);

TRACKER_POSITION

bytes32 constant TRACKER_POSITION = bytes32(uint256(keccak256("tracker-position")) - 1);

CALLING_FUNCTION_POSITION

bytes32 constant CALLING_FUNCTION_POSITION = bytes32(uint256(keccak256("calling-function-position")) - 1);

RULE_POSITION

bytes32 constant RULE_POSITION = bytes32(uint256(keccak256("rule-position")) - 1);

POLICY_POSITION

bytes32 constant POLICY_POSITION = bytes32(uint256(keccak256("policy-position")) - 1);

POLICY_ASSOCIATION_POSITION

bytes32 constant POLICY_ASSOCIATION_POSITION = bytes32(uint256(keccak256("policy-association-position")) - 1);

FOREIGN_CALL_METADATA_POSITION

bytes32 constant FOREIGN_CALL_METADATA_POSITION = bytes32(uint256(keccak256("foreign-call-metadata-position")) - 1);

CALLING_FUNCTION_METADATA_POSITION

bytes32 constant CALLING_FUNCTION_METADATA_POSITION =
    bytes32(uint256(keccak256("calling-function-metadata-position")) - 1);

TRACKER_METADATA_POSITION

bytes32 constant TRACKER_METADATA_POSITION = bytes32(uint256(keccak256("tracker-metadata-position")) - 1);

Functions

_initializedStorage

Retrieves the storage for the initialized flag.

Uses a fixed storage slot to avoid conflicts with other contracts.

function _initializedStorage() internal pure returns (InitializedStorage storage _ds);

Returns

NameTypeDescription
_dsInitializedStorageThe storage structure for the initialized flag.

_getForeignCallStorage

Retrieves the storage for foreign calls.

Uses a fixed storage slot to avoid conflicts with other contracts.

function _getForeignCallStorage() internal pure returns (ForeignCallStorage storage _ds);

Returns

NameTypeDescription
_dsForeignCallStorageThe storage structure for the foreign call map.

_getForeignCallMetadataStorage

Retrieves the storage for foreign call metadata.

Uses a fixed storage slot to avoid conflicts with other contracts.

function _getForeignCallMetadataStorage() internal pure returns (ForeignCallMetadataStruct storage _ds);

Returns

NameTypeDescription
_dsForeignCallMetadataStructThe storage structure for the foreign call metadata map.

_getTrackerStorage

Retrieves the storage for trackers.

Uses a fixed storage slot to avoid conflicts with other contracts.

function _getTrackerStorage() internal pure returns (TrackerStorage storage _ds);

Returns

NameTypeDescription
_dsTrackerStorageThe storage structure for the tracker map.

_getTrackerMetadataStorage

Retrieves the storage for tracker metadata.

Uses a fixed storage slot to avoid conflicts with other contracts.

function _getTrackerMetadataStorage() internal pure returns (TrackerMetadataStruct storage _ds);

Returns

NameTypeDescription
_dsTrackerMetadataStructThe storage structure for the tracker metadata map.

_getCallingFunctionStorage

Retrieves the storage for calling functions.

Uses a fixed storage slot to avoid conflicts with other contracts.

function _getCallingFunctionStorage() internal pure returns (CallingFunctionStruct storage _ds);

Returns

NameTypeDescription
_dsCallingFunctionStructThe storage structure for the calling function map.

_getCallingFunctioneMetadataStorage

Retrieves the storage for calling function metadata.

Uses a fixed storage slot to avoid conflicts with other contracts.

function _getCallingFunctioneMetadataStorage() internal pure returns (CallingFunctionMetadataStruct storage _ds);

Returns

NameTypeDescription
_dsCallingFunctionMetadataStructThe storage structure for the calling function metadata map.

_getRuleStorage

Retrieves the storage for rules.

Uses a fixed storage slot to avoid conflicts with other contracts.

function _getRuleStorage() internal pure returns (RuleStorage storage _ds);

Returns

NameTypeDescription
_dsRuleStorageThe storage structure for the rule map.

_getPolicyStorage

Retrieves the storage for policies.

Uses a fixed storage slot to avoid conflicts with other contracts.

function _getPolicyStorage() internal pure returns (PolicyStorage storage _ds);

Returns

NameTypeDescription
_dsPolicyStorageThe storage structure for the policy map.

_getPolicyAssociationStorage

Retrieves the storage for policy associations.

Uses a fixed storage slot to avoid conflicts with other contracts.

function _getPolicyAssociationStorage() internal pure returns (PolicyAssociationStorage storage _ds);

Returns

NameTypeDescription
_dsPolicyAssociationStorageThe storage structure for the policy association map.