Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit f5a6dc6

Browse files
authored
token-2022: Zeroize account data on close (#2764)
* token-2022: Zeroize account data on close * Address feedback
1 parent 81f5012 commit f5a6dc6

File tree

3 files changed

+299
-62
lines changed

3 files changed

+299
-62
lines changed

token/program-2022/src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ mod entrypoint;
1616

1717
// Export current sdk types for downstream users building with a different sdk version
1818
pub use solana_program;
19-
use solana_program::{entrypoint::ProgramResult, program_error::ProgramError, pubkey::Pubkey};
19+
use solana_program::{
20+
entrypoint::ProgramResult,
21+
program_error::ProgramError,
22+
program_memory::sol_memcmp,
23+
pubkey::{Pubkey, PUBKEY_BYTES},
24+
};
2025

2126
/// Convert the UI representation of a token amount (using the decimals field defined in its mint)
2227
/// to the raw amount
@@ -38,3 +43,9 @@ pub fn check_program_account(spl_token_program_id: &Pubkey) -> ProgramResult {
3843
}
3944
Ok(())
4045
}
46+
47+
/// Checks two pubkeys for equality in a computationally cheap way using
48+
/// `sol_memcmp`
49+
pub fn cmp_pubkeys(a: &Pubkey, b: &Pubkey) -> bool {
50+
sol_memcmp(a.as_ref(), b.as_ref(), PUBKEY_BYTES) == 0
51+
}

0 commit comments

Comments
 (0)