0x1::RewardConfig
The module provide configuration for block reward.
RewardConfig
initialize
new_reward_config
get_reward_config
reward_delay
use 0x1::Config;
use 0x1::CoreAddresses;
use 0x1::Timestamp;
RewardConfig
Reward configuration
struct RewardConfig has copy, drop, store
reward_delay: u64
const EINVALID_ARGUMENT: u64 = 18;
initialize
Module initialization.
public fun initialize(account: &signer, reward_delay: u64)
public fun initialize(account: &signer, reward_delay: u64) {
Timestamp::assert_genesis();
CoreAddresses::assert_genesis_address(account);
Config::publish_new_config<Self::RewardConfig>(
account,
new_reward_config(reward_delay)
);
}
aborts_if !Timestamp::is_genesis();
aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
aborts_if exists<Config::Config<RewardConfig>>(Signer::address_of(account));
include Config::PublishNewConfigAbortsIf<RewardConfig>;
include Config::PublishNewConfigEnsures<RewardConfig>;
new_reward_config
Create a new reward config mainly used in DAO.
public fun new_reward_config(reward_delay: u64): RewardConfig::RewardConfig
public fun new_reward_config(reward_delay: u64) : RewardConfig {
RewardConfig {reward_delay: reward_delay}
}
get_reward_config
Get reward configuration.
public fun get_reward_config(): RewardConfig::RewardConfig
public fun get_reward_config(): RewardConfig {
Config::get_by_address<RewardConfig>(CoreAddresses::GENESIS_ADDRESS())
}
include GetRewardConfigAbortsIf;
schema GetRewardConfigAbortsIf {
aborts_if !exists<Config::Config<RewardConfig>>(CoreAddresses::GENESIS_ADDRESS());
}
reward_delay
Get reward delay.
public fun reward_delay(): u64
public fun reward_delay() :u64 {
let reward_config = get_reward_config();
reward_config.reward_delay
}
aborts_if !exists<Config::Config<RewardConfig>>(CoreAddresses::GENESIS_ADDRESS());
pragma verify = false;
pragma aborts_if_is_strict = true;