starcoin-framework

Module 0x1::GenesisSignerCapability

use 0x1::Account;
use 0x1::CoreAddresses;
use 0x1::Errors;

Resource GenesisSignerCapability

struct GenesisSignerCapability has key
Fields
cap: Account::SignerCapability

Constants

const ENOT_GENESIS_ACCOUNT: u64 = 11;

Function initialize

public(friend) fun initialize(signer: &signer, cap: Account::SignerCapability)
Implementation
public(friend) fun initialize(signer:&signer, cap: Account::SignerCapability) {
    CoreAddresses::assert_genesis_address(signer);
    assert!(Account::signer_address(&cap) == CoreAddresses::GENESIS_ADDRESS(), Errors::invalid_argument(ENOT_GENESIS_ACCOUNT));
    move_to(signer, GenesisSignerCapability{cap});
}

Function get_genesis_signer

public(friend) fun get_genesis_signer(): signer
Implementation
public(friend) fun get_genesis_signer(): signer acquires GenesisSignerCapability {
    let cap = borrow_global<GenesisSignerCapability>(CoreAddresses::GENESIS_ADDRESS());
    Account::create_signer_with_cap(&cap.cap)
}