fix minimum rent error and lamports conversion
This commit is contained in:
@@ -16,4 +16,6 @@ pub enum EscrowError {
|
||||
DisputeTimeoutNotReached,
|
||||
#[msg("Vault balance is insufficient for the requested escrow amount")]
|
||||
InsufficientVaultBalance,
|
||||
#[msg("Amount must be at least rent-exempt minimum for the vault (~890880 lamports)")]
|
||||
AmountBelowRentMinimum,
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use anchor_lang::prelude::*;
|
||||
use crate::state::{EscrowAccount, EscrowState};
|
||||
use crate::EscrowError;
|
||||
|
||||
#[derive(Accounts)]
|
||||
#[instruction(amount: u64, dispute_resolver: Option<Pubkey>, escrow_id: u64)]
|
||||
@@ -36,6 +37,9 @@ pub fn handler(
|
||||
dispute_resolver: Option<Pubkey>,
|
||||
escrow_id: u64,
|
||||
) -> Result<()> {
|
||||
let rent_min = Rent::get()?.minimum_balance(0);
|
||||
require!(amount >= rent_min, EscrowError::AmountBelowRentMinimum);
|
||||
|
||||
let escrow = &mut ctx.accounts.escrow_account;
|
||||
escrow.seller = ctx.accounts.seller.key();
|
||||
escrow.buyer = ctx.accounts.buyer.key();
|
||||
|
||||
Reference in New Issue
Block a user