Skip to content

Commit

Permalink
chore: use CanisterSettingsArgsBuilder instead of corresponding const…
Browse files Browse the repository at this point in the history
…ructor
  • Loading branch information
maksymar committed Jan 17, 2024
1 parent b870ce3 commit 6808e9d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
12 changes: 4 additions & 8 deletions rs/cycles_account_manager/src/lib.rs
Expand Up @@ -1127,7 +1127,7 @@ pub enum IngressInductionCostError {
mod tests {
use super::*;
use candid::Encode;
use ic_ic00_types::{CanisterSettingsArgs, UpdateSettingsArgs};
use ic_ic00_types::{CanisterSettingsArgsBuilder, UpdateSettingsArgs};
use ic_test_utilities::types::ids::subnet_test_id;

fn create_cycles_account_manager(reference_subnet_size: usize) -> CyclesAccountManager {
Expand All @@ -1148,13 +1148,9 @@ mod tests {
let default_freezing_limit = 30 * 24 * 3600; // 30 days
let payload = UpdateSettingsArgs {
canister_id: CanisterId::from_u64(0).into(),
settings: CanisterSettingsArgs::new(
None,
None,
None,
Some(default_freezing_limit),
None,
),
settings: CanisterSettingsArgsBuilder::new()
.with_freezing_threshold(default_freezing_limit)
.build(),
sender_canister_version: None, // ingress messages are not supposed to set this field
};
assert!(2 * Encode!(&payload).unwrap().len() <= MAX_DELAYED_INGRESS_COST_PAYLOAD_SIZE);
Expand Down
4 changes: 3 additions & 1 deletion rs/test_utilities/execution_environment/src/lib.rs
Expand Up @@ -540,7 +540,9 @@ impl ExecutionTest {
) -> Result<WasmResult, UserError> {
let payload = UpdateSettingsArgs {
canister_id: canister_id.into(),
settings: CanisterSettingsArgs::new(Some(controllers), None, None, None, None),
settings: CanisterSettingsArgsBuilder::new()
.with_controllers(controllers)
.build(),
sender_canister_version: None,
}
.encode();
Expand Down
20 changes: 8 additions & 12 deletions rs/types/ic00_types/src/lib.rs
Expand Up @@ -1466,20 +1466,16 @@ pub struct CanisterSettingsArgs {
impl Payload<'_> for CanisterSettingsArgs {}

impl CanisterSettingsArgs {
pub fn new(
controllers: Option<Vec<PrincipalId>>,
compute_allocation: Option<u64>,
memory_allocation: Option<u64>,
freezing_threshold: Option<u64>,
reserved_cycles_limit: Option<u128>,
) -> Self {
/// Note: do not use `new(...)` with passing all the arguments, use corresponding builder instead.
#[deprecated(note = "please use `CanisterSettingsArgsBuilder` instead")]
pub fn new() -> Self {
Self {
controller: None,
controllers: controllers.map(BoundedControllers::new),
compute_allocation: compute_allocation.map(candid::Nat::from),
memory_allocation: memory_allocation.map(candid::Nat::from),
freezing_threshold: freezing_threshold.map(candid::Nat::from),
reserved_cycles_limit: reserved_cycles_limit.map(candid::Nat::from),
controllers: None,
compute_allocation: None,
memory_allocation: None,
freezing_threshold: None,
reserved_cycles_limit: None,
}
}

Expand Down

0 comments on commit 6808e9d

Please sign in to comment.