Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion libraries/discriminator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ borsh = ["dep:borsh"]
[dependencies]
borsh = { version = "1", optional = true }
bytemuck = { version = "1.19.0", features = ["derive"] }
solana-program = "2.1.0"
solana-program-error = "2.1.0"
solana-sha256-hasher = "2.1.0"
spl-discriminator-derive = { version = "0.2.0", path = "./derive" }

[lib]
Expand Down
5 changes: 3 additions & 2 deletions libraries/discriminator/src/discriminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

use {
bytemuck::{Pod, Zeroable},
solana_program::{hash, program_error::ProgramError},
solana_program_error::ProgramError,
solana_sha256_hasher::hashv,
};

/// A trait for managing 8-byte discriminators in a slab of bytes
Expand Down Expand Up @@ -36,7 +37,7 @@ impl ArrayDiscriminator {
}
/// Creates a new `ArrayDiscriminator` from some hash input string literal
pub fn new_with_hash_input(hash_input: &str) -> Self {
let hash_bytes = hash::hashv(&[hash_input.as_bytes()]).to_bytes();
let hash_bytes = hashv(&[hash_input.as_bytes()]).to_bytes();
let mut discriminator_bytes = [0u8; 8];
discriminator_bytes.copy_from_slice(&hash_bytes[..8]);
Self(discriminator_bytes)
Expand Down
2 changes: 1 addition & 1 deletion libraries/discriminator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ mod tests {
}

fn build_discriminator(hash_input: &str) -> ArrayDiscriminator {
let preimage = solana_program::hash::hashv(&[hash_input.as_bytes()]);
let preimage = solana_sha256_hasher::hashv(&[hash_input.as_bytes()]);
let mut bytes = [0u8; 8];
bytes.copy_from_slice(&preimage.to_bytes()[..8]);
ArrayDiscriminator::new(bytes)
Expand Down
Loading