(
&self,
user_id: &UserId,
station_canister_id: Principal,
ctx: &CallContext,
)
| 132 | } |
| 133 | |
| 134 | pub fn add_deployed_station( |
| 135 | &self, |
| 136 | user_id: &UserId, |
| 137 | station_canister_id: Principal, |
| 138 | ctx: &CallContext, |
| 139 | ) -> ServiceResult<User> { |
| 140 | let mut user = self.get_user(user_id, ctx)?; |
| 141 | let mut config = canister_config().ok_or(DeployError::Failed { |
| 142 | reason: "Canister config not initialized.".to_string(), |
| 143 | })?; |
| 144 | |
| 145 | config.global_rate_limiter.add_deployed_station(); |
| 146 | user.add_deployed_station(station_canister_id); |
| 147 | |
| 148 | user.validate()?; |
| 149 | |
| 150 | write_canister_config(config); |
| 151 | self.user_repository.insert(user.to_key(), user.clone()); |
| 152 | |
| 153 | FUND_MANAGER.with(|fund_manager| { |
| 154 | fund_manager.borrow_mut().register( |
| 155 | station_canister_id, |
| 156 | RegisterOpts::new() |
| 157 | .with_cycles_fetcher(CANISTER_SERVICE.create_station_cycles_fetcher()), |
| 158 | ); |
| 159 | }); |
| 160 | |
| 161 | Ok(user) |
| 162 | } |
| 163 | |
| 164 | /// Checks if a user can deploy a station. |
| 165 | pub fn can_deploy_station(&self, ctx: &CallContext) -> ServiceResult<CanDeployStation> { |
no test coverage detected