starcoin-framework

Module 0x1::ModuleUpgradeScripts

use 0x1::Config;
use 0x1::Option;
use 0x1::PackageTxnManager;
use 0x1::Signer;
use 0x1::UpgradeModuleDaoProposal;
use 0x1::Version;

Function propose_module_upgrade_v2

public(script) fun propose_module_upgrade_v2<Token: copy, drop, store>(signer: signer, module_address: address, package_hash: vector<u8>, version: u64, exec_delay: u64, enforced: bool)
Implementation
public(script) fun propose_module_upgrade_v2<Token: copy + drop + store>(
    signer: signer,
    module_address: address,
    package_hash: vector<u8>,
    version: u64,
    exec_delay: u64,
    enforced: bool,
) {
    UpgradeModuleDaoProposal::propose_module_upgrade_v2<Token>(
        &signer,
        module_address,
        package_hash,
        version,
        exec_delay,
        enforced
    );
}

Function update_module_upgrade_strategy

Update sender’s module upgrade strategy to strategy

public(script) fun update_module_upgrade_strategy(sender: signer, strategy: u8)
Implementation
public(script) fun update_module_upgrade_strategy(
    sender: signer,
    strategy: u8,
) {
    // 1. check version
    if (strategy == PackageTxnManager::get_strategy_two_phase()) {
        if (!Config::config_exist_by_address<Version::Version>(Signer::address_of(&sender))) {
            Config::publish_new_config<Version::Version>(&sender, Version::new_version(1));
        }
    };

    // 2. update strategy
    PackageTxnManager::update_module_upgrade_strategy(
        &sender,
        strategy,
        Option::none<u64>(),
    );
}

Function submit_module_upgrade_plan

a alias of execute_module_upgrade_plan_propose, will deprecated in the future.

public(script) fun submit_module_upgrade_plan<Token: copy, drop, store>(sender: signer, proposer_address: address, proposal_id: u64)
Implementation
public(script) fun submit_module_upgrade_plan<Token: copy + drop + store>(
    sender: signer,
    proposer_address: address,
    proposal_id: u64,
) {
    Self::execute_module_upgrade_plan_propose<Token>(sender, proposer_address, proposal_id);
}

Function execute_module_upgrade_plan_propose

Execute module upgrade plan propose by submit module upgrade plan, the propose must been agreed, and anyone can execute this function.

public(script) fun execute_module_upgrade_plan_propose<Token: copy, drop, store>(_sender: signer, proposer_address: address, proposal_id: u64)
Implementation
public(script) fun execute_module_upgrade_plan_propose<Token: copy + drop + store>(
    _sender: signer,
    proposer_address: address,
    proposal_id: u64,
) {
    UpgradeModuleDaoProposal::submit_module_upgrade_plan<Token>(proposer_address, proposal_id);
}
Specification
pragma verify = false;

Function submit_upgrade_plan

Directly submit a upgrade plan, the sender’s module upgrade plan must been PackageTxnManager::STRATEGY_TWO_PHASE and have UpgradePlanCapability

public(script) fun submit_upgrade_plan(sender: signer, package_hash: vector<u8>, version: u64, enforced: bool)
Implementation
public(script) fun submit_upgrade_plan(sender: signer, package_hash: vector<u8>, version:u64, enforced: bool) {
    PackageTxnManager::submit_upgrade_plan_v2(&sender, package_hash, version, enforced);
}
Specification
pragma verify = false;

Function cancel_upgrade_plan

Cancel current upgrade plan, the sender must have UpgradePlanCapability.

public(script) fun cancel_upgrade_plan(signer: signer)
Implementation
public(script) fun cancel_upgrade_plan(
    signer: signer,
) {
    PackageTxnManager::cancel_upgrade_plan(&signer);
}
Specification
pragma verify = false;

Module Specification

pragma verify = false;
pragma aborts_if_is_partial = false;
pragma aborts_if_is_strict = true;