pub(crate) fn deposit_near_for_account_to_stake(
        &mut self,
        account: &mut RegisteredAccount,
        amount: domain::YoctoNear,
    ) -> domain::BatchId {
        assert!(amount.value() > 0, DEPOSIT_REQUIRED_FOR_STAKE);

        self.claim_receipt_funds(account);

        // use current batch if not staking, i.e., the stake batch is not running
        if !self.stake_batch_locked() {
            // apply at contract level
            let mut contract_batch = self.stake_batch.unwrap_or_else(|| self.new_stake_batch());
            contract_batch.add(amount);
            self.stake_batch = Some(contract_batch);

            // apply at account level
            // NOTE: account batch ID must match contract batch ID
            let mut account_batch = account
                .stake_batch
                .unwrap_or_else(|| contract_batch.id().new_stake_batch());
            account_batch.add(amount);
            account.stake_batch = Some(account_batch);

            account_batch.id()
        } else {
            // apply at contract level
            let mut contract_batch = self
                .next_stake_batch
                .unwrap_or_else(|| self.new_stake_batch());
            contract_batch.add(amount);
            self.next_stake_batch = Some(contract_batch);

            // apply at account level
            // NOTE: account batch ID must match contract batch ID
            let mut account_batch = account
                .next_stake_batch
                .unwrap_or_else(|| contract_batch.id().new_stake_batch());
            account_batch.add(amount);
            account.next_stake_batch = Some(account_batch);

            account_batch.id()
        }
    }
/// batches the NEAR to stake at the contract level and account level
///
/// ## Panics
/// if [amount] is zero
///
/// ## Notes
/// - before applying the deposit, batch receipts are processed [claim_receipt_funds]
batches the NEAR to stake at the contract level and account level
batches the NEAR to stake at the contract level and account level
pub(crate) fn deposit_near_for_account_to_stake(
        &mut self,
        account: &mut RegisteredAccount,
        amount: domain::YoctoNear,
    ) -> domain::BatchId {
        assert!(amount.value() > 0, DEPOSIT_REQUIRED_FOR_STAKE);
        self.claim_receipt_funds(account);
        // use current batch if not staking, i.e., the stake batch is not running
        if !self.stake_batch_locked() {
            // apply at contract level
            let mut contract_batch = self.stake_batch.unwrap_or_else(|| self.new_stake_batch());
            contract_batch.add(amount);
            self.stake_batch = Some(contract_batch);
            // apply at account level
            // NOTE: account batch ID must match contract batch ID
            let mut account_batch = account
                .stake_batch
                .unwrap_or_else(|| contract_batch.id().new_stake_batch());
            account_batch.add(amount);
            account.stake_batch = Some(account_batch);
            account_batch.id()
        } else {
            // apply at contract level
            let mut contract_batch = self
                .next_stake_batch
                .unwrap_or_else(|| self.new_stake_batch());
            contract_batch.add(amount);
            self.next_stake_batch = Some(contract_batch);
            // apply at account level
            // NOTE: account batch ID must match contract batch ID
            let mut account_batch = account
                .next_stake_batch
                .unwrap_or_else(|| contract_batch.id().new_stake_batch());
            account_batch.add(amount);
            account.next_stake_batch = Some(account_batch);
            account_batch.id()
        }
    }
pub ( crate ) fn deposit_near_for_account_to_stake ( & mut self , account : & mut RegisteredAccount , amount : domain :: YoctoNear , ) -> domain :: BatchId { assert ! ( amount value ( ) 0 DEPOSIT_REQUIRED_FOR_STAKE ) ; self . claim_receipt_funds ( account ) ; // use current batch if not staking, i.e., the stake batch is not running if ! self . stake_batch_locked ( ) { // apply at contract level let mut contract_batch = self . stake_batch . unwrap_or_else ( | | self . new_stake_batch ( ) ) ; contract_batch . add ( amount ) ; self . stake_batch = Some ( contract_batch ) ; // apply at account level // NOTE: account batch ID must match contract batch ID let mut account_batch = account . stake_batch . unwrap_or_else ( | | contract_batch . id ( ) . new_stake_batch ( ) ) ; account_batch . add ( amount ) ; account . stake_batch = Some ( account_batch ) ; account_batch . id ( ) } else { // apply at contract level let mut contract_batch = self . next_stake_batch . unwrap_or_else ( | | self . new_stake_batch ( ) ) ; contract_batch . add ( amount ) ; self . next_stake_batch = Some ( contract_batch ) ; // apply at account level // NOTE: account batch ID must match contract batch ID let mut account_batch = account . next_stake_batch . unwrap_or_else ( | | contract_batch . id ( ) . new_stake_batch ( ) ) ; account_batch . add ( amount ) ; account . next_stake_batch = Some ( account_batch ) ; account_batch . id ( ) } }
batches the NEAR to stake at the contract level and account level
batches the NEAR to stake at the contract level and account level
&mut self
account
&mut RegisteredAccount
amount
domain::YoctoNear
panics
if [amount] is zero
if [ amount ] is zero
notes
before applying the deposit, batch receipts are processed [claim_receipt_funds]
before applying the deposit batch receipts are processed [ claim_receipt_funds ]