Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove deprecated CanisterStatusResult type #3431

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions rs/rust_canisters/tests/test/canister_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use assert_matches::assert_matches;
use candid::{Decode, Encode};
use canister_test::{local_test_e, Canister, Runtime, Wasm};
use ic_error_types::ErrorCode;
use ic_management_canister_types::{self as ic00, CanisterIdRecord, CanisterStatusResult, IC_00};
use ic_management_canister_types::{self as ic00, CanisterIdRecord, CanisterStatusResultV2, IC_00};
use ic_test_utilities::universal_canister::UNIVERSAL_CANISTER_WASM;
use ic_test_utilities::universal_canister::{
wasm as universal_canister_argument_builder, CallArgs,
Expand Down Expand Up @@ -32,7 +32,7 @@ fn test_set_controller() {
// aaaaa-aa"
//
// The anonymous user is not allowed to do a "canister_status"
let res: Result<CanisterStatusResult, String> = runtime
let res: Result<CanisterStatusResultV2, String> = runtime
.get_management_canister_with_effective_canister_id(
universal_canister.canister_id().into(),
)
Expand All @@ -59,7 +59,7 @@ fn test_set_controller() {
.update_("update", bytes, arg)
.await
.unwrap();
let status = Decode!(&status_bytes, CanisterStatusResult).unwrap();
let status = Decode!(&status_bytes, CanisterStatusResultV2).unwrap();
assert_eq!(status.controller(), universal_canister.canister_id().get());

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions rs/tests/driver/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use ic_agent::{
use ic_canister_client::{Agent as DeprecatedAgent, Sender};
use ic_config::ConfigOptional;
use ic_limits::MAX_INGRESS_TTL;
use ic_management_canister_types::{CanisterStatusResult, EmptyBlob, Payload};
use ic_management_canister_types::{CanisterStatusResultV2, EmptyBlob, Payload};
use ic_message::ForwardParams;
use ic_nervous_system_proto::pb::v1::GlobalTimeOfDay;
use ic_nns_constants::{GOVERNANCE_CANISTER_ID, ROOT_CANISTER_ID};
Expand Down Expand Up @@ -1241,7 +1241,7 @@ pub async fn get_balance_via_canister(
)
.await
.map(|res| {
Decode!(res.as_slice(), CanisterStatusResult)
Decode!(res.as_slice(), CanisterStatusResultV2)
.unwrap()
.cycles()
.into()
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
Loading