IFactoryConfig
Interface for factory configuration with subscription-based access control
Provides tier-based functionality for subscription management
Functions
setSubscriptionManager
Set the subscription manager contract address
function setSubscriptionManager(address subscriptionManager) external;
Parameters
subscriptionManager
address
Address of the subscription manager
getSubscriptionManager
Get the subscription manager contract address
function getSubscriptionManager() external view returns (address);
Returns
<none>
address
Address of the subscription manager
getUserTier
Get the subscription tier for a user
function getUserTier(address user) external view returns (uint8 tier);
Parameters
user
address
The user address
Returns
tier
uint8
The user's current subscription tier (0-255)
hasActiveSubscription
Check if a user has an active subscription
function hasActiveSubscription(address user) external view returns (bool);
Parameters
user
address
The user address
Returns
<none>
bool
True if user has active subscription
setTieredFeature
Set a tiered feature with minimum required tier
function setTieredFeature(string calldata feature, uint8 minimumTier, bool enabled) external;
Parameters
feature
string
The feature identifier
minimumTier
uint8
Minimum tier required to access this feature
enabled
bool
Whether the feature is globally enabled
isTieredFeatureAvailable
Check if a feature is available for a specific tier
function isTieredFeatureAvailable(string calldata feature, uint8 tier) external view returns (bool);
Parameters
feature
string
The feature identifier
tier
uint8
The tier to check
Returns
<none>
bool
True if feature is available for the tier
isFeatureAvailableForUser
Check if a feature is available for a user based on their subscription
function isFeatureAvailableForUser(string calldata feature, address user) external view returns (bool);
Parameters
feature
string
The feature identifier
user
address
The user address
Returns
<none>
bool
True if feature is available for the user
getAvailableFeaturesForTier
Get all features available for a specific tier
function getAvailableFeaturesForTier(uint8 tier) external view returns (string[] memory);
Parameters
tier
uint8
The tier to query
Returns
<none>
string[]
Array of available feature names
getTieredFeatureInfo
Get the minimum tier required for a feature
function getTieredFeatureInfo(string calldata feature) external view returns (uint8 minimumTier, bool enabled);
Parameters
feature
string
The feature identifier
Returns
minimumTier
uint8
The minimum tier required
enabled
bool
Whether the feature is globally enabled
setTieredLimit
Set a limit for a specific tier
function setTieredLimit(string calldata limitType, uint8 tier, uint256 value) external;
Parameters
limitType
string
The limit identifier
tier
uint8
The tier to set the limit for
value
uint256
The limit value (0 = unlimited)
getTieredLimit
Get the limit value for a specific tier
function getTieredLimit(string calldata limitType, uint8 tier) external view returns (uint256);
Parameters
limitType
string
The limit identifier
tier
uint8
The tier to query
Returns
<none>
uint256
The limit value (0 = unlimited)
getLimitForUser
Get the limit value for a user based on their subscription
function getLimitForUser(string calldata limitType, address user) external view returns (uint256);
Parameters
limitType
string
The limit identifier
user
address
The user address
Returns
<none>
uint256
The limit value for the user
wouldExceedLimit
Check if a user would exceed their tier limit
function wouldExceedLimit(string calldata limitType, address user, uint256 currentUsage, uint256 additionalUsage)
external
view
returns (bool wouldExceed, uint256 currentLimit);
Parameters
limitType
string
The limit identifier
user
address
The user address
currentUsage
uint256
Current usage amount
additionalUsage
uint256
Additional usage to check
Returns
wouldExceed
bool
True if the additional usage would exceed the limit
currentLimit
uint256
The user's current limit
setTieredPermission
Set a permission for a specific tier
function setTieredPermission(string calldata permissionType, uint8 tier, bool granted) external;
Parameters
permissionType
string
The permission identifier
tier
uint8
The tier to set the permission for
granted
bool
Whether the permission is granted
isTieredPermissionGranted
Check if a permission is granted for a specific tier
function isTieredPermissionGranted(string calldata permissionType, uint8 tier) external view returns (bool);
Parameters
permissionType
string
The permission identifier
tier
uint8
The tier to check
Returns
<none>
bool
True if permission is granted for the tier
isPermissionGrantedForUser
Check if a permission is granted for a user based on their subscription
function isPermissionGrantedForUser(string calldata permissionType, address user) external view returns (bool);
Parameters
permissionType
string
The permission identifier
user
address
The user address
Returns
<none>
bool
True if permission is granted for the user
setTieredFeaturesBatch
Set multiple tiered features at once
function setTieredFeaturesBatch(string[] calldata features, uint8[] calldata minimumTiers, bool[] calldata enabled)
external;
Parameters
features
string[]
Array of feature identifiers
minimumTiers
uint8[]
Array of minimum tiers for each feature
enabled
bool[]
Array of enabled flags for each feature
setTieredLimitsBatch
Set multiple tiered limits for a specific tier
function setTieredLimitsBatch(string[] calldata limitTypes, uint8 tier, uint256[] calldata values) external;
Parameters
limitTypes
string[]
Array of limit identifiers
tier
uint8
The tier to set limits for
values
uint256[]
Array of limit values
getUserConfigSummary
Get configuration summary for a user
function getUserConfigSummary(address user)
external
view
returns (uint8 tier, bool hasSubscription, string[] memory availableFeatures, uint256[] memory limits);
Parameters
user
address
The user address
Returns
tier
uint8
User's current tier
hasSubscription
bool
Whether user has active subscription
availableFeatures
string[]
Features available to the user
limits
uint256[]
Key limits for the user
getTierInfo
Get tier information from subscription manager
function getTierInfo(uint8 tier) external view returns (string memory name, uint256 monthlyFeeUSD, bool isActive);
Parameters
tier
uint8
The tier to query
Returns
name
string
Tier name
monthlyFeeUSD
uint256
Monthly fee in USD (6 decimals)
isActive
bool
Whether the tier is active
getAllTiers
Get all available tiers
function getAllTiers() external view returns (uint8[] memory tiers, string[] memory names, uint256[] memory fees);
Returns
tiers
uint8[]
Array of tier numbers
names
string[]
Array of tier names
fees
uint256[]
Array of monthly fees
initializeConfig
Initialize the factory configuration
function initializeConfig() external;
isConfigInitialized
Check if configuration is initialized
function isConfigInitialized() external view returns (bool);
Returns
<none>
bool
True if initialized
setFeatureEnabled
Enable or disable a factory feature
function setFeatureEnabled(string calldata feature, bool enabled) external;
Parameters
feature
string
The feature identifier
enabled
bool
Whether the feature should be enabled
isFeatureEnabled
Check if a feature is enabled
function isFeatureEnabled(string calldata feature) external view returns (bool);
Parameters
feature
string
The feature identifier
Returns
<none>
bool
True if feature is enabled
getEnabledFeatures
Get all enabled features (convenience function)
function getEnabledFeatures() external view returns (string[] memory);
Returns
<none>
string[]
Array of enabled feature names
setLimit
Set a numeric limit for factory operations
function setLimit(string calldata limitType, uint256 value) external;
Parameters
limitType
string
The limit identifier
value
uint256
The limit value
getLimit
Get a numeric limit value
function getLimit(string calldata limitType) external view returns (uint256);
Parameters
limitType
string
The limit identifier
Returns
<none>
uint256
The limit value
setPermission
Set permission for a specific operation type
function setPermission(string calldata permissionType, bool granted) external;
Parameters
permissionType
string
The permission identifier
granted
bool
Whether the permission is granted
hasPermission
Check if a permission is granted
function hasPermission(string calldata permissionType) external view returns (bool);
Parameters
permissionType
string
The permission identifier
Returns
<none>
bool
True if permission is granted
getFactoryConfiguration
Get comprehensive factory configuration
function getFactoryConfiguration()
external
view
returns (
string[] memory features,
string[] memory limits,
uint256[] memory limitValues,
string[] memory permissions,
bool[] memory permissionStates
);
Returns
features
string[]
Array of enabled features
limits
string[]
Array of limit types
limitValues
uint256[]
Array of limit values
permissions
string[]
Array of permission types
permissionStates
bool[]
Array of permission states
getConfigurationStats
Get factory configuration statistics
function getConfigurationStats()
external
view
returns (uint256 totalFeatures, uint256 enabledFeatures, uint256 totalLimits, uint256 totalPermissions);
Returns
totalFeatures
uint256
Total number of features
enabledFeatures
uint256
Number of enabled features
totalLimits
uint256
Total number of limits
totalPermissions
uint256
Total number of permissions
Events
SubscriptionManagerUpdated
event SubscriptionManagerUpdated(address indexed oldManager, address indexed newManager);
TieredFeatureSet
event TieredFeatureSet(string indexed feature, uint8 minimumTier, bool enabled);
TieredLimitSet
event TieredLimitSet(string indexed limitType, uint8 tier, uint256 value);
TieredPermissionSet
event TieredPermissionSet(string indexed permissionType, uint8 tier, bool granted);
TierUpgradeRequired
event TierUpgradeRequired(address indexed user, uint8 currentTier, uint8 requiredTier, string reason);
ConfigurationInitialized
event ConfigurationInitialized(address indexed factory);
FeatureToggled
event FeatureToggled(string indexed feature, bool enabled);
LimitUpdated
event LimitUpdated(string indexed limitType, uint256 oldValue, uint256 newValue);
PermissionUpdated
event PermissionUpdated(string indexed permissionType, bool granted);
Errors
TierUpgradeRequiredError
error TierUpgradeRequiredError(string message, uint8 requiredTier, uint8 currentTier);
InvalidTier
error InvalidTier(uint8 tier);
TieredModeNotEnabled
error TieredModeNotEnabled();
SubscriptionManagerNotSet
error SubscriptionManagerNotSet();
FeatureNotAvailableForTier
error FeatureNotAvailableForTier(string feature, uint8 tier);
LimitExceededForTier
error LimitExceededForTier(string limitType, uint256 current, uint256 max, uint8 tier);
Last updated
Was this helpful?