Skip to content

Commit

Permalink
remove hard dep on solana program
Browse files Browse the repository at this point in the history
  • Loading branch information
macalinao committed Nov 22, 2021
1 parent eb0e491 commit 888bcd3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

5 changes: 2 additions & 3 deletions programs/merkle-distributor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ cpi = ["no-entrypoint"]
default = []

[dependencies]
anchor-lang = "0.17.0"
anchor-spl = "0.17.0"
solana-program = "1.7.11"
anchor-lang = ">=0.17.0"
anchor-spl = ">=0.17.0"
spl-associated-token-account = { version = "1.0.3", features = [
"no-entrypoint"
] }
Expand Down
2 changes: 1 addition & 1 deletion programs/merkle-distributor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub mod merkle_distributor {
require!(claimant_account.is_signer, Unauthorized);

// Verify the merkle proof.
let node = solana_program::keccak::hashv(&[
let node = anchor_lang::solana_program::keccak::hashv(&[
&index.to_le_bytes(),
&claimant_account.key().to_bytes(),
&amount.to_le_bytes(),
Expand Down
6 changes: 4 additions & 2 deletions programs/merkle-distributor/src/merkle_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ pub fn verify(proof: Vec<[u8; 32]>, root: [u8; 32], leaf: [u8; 32]) -> bool {
for proof_element in proof.into_iter() {
if computed_hash <= proof_element {
// Hash(current computed hash + current element of the proof)
computed_hash = solana_program::keccak::hashv(&[&computed_hash, &proof_element]).0;
computed_hash =
anchor_lang::solana_program::keccak::hashv(&[&computed_hash, &proof_element]).0;
} else {
// Hash(current element of the proof + current computed hash)
computed_hash = solana_program::keccak::hashv(&[&proof_element, &computed_hash]).0;
computed_hash =
anchor_lang::solana_program::keccak::hashv(&[&proof_element, &computed_hash]).0;
}
}
// Check if the computed hash (root) is equal to the provided root
Expand Down

0 comments on commit 888bcd3

Please sign in to comment.