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

Commit 5a2bd4c

Browse files
authored
remove solana-program from spl-discriminator (#7427)
1 parent 0189588 commit 5a2bd4c

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libraries/discriminator/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ borsh = ["dep:borsh"]
1313
[dependencies]
1414
borsh = { version = "1", optional = true }
1515
bytemuck = { version = "1.19.0", features = ["derive"] }
16-
solana-program = "2.1.0"
16+
solana-program-error = "2.1.0"
17+
solana-sha256-hasher = "2.1.0"
1718
spl-discriminator-derive = { version = "0.2.0", path = "./derive" }
1819

1920
[lib]

libraries/discriminator/src/discriminator.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
33
use {
44
bytemuck::{Pod, Zeroable},
5-
solana_program::{hash, program_error::ProgramError},
5+
solana_program_error::ProgramError,
6+
solana_sha256_hasher::hashv,
67
};
78

89
/// A trait for managing 8-byte discriminators in a slab of bytes
@@ -36,7 +37,7 @@ impl ArrayDiscriminator {
3637
}
3738
/// Creates a new `ArrayDiscriminator` from some hash input string literal
3839
pub fn new_with_hash_input(hash_input: &str) -> Self {
39-
let hash_bytes = hash::hashv(&[hash_input.as_bytes()]).to_bytes();
40+
let hash_bytes = hashv(&[hash_input.as_bytes()]).to_bytes();
4041
let mut discriminator_bytes = [0u8; 8];
4142
discriminator_bytes.copy_from_slice(&hash_bytes[..8]);
4243
Self(discriminator_bytes)

libraries/discriminator/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ mod tests {
9898
}
9999

100100
fn build_discriminator(hash_input: &str) -> ArrayDiscriminator {
101-
let preimage = solana_program::hash::hashv(&[hash_input.as_bytes()]);
101+
let preimage = solana_sha256_hasher::hashv(&[hash_input.as_bytes()]);
102102
let mut bytes = [0u8; 8];
103103
bytes.copy_from_slice(&preimage.to_bytes()[..8]);
104104
ArrayDiscriminator::new(bytes)

0 commit comments

Comments
 (0)