GovernanceConfigFacet
Inherits: IFactoryConfig
Handles governance type permissions and factory configuration through tiered interface
Standalone diamond facet for configuring governance factory settings
Access control is handled by AccessControlFacet
Functions
initializeGovernanceFactory
Initialize governance factory with tiered configuration
function initializeGovernanceFactory(address subscriptionManager) external;
Parameters
subscriptionManager
address
Address of the subscription manager
_setupDefaultGovernanceTiers
Set up default governance tier configuration
function _setupDefaultGovernanceTiers() internal;
canCreateGovernanceType
Check if a user can create a specific governance type
function canCreateGovernanceType(address user, string calldata governanceType)
external
view
returns (bool canCreate, string memory reason);
Parameters
user
address
The user address
governanceType
string
The governance type to check
Returns
canCreate
bool
Whether the user can create this governance type
reason
string
Reason if cannot create
wouldExceedGovernanceLimit
Check if a user would exceed their governance creation limit
function wouldExceedGovernanceLimit(address user, uint256 currentGovernanceCount)
external
view
returns (bool wouldExceed, uint256 currentLimit);
Parameters
user
address
The user address
currentGovernanceCount
uint256
Current number of governances owned by user
Returns
wouldExceed
bool
Whether creating a governance would exceed the limit
currentLimit
uint256
The user's current governance limit
getGovernanceCreationSummary
Get governance creation summary for a user
function getGovernanceCreationSummary(address user)
external
view
returns (uint8 tier, uint256 maxGovernances, string[] memory availableGovernanceTypes, bool hasSubscription);
Parameters
user
address
The user address
Returns
tier
uint8
User's subscription tier
maxGovernances
uint256
Maximum governances allowed for this tier
availableGovernanceTypes
string[]
Governance types available for this tier
hasSubscription
bool
Whether user has active subscription
setFeeRecipient
Set the fee recipient address (admin only)
function setFeeRecipient(address feeRecipient) external;
Parameters
feeRecipient
address
New fee recipient address
getFeeRecipient
Get the current fee recipient address
function getFeeRecipient() external view returns (address feeRecipient);
Returns
feeRecipient
address
Current fee recipient address
emergencyWithdrawFees
Emergency withdrawal of any fees stuck in the factory (admin only)
function emergencyWithdrawFees(address payable recipient) external;
Parameters
recipient
address payable
Address to receive the withdrawn funds
initializeConfig
function initializeConfig() external override;
isConfigInitialized
function isConfigInitialized() external view override returns (bool);
setFeatureEnabled
function setFeatureEnabled(string calldata feature, bool enabled) external override;
isFeatureEnabled
function isFeatureEnabled(string calldata feature) external view override returns (bool);
getEnabledFeatures
function getEnabledFeatures() external view override returns (string[] memory);
setLimit
function setLimit(string calldata limitType, uint256 value) external override;
getLimit
function getLimit(string calldata limitType) external view override returns (uint256);
setPermission
function setPermission(string calldata permissionType, bool granted) external override;
hasPermission
function hasPermission(string calldata permissionType) external view override returns (bool);
getFactoryConfiguration
function getFactoryConfiguration()
external
view
override
returns (
string[] memory features,
string[] memory limits,
uint256[] memory limitValues,
string[] memory permissions,
bool[] memory permissionStates
);
getConfigurationStats
function getConfigurationStats()
external
view
override
returns (uint256 totalFeatures, uint256 enabledFeatures, uint256 totalLimits, uint256 totalPermissions);
setSubscriptionManager
function setSubscriptionManager(address subscriptionManager) external override;
getSubscriptionManager
function getSubscriptionManager() external view override returns (address);
getUserTier
function getUserTier(address user) external view override returns (uint8);
hasActiveSubscription
function hasActiveSubscription(address user) external view override returns (bool);
_getUserTier
function _getUserTier(address user) internal view returns (uint8);
_hasActiveSubscription
function _hasActiveSubscription(address user) internal view returns (bool);
setTieredFeature
function setTieredFeature(string calldata feature, uint8 minimumTier, bool enabled) external override;
isTieredFeatureAvailable
function isTieredFeatureAvailable(string calldata feature, uint8 tier) external view override returns (bool);
isFeatureAvailableForUser
function isFeatureAvailableForUser(string calldata feature, address user) external view override returns (bool);
getAvailableFeaturesForTier
function getAvailableFeaturesForTier(uint8 tier) external view override returns (string[] memory);
getTieredFeatureInfo
function getTieredFeatureInfo(string calldata feature)
external
view
override
returns (uint8 minimumTier, bool enabled);
setTieredLimit
function setTieredLimit(string calldata limitType, uint8 tier, uint256 value) external override;
getTieredLimit
function getTieredLimit(string calldata limitType, uint8 tier) external view override returns (uint256);
getLimitForUser
function getLimitForUser(string calldata limitType, address user) external view override returns (uint256);
wouldExceedLimit
function wouldExceedLimit(string calldata limitType, address user, uint256 currentUsage, uint256 additionalUsage)
external
view
override
returns (bool wouldExceed, uint256 currentLimit);
setTieredPermission
function setTieredPermission(string calldata permissionType, uint8 tier, bool granted) external override;
isTieredPermissionGranted
function isTieredPermissionGranted(string calldata permissionType, uint8 tier) external view override returns (bool);
isPermissionGrantedForUser
function isPermissionGrantedForUser(string calldata permissionType, address user)
external
view
override
returns (bool);
setTieredFeaturesBatch
function setTieredFeaturesBatch(string[] calldata features, uint8[] calldata minimumTiers, bool[] calldata enabled)
external
override;
setTieredLimitsBatch
function setTieredLimitsBatch(string[] calldata limitTypes, uint8 tier, uint256[] calldata values) external override;
getUserConfigSummary
function getUserConfigSummary(address user)
external
view
override
returns (uint8 tier, bool hasSubscription, string[] memory availableFeatures, uint256[] memory limits);
getTierInfo
function getTierInfo(uint8 tier)
external
pure
override
returns (string memory name, uint256 monthlyFeeUSD, bool isActive);
getAllTiers
function getAllTiers()
external
pure
override
returns (uint8[] memory tiers, string[] memory names, uint256[] memory fees);
_getAllGovernanceTypes
Get all governance types supported by this factory
function _getAllGovernanceTypes() internal pure returns (string[] memory governanceTypes);
Returns
governanceTypes
string[]
Array of governance type names
_requireAdmin
function _requireAdmin() internal view;
_getAuthority
Get the authority (access manager) for this facet
function _getAuthority() internal view returns (address);
Returns
<none>
address
The address of the access manager
Events
GovernanceCreationValidated
event GovernanceCreationValidated(address indexed user, string governanceType, uint8 userTier);
GovernanceLimitChecked
event GovernanceLimitChecked(address indexed user, uint256 currentCount, uint256 limit, uint8 tier);
FeeRecipientUpdated
event FeeRecipientUpdated(address indexed feeRecipient);
EmergencyFeesWithdrawn
event EmergencyFeesWithdrawn(address indexed recipient, uint256 amount);
Last updated
Was this helpful?