Defines feature flags for Rooch frameworks. Those are used in implementations of features in the moveos-stdlib, rooch-framework and other frameworks.
============================================================================================ Feature Flag Definitions
Each feature flag should come with documentation which justifies the need of the flag. Introduction of a new feature flag requires approval of framework owners. Be frugal when introducing new feature flags, as too many can make it hard to understand the code.
Note that removing a feature flag still requires the function which tests for the feature to stay around for compatibility reasons, as it is a public function. However, once the feature flag is disabled, those functions can constantly return true.
- Resource
FeatureStore
- Constants
- Function
init_feature_store
- Function
change_feature_flags
- Function
is_enabled
- Function
get_localnet_feature
- Function
localnet_enabled
- Function
ensure_localnet_enabled
- Function
get_devnet_feature
- Function
devnet_enabled
- Function
ensure_devnet_enabled
- Function
get_testnet_feature
- Function
testnet_enabled
- Function
ensure_testnet_enabled
- Function
get_module_template_feature
- Function
module_template_enabled
- Function
ensure_module_template_enabled
- Function
get_module_publishing_allowlist_feature
- Function
module_publishing_allowlist_enabled
- Function
ensure_module_publishing_allowlist_enabled
- Function
get_wasm_feature
- Function
wasm_enabled
- Function
ensure_wasm_enabled
- Function
get_value_size_gas_feature
- Function
value_size_gas_enabled
- Function
ensure_value_size_gas_enabled
- Function
get_all_features
use 0x2::core_addresses;
use 0x2::object;
The enabled features, represented by a bitset stored on chain.
struct FeatureStore has key
This feature will only be enabled on devnet.
const DEVNET: u64 = 2;
const EAPI_DISABLED: u64 = 2;
const EINVALID_FEATURE: u64 = 1;
This feature will only be enabled on localnet.
const LOCALNET: u64 = 1;
Whether enable the allowlist feature for publishing modules.
const MODULE_PUBLISHING_ALLOWLIST: u64 = 5;
Whether allowing replacing module's address, module identifier, struct identifier and constant address. This feature is used for creating a new module through a module template bytes, thus developers can used to publish new modules in Move.
const MODULE_TEMPLATE: u64 = 4;
This feature will only be enabled on testnet, devnet or localnet.
const TESTNET: u64 = 3;
Whether to enable size-based gas fee for adding field values
const VALUE_SIZE_GAS: u64 = 7;
Whether enable the wasm feature.
const WASM: u64 = 6;
public(friend) fun init_feature_store()
Enable or disable features. Only the framework signers can call this function.
public fun change_feature_flags(framework: &signer, enable: vector<u64>, disable: vector<u64>)
Check whether the feature is enabled. All features are enabled for system reserved accounts.
public fun is_enabled(feature: u64): bool
public fun get_localnet_feature(): u64
public fun localnet_enabled(): bool
public fun ensure_localnet_enabled()
public fun get_devnet_feature(): u64
public fun devnet_enabled(): bool
public fun ensure_devnet_enabled()
public fun get_testnet_feature(): u64
public fun testnet_enabled(): bool
public fun ensure_testnet_enabled()
public fun get_module_template_feature(): u64
public fun module_template_enabled(): bool
public fun ensure_module_template_enabled()
public fun get_module_publishing_allowlist_feature(): u64
public fun module_publishing_allowlist_enabled(): bool
public fun ensure_module_publishing_allowlist_enabled()
public fun get_wasm_feature(): u64
public fun wasm_enabled(): bool
public fun ensure_wasm_enabled()
public fun get_value_size_gas_feature(): u64
public fun value_size_gas_enabled(): bool
public fun ensure_value_size_gas_enabled()
Helper for getting all features. Update this once new feature added.
public fun get_all_features(): vector<u64>