pub fn create_genesis_effects(
    genesis_account_addr: [u8; 32],
    initial_motes: U512,
    mint_code_bytes: WasmiBytes,
    pos_code_bytes: WasmiBytes,
    genesis_validators: Vec<(PublicKey, U512)>,
    protocol_version: u64,
) -> Result<ExecutionEffect, execution::Error> {
    let rng = GenesisURefsSource::default();

    let genesis_validator_stakes: U512 = genesis_validators
        .iter()
        .map(|t| t.1)
        .fold(U512::zero(), |a, b| a + b);

    let pos_effects =
        create_pos_effects(&rng, pos_code_bytes, genesis_validators, protocol_version)?;

    let mint_effects = create_mint_effects(
        &rng,
        genesis_account_addr,
        initial_motes,
        mint_code_bytes,
        genesis_validator_stakes,
        protocol_version,
    )?;

    let mut execution_effect: ExecutionEffect = Default::default();

    for (k, v) in mint_effects.into_iter().chain(pos_effects.into_iter()) {
        let k = if let Key::URef(_) = k {
            k.normalize()
        } else {
            k
        };
        execution_effect.ops.insert(k, Op::Write);
        execution_effect.transforms.insert(k, Transform::Write(v));
    }

    Ok(execution_effect)
}
// TODO: Post devnet, make genesis creation regular contract execution.
Post devnet, make genesis creation regular contract execution.
Post devnet make genesis creation regular contract execution .
pub fn create_genesis_effects(
    genesis_account_addr: [u8; 32],
    initial_motes: U512,
    mint_code_bytes: WasmiBytes,
    pos_code_bytes: WasmiBytes,
    genesis_validators: Vec<(PublicKey, U512)>,
    protocol_version: u64,
) -> Result<ExecutionEffect, execution::Error> {
    let rng = GenesisURefsSource::default();
    let genesis_validator_stakes: U512 = genesis_validators
        .iter()
        .map(|t| t.1)
        .fold(U512::zero(), |a, b| a + b);
    let pos_effects =
        create_pos_effects(&rng, pos_code_bytes, genesis_validators, protocol_version)?;
    let mint_effects = create_mint_effects(
        &rng,
        genesis_account_addr,
        initial_motes,
        mint_code_bytes,
        genesis_validator_stakes,
        protocol_version,
    )?;
    let mut execution_effect: ExecutionEffect = Default::default();
    for (k, v) in mint_effects.into_iter().chain(pos_effects.into_iter()) {
        let k = if let Key::URef(_) = k {
            k.normalize()
        } else {
            k
        };
        execution_effect.ops.insert(k, Op::Write);
        execution_effect.transforms.insert(k, Transform::Write(v));
    }
    Ok(execution_effect)
}
pub fn create_genesis_effects ( genesis_account_addr : [ u8 ; 32 ] , initial_motes : U512 , mint_code_bytes : WasmiBytes , pos_code_bytes : WasmiBytes , genesis_validators : Vec < ( PublicKey , U512 ) > , protocol_version : u64 , ) -> Result < ExecutionEffect , execution :: Error > { let rng = GenesisURefsSource :: default ( ) ; let genesis_validator_stakes : U512 = genesis_validators . iter ( ) . map ( | t | t . 1 ) . fold ( U512 :: zero ( ) , | a , b | a + b ) ; let pos_effects = create_pos_effects ( & rng , pos_code_bytes , genesis_validators , protocol_version ) ? ; let mint_effects = create_mint_effects ( & rng , genesis_account_addr , initial_motes , mint_code_bytes , genesis_validator_stakes , protocol_version , ) ? ; let mut execution_effect : ExecutionEffect = Default :: default ( ) ; for ( k , v ) in mint_effects . into_iter ( ) . chain ( pos_effects . into_iter ( ) ) { let k = if let Key :: URef ( _ ) = k { k . normalize ( ) } else { k } ; execution_effect . ops . insert ( k , Op :: Write ) ; execution_effect . transforms . insert ( k , Transform :: Write ( v ) ) ; } Ok ( execution_effect ) }
TODO: Post devnet, make genesis creation regular contract execution.
TODO : Post devnet make genesis creation regular contract execution .
genesis_account_addr
[u8; 32]
initial_motes
U512
mint_code_bytes
WasmiBytes
pos_code_bytes
WasmiBytes
genesis_validators
Vec<(PublicKey, U512)>
protocol_version
u64
genesis_account_addr
[u8; 32]
initial_motes
U512
mint_code_bytes
WasmiBytes
pos_code_bytes
WasmiBytes
genesis_validators
Vec<(PublicKey, U512)>
protocol_version
u64