pub fn claim_unbonded_withdrawals(
    depositor: &mut DepositorInfo,
    block: &BlockInfo,
    cap: Option<Uint128>,
) -> StdResult<Uint128> {
    let mut to_send = Uint128::zero();

    if depositor.unbonding_info.is_empty() {
        return Ok(to_send);
    }

    let (_send, waiting): (Vec<_>, _) = depositor.unbonding_info.iter().cloned().partition(|c| {
        // if mature and we can pay fully, then include in _send
        if c.release_at.is_expired(block) {
            let new_amount = c.amount;
            if let Some(limit) = cap {
                if to_send + Uint128::from(new_amount) > limit {
                    return false;
                }
            }
            to_send += Uint128::from(new_amount);
            true
        } else {
            //nothing to send, leave all claims in waiting status
            false
        }
    });
    depositor.unbonding_info = waiting;
    Ok(to_send)
}
/// This iterates over all mature claims for the address, and removes them, up to an optional cap.
/// it removes the finished claims and returns the total amount of tokens to be released.
This iterates over all mature claims for the address, and removes them, up to an optional cap.
it removes the finished claims and returns the total amount of tokens to be released.
This iterates over all mature claims for the address and removes them up to an optional cap . it removes the finished claims and returns the total amount of tokens to be released .
pub fn claim_unbonded_withdrawals(
    depositor: &mut DepositorInfo,
    block: &BlockInfo,
    cap: Option<Uint128>,
) -> StdResult<Uint128> {
    let mut to_send = Uint128::zero();
    if depositor.unbonding_info.is_empty() {
        return Ok(to_send);
    }
    let (_send, waiting): (Vec<_>, _) = depositor.unbonding_info.iter().cloned().partition(|c| {
        // if mature and we can pay fully, then include in _send
        if c.release_at.is_expired(block) {
            let new_amount = c.amount;
            if let Some(limit) = cap {
                if to_send + Uint128::from(new_amount) > limit {
                    return false;
                }
            }
            to_send += Uint128::from(new_amount);
            true
        } else {
            //nothing to send, leave all claims in waiting status
            false
        }
    });
    depositor.unbonding_info = waiting;
    Ok(to_send)
}
pub fn claim_unbonded_withdrawals ( depositor : & mut DepositorInfo , block : & BlockInfo , cap : Option < Uint128 > , ) -> StdResult < Uint128 > { let mut to_send = Uint128 :: zero ( ) ; if depositor . unbonding_info . is_empty ( ) { return Ok ( to_send ) ; } let ( _send , waiting ) : ( Vec < _ > , _ ) = depositor . unbonding_info . iter ( ) . cloned ( ) . partition ( | c | { // if mature and we can pay fully, then include in _send if c . release_at . is_expired ( block ) { let new_amount = c . amount ; if let Some ( limit ) = cap { if to_send + Uint128 :: from ( new_amount ) > limit { return false ; } } to_send += Uint128 :: from ( new_amount ) ; true } else { //nothing to send, leave all claims in waiting status false } } ) ; depositor . unbonding_info = waiting ; Ok ( to_send ) }
This iterates over all mature claims for the address, and removes them, up to an optional cap.
This iterates over all mature claims for the address and removes them up to an optional cap .
depositor
&mut DepositorInfo
block
&BlockInfo
cap
Option<Uint128>
depositor
&mut DepositorInfo
block
&BlockInfo
cap
Option<Uint128>