use super::types::{CanisterSettings, CreateCanisterArgs, DeleteCanisterArgs, StartCanisterArgs, StopCanisterArgs};
use crate::identity::CanisterId;
pub async fn create_canister(
settings: Option<CanisterSettings>,
cycles: u128,
) -> Result<CanisterId, ic_cdk::call::Error> {
let call_result =
ic_cdk_management_canister::create_canister_with_extra_cycles(&CreateCanisterArgs { settings }, cycles).await;
call_result.map(|r| r.canister_id)
}
pub async fn start_canister(canister_id: CanisterId) -> super::types::CanisterCallResult<()> {
let call_result = ic_cdk_management_canister::start_canister(&StartCanisterArgs { canister_id }).await;
super::wrap_call_result(canister_id, "ic#start_canister", call_result)
}
pub async fn stop_canister(canister_id: CanisterId) -> super::types::CanisterCallResult<()> {
let call_result = ic_cdk_management_canister::stop_canister(&StopCanisterArgs { canister_id }).await;
super::wrap_call_result(canister_id, "ic#stop_canister", call_result)
}
pub async fn delete_canister(canister_id: CanisterId) -> super::types::CanisterCallResult<()> {
let call_result = ic_cdk_management_canister::delete_canister(&DeleteCanisterArgs { canister_id }).await;
super::wrap_call_result(canister_id, "ic#delete_canister", call_result)
}