starcoin-framework

Module 0x1::RewardConfig

The module provide configuration for block reward.

use 0x1::Config;
use 0x1::CoreAddresses;
use 0x1::Timestamp;

Struct RewardConfig

Reward configuration

struct RewardConfig has copy, drop, store
Fields
reward_delay: u64
how many blocks delay reward distribution.

Constants

const EINVALID_ARGUMENT: u64 = 18;

Function initialize

Module initialization.

public fun initialize(account: &signer, reward_delay: u64)
Implementation
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)
    );
}
Specification
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>;

Function new_reward_config

Create a new reward config mainly used in DAO.

public fun new_reward_config(reward_delay: u64): RewardConfig::RewardConfig
Implementation
public fun new_reward_config(reward_delay: u64) : RewardConfig {
    RewardConfig {reward_delay: reward_delay}
}
Specification

Function get_reward_config

Get reward configuration.

public fun get_reward_config(): RewardConfig::RewardConfig
Implementation
public fun get_reward_config(): RewardConfig {
    Config::get_by_address<RewardConfig>(CoreAddresses::GENESIS_ADDRESS())
}
Specification
include GetRewardConfigAbortsIf;
schema GetRewardConfigAbortsIf {
    aborts_if !exists<Config::Config<RewardConfig>>(CoreAddresses::GENESIS_ADDRESS());
}

Function reward_delay

Get reward delay.

public fun reward_delay(): u64
Implementation
public fun reward_delay() :u64 {
    let reward_config = get_reward_config();
    reward_config.reward_delay
}
Specification
aborts_if !exists<Config::Config<RewardConfig>>(CoreAddresses::GENESIS_ADDRESS());

Module Specification

pragma verify = false;
pragma aborts_if_is_strict = true;