// Returns Ok if the locked vesting account has been "realized". Realization
// is application dependent. For example, in the case of staking, one must first
// unstake before being able to earn locked tokens.
Returns Ok if the locked vesting account has been "realized". Realization
is application dependent. For example, in the case of staking, one must first
unstake before being able to earn locked tokens.
Returns Ok if the locked vesting account has been " realized " . Realization is application dependent . For example in the case of staking one must first unstake before being able to earn locked tokens .
fn is_realized(ctx: &Context<Withdraw>) -> Result<()> {
    if let Some(realizor) = &ctx.accounts.vesting.realizor {
        let cpi_program = {
            let p = ctx.remaining_accounts[0].clone();
            if p.key != &realizor.program {
                return Err(ErrorCode::InvalidLockRealizor.into());
            }
            p
        };
        let cpi_accounts = ctx.remaining_accounts.to_vec()[1..].to_vec();
        let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts);
        let vesting = (*ctx.accounts.vesting).clone();
        realize_lock::is_realized(cpi_ctx, vesting).map_err(|_| ErrorCode::UnrealizedVesting)?;
    }
    Ok(())
}
fn is_realized ( ctx : & Context < Withdraw > ) -> Result < ( ) > { if let Some ( realizor ) = & ctx . accounts . vesting . realizor { let cpi_program = { let p = ctx . remaining_accounts [ 0 ] . clone ( ) ; if p . key != & realizor . program { return Err ( ErrorCode :: InvalidLockRealizor . into ( ) ) ; } p } ; let cpi_accounts = ctx . remaining_accounts . to_vec ( ) [ 1 .. ] . to_vec ( ) ; let cpi_ctx = CpiContext :: new ( cpi_program , cpi_accounts ) ; let vesting = ( * ctx . accounts . vesting ) . clone ( ) ; realize_lock :: is_realized ( cpi_ctx , vesting ) . map_err ( | _ | ErrorCode :: UnrealizedVesting ) ? ; } Ok ( ( ) ) }
Returns Ok if the locked vesting account has been "realized".
Returns Ok if the locked vesting account has been " realized " .
ctx
&Context<Withdraw>