fn run_vm(module: VerifiedModule) -> Result<(), String> {
    // By convention the 0'th index function definition is the entrypoint to the module (i.e. that
    // will contain only simply-typed arguments).
    let entry_idx = FunctionDefinitionIndex::new(0);
    let function_signature = {
        let handle = module.function_def_at(entry_idx).function;
        let sig_idx = module.function_handle_at(handle).signature;
        module.function_signature_at(sig_idx).clone()
    };
    let main_args: Vec<Value> = function_signature
        .arg_types
        .iter()
        .map(|sig_tok| match sig_tok {
            SignatureToken::Address => Value::address(AccountAddress::new([0; 32])),
            SignatureToken::U64 => Value::u64(0),
            SignatureToken::Bool => Value::bool(true),
            SignatureToken::ByteArray => Value::byte_array(ByteArray::new(vec![])),
            _ => unimplemented!("Unsupported argument type: {:#?}", sig_tok),
        })
        .collect();

    let executor = FakeExecutor::from_genesis_file();
    execute_function_in_module(
        executor.get_state_view(),
        module.clone(),
        entry_idx,
        main_args,
    )
    .map_err(|err| format!("Runtime error: {:?}", err))?;
    Ok(())
}
/// This function runs a verified module in the VM runtime
This function runs a verified module in the VM runtime
This function runs a verified module in the VM runtime
fn run_vm(module: VerifiedModule) -> Result<(), String> {
    // By convention the 0'th index function definition is the entrypoint to the module (i.e. that
    // will contain only simply-typed arguments).
    let entry_idx = FunctionDefinitionIndex::new(0);
    let function_signature = {
        let handle = module.function_def_at(entry_idx).function;
        let sig_idx = module.function_handle_at(handle).signature;
        module.function_signature_at(sig_idx).clone()
    };
    let main_args: Vec<Value> = function_signature
        .arg_types
        .iter()
        .map(|sig_tok| match sig_tok {
            SignatureToken::Address => Value::address(AccountAddress::new([0; 32])),
            SignatureToken::U64 => Value::u64(0),
            SignatureToken::Bool => Value::bool(true),
            SignatureToken::ByteArray => Value::byte_array(ByteArray::new(vec![])),
            _ => unimplemented!("Unsupported argument type: {:#?}", sig_tok),
        })
        .collect();
    let executor = FakeExecutor::from_genesis_file();
    execute_function_in_module(
        executor.get_state_view(),
        module.clone(),
        entry_idx,
        main_args,
    )
    .map_err(|err| format!("Runtime error: {:?}", err))?;
    Ok(())
}
fn run_vm ( module : VerifiedModule ) -> Result < ( ) , String > { // By convention the 0'th index function definition is the entrypoint to the module (i.e. that // will contain only simply-typed arguments). let entry_idx = FunctionDefinitionIndex :: new ( 0 ) ; let function_signature = { let handle = module . function_def_at ( entry_idx ) . function ; let sig_idx = module . function_handle_at ( handle ) . signature ; module . function_signature_at ( sig_idx ) . clone ( ) } ; let main_args : Vec < Value > = function_signature . arg_types . iter ( ) . map ( | sig_tok | match sig_tok { SignatureToken :: Address => Value :: address ( AccountAddress :: new ( [ 0 ; 32 ] ) ) , SignatureToken :: U64 => Value :: u64 ( 0 ) , SignatureToken :: Bool => Value :: bool ( true ) , SignatureToken :: ByteArray => Value :: byte_array ( ByteArray :: new ( vec ! [ ] ) ) , _ => unimplemented ! ( " " sig_tok ) , } ) . collect ( ) ; let executor = FakeExecutor :: from_genesis_file ( ) ; execute_function_in_module ( executor . get_state_view ( ) , module . clone ( ) , entry_idx , main_args , ) . map_err ( | err | format ! ( " " err ) ) ? ; Ok ( ( ) ) }
This function runs a verified module in the VM runtime
This function runs a verified module in the VM runtime
module
VerifiedModule
module
VerifiedModule