MCPcopy Create free account
hub / github.com/dfinity/orbit / add_deployed_station

Method add_deployed_station

core/control-panel/impl/src/services/user.rs:134–162  ·  view source on GitHub ↗
(
        &self,
        user_id: &UserId,
        station_canister_id: Principal,
        ctx: &CallContext,
    )

Source from the content-addressed store, hash-verified

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> {

Callers 1

deploy_stationMethod · 0.45

Calls 8

canister_configFunction · 0.85
write_canister_configFunction · 0.85
get_userMethod · 0.45
validateMethod · 0.45
insertMethod · 0.45
to_keyMethod · 0.45
registerMethod · 0.45

Tested by

no test coverage detected