pub(crate) fn deposit_funds(
        &self,
        sender: PrincipalId,
        canister_id: CanisterId,
        mut funds: Funds,
        state: &mut ReplicatedState,
    ) -> (Funds, Result<(), CanisterManagerError>) {
        match self.validate_canister_exists(state, canister_id) {
            Err(err) => (funds, Err(err)),
            Ok(canister) => {
                if let Err(err) = self.validate_controller(&canister, &sender) {
                    return (funds, Err(err));
                }
                let canister = state.canister_state_mut(&canister_id).unwrap();
                self.cycles_account_manager
                    .add_cycles(&mut canister.system_state, funds.take_cycles());
                (Funds::zero(), Ok(()))
            }
        }
    }
/// Deposits the amount of funds specified from the sender to the target
/// `canister_id`.
///
/// # Errors
///
/// Returns a `CanisterManagerError` in case the canister does not exist or
/// this was invoked not by the controller or the receiving canister did not
/// have enough cycles to cover the cost.
Deposits the amount of funds specified from the sender to the target
`canister_id`.
Deposits the amount of funds specified from the sender to the target ` canister_id ` .
pub(crate) fn deposit_funds(
        &self,
        sender: PrincipalId,
        canister_id: CanisterId,
        mut funds: Funds,
        state: &mut ReplicatedState,
    ) -> (Funds, Result<(), CanisterManagerError>) {
        match self.validate_canister_exists(state, canister_id) {
            Err(err) => (funds, Err(err)),
            Ok(canister) => {
                if let Err(err) = self.validate_controller(&canister, &sender) {
                    return (funds, Err(err));
                }
                let canister = state.canister_state_mut(&canister_id).unwrap();
                self.cycles_account_manager
                    .add_cycles(&mut canister.system_state, funds.take_cycles());
                (Funds::zero(), Ok(()))
            }
        }
    }
pub ( crate ) fn deposit_funds ( & self , sender : PrincipalId , canister_id : CanisterId , mut funds : Funds , state : & mut ReplicatedState , ) -> ( Funds , Result < ( ) , CanisterManagerError > ) { match self . validate_canister_exists ( state , canister_id ) { Err ( err ) => ( funds , Err ( err ) ) , Ok ( canister ) => { if let Err ( err ) = self . validate_controller ( & canister , & sender ) { return ( funds , Err ( err ) ) ; } let canister = state . canister_state_mut ( & canister_id ) . unwrap ( ) ; self . cycles_account_manager . add_cycles ( & mut canister . system_state , funds . take_cycles ( ) ) ; ( Funds :: zero ( ) , Ok ( ( ) ) ) } } }
Deposits the amount of funds specified from the sender to the target
`canister_id`.
Deposits the amount of funds specified from the sender to the target ` canister_id ` .
&self
sender
PrincipalId
canister_id
CanisterId
funds
Funds
state
&mut ReplicatedState
&self
sender
PrincipalId
canister_id
CanisterId
funds
Funds
state
&mut ReplicatedState
errors
Returns a `CanisterManagerError` in case the canister does not exist or
this was invoked not by the controller or the receiving canister did not
have enough cycles to cover the cost.
Returns a ` CanisterManagerError ` in case the canister does not exist or this was invoked not by the controller or the receiving canister did not have enough cycles to cover the cost .