async fn try_to_create_and_install_canister(
    payload: AddNnsCanisterProposalPayload,
) -> Result<CanisterId, String> {
    let (id,): (CanisterIdRecord,) = call_with_funds(
        CanisterId::ic_00(),
        "create_canister",
        dfn_candid::candid_multi_arity,
        (),
        Funds::new(payload.initial_cycles),
    )
    .await
    .map_err(|(code, msg)| {
        format!(
            "{}{}",
            code.map(|c| format!("error code {}: ", c))
                .unwrap_or_default(),
            msg
        )
    })?;
    let install_args = InstallCodeArgs {
        mode: Install,
        canister_id: id.get_canister_id().get(),
        wasm_module: payload.wasm_module,
        arg: payload.arg,
        compute_allocation: payload.compute_allocation,
        memory_allocation: payload.memory_allocation,
        query_allocation: payload.query_allocation,
    };
    let install_res: Result<(), (Option<i32>, String)> = call(
        CanisterId::ic_00(),
        "install_code",
        dfn_candid::candid_multi_arity,
        (install_args,),
    )
    .await;
    install_res.map_err(|(code, msg)| {
        format!(
            "{}{}",
            code.map(|c| format!("error code {}: ", c))
                .unwrap_or_default(),
            msg
        )
    })?;
    Ok(id.get_canister_id())
}
/// Tries to create and install the canister specified in the payload. Does not
/// care about the name service. This function is supposed never to panic, so
/// that cleanup can be done if the install does not go through.
Tries to create and install the canister specified in the payload. Does not
care about the name service. This function is supposed never to panic, so
that cleanup can be done if the install does not go through.
Tries to create and install the canister specified in the payload . Does not care about the name service . This function is supposed never to panic so that cleanup can be done if the install does not go through .
async fn try_to_create_and_install_canister(
    payload: AddNnsCanisterProposalPayload,
) -> Result<CanisterId, String> {
    let (id,): (CanisterIdRecord,) = call_with_funds(
        CanisterId::ic_00(),
        "create_canister",
        dfn_candid::candid_multi_arity,
        (),
        Funds::new(payload.initial_cycles),
    )
    .await
    .map_err(|(code, msg)| {
        format!(
            "{}{}",
            code.map(|c| format!("error code {}: ", c))
                .unwrap_or_default(),
            msg
        )
    })?;
    let install_args = InstallCodeArgs {
        mode: Install,
        canister_id: id.get_canister_id().get(),
        wasm_module: payload.wasm_module,
        arg: payload.arg,
        compute_allocation: payload.compute_allocation,
        memory_allocation: payload.memory_allocation,
        query_allocation: payload.query_allocation,
    };
    let install_res: Result<(), (Option<i32>, String)> = call(
        CanisterId::ic_00(),
        "install_code",
        dfn_candid::candid_multi_arity,
        (install_args,),
    )
    .await;
    install_res.map_err(|(code, msg)| {
        format!(
            "{}{}",
            code.map(|c| format!("error code {}: ", c))
                .unwrap_or_default(),
            msg
        )
    })?;
    Ok(id.get_canister_id())
}
async fn try_to_create_and_install_canister ( payload : AddNnsCanisterProposalPayload , ) -> Result < CanisterId , String > { let ( id , ) : ( CanisterIdRecord , ) = call_with_funds ( CanisterId :: ic_00 ( ) , " " , dfn_candid :: candid_multi_arity , ( ) , Funds :: new ( payload . initial_cycles ) , ) . await . map_err ( | ( code , msg ) | { format ! ( " " code map ( c format ( " " c ) ) unwrap_or_default ( ) msg ) } ) ? ; let install_args = InstallCodeArgs { mode : Install , canister_id : id . get_canister_id ( ) . get ( ) , wasm_module : payload . wasm_module , arg : payload . arg , compute_allocation : payload . compute_allocation , memory_allocation : payload . memory_allocation , query_allocation : payload . query_allocation , } ; let install_res : Result < ( ) , ( Option < i32 > , String ) > = call ( CanisterId :: ic_00 ( ) , " " , dfn_candid :: candid_multi_arity , ( install_args , ) , ) . await ; install_res . map_err ( | ( code , msg ) | { format ! ( " " code map ( c format ( " " c ) ) unwrap_or_default ( ) msg ) } ) ? ; Ok ( id . get_canister_id ( ) ) }
Tries to create and install the canister specified in the payload.
Tries to create and install the canister specified in the payload .
payload
AddNnsCanisterProposalPayload
payload
AddNnsCanisterProposalPayload