From fce2d6d8360f0d3c84b39ce12cbe61da3b5b9ae8 Mon Sep 17 00:00:00 2001 From: Sergey Timoshin Date: Fri, 10 Jan 2025 23:15:43 +0000 Subject: [PATCH] Rename `get_multiple_new_address_proofs_full` to `get_multiple_new_address_proofs_h40`. --- forester-utils/src/instructions.rs | 8 +++---- forester/src/photon_indexer.rs | 8 +++---- js/compressed-token/rollup.config.js | 6 +---- js/stateless.js/rollup.config.js | 6 +---- sdk-libs/client/src/indexer/mod.rs | 2 +- .../program-test/src/indexer/test_indexer.rs | 24 +++++++++---------- .../program-test/src/test_batch_forester.rs | 2 +- 7 files changed, 24 insertions(+), 32 deletions(-) diff --git a/forester-utils/src/instructions.rs b/forester-utils/src/instructions.rs index 73f64bfc9..f303de3b0 100644 --- a/forester-utils/src/instructions.rs +++ b/forester-utils/src/instructions.rs @@ -39,7 +39,6 @@ pub enum ForesterUtilsError { IndexerError(String), } -// TODO: replace TestIndexerExtensions with IndexerType pub async fn create_batch_update_address_tree_instruction_data( rpc: &mut R, indexer: &mut I, @@ -47,7 +46,7 @@ pub async fn create_batch_update_address_tree_instruction_data( ) -> Result<(InstructionDataBatchNullifyInputs, usize), ForesterUtilsError> where R: RpcConnection, - I: Indexer, //+ TestIndexerExtensions, + I: Indexer, { let mut merkle_tree_account = rpc.get_account(merkle_tree_pubkey).await .map_err(|e| { @@ -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(), ) @@ -389,7 +388,8 @@ pub async fn create_nullify_batch_ix_data>( 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); } diff --git a/forester/src/photon_indexer.rs b/forester/src/photon_indexer.rs index ae144b3f2..abbbf61b8 100644 --- a/forester/src/photon_indexer.rs +++ b/forester/src/photon_indexer.rs @@ -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, }; @@ -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 { @@ -224,7 +224,7 @@ impl Indexer for PhotonIndexer { 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]>, diff --git a/js/compressed-token/rollup.config.js b/js/compressed-token/rollup.config.js index 6f02c4084..5e1d6f531 100644 --- a/js/compressed-token/rollup.config.js +++ b/js/compressed-token/rollup.config.js @@ -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]; diff --git a/js/stateless.js/rollup.config.js b/js/stateless.js/rollup.config.js index 72140f365..6285eb30b 100644 --- a/js/stateless.js/rollup.config.js +++ b/js/stateless.js/rollup.config.js @@ -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]; diff --git a/sdk-libs/client/src/indexer/mod.rs b/sdk-libs/client/src/indexer/mod.rs index 29f7970c1..cb7b61b88 100644 --- a/sdk-libs/client/src/indexer/mod.rs +++ b/sdk-libs/client/src/indexer/mod.rs @@ -74,7 +74,7 @@ pub trait Indexer: Sync + Send + Debug + 'static { addresses: Vec<[u8; 32]>, ) -> Result>, 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]>, diff --git a/sdk-libs/program-test/src/indexer/test_indexer.rs b/sdk-libs/program-test/src/indexer/test_indexer.rs index 2568c072f..4de59c522 100644 --- a/sdk-libs/program-test/src/indexer/test_indexer.rs +++ b/sdk-libs/program-test/src/indexer/test_indexer.rs @@ -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, @@ -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, @@ -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]>, @@ -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 @@ -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![]; diff --git a/sdk-libs/program-test/src/test_batch_forester.rs b/sdk-libs/program-test/src/test_batch_forester.rs index f733ca11d..960ad2377 100644 --- a/sdk-libs/program-test/src/test_batch_forester.rs +++ b/sdk-libs/program-test/src/test_batch_forester.rs @@ -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::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 {