Skip to content

Commit

Permalink
fix: correct rent handling for token Accounts (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xcypher02 authored Nov 9, 2024
1 parent 2162342 commit b0faca2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions crates/svm-test/src/utils/spl_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ where
}

pub fn program_account(account: spl_token::state::Account) -> Account {
let rent = Rent::default().minimum_balance(spl_token::state::Account::LEN);
let lamports = match account.mint {
_ if account.mint == WSOL => account.amount + rent,
_ => rent,
};
Account {
owner: spl_token::ID,
data: super::pack_to_vec(account),
lamports: Rent::default().minimum_balance(spl_token::state::Account::LEN),
lamports,
..Default::default()
}
}
Expand All @@ -40,7 +45,9 @@ pub fn token(mint: Pubkey, owner: Pubkey, amount: u64) -> spl_token::state::Acco
delegated_amount: 0,
state: AccountState::Initialized,
is_native: match mint {
_ if mint == WSOL => COption::Some(0),
_ if mint == WSOL => {
COption::Some(Rent::default().minimum_balance(spl_token::state::Account::LEN))
}
_ => COption::None,
},
close_authority: COption::None,
Expand Down

0 comments on commit b0faca2

Please sign in to comment.