Skip to content

Commit

Permalink
Rename get_multiple_new_address_proofs_full to `get_multiple_new_ad…
Browse files Browse the repository at this point in the history
…dress_proofs_h40`.
  • Loading branch information
sergeytimoshin committed Jan 10, 2025
1 parent 0f7bfd2 commit fce2d6d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 32 deletions.
8 changes: 4 additions & 4 deletions forester-utils/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ pub enum ForesterUtilsError {
IndexerError(String),
}

// TODO: replace TestIndexerExtensions with IndexerType
pub async fn create_batch_update_address_tree_instruction_data<R, I>(
rpc: &mut R,
indexer: &mut I,
merkle_tree_pubkey: Pubkey,
) -> Result<(InstructionDataBatchNullifyInputs, usize), ForesterUtilsError>
where
R: RpcConnection,
I: Indexer<R>, //+ TestIndexerExtensions<R>,
I: Indexer<R>,
{
let mut merkle_tree_account = rpc.get_account(merkle_tree_pubkey).await
.map_err(|e| {
Expand Down Expand Up @@ -117,7 +116,7 @@ where

// Get proof info after addresses are retrieved
let non_inclusion_proofs = indexer
.get_multiple_new_address_proofs_full(
.get_multiple_new_address_proofs_h40(
merkle_tree_pubkey.to_bytes(),
addresses.clone(),
)
Expand Down Expand Up @@ -389,7 +388,8 @@ pub async fn create_nullify_batch_ix_data<R: RpcConnection, I: Indexer<R>>(
merkle_proofs.push(proof.proof.clone());
tx_hashes.push(leaf_info.tx_hash);
let index_bytes = leaf_info.leaf_index.to_be_bytes();
let nullifier = Poseidon::hashv(&[&leaf_info.leaf, &index_bytes, &leaf_info.tx_hash]).unwrap();
let nullifier =
Poseidon::hashv(&[&leaf_info.leaf, &index_bytes, &leaf_info.tx_hash]).unwrap();
nullifiers.push(nullifier);
}

Expand Down
8 changes: 4 additions & 4 deletions forester/src/photon_indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use account_compression::initialize_address_merkle_tree::Pubkey;
use async_trait::async_trait;
use light_client::{
indexer::{
AddressMerkleTreeBundle, Indexer, IndexerError, MerkleProof, NewAddressProofWithContext,
ProofOfLeaf,
AddressMerkleTreeBundle, Indexer, IndexerError, LeafIndexInfo, MerkleProof,
NewAddressProofWithContext, ProofOfLeaf,
},
rpc::RpcConnection,
};
Expand All @@ -16,7 +16,7 @@ use photon_api::{
};
use solana_sdk::bs58;
use tracing::debug;
use light_client::indexer::LeafIndexInfo;

use crate::utils::decode_hash;

pub struct PhotonIndexer<R: RpcConnection> {
Expand Down Expand Up @@ -224,7 +224,7 @@ impl<R: RpcConnection> Indexer<R> for PhotonIndexer<R> {
Ok(proofs)
}

async fn get_multiple_new_address_proofs_full(
async fn get_multiple_new_address_proofs_h40(
&self,
_merkle_tree_pubkey: [u8; 32],
_addresses: Vec<[u8; 32]>,
Expand Down
6 changes: 1 addition & 5 deletions js/compressed-token/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,4 @@ const typesConfig = {
plugins: [dts()],
};

export default [
rolls('cjs', 'browser'),
rolls('cjs', 'node'),
typesConfig,
];
export default [rolls('cjs', 'browser'), rolls('cjs', 'node'), typesConfig];
6 changes: 1 addition & 5 deletions js/stateless.js/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,4 @@ const typesConfig = {
plugins: [dts()],
};

export default [
rolls('cjs', 'browser'),
rolls('cjs', 'node'),
typesConfig,
];
export default [rolls('cjs', 'browser'), rolls('cjs', 'node'), typesConfig];
2 changes: 1 addition & 1 deletion sdk-libs/client/src/indexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub trait Indexer<R: RpcConnection>: Sync + Send + Debug + 'static {
addresses: Vec<[u8; 32]>,
) -> Result<Vec<NewAddressProofWithContext<16>>, IndexerError>;

async fn get_multiple_new_address_proofs_full(
async fn get_multiple_new_address_proofs_h40(
&self,
merkle_tree_pubkey: [u8; 32],
addresses: Vec<[u8; 32]>,
Expand Down
24 changes: 12 additions & 12 deletions sdk-libs/program-test/src/indexer/test_indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ use light_batched_merkle_tree::{
};
use light_client::{
indexer::{
AddressMerkleTreeAccounts, AddressMerkleTreeBundle, Indexer, IndexerError, MerkleProof,
NewAddressProofWithContext, ProofOfLeaf, StateMerkleTreeAccounts, StateMerkleTreeBundle,
AddressMerkleTreeAccounts, AddressMerkleTreeBundle, Indexer, IndexerError, LeafIndexInfo,
MerkleProof, NewAddressProofWithContext, ProofOfLeaf, StateMerkleTreeAccounts,
StateMerkleTreeBundle,
},
rpc::{merkle_tree::MerkleTreeExt, RpcConnection},
transaction_params::FeeConfig,
Expand Down Expand Up @@ -67,7 +68,7 @@ use solana_sdk::{
pubkey::Pubkey,
signature::{Keypair, Signer},
};
use light_client::indexer::LeafIndexInfo;

use crate::{
indexer::{
utils::create_address_merkle_tree_and_queue_account_with_assert, TestIndexerExtensions,
Expand Down Expand Up @@ -546,7 +547,7 @@ where
.await
}

async fn get_multiple_new_address_proofs_full(
async fn get_multiple_new_address_proofs_h40(
&self,
merkle_tree_pubkey: [u8; 32],
addresses: Vec<[u8; 32]>,
Expand Down Expand Up @@ -1006,7 +1007,8 @@ where
let leaf = leaf_info.leaf;
let index_bytes = index.to_be_bytes();

let nullifier = Poseidon::hashv(&[&leaf, &index_bytes, &leaf_info.tx_hash]).unwrap();
let nullifier =
Poseidon::hashv(&[&leaf, &index_bytes, &leaf_info.tx_hash]).unwrap();

state_merkle_tree_bundle.input_leaf_indices.remove(0);
state_merkle_tree_bundle
Expand Down Expand Up @@ -1673,13 +1675,11 @@ where
// Store leaf indices of input accounts for batched trees
if bundle.version == 2 {
let leaf_hash = event.input_compressed_account_hashes[i];
bundle
.input_leaf_indices
.push(LeafIndexInfo {
leaf_index,
leaf: leaf_hash,
tx_hash,
});
bundle.input_leaf_indices.push(LeafIndexInfo {
leaf_index,
leaf: leaf_hash,
tx_hash,
});
}
}
let mut new_addresses = vec![];
Expand Down
2 changes: 1 addition & 1 deletion sdk-libs/program-test/src/test_batch_forester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ pub async fn create_batch_update_address_tree_instruction_data_with_proof<
let mut low_element_next_values = Vec::new();
let mut low_element_proofs: Vec<Vec<[u8; 32]>> = Vec::new();
let non_inclusion_proofs = indexer
.get_multiple_new_address_proofs_full(merkle_tree_pubkey.to_bytes(), addresses.clone())
.get_multiple_new_address_proofs_h40(merkle_tree_pubkey.to_bytes(), addresses.clone())
.await
.unwrap();
for non_inclusion_proof in &non_inclusion_proofs {
Expand Down

0 comments on commit fce2d6d

Please sign in to comment.