Skip to content

Commit

Permalink
Remove deprecated CanisterStatusResult type
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonz-dfinity committed Jan 13, 2025
1 parent a726b71 commit 6264280
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 58 deletions.
4 changes: 2 additions & 2 deletions rs/rust_canisters/canister_test/src/canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use ic_canister_client::{Agent, Sender};
use ic_config::Config;
use ic_management_canister_types::CanisterStatusType::Stopped;
pub use ic_management_canister_types::{
self as ic00, CanisterIdRecord, CanisterInstallMode, CanisterStatusResult, InstallCodeArgs,
self as ic00, CanisterIdRecord, CanisterInstallMode, InstallCodeArgs,
ProvisionalCreateCanisterWithCyclesArgs, IC_00,
};
use ic_registry_transport::pb::v1::RegistryMutation;
Expand Down Expand Up @@ -808,7 +808,7 @@ impl<'a> Canister<'a> {
.await;
stop_res?;
loop {
let status_res: Result<CanisterStatusResult, String> = self
let status_res: Result<CanisterStatusResultV2, String> = self
.runtime
.get_management_canister_with_effective_canister_id(self.canister_id().into())
.update_("canister_status", candid, (self.as_record(),))
Expand Down
56 changes: 0 additions & 56 deletions rs/types/management_canister_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,62 +956,6 @@ impl DefiniteCanisterSettingsArgs {

impl Payload<'_> for DefiniteCanisterSettingsArgs {}

/// The deprecated version of CanisterStatusResult that is being
/// used by NNS canisters.
#[derive(Eq, PartialEq, Debug, CandidType, Deserialize)]
pub struct CanisterStatusResult {
status: CanisterStatusType,
module_hash: Option<Vec<u8>>,
controller: candid::Principal,
memory_size: candid::Nat,
cycles: candid::Nat,
// this is for compat with Spec 0.12/0.13
balance: Vec<(Vec<u8>, candid::Nat)>,
}

impl CanisterStatusResult {
pub fn new(
status: CanisterStatusType,
module_hash: Option<Vec<u8>>,
controller: PrincipalId,
memory_size: NumBytes,
cycles: u128,
) -> Self {
Self {
status,
module_hash,
controller: candid::Principal::from_text(controller.to_string()).unwrap(),
memory_size: candid::Nat::from(memory_size.get()),
cycles: candid::Nat::from(cycles),
// the following is spec 0.12/0.13 compat;
// "\x00" denotes cycles
balance: vec![(vec![0], candid::Nat::from(cycles))],
}
}

pub fn status(&self) -> CanisterStatusType {
self.status.clone()
}

pub fn module_hash(&self) -> Option<Vec<u8>> {
self.module_hash.clone()
}

pub fn controller(&self) -> PrincipalId {
PrincipalId::try_from(self.controller.as_slice()).unwrap()
}

pub fn memory_size(&self) -> NumBytes {
NumBytes::from(self.memory_size.0.to_u64().unwrap())
}

pub fn cycles(&self) -> u128 {
self.cycles.0.to_u128().unwrap()
}
}

impl Payload<'_> for CanisterStatusResult {}

#[derive(Eq, PartialEq, Debug, CandidType, Deserialize)]
pub struct QueryStats {
num_calls_total: candid::Nat,
Expand Down

0 comments on commit 6264280

Please sign in to comment.