From 31e64a9559e15aea59cd6235655d983f4246f1e3 Mon Sep 17 00:00:00 2001 From: Jan Hrubes Date: Wed, 20 Nov 2024 10:31:44 +0100 Subject: [PATCH 1/9] feat(station): store monitoring data in ExternalCanister --- core/station/api/spec.did | 13 ++- core/station/api/src/external_canister.rs | 11 ++- .../requests/monitor_external_canister.rs | 5 +- .../impl/src/mappers/external_canister.rs | 93 +++++++++++-------- .../impl/src/models/external_canister.rs | 8 +- .../impl/src/models/request_operation.rs | 17 +++- .../impl/src/services/external_canister.rs | 4 +- 7 files changed, 101 insertions(+), 50 deletions(-) diff --git a/core/station/api/spec.did b/core/station/api/spec.did index f440dd406..4b27c597b 100644 --- a/core/station/api/spec.did +++ b/core/station/api/spec.did @@ -794,10 +794,17 @@ type MonitorExternalCanisterStrategyInput = variant { Always : nat; }; +// The input type for specifying the strategy for obtaining cycles for the funding operation. +type MonitorExternalCanisterObtainCyclesStrategy = variant { + Disabled; +}; + // The input type for specifying the strategy for monitoring an external canister. type MonitorExternalCanisterStartInput = record { - // The amount of cycles to send to the canister. - strategy : MonitorExternalCanisterStrategyInput; + // The strategy for funding the canister. + funding_strategy : MonitorExternalCanisterStrategyInput; + // The strategy for obtaining cycles for the funding operation. + cycle_obtain_strategy: opt MonitorExternalCanisterObtainCyclesStrategy; }; // The operation kind for monitoring an external canister in the station. @@ -2595,6 +2602,8 @@ type ExternalCanister = record { created_at : TimestampRFC3339; // The time at which the canister was last modified, if available. modified_at : opt TimestampRFC3339; + // Monitoring configuration for the canister. + monitoring : opt MonitorExternalCanisterStartInput; }; // The state of the external canister. diff --git a/core/station/api/src/external_canister.rs b/core/station/api/src/external_canister.rs index 487aa9752..b023ef08b 100644 --- a/core/station/api/src/external_canister.rs +++ b/core/station/api/src/external_canister.rs @@ -285,6 +285,7 @@ pub struct ExternalCanisterDTO { pub request_policies: ExternalCanisterRequestPoliciesDTO, pub created_at: TimestampRfc3339, pub modified_at: Option, + pub monitoring: Option, } #[derive(CandidType, serde::Serialize, Deserialize, Debug, Clone)] @@ -398,7 +399,7 @@ pub struct MonitoringExternalCanisterCyclesThresholdInput { } #[derive(CandidType, serde::Serialize, Deserialize, Debug, Clone)] -pub enum MonitorExternalCanisterStartStrategyDTO { +pub enum MonitorExternalCanisterStrategyDTO { Always(u128), BelowThreshold(MonitoringExternalCanisterCyclesThresholdInput), BelowEstimatedRuntime(MonitoringExternalCanisterEstimatedRuntimeInput), @@ -406,7 +407,8 @@ pub enum MonitorExternalCanisterStartStrategyDTO { #[derive(CandidType, serde::Serialize, Deserialize, Debug, Clone)] pub struct MonitorExternalCanisterStartInput { - pub strategy: MonitorExternalCanisterStartStrategyDTO, + pub funding_strategy: MonitorExternalCanisterStrategyDTO, + pub obtain_cycles_strategy: Option, } #[derive(CandidType, serde::Serialize, Deserialize, Debug, Clone)] @@ -422,3 +424,8 @@ pub struct MonitorExternalCanisterOperationInput { } pub type MonitorExternalCanisterOperationDTO = MonitorExternalCanisterOperationInput; + +#[derive(CandidType, serde::Serialize, Deserialize, Debug, Clone)] +pub enum MonitorExternalCanisterObtainCyclesStrategyDTO { + Disabled, +} diff --git a/core/station/impl/src/factories/requests/monitor_external_canister.rs b/core/station/impl/src/factories/requests/monitor_external_canister.rs index dbf7f4384..3a05982b2 100644 --- a/core/station/impl/src/factories/requests/monitor_external_canister.rs +++ b/core/station/impl/src/factories/requests/monitor_external_canister.rs @@ -60,7 +60,10 @@ impl Execute for MonitorExternalCanisterRequestExecute<'_, '_> { match &self.operation.kind { MonitorExternalCanisterOperationKind::Start(input) => { self.external_canister_service - .canister_monitor_start(self.operation.canister_id, input.strategy.clone()) + .canister_monitor_start( + self.operation.canister_id, + input.funding_strategy.clone(), + ) .map_err(|e| RequestExecuteError::Failed { reason: format!("Failed to monitor canister: {}", e), })?; diff --git a/core/station/impl/src/mappers/external_canister.rs b/core/station/impl/src/mappers/external_canister.rs index 6b5812a63..a5af6bce3 100644 --- a/core/station/impl/src/mappers/external_canister.rs +++ b/core/station/impl/src/mappers/external_canister.rs @@ -5,12 +5,13 @@ use crate::{ ConfigureExternalCanisterSettingsInput, CreateExternalCanisterOperationInput, DefiniteCanisterSettingsInput, ExternalCanister, ExternalCanisterCallRequestPolicyRule, ExternalCanisterCallerMethodsPrivileges, ExternalCanisterCallerPrivileges, - ExternalCanisterChangeRequestPolicyRule, ExternalCanisterPermissions, - ExternalCanisterRequestPolicies, ExternalCanisterState, FundExternalCanisterOperation, - FundExternalCanisterOperationInput, FundExternalCanisterOperationKind, - FundExternalCanisterSendCyclesInput, LogVisibility, MonitorExternalCanisterOperationInput, - MonitorExternalCanisterOperationKind, MonitorExternalCanisterStartInput, - MonitorExternalCanisterStartStrategy, MonitoringExternalCanisterCyclesThresholdInput, + ExternalCanisterChangeRequestPolicyRule, ExternalCanisterObtainCyclesStrategy, + ExternalCanisterPermissions, ExternalCanisterRequestPolicies, ExternalCanisterState, + FundExternalCanisterOperation, FundExternalCanisterOperationInput, + FundExternalCanisterOperationKind, FundExternalCanisterSendCyclesInput, LogVisibility, + MonitorExternalCanisterOperationInput, MonitorExternalCanisterOperationKind, + MonitorExternalCanisterStartInput, MonitorExternalCanisterStrategy, + MonitoringExternalCanisterCyclesThresholdInput, MonitoringExternalCanisterEstimatedRuntimeInput, }, repositories::ExternalCanisterWhereClauseSort, @@ -19,7 +20,7 @@ use candid::Principal; use canfund::manager::options::{CyclesThreshold, EstimatedRuntime}; use ic_cdk::api::management_canister::main::{self as mgmt}; use orbit_essentials::{repository::SortDirection, utils::timestamp_to_rfc3339}; -use station_api::ExternalCanisterDTO; +use station_api::{ExternalCanisterDTO, MonitorExternalCanisterObtainCyclesStrategyDTO}; use uuid::Uuid; #[derive(Default, Clone, Debug)] @@ -40,6 +41,7 @@ impl ExternalCanisterMapper { state: ExternalCanisterState::Active, created_at: next_time(), modified_at: None, + monitoring: None, } } } @@ -62,6 +64,7 @@ impl ExternalCanister { request_policies: policies.into(), created_at: timestamp_to_rfc3339(&self.created_at), modified_at: self.modified_at.map(|ts| timestamp_to_rfc3339(&ts)), + monitoring: self.monitoring.map(Into::into), } } } @@ -376,7 +379,8 @@ impl From impl From for MonitorExternalCanisterStartInput { fn from(input: station_api::MonitorExternalCanisterStartInput) -> Self { MonitorExternalCanisterStartInput { - strategy: input.strategy.into(), + funding_strategy: input.funding_strategy.into(), + obtain_cycles_strategy: input.obtain_cycles_strategy.map(Into::into), } } } @@ -384,44 +388,39 @@ impl From for MonitorExternalCan impl From for station_api::MonitorExternalCanisterStartInput { fn from(input: MonitorExternalCanisterStartInput) -> Self { station_api::MonitorExternalCanisterStartInput { - strategy: input.strategy.into(), + funding_strategy: input.funding_strategy.into(), + obtain_cycles_strategy: input.obtain_cycles_strategy.map(Into::into), } } } -impl From - for MonitorExternalCanisterStartStrategy -{ - fn from(strategy: station_api::MonitorExternalCanisterStartStrategyDTO) -> Self { +impl From for MonitorExternalCanisterStrategy { + fn from(strategy: station_api::MonitorExternalCanisterStrategyDTO) -> Self { match strategy { - station_api::MonitorExternalCanisterStartStrategyDTO::Always(cycles) => { - MonitorExternalCanisterStartStrategy::Always(cycles) + station_api::MonitorExternalCanisterStrategyDTO::Always(cycles) => { + MonitorExternalCanisterStrategy::Always(cycles) + } + station_api::MonitorExternalCanisterStrategyDTO::BelowThreshold(threshold) => { + MonitorExternalCanisterStrategy::BelowThreshold(threshold.into()) } - station_api::MonitorExternalCanisterStartStrategyDTO::BelowThreshold(threshold) => { - MonitorExternalCanisterStartStrategy::BelowThreshold(threshold.into()) + station_api::MonitorExternalCanisterStrategyDTO::BelowEstimatedRuntime(runtime) => { + MonitorExternalCanisterStrategy::BelowEstimatedRuntime(runtime.into()) } - station_api::MonitorExternalCanisterStartStrategyDTO::BelowEstimatedRuntime( - runtime, - ) => MonitorExternalCanisterStartStrategy::BelowEstimatedRuntime(runtime.into()), } } } -impl From - for station_api::MonitorExternalCanisterStartStrategyDTO -{ - fn from(strategy: MonitorExternalCanisterStartStrategy) -> Self { +impl From for station_api::MonitorExternalCanisterStrategyDTO { + fn from(strategy: MonitorExternalCanisterStrategy) -> Self { match strategy { - MonitorExternalCanisterStartStrategy::Always(cycles) => { - station_api::MonitorExternalCanisterStartStrategyDTO::Always(cycles) + MonitorExternalCanisterStrategy::Always(cycles) => { + station_api::MonitorExternalCanisterStrategyDTO::Always(cycles) } - MonitorExternalCanisterStartStrategy::BelowThreshold(threshold) => { - station_api::MonitorExternalCanisterStartStrategyDTO::BelowThreshold( - threshold.into(), - ) + MonitorExternalCanisterStrategy::BelowThreshold(threshold) => { + station_api::MonitorExternalCanisterStrategyDTO::BelowThreshold(threshold.into()) } - MonitorExternalCanisterStartStrategy::BelowEstimatedRuntime(runtime) => { - station_api::MonitorExternalCanisterStartStrategyDTO::BelowEstimatedRuntime( + MonitorExternalCanisterStrategy::BelowEstimatedRuntime(runtime) => { + station_api::MonitorExternalCanisterStrategyDTO::BelowEstimatedRuntime( runtime.into(), ) } @@ -479,16 +478,16 @@ impl From } } -impl From for canfund::manager::options::FundStrategy { - fn from(strategy: MonitorExternalCanisterStartStrategy) -> Self { +impl From for canfund::manager::options::FundStrategy { + fn from(strategy: MonitorExternalCanisterStrategy) -> Self { match strategy { - MonitorExternalCanisterStartStrategy::Always(cycles) => { + MonitorExternalCanisterStrategy::Always(cycles) => { canfund::manager::options::FundStrategy::Always(cycles) } - MonitorExternalCanisterStartStrategy::BelowThreshold(threshold) => { + MonitorExternalCanisterStrategy::BelowThreshold(threshold) => { canfund::manager::options::FundStrategy::BelowThreshold(threshold.into()) } - MonitorExternalCanisterStartStrategy::BelowEstimatedRuntime(runtime) => { + MonitorExternalCanisterStrategy::BelowEstimatedRuntime(runtime) => { canfund::manager::options::FundStrategy::BelowEstimatedRuntime(runtime.into()) } } @@ -513,3 +512,23 @@ impl From for EstimatedRuntime .with_fallback_min_cycles(input.fallback_min_cycles) } } + +impl From for MonitorExternalCanisterObtainCyclesStrategyDTO { + fn from(strategy: ExternalCanisterObtainCyclesStrategy) -> Self { + match strategy { + ExternalCanisterObtainCyclesStrategy::Disabled => { + MonitorExternalCanisterObtainCyclesStrategyDTO::Disabled + } + } + } +} + +impl From for ExternalCanisterObtainCyclesStrategy { + fn from(value: MonitorExternalCanisterObtainCyclesStrategyDTO) -> Self { + match value { + MonitorExternalCanisterObtainCyclesStrategyDTO::Disabled => { + ExternalCanisterObtainCyclesStrategy::Disabled + } + } + } +} diff --git a/core/station/impl/src/models/external_canister.rs b/core/station/impl/src/models/external_canister.rs index 2e1b62ddd..a8d59948a 100644 --- a/core/station/impl/src/models/external_canister.rs +++ b/core/station/impl/src/models/external_canister.rs @@ -8,7 +8,7 @@ use super::{ CanisterMethod, ConfigureExternalCanisterSettingsInput, CreateExternalCanisterOperationInput, CreateExternalCanisterOperationKind, ExternalCanisterChangeCallRequestPoliciesInput, ExternalCanisterRequestPoliciesCreateInput, ExternalCanisterRequestPoliciesUpdateInput, - Metadata, RequestPolicy, RequestPolicyRule, + Metadata, MonitorExternalCanisterStartInput, RequestPolicy, RequestPolicyRule, }; use crate::errors::{ExternalCanisterError, ExternalCanisterValidationError}; use crate::repositories::REQUEST_POLICY_REPOSITORY; @@ -57,6 +57,8 @@ pub struct ExternalCanister { pub created_at: Timestamp, /// The last time the record was updated. pub modified_at: Option, + /// Is the canister monitored by the station. + pub monitoring: Option, } #[storable] @@ -129,6 +131,8 @@ pub struct ExternalCanisterCallerPrivileges { pub type ExternalCanisterAvailableFilters = GetExternalCanisterFiltersResponse; +pub type ExternalCanisterMonitoring = MonitorExternalCanisterStartInput; + impl ExternalCanister { pub const MAX_NAME_LENGTH: usize = 100; pub const MAX_LABEL_LENGTH: usize = 50; @@ -448,6 +452,7 @@ pub mod external_canister_test_utils { state: ExternalCanisterState::Active, created_at: next_time(), modified_at: None, + monitoring: None, } } } @@ -483,6 +488,7 @@ mod tests { assert_eq!(model.state, deserialized_model.state); assert_eq!(model.created_at, deserialized_model.created_at); assert_eq!(model.modified_at, deserialized_model.modified_at); + assert_eq!(model.monitoring, deserialized_model.monitoring); } #[test] diff --git a/core/station/impl/src/models/request_operation.rs b/core/station/impl/src/models/request_operation.rs index 52ee6316c..2335c769a 100644 --- a/core/station/impl/src/models/request_operation.rs +++ b/core/station/impl/src/models/request_operation.rs @@ -546,22 +546,29 @@ pub struct MonitoringExternalCanisterCyclesThresholdInput { #[storable] #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] -pub enum MonitorExternalCanisterStartStrategy { +pub enum MonitorExternalCanisterStrategy { Always(u128), BelowThreshold(MonitoringExternalCanisterCyclesThresholdInput), BelowEstimatedRuntime(MonitoringExternalCanisterEstimatedRuntimeInput), } +#[storable] +#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub enum ExternalCanisterObtainCyclesStrategy { + Disabled, +} + #[storable] #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct MonitorExternalCanisterStartInput { - pub strategy: MonitorExternalCanisterStartStrategy, + pub funding_strategy: MonitorExternalCanisterStrategy, + pub obtain_cycles_strategy: Option, } #[storable] #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub enum MonitorExternalCanisterOperationKind { - Start(crate::models::MonitorExternalCanisterStartInput), + Start(MonitorExternalCanisterStartInput), Stop, } @@ -569,10 +576,10 @@ pub enum MonitorExternalCanisterOperationKind { #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct MonitorExternalCanisterOperationInput { pub canister_id: Principal, - pub kind: crate::models::MonitorExternalCanisterOperationKind, + pub kind: MonitorExternalCanisterOperationKind, } -pub type MonitorExternalCanisterOperation = crate::models::MonitorExternalCanisterOperationInput; +pub type MonitorExternalCanisterOperation = MonitorExternalCanisterOperationInput; #[storable] #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] diff --git a/core/station/impl/src/services/external_canister.rs b/core/station/impl/src/services/external_canister.rs index 96ed7382b..a676778d0 100644 --- a/core/station/impl/src/services/external_canister.rs +++ b/core/station/impl/src/services/external_canister.rs @@ -25,7 +25,7 @@ use crate::models::{ ExternalCanisterChangeRequestPolicyRule, ExternalCanisterEntryId, ExternalCanisterKey, ExternalCanisterPermissions, ExternalCanisterPermissionsUpdateInput, ExternalCanisterRequestPolicies, ExternalCanisterRequestPoliciesUpdateInput, - MonitorExternalCanisterStartStrategy, RequestPolicy, + MonitorExternalCanisterStrategy, RequestPolicy, }; use crate::repositories::permission::{PermissionRepository, PERMISSION_REPOSITORY}; use crate::repositories::{ @@ -1027,7 +1027,7 @@ impl ExternalCanisterService { pub fn canister_monitor_start( &self, canister_id: Principal, - strategy: MonitorExternalCanisterStartStrategy, + strategy: MonitorExternalCanisterStrategy, ) -> ServiceResult<()> { self.cycle_manager .add_canister(canister_id, strategy.into()); From 9b7fca70a0dbf6d6e0e5645186af2e926ad7b8fb Mon Sep 17 00:00:00 2001 From: Jan Hrubes Date: Wed, 20 Nov 2024 11:04:00 +0100 Subject: [PATCH 2/9] refactor: use existing struct for obtain cycles --- core/station/api/spec.did | 7 +----- core/station/api/src/external_canister.rs | 11 +++------ .../impl/src/mappers/external_canister.rs | 24 ++----------------- .../impl/src/models/request_operation.rs | 8 +------ 4 files changed, 7 insertions(+), 43 deletions(-) diff --git a/core/station/api/spec.did b/core/station/api/spec.did index 4b27c597b..2e1d2f9e8 100644 --- a/core/station/api/spec.did +++ b/core/station/api/spec.did @@ -794,17 +794,12 @@ type MonitorExternalCanisterStrategyInput = variant { Always : nat; }; -// The input type for specifying the strategy for obtaining cycles for the funding operation. -type MonitorExternalCanisterObtainCyclesStrategy = variant { - Disabled; -}; - // The input type for specifying the strategy for monitoring an external canister. type MonitorExternalCanisterStartInput = record { // The strategy for funding the canister. funding_strategy : MonitorExternalCanisterStrategyInput; // The strategy for obtaining cycles for the funding operation. - cycle_obtain_strategy: opt MonitorExternalCanisterObtainCyclesStrategy; + cycle_obtain_strategy: opt CycleObtainStrategyInput; }; // The operation kind for monitoring an external canister in the station. diff --git a/core/station/api/src/external_canister.rs b/core/station/api/src/external_canister.rs index b023ef08b..f79c9d2db 100644 --- a/core/station/api/src/external_canister.rs +++ b/core/station/api/src/external_canister.rs @@ -1,6 +1,6 @@ use crate::{ - AllowDTO, CanisterInstallMode, ChangeMetadataDTO, MetadataDTO, PaginationInput, - RequestPolicyRuleDTO, Sha256HashDTO, SortDirection, TimestampRfc3339, UuidDTO, + AllowDTO, CanisterInstallMode, ChangeMetadataDTO, CycleObtainStrategyInput, MetadataDTO, + PaginationInput, RequestPolicyRuleDTO, Sha256HashDTO, SortDirection, TimestampRfc3339, UuidDTO, ValidationMethodResourceTargetDTO, }; use candid::{CandidType, Deserialize, Nat, Principal}; @@ -408,7 +408,7 @@ pub enum MonitorExternalCanisterStrategyDTO { #[derive(CandidType, serde::Serialize, Deserialize, Debug, Clone)] pub struct MonitorExternalCanisterStartInput { pub funding_strategy: MonitorExternalCanisterStrategyDTO, - pub obtain_cycles_strategy: Option, + pub obtain_cycles_strategy: Option, } #[derive(CandidType, serde::Serialize, Deserialize, Debug, Clone)] @@ -424,8 +424,3 @@ pub struct MonitorExternalCanisterOperationInput { } pub type MonitorExternalCanisterOperationDTO = MonitorExternalCanisterOperationInput; - -#[derive(CandidType, serde::Serialize, Deserialize, Debug, Clone)] -pub enum MonitorExternalCanisterObtainCyclesStrategyDTO { - Disabled, -} diff --git a/core/station/impl/src/mappers/external_canister.rs b/core/station/impl/src/mappers/external_canister.rs index a5af6bce3..f6e99d23d 100644 --- a/core/station/impl/src/mappers/external_canister.rs +++ b/core/station/impl/src/mappers/external_canister.rs @@ -5,7 +5,7 @@ use crate::{ ConfigureExternalCanisterSettingsInput, CreateExternalCanisterOperationInput, DefiniteCanisterSettingsInput, ExternalCanister, ExternalCanisterCallRequestPolicyRule, ExternalCanisterCallerMethodsPrivileges, ExternalCanisterCallerPrivileges, - ExternalCanisterChangeRequestPolicyRule, ExternalCanisterObtainCyclesStrategy, + ExternalCanisterChangeRequestPolicyRule, ExternalCanisterPermissions, ExternalCanisterRequestPolicies, ExternalCanisterState, FundExternalCanisterOperation, FundExternalCanisterOperationInput, FundExternalCanisterOperationKind, FundExternalCanisterSendCyclesInput, LogVisibility, @@ -20,7 +20,7 @@ use candid::Principal; use canfund::manager::options::{CyclesThreshold, EstimatedRuntime}; use ic_cdk::api::management_canister::main::{self as mgmt}; use orbit_essentials::{repository::SortDirection, utils::timestamp_to_rfc3339}; -use station_api::{ExternalCanisterDTO, MonitorExternalCanisterObtainCyclesStrategyDTO}; +use station_api::ExternalCanisterDTO; use uuid::Uuid; #[derive(Default, Clone, Debug)] @@ -512,23 +512,3 @@ impl From for EstimatedRuntime .with_fallback_min_cycles(input.fallback_min_cycles) } } - -impl From for MonitorExternalCanisterObtainCyclesStrategyDTO { - fn from(strategy: ExternalCanisterObtainCyclesStrategy) -> Self { - match strategy { - ExternalCanisterObtainCyclesStrategy::Disabled => { - MonitorExternalCanisterObtainCyclesStrategyDTO::Disabled - } - } - } -} - -impl From for ExternalCanisterObtainCyclesStrategy { - fn from(value: MonitorExternalCanisterObtainCyclesStrategyDTO) -> Self { - match value { - MonitorExternalCanisterObtainCyclesStrategyDTO::Disabled => { - ExternalCanisterObtainCyclesStrategy::Disabled - } - } - } -} diff --git a/core/station/impl/src/models/request_operation.rs b/core/station/impl/src/models/request_operation.rs index 2335c769a..78c760797 100644 --- a/core/station/impl/src/models/request_operation.rs +++ b/core/station/impl/src/models/request_operation.rs @@ -552,17 +552,11 @@ pub enum MonitorExternalCanisterStrategy { BelowEstimatedRuntime(MonitoringExternalCanisterEstimatedRuntimeInput), } -#[storable] -#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] -pub enum ExternalCanisterObtainCyclesStrategy { - Disabled, -} - #[storable] #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct MonitorExternalCanisterStartInput { pub funding_strategy: MonitorExternalCanisterStrategy, - pub obtain_cycles_strategy: Option, + pub obtain_cycles_strategy: Option, } #[storable] From a36bc729637831697978c61659bbd79fe0e9d8e9 Mon Sep 17 00:00:00 2001 From: Jan Hrubes Date: Wed, 20 Nov 2024 11:37:40 +0100 Subject: [PATCH 3/9] cs --- core/station/impl/src/mappers/external_canister.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/core/station/impl/src/mappers/external_canister.rs b/core/station/impl/src/mappers/external_canister.rs index f6e99d23d..edbfd6ad5 100644 --- a/core/station/impl/src/mappers/external_canister.rs +++ b/core/station/impl/src/mappers/external_canister.rs @@ -5,13 +5,12 @@ use crate::{ ConfigureExternalCanisterSettingsInput, CreateExternalCanisterOperationInput, DefiniteCanisterSettingsInput, ExternalCanister, ExternalCanisterCallRequestPolicyRule, ExternalCanisterCallerMethodsPrivileges, ExternalCanisterCallerPrivileges, - ExternalCanisterChangeRequestPolicyRule, - ExternalCanisterPermissions, ExternalCanisterRequestPolicies, ExternalCanisterState, - FundExternalCanisterOperation, FundExternalCanisterOperationInput, - FundExternalCanisterOperationKind, FundExternalCanisterSendCyclesInput, LogVisibility, - MonitorExternalCanisterOperationInput, MonitorExternalCanisterOperationKind, - MonitorExternalCanisterStartInput, MonitorExternalCanisterStrategy, - MonitoringExternalCanisterCyclesThresholdInput, + ExternalCanisterChangeRequestPolicyRule, ExternalCanisterPermissions, + ExternalCanisterRequestPolicies, ExternalCanisterState, FundExternalCanisterOperation, + FundExternalCanisterOperationInput, FundExternalCanisterOperationKind, + FundExternalCanisterSendCyclesInput, LogVisibility, MonitorExternalCanisterOperationInput, + MonitorExternalCanisterOperationKind, MonitorExternalCanisterStartInput, + MonitorExternalCanisterStrategy, MonitoringExternalCanisterCyclesThresholdInput, MonitoringExternalCanisterEstimatedRuntimeInput, }, repositories::ExternalCanisterWhereClauseSort, From 94b058c2f1a4ae125d840fac77e5097b0d129c47 Mon Sep 17 00:00:00 2001 From: Jan Hrubes Date: Wed, 20 Nov 2024 14:03:49 +0100 Subject: [PATCH 4/9] save data --- .../impl/src/services/external_canister.rs | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/core/station/impl/src/services/external_canister.rs b/core/station/impl/src/services/external_canister.rs index a676778d0..8cb275879 100644 --- a/core/station/impl/src/services/external_canister.rs +++ b/core/station/impl/src/services/external_canister.rs @@ -13,20 +13,7 @@ use crate::models::resource::{ CallExternalCanisterResourceTarget, ExecutionMethodResourceTarget, ExternalCanisterId, ExternalCanisterResourceAction, Resource, ValidationMethodResourceTarget, }; -use crate::models::{ - AddRequestPolicyOperationInput, CanisterExecutionAndValidationMethodPairInput, CanisterMethod, - ConfigureExternalCanisterSettingsInput, CreateExternalCanisterOperationInput, - CreateExternalCanisterOperationKind, DefiniteCanisterSettingsInput, - EditPermissionOperationInput, EditRequestPolicyOperationInput, ExternalCanister, - ExternalCanisterAvailableFilters, ExternalCanisterCallPermission, - ExternalCanisterCallRequestPolicyRule, ExternalCanisterCallRequestPolicyRuleInput, - ExternalCanisterCallerMethodsPrivileges, ExternalCanisterCallerPrivileges, - ExternalCanisterChangeCallPermissionsInput, ExternalCanisterChangeCallRequestPoliciesInput, - ExternalCanisterChangeRequestPolicyRule, ExternalCanisterEntryId, ExternalCanisterKey, - ExternalCanisterPermissions, ExternalCanisterPermissionsUpdateInput, - ExternalCanisterRequestPolicies, ExternalCanisterRequestPoliciesUpdateInput, - MonitorExternalCanisterStrategy, RequestPolicy, -}; +use crate::models::{AddRequestPolicyOperationInput, CanisterExecutionAndValidationMethodPairInput, CanisterMethod, ConfigureExternalCanisterSettingsInput, CreateExternalCanisterOperationInput, CreateExternalCanisterOperationKind, DefiniteCanisterSettingsInput, EditPermissionOperationInput, EditRequestPolicyOperationInput, ExternalCanister, ExternalCanisterAvailableFilters, ExternalCanisterCallPermission, ExternalCanisterCallRequestPolicyRule, ExternalCanisterCallRequestPolicyRuleInput, ExternalCanisterCallerMethodsPrivileges, ExternalCanisterCallerPrivileges, ExternalCanisterChangeCallPermissionsInput, ExternalCanisterChangeCallRequestPoliciesInput, ExternalCanisterChangeRequestPolicyRule, ExternalCanisterEntryId, ExternalCanisterKey, ExternalCanisterMonitoring, ExternalCanisterPermissions, ExternalCanisterPermissionsUpdateInput, ExternalCanisterRequestPolicies, ExternalCanisterRequestPoliciesUpdateInput, MonitorExternalCanisterStrategy, RequestPolicy}; use crate::repositories::permission::{PermissionRepository, PERMISSION_REPOSITORY}; use crate::repositories::{ ExternalCanisterRepository, ExternalCanisterWhereClause, RequestPolicyRepository, @@ -1029,15 +1016,40 @@ impl ExternalCanisterService { canister_id: Principal, strategy: MonitorExternalCanisterStrategy, ) -> ServiceResult<()> { + let mut external_canister = self.get_external_canister_by_canister_id(&canister_id)?; + if let Some(monitoring) = &external_canister.monitoring { + Err(ExternalCanisterError::Failed { + reason: format!( + "Failed to monitor canister {}. The canister is already monitored.", + canister_id.to_text(), + ), + })?; + } + self.cycle_manager - .add_canister(canister_id, strategy.into()); + .add_canister(canister_id, strategy.clone().into()); + + external_canister.monitoring = Some(ExternalCanisterMonitoring{ + funding_strategy: strategy, + obtain_cycles_strategy: None, + }); + + self.external_canister_repository + .insert(external_canister.key(), external_canister.clone()); Ok(()) } pub fn canister_monitor_stop(&self, canister_id: Principal) -> ServiceResult<()> { + let mut external_canister = self.get_external_canister_by_canister_id(&canister_id)?; + self.cycle_manager.remove_canister(canister_id); + external_canister.monitoring = None; + + self.external_canister_repository + .insert(external_canister.key(), external_canister.clone()); + Ok(()) } From b82933505453d9343682b0d454abc5ef92b8af70 Mon Sep 17 00:00:00 2001 From: Jan Hrubes Date: Thu, 21 Nov 2024 09:53:05 +0100 Subject: [PATCH 5/9] generate station --- apps/wallet/src/generated/station/station.did | 8 ++++++-- apps/wallet/src/generated/station/station.did.d.ts | 4 +++- apps/wallet/src/generated/station/station.did.js | 12 +++++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/wallet/src/generated/station/station.did b/apps/wallet/src/generated/station/station.did index f440dd406..2e1d2f9e8 100644 --- a/apps/wallet/src/generated/station/station.did +++ b/apps/wallet/src/generated/station/station.did @@ -796,8 +796,10 @@ type MonitorExternalCanisterStrategyInput = variant { // The input type for specifying the strategy for monitoring an external canister. type MonitorExternalCanisterStartInput = record { - // The amount of cycles to send to the canister. - strategy : MonitorExternalCanisterStrategyInput; + // The strategy for funding the canister. + funding_strategy : MonitorExternalCanisterStrategyInput; + // The strategy for obtaining cycles for the funding operation. + cycle_obtain_strategy: opt CycleObtainStrategyInput; }; // The operation kind for monitoring an external canister in the station. @@ -2595,6 +2597,8 @@ type ExternalCanister = record { created_at : TimestampRFC3339; // The time at which the canister was last modified, if available. modified_at : opt TimestampRFC3339; + // Monitoring configuration for the canister. + monitoring : opt MonitorExternalCanisterStartInput; }; // The state of the external canister. diff --git a/apps/wallet/src/generated/station/station.did.d.ts b/apps/wallet/src/generated/station/station.did.d.ts index 426766b9e..3af383bf4 100644 --- a/apps/wallet/src/generated/station/station.did.d.ts +++ b/apps/wallet/src/generated/station/station.did.d.ts @@ -402,6 +402,7 @@ export interface ExternalCanister { 'created_at' : TimestampRFC3339, 'request_policies' : ExternalCanisterRequestPolicies, 'state' : ExternalCanisterState, + 'monitoring' : [] | [MonitorExternalCanisterStartInput], } export interface ExternalCanisterCallPermission { 'execution_method' : string, @@ -840,7 +841,8 @@ export type MonitorExternalCanisterOperationKind = { } | { 'Stop' : null }; export interface MonitorExternalCanisterStartInput { - 'strategy' : MonitorExternalCanisterStrategyInput, + 'cycle_obtain_strategy' : [] | [CycleObtainStrategyInput], + 'funding_strategy' : MonitorExternalCanisterStrategyInput, } export type MonitorExternalCanisterStrategyInput = { 'Always' : bigint } | { 'BelowThreshold' : MonitoringExternalCanisterCyclesThresholdInput } | diff --git a/apps/wallet/src/generated/station/station.did.js b/apps/wallet/src/generated/station/station.did.js index e4fea8d13..4d3dbffdd 100644 --- a/apps/wallet/src/generated/station/station.did.js +++ b/apps/wallet/src/generated/station/station.did.js @@ -311,6 +311,10 @@ export const idlFactory = ({ IDL }) => { 'module_checksum' : Sha256Hash, 'arg_checksum' : IDL.Opt(Sha256Hash), }); + const CycleObtainStrategyInput = IDL.Variant({ + 'Disabled' : IDL.Null, + 'MintFromNativeToken' : IDL.Record({ 'account_id' : UUID }), + }); const MonitoringExternalCanisterCyclesThresholdInput = IDL.Record({ 'fund_cycles' : IDL.Nat, 'min_cycles' : IDL.Nat, @@ -328,7 +332,8 @@ export const idlFactory = ({ IDL }) => { 'BelowEstimatedRuntime' : MonitoringExternalCanisterEstimatedRuntimeInput, }); const MonitorExternalCanisterStartInput = IDL.Record({ - 'strategy' : MonitorExternalCanisterStrategyInput, + 'cycle_obtain_strategy' : IDL.Opt(CycleObtainStrategyInput), + 'funding_strategy' : MonitorExternalCanisterStrategyInput, }); const MonitorExternalCanisterOperationKind = IDL.Variant({ 'Start' : MonitorExternalCanisterStartInput, @@ -504,10 +509,6 @@ export const idlFactory = ({ IDL }) => { 'identities' : IDL.Opt(IDL.Vec(IDL.Principal)), }); const EditUserOperation = IDL.Record({ 'input' : EditUserOperationInput }); - const CycleObtainStrategyInput = IDL.Variant({ - 'Disabled' : IDL.Null, - 'MintFromNativeToken' : IDL.Record({ 'account_id' : UUID }), - }); const ManageSystemInfoOperationInput = IDL.Record({ 'name' : IDL.Opt(IDL.Text), 'cycle_obtain_strategy' : IDL.Opt(CycleObtainStrategyInput), @@ -933,6 +934,7 @@ export const idlFactory = ({ IDL }) => { 'created_at' : TimestampRFC3339, 'request_policies' : ExternalCanisterRequestPolicies, 'state' : ExternalCanisterState, + 'monitoring' : IDL.Opt(MonitorExternalCanisterStartInput), }); const GetExternalCanisterResult = IDL.Variant({ 'Ok' : IDL.Record({ From 3c2dd3d46450ad9250440e2761420bfc729a48b8 Mon Sep 17 00:00:00 2001 From: Jan Hrubes Date: Thu, 21 Nov 2024 10:20:25 +0100 Subject: [PATCH 6/9] fix validation --- .../components/external-canisters/CanisterMonitorDialog.vue | 3 ++- core/station/impl/src/services/external_canister.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/wallet/src/components/external-canisters/CanisterMonitorDialog.vue b/apps/wallet/src/components/external-canisters/CanisterMonitorDialog.vue index 84ad563dc..e15affd25 100644 --- a/apps/wallet/src/components/external-canisters/CanisterMonitorDialog.vue +++ b/apps/wallet/src/components/external-canisters/CanisterMonitorDialog.vue @@ -122,7 +122,8 @@ const submit = async (input: CanisterMonitorModel) => { canister_id: assertAndReturn(input.canisterId, 'canisterId'), kind: { Start: { - strategy: assertAndReturn(input.strategy, 'strategy'), + funding_strategy: assertAndReturn(input.strategy, 'strategy'), + cycle_obtain_strategy: [], }, }, }); diff --git a/core/station/impl/src/services/external_canister.rs b/core/station/impl/src/services/external_canister.rs index 8cb275879..9a6195d2f 100644 --- a/core/station/impl/src/services/external_canister.rs +++ b/core/station/impl/src/services/external_canister.rs @@ -1017,7 +1017,7 @@ impl ExternalCanisterService { strategy: MonitorExternalCanisterStrategy, ) -> ServiceResult<()> { let mut external_canister = self.get_external_canister_by_canister_id(&canister_id)?; - if let Some(monitoring) = &external_canister.monitoring { + if let Some(_) = &external_canister.monitoring { Err(ExternalCanisterError::Failed { reason: format!( "Failed to monitor canister {}. The canister is already monitored.", From 031c1188bd4a6a0e2bb9d6b7ac1abd69e5cae1ff Mon Sep 17 00:00:00 2001 From: Jan Hrubes Date: Thu, 21 Nov 2024 11:31:03 +0100 Subject: [PATCH 7/9] cs --- .../impl/src/services/external_canister.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/core/station/impl/src/services/external_canister.rs b/core/station/impl/src/services/external_canister.rs index 9a6195d2f..641b355d2 100644 --- a/core/station/impl/src/services/external_canister.rs +++ b/core/station/impl/src/services/external_canister.rs @@ -13,7 +13,20 @@ use crate::models::resource::{ CallExternalCanisterResourceTarget, ExecutionMethodResourceTarget, ExternalCanisterId, ExternalCanisterResourceAction, Resource, ValidationMethodResourceTarget, }; -use crate::models::{AddRequestPolicyOperationInput, CanisterExecutionAndValidationMethodPairInput, CanisterMethod, ConfigureExternalCanisterSettingsInput, CreateExternalCanisterOperationInput, CreateExternalCanisterOperationKind, DefiniteCanisterSettingsInput, EditPermissionOperationInput, EditRequestPolicyOperationInput, ExternalCanister, ExternalCanisterAvailableFilters, ExternalCanisterCallPermission, ExternalCanisterCallRequestPolicyRule, ExternalCanisterCallRequestPolicyRuleInput, ExternalCanisterCallerMethodsPrivileges, ExternalCanisterCallerPrivileges, ExternalCanisterChangeCallPermissionsInput, ExternalCanisterChangeCallRequestPoliciesInput, ExternalCanisterChangeRequestPolicyRule, ExternalCanisterEntryId, ExternalCanisterKey, ExternalCanisterMonitoring, ExternalCanisterPermissions, ExternalCanisterPermissionsUpdateInput, ExternalCanisterRequestPolicies, ExternalCanisterRequestPoliciesUpdateInput, MonitorExternalCanisterStrategy, RequestPolicy}; +use crate::models::{ + AddRequestPolicyOperationInput, CanisterExecutionAndValidationMethodPairInput, CanisterMethod, + ConfigureExternalCanisterSettingsInput, CreateExternalCanisterOperationInput, + CreateExternalCanisterOperationKind, DefiniteCanisterSettingsInput, + EditPermissionOperationInput, EditRequestPolicyOperationInput, ExternalCanister, + ExternalCanisterAvailableFilters, ExternalCanisterCallPermission, + ExternalCanisterCallRequestPolicyRule, ExternalCanisterCallRequestPolicyRuleInput, + ExternalCanisterCallerMethodsPrivileges, ExternalCanisterCallerPrivileges, + ExternalCanisterChangeCallPermissionsInput, ExternalCanisterChangeCallRequestPoliciesInput, + ExternalCanisterChangeRequestPolicyRule, ExternalCanisterEntryId, ExternalCanisterKey, + ExternalCanisterMonitoring, ExternalCanisterPermissions, + ExternalCanisterPermissionsUpdateInput, ExternalCanisterRequestPolicies, + ExternalCanisterRequestPoliciesUpdateInput, MonitorExternalCanisterStrategy, RequestPolicy, +}; use crate::repositories::permission::{PermissionRepository, PERMISSION_REPOSITORY}; use crate::repositories::{ ExternalCanisterRepository, ExternalCanisterWhereClause, RequestPolicyRepository, @@ -1017,7 +1030,7 @@ impl ExternalCanisterService { strategy: MonitorExternalCanisterStrategy, ) -> ServiceResult<()> { let mut external_canister = self.get_external_canister_by_canister_id(&canister_id)?; - if let Some(_) = &external_canister.monitoring { + if external_canister.monitoring.is_some() { Err(ExternalCanisterError::Failed { reason: format!( "Failed to monitor canister {}. The canister is already monitored.", @@ -1029,7 +1042,7 @@ impl ExternalCanisterService { self.cycle_manager .add_canister(canister_id, strategy.clone().into()); - external_canister.monitoring = Some(ExternalCanisterMonitoring{ + external_canister.monitoring = Some(ExternalCanisterMonitoring { funding_strategy: strategy, obtain_cycles_strategy: None, }); From 5fd7e3a042a47f66ea48e39d45eec46508bd05d1 Mon Sep 17 00:00:00 2001 From: Jan Hrubes Date: Thu, 21 Nov 2024 14:27:55 +0100 Subject: [PATCH 8/9] fix naming --- core/station/api/src/external_canister.rs | 2 +- core/station/impl/src/mappers/external_canister.rs | 4 ++-- core/station/impl/src/models/request_operation.rs | 2 +- core/station/impl/src/services/account.rs | 2 +- core/station/impl/src/services/cycle_manager.rs | 2 +- core/station/impl/src/services/external_canister.rs | 2 +- core/station/impl/src/services/system.rs | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/station/api/src/external_canister.rs b/core/station/api/src/external_canister.rs index f79c9d2db..b7765db40 100644 --- a/core/station/api/src/external_canister.rs +++ b/core/station/api/src/external_canister.rs @@ -408,7 +408,7 @@ pub enum MonitorExternalCanisterStrategyDTO { #[derive(CandidType, serde::Serialize, Deserialize, Debug, Clone)] pub struct MonitorExternalCanisterStartInput { pub funding_strategy: MonitorExternalCanisterStrategyDTO, - pub obtain_cycles_strategy: Option, + pub cycle_obtain_strategy: Option, } #[derive(CandidType, serde::Serialize, Deserialize, Debug, Clone)] diff --git a/core/station/impl/src/mappers/external_canister.rs b/core/station/impl/src/mappers/external_canister.rs index edbfd6ad5..fb3bb7bc2 100644 --- a/core/station/impl/src/mappers/external_canister.rs +++ b/core/station/impl/src/mappers/external_canister.rs @@ -379,7 +379,7 @@ impl From for MonitorExternalCan fn from(input: station_api::MonitorExternalCanisterStartInput) -> Self { MonitorExternalCanisterStartInput { funding_strategy: input.funding_strategy.into(), - obtain_cycles_strategy: input.obtain_cycles_strategy.map(Into::into), + cycle_obtain_strategy: input.cycle_obtain_strategy.map(Into::into), } } } @@ -388,7 +388,7 @@ impl From for station_api::MonitorExternalCan fn from(input: MonitorExternalCanisterStartInput) -> Self { station_api::MonitorExternalCanisterStartInput { funding_strategy: input.funding_strategy.into(), - obtain_cycles_strategy: input.obtain_cycles_strategy.map(Into::into), + cycle_obtain_strategy: input.cycle_obtain_strategy.map(Into::into), } } } diff --git a/core/station/impl/src/models/request_operation.rs b/core/station/impl/src/models/request_operation.rs index 78c760797..7850cc1ee 100644 --- a/core/station/impl/src/models/request_operation.rs +++ b/core/station/impl/src/models/request_operation.rs @@ -556,7 +556,7 @@ pub enum MonitorExternalCanisterStrategy { #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct MonitorExternalCanisterStartInput { pub funding_strategy: MonitorExternalCanisterStrategy, - pub obtain_cycles_strategy: Option, + pub cycle_obtain_strategy: Option, } #[storable] diff --git a/core/station/impl/src/services/account.rs b/core/station/impl/src/services/account.rs index 8773f0ea1..5885f3091 100644 --- a/core/station/impl/src/services/account.rs +++ b/core/station/impl/src/services/account.rs @@ -260,7 +260,7 @@ impl AccountService { write_system_info(system_info); #[cfg(target_arch = "wasm32")] - crate::services::cycle_manager::CYCLE_MANAGER.set_global_obtain_cycles_strategy( + crate::services::cycle_manager::CYCLE_MANAGER.set_global_cycle_obtain_strategy( &CycleObtainStrategy::MintFromNativeToken { account_id: new_account.id, }, diff --git a/core/station/impl/src/services/cycle_manager.rs b/core/station/impl/src/services/cycle_manager.rs index 2d264c1a0..cebdbb2b6 100644 --- a/core/station/impl/src/services/cycle_manager.rs +++ b/core/station/impl/src/services/cycle_manager.rs @@ -69,7 +69,7 @@ impl CycleManager { ic_cdk::print("Cycle manager: monitoring started."); } - pub fn set_global_obtain_cycles_strategy(&self, strategy: &CycleObtainStrategy) { + pub fn set_global_cycle_obtain_strategy(&self, strategy: &CycleObtainStrategy) { FUND_MANAGER.with(|manager| { let mut fund_manager = manager.borrow_mut(); let options = fund_manager.get_options(); diff --git a/core/station/impl/src/services/external_canister.rs b/core/station/impl/src/services/external_canister.rs index 641b355d2..5e58c77ec 100644 --- a/core/station/impl/src/services/external_canister.rs +++ b/core/station/impl/src/services/external_canister.rs @@ -1044,7 +1044,7 @@ impl ExternalCanisterService { external_canister.monitoring = Some(ExternalCanisterMonitoring { funding_strategy: strategy, - obtain_cycles_strategy: None, + cycle_obtain_strategy: None, }); self.external_canister_repository diff --git a/core/station/impl/src/services/system.rs b/core/station/impl/src/services/system.rs index 95c14213a..6998d7b70 100644 --- a/core/station/impl/src/services/system.rs +++ b/core/station/impl/src/services/system.rs @@ -698,7 +698,7 @@ mod install_canister_handlers { .with_fallback_fund_cycles(250_000_000_000), ); - CYCLE_MANAGER.set_global_obtain_cycles_strategy(cycle_obtain_strategy); + CYCLE_MANAGER.set_global_cycle_obtain_strategy(cycle_obtain_strategy); CYCLE_MANAGER.add_canister(id(), fund_strategy.clone()); CYCLE_MANAGER.add_canister(upgrader_id, fund_strategy.clone()); From dd315215bd1126bdf433b1a0037f80d9245c3c05 Mon Sep 17 00:00:00 2001 From: Jan Hrubes Date: Fri, 22 Nov 2024 10:18:44 +0100 Subject: [PATCH 9/9] feat(wallet): stop monitoring for external canister (#431) --- apps/wallet/src/locales/en.locale.ts | 1 + apps/wallet/src/locales/fr.locale.ts | 1 + apps/wallet/src/locales/pt.locale.ts | 1 + .../src/pages/ExternalCanisterDetailPage.vue | 69 ++++++++++++++++--- .../impl/src/services/external_canister.rs | 2 +- 5 files changed, 65 insertions(+), 9 deletions(-) diff --git a/apps/wallet/src/locales/en.locale.ts b/apps/wallet/src/locales/en.locale.ts index 3b97e2f32..319ff527f 100644 --- a/apps/wallet/src/locales/en.locale.ts +++ b/apps/wallet/src/locales/en.locale.ts @@ -463,6 +463,7 @@ export default { start_monitoring: 'Start Monitoring', monitor: { title: 'Monitor cycles', + stop_title: 'Stop Monitoring', strategy: { label: 'Monitoring strategy', BelowEstimatedRuntime: 'Below estimated runtime', diff --git a/apps/wallet/src/locales/fr.locale.ts b/apps/wallet/src/locales/fr.locale.ts index 3f5b88f76..87e5dafdd 100644 --- a/apps/wallet/src/locales/fr.locale.ts +++ b/apps/wallet/src/locales/fr.locale.ts @@ -470,6 +470,7 @@ export default { start_monitoring: 'Démarrer la surveillance', monitor: { title: 'Contrôler les cycles', + stop_title: 'Arrêter la surveillance', strategy: { label: 'Stratégie de suivi', BelowEstimatedRuntime: "Durée d'exécution inférieure à l'estimation", diff --git a/apps/wallet/src/locales/pt.locale.ts b/apps/wallet/src/locales/pt.locale.ts index 134a16b56..630c17865 100644 --- a/apps/wallet/src/locales/pt.locale.ts +++ b/apps/wallet/src/locales/pt.locale.ts @@ -465,6 +465,7 @@ export default { start_monitoring: 'Iniciar monitoramento', monitor: { title: 'Monitorizar ciclos', + stop_title: 'Parar monitorização', strategy: { label: 'Estratégia de controlo', BelowEstimatedRuntime: 'Tempo de execução inferior ao estimado', diff --git a/apps/wallet/src/pages/ExternalCanisterDetailPage.vue b/apps/wallet/src/pages/ExternalCanisterDetailPage.vue index 29a4cb0d0..7eb6213ee 100644 --- a/apps/wallet/src/pages/ExternalCanisterDetailPage.vue +++ b/apps/wallet/src/pages/ExternalCanisterDetailPage.vue @@ -78,7 +78,9 @@
{{ $t('external_canisters.configuration') }}
-
+
+ +
{{ $t('external_canisters.ic_settings') }}
-
+
+ +
{{ $t('external_canisters.unlink') }}
-
+
+ +
@@ -289,6 +295,11 @@ + {{ $t(`external_canisters.cycles`) }} @@ -397,9 +422,12 @@ diff --git a/core/station/impl/src/services/external_canister.rs b/core/station/impl/src/services/external_canister.rs index 5e58c77ec..4577223cc 100644 --- a/core/station/impl/src/services/external_canister.rs +++ b/core/station/impl/src/services/external_canister.rs @@ -1044,7 +1044,7 @@ impl ExternalCanisterService { external_canister.monitoring = Some(ExternalCanisterMonitoring { funding_strategy: strategy, - cycle_obtain_strategy: None, + cycle_obtain_strategy: None, // TODO add cycle obtain strategy }); self.external_canister_repository