Skip to content

Commit

Permalink
fix: add constraint to prevent duplicate sender accounts in send func…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
ziming-zung committed Dec 5, 2024
1 parent 943ce4a commit 34321ac
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ pub fn send(
if sender != accounts[1].key() {
return Err(ErrorCode::ConstraintAddress.into());
}
if accounts.iter().filter(|acc| acc.key == &sender).count() > 1 {
return Err(ErrorCode::ConstraintAddress.into());
}
let cpi_ctx = Send::construct_context(endpoint_program, accounts)?;
let rtn = endpoint::cpi::send(cpi_ctx.with_signer(&[&seeds]), params)?;
Ok(rtn.get())
Expand Down

0 comments on commit 34321ac

Please sign in to comment.