Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Merge branch 'master' into hotfix/account-compression-stack-overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ngundotra authored Jun 24, 2024
2 parents 746de54 + 61794be commit 4bf0d9a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions token/program-2022-test/tests/memo_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@ async fn test_memo_transfers(
let bob_state = token.get_account_info(&bob_account).await.unwrap();
assert_eq!(bob_state.base.amount, 0);

// attempt to transfer from bob to bob without memo
let err = token
.transfer(&bob_account, &bob_account, &bob.pubkey(), 0, &[&bob])
.await
.unwrap_err();
assert_eq!(
err,
TokenClientError::Client(Box::new(TransportError::TransactionError(
TransactionError::InstructionError(
0,
InstructionError::Custom(TokenError::NoMemo as u32)
)
)))
);
let bob_state = token.get_account_info(&bob_account).await.unwrap();
assert_eq!(bob_state.base.amount, 0);

// attempt to transfer from alice to bob with misplaced memo, v1 and current
let mut memo_ix = spl_memo::build_memo(&[240, 159, 166, 150], &[]);
for program_id in [spl_memo::id(), spl_memo::v1::id()] {
Expand Down
3 changes: 3 additions & 0 deletions token/program-2022/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ impl Processor {
// This check MUST occur just before the amounts are manipulated
// to ensure self-transfers are fully validated
if self_transfer {
if memo_required(&source_account) {
check_previous_sibling_instruction_is_memo()?;
}
return Ok(());
}

Expand Down

0 comments on commit 4bf0d9a

Please sign in to comment.