diff --git a/Cargo.toml b/Cargo.toml index 65ecb166b..96d9719dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ ic-cdk = { path = "ic-cdk", version = "0.19.0" } ic-cdk-bindgen = { path = "ic-cdk-bindgen", version = "0.2.0-alpha.2" } ic-cdk-timers = { path = "ic-cdk-timers", version = "1.0.0" } ic-cdk-executor = { path = "ic-cdk-executor", version = "2.0.0" } -ic-management-canister-types = { path = "ic-management-canister-types", version = "0.5.0" } +ic-management-canister-types = { path = "ic-management-canister-types", version = "0.6.0" } candid = "0.10.18" # sync with the doc comment in ic-cdk/README.md candid_parser = "0.2.1" diff --git a/e2e-tests/src/bin/management_canister.rs b/e2e-tests/src/bin/management_canister.rs index b51f613a0..39853474d 100644 --- a/e2e-tests/src/bin/management_canister.rs +++ b/e2e-tests/src/bin/management_canister.rs @@ -335,6 +335,8 @@ async fn snapshots() { let arg = TakeCanisterSnapshotArgs { canister_id, replace_snapshot: None, + uninstall_code: None, + sender_canister_version: None, }; let snapshot1 = take_canister_snapshot(&arg).await.unwrap(); diff --git a/ic-management-canister-types/CHANGELOG.md b/ic-management-canister-types/CHANGELOG.md index 86764c36a..c8565fe8c 100644 --- a/ic-management-canister-types/CHANGELOG.md +++ b/ic-management-canister-types/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] +## [0.6.0] - 2026-01-09 + +### Changed + +- Added `uninstall_code` and `sender_canister_version` fields to `TakeCanisterSnapshotArgs`. +- Added `rename_canister` variant to `ChangeDetails`. + - Added the types `RenameCanisterRecord` and `RenameToRecord`. + ## [0.5.0] - 2025-11-13 ### Changed diff --git a/ic-management-canister-types/Cargo.toml b/ic-management-canister-types/Cargo.toml index bb193776c..fd2c0b276 100644 --- a/ic-management-canister-types/Cargo.toml +++ b/ic-management-canister-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ic-management-canister-types" -version = "0.5.0" +version = "0.6.0" authors.workspace = true edition.workspace = true repository.workspace = true diff --git a/ic-management-canister-types/src/lib.rs b/ic-management-canister-types/src/lib.rs index e952fa190..929a8a407 100644 --- a/ic-management-canister-types/src/lib.rs +++ b/ic-management-canister-types/src/lib.rs @@ -674,6 +674,59 @@ pub struct LoadSnapshotRecord { pub source: SnapshotSource, } +/// # Rename To Record +/// +/// Details about the new canister ID in a rename operation. +/// +/// Contains the canister ID, version, and total number of changes of the new canister ID. +/// After renaming, the total number of canister changes reported by the IC method `canister_info` +/// is overridden to this value. +/// +/// See [`RenameCanisterRecord::rename_to`]. +#[derive( + CandidType, Serialize, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, +)] +pub struct RenameToRecord { + /// The new canister ID. + pub canister_id: Principal, + /// The version of the new canister. + pub version: u64, + /// The total number of changes in the new canister's history. + /// This value overrides the total reported by `canister_info` after renaming. + pub total_num_changes: u64, +} + +/// # Rename Canister Record +/// +/// Details about a canister rename operation. +/// +/// Canister renaming is described by the canister ID and the total number of canister changes +/// before renaming as well as the canister ID, version, and total number of changes of the new +/// canister ID. Because only a dedicated NNS canister can perform canister renaming, the actual +/// principal who requested canister renaming is recorded in the [`requested_by`](Self::requested_by) field. +/// +/// After renaming, the total number of canister changes reported by the IC method `canister_info` +/// is overridden to the total number of canister changes of the new canister ID. Canister changes +/// referring to the canister ID before renaming are preserved. +/// +/// See [`ChangeDetails::RenameCanister`]. +#[derive( + CandidType, Serialize, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, +)] +pub struct RenameCanisterRecord { + /// The canister ID before renaming. + pub canister_id: Principal, + /// The total number of changes in the canister's history before renaming. + pub total_num_changes: u64, + /// Details about the new canister ID after renaming. + pub rename_to: RenameToRecord, + /// The principal that requested the rename operation. + /// + /// Because only a dedicated NNS canister can perform canister renaming, + /// this field records the actual principal who requested it. + pub requested_by: Principal, +} + /// # Controllers Change Record /// /// Details about updating canister controllers. @@ -711,6 +764,9 @@ pub enum ChangeDetails { /// The change was updating canister controllers. #[serde(rename = "controllers_change")] ControllersChange(ControllersChangeRecord), + /// The change was renaming a canister. + #[serde(rename = "rename_canister")] + RenameCanister(RenameCanisterRecord), } /// # Change @@ -1332,6 +1388,10 @@ pub struct TakeCanisterSnapshotArgs { /// /// The snapshot identified by the specified ID will be deleted once a new snapshot has been successfully created. pub replace_snapshot: Option, + /// If true, uninstall the canister code after taking the snapshot. + pub uninstall_code: Option, + /// Must match the canister's [`canister_version`](https://internetcomputer.org/docs/current/references/ic-interface-spec/#system-api-canister-version) value when specified. + pub sender_canister_version: Option, } /// # Take Canister Snapshot Result. diff --git a/ic-management-canister-types/tests/ic.did b/ic-management-canister-types/tests/ic.did index b74e7538f..045189f2d 100644 --- a/ic-management-canister-types/tests/ic.did +++ b/ic-management-canister-types/tests/ic.did @@ -70,6 +70,16 @@ type change_details = variant { controllers_change : record { controllers : vec principal; }; + rename_canister : record { + canister_id : principal; + total_num_changes : nat64; + rename_to : record { + canister_id : principal; + version : nat64; + total_num_changes : nat64; + }; + requested_by : principal; + }; }; type change = record { @@ -456,6 +466,8 @@ type snapshot = record { type take_canister_snapshot_args = record { canister_id : canister_id; replace_snapshot : opt snapshot_id; + uninstall_code : opt bool; + sender_canister_version : opt nat64; }; type take_canister_snapshot_result = snapshot;