pub(crate) fn deposit_with_storage_check(&mut self, token: &AccountId, amount: Balance) -> bool { 
        if let Some(balance) = self.tokens.get(token) {
            // token has been registered, just add without storage check, 
            let new_balance = balance + amount;
            self.tokens.insert(token, &new_balance);
            true
        } else if let Some(x) = self.legacy_tokens.get_mut(token) {
            // token has been registered, just add without storage check
            *x += amount;
            true
        } else {
            // check storage after insert, if fail should unregister the token
            self.tokens.insert(token, &(amount));
            if self.storage_usage() <= self.near_amount {
                true
            } else {
                self.tokens.remove(token);
                false
            }
        }
    }
/// Deposit amount to the balance of given token,
/// if given token not register and not enough storage, deposit fails 
Deposit amount to the balance of given token,
if given token not register and not enough storage, deposit fails
Deposit amount to the balance of given token if given token not register and not enough storage deposit fails
pub(crate) fn deposit_with_storage_check(&mut self, token: &AccountId, amount: Balance) -> bool { 
        if let Some(balance) = self.tokens.get(token) {
            // token has been registered, just add without storage check, 
            let new_balance = balance + amount;
            self.tokens.insert(token, &new_balance);
            true
        } else if let Some(x) = self.legacy_tokens.get_mut(token) {
            // token has been registered, just add without storage check
            *x += amount;
            true
        } else {
            // check storage after insert, if fail should unregister the token
            self.tokens.insert(token, &(amount));
            if self.storage_usage() <= self.near_amount {
                true
            } else {
                self.tokens.remove(token);
                false
            }
        }
    }
pub ( crate ) fn deposit_with_storage_check ( & mut self , token : & AccountId , amount : Balance ) -> bool { if let Some ( balance ) = self . tokens . get ( token ) { // token has been registered, just add without storage check,  let new_balance = balance + amount ; self . tokens . insert ( token , & new_balance ) ; true } else if let Some ( x ) = self . legacy_tokens . get_mut ( token ) { // token has been registered, just add without storage check * x += amount ; true } else { // check storage after insert, if fail should unregister the token self . tokens . insert ( token , & ( amount ) ) ; if self . storage_usage ( ) <= self . near_amount { true } else { self . tokens . remove ( token ) ; false } } }
Deposit amount to the balance of given token,
if given token not register and not enough storage, deposit fails
Deposit amount to the balance of given token if given token not register and not enough storage deposit fails
&mut self
token
&AccountId
amount
Balance
&mut self
token
&AccountId
amount
Balance