1use async_trait::async_trait;
2use solana_pubkey::Pubkey;
3
4use super::{
5 response::{Items, ItemsWithCursor, Response},
6 types::{
7 CompressedAccount, CompressedTokenAccount, OwnerBalance, QueueElementsResult,
8 QueueInfoResult, SignatureWithMetadata, TokenBalance, ValidityProofWithContext,
9 },
10 Address, AddressWithTree, BatchAddressUpdateIndexerResponse,
11 GetCompressedAccountsByOwnerConfig, GetCompressedTokenAccountsByOwnerOrDelegateOptions, Hash,
12 IndexerError, IndexerRpcConfig, MerkleProof, NewAddressProofWithContext, PaginatedOptions,
13 RetryConfig,
14};
15#[async_trait]
17pub trait Indexer: std::marker::Send + std::marker::Sync {
18 async fn get_compressed_account(
20 &self,
21 address: Address,
22 config: Option<IndexerRpcConfig>,
23 ) -> Result<Response<Option<CompressedAccount>>, IndexerError>;
24
25 async fn get_compressed_account_by_hash(
27 &self,
28 hash: Hash,
29 config: Option<IndexerRpcConfig>,
30 ) -> Result<Response<Option<CompressedAccount>>, IndexerError>;
31
32 async fn get_compressed_accounts_by_owner(
34 &self,
35 owner: &Pubkey,
36 options: Option<GetCompressedAccountsByOwnerConfig>,
37 config: Option<IndexerRpcConfig>,
38 ) -> Result<Response<ItemsWithCursor<CompressedAccount>>, IndexerError>;
39
40 async fn get_compressed_balance(
42 &self,
43 address: Option<Address>,
44 hash: Option<Hash>,
45 config: Option<IndexerRpcConfig>,
46 ) -> Result<Response<u64>, IndexerError>;
47
48 async fn get_compressed_balance_by_owner(
50 &self,
51 owner: &Pubkey,
52 config: Option<IndexerRpcConfig>,
53 ) -> Result<Response<u64>, IndexerError>;
54
55 async fn get_compressed_mint_token_holders(
57 &self,
58 mint: &Pubkey,
59 options: Option<PaginatedOptions>,
60 config: Option<IndexerRpcConfig>,
61 ) -> Result<Response<ItemsWithCursor<OwnerBalance>>, IndexerError>;
62
63 async fn get_compressed_token_account_balance(
65 &self,
66 address: Option<Address>,
67 hash: Option<Hash>,
68 config: Option<IndexerRpcConfig>,
69 ) -> Result<Response<u64>, IndexerError>;
70
71 async fn get_compressed_token_accounts_by_delegate(
73 &self,
74 delegate: &Pubkey,
75 options: Option<GetCompressedTokenAccountsByOwnerOrDelegateOptions>,
76 config: Option<IndexerRpcConfig>,
77 ) -> Result<Response<ItemsWithCursor<CompressedTokenAccount>>, IndexerError>;
78
79 async fn get_compressed_token_accounts_by_owner(
80 &self,
81 owner: &Pubkey,
82 options: Option<GetCompressedTokenAccountsByOwnerOrDelegateOptions>,
83 config: Option<IndexerRpcConfig>,
84 ) -> Result<Response<ItemsWithCursor<CompressedTokenAccount>>, IndexerError>;
85
86 async fn get_compressed_token_balances_by_owner_v2(
88 &self,
89 owner: &Pubkey,
90 options: Option<GetCompressedTokenAccountsByOwnerOrDelegateOptions>,
91 config: Option<IndexerRpcConfig>,
92 ) -> Result<Response<ItemsWithCursor<TokenBalance>>, IndexerError>;
93
94 async fn get_compression_signatures_for_account(
96 &self,
97 hash: Hash,
98 config: Option<IndexerRpcConfig>,
99 ) -> Result<Response<Items<SignatureWithMetadata>>, IndexerError>;
100
101 async fn get_compression_signatures_for_address(
104 &self,
105 address: &[u8; 32],
106 options: Option<PaginatedOptions>,
107 config: Option<IndexerRpcConfig>,
108 ) -> Result<Response<ItemsWithCursor<SignatureWithMetadata>>, IndexerError>;
109
110 async fn get_compression_signatures_for_owner(
113 &self,
114 owner: &Pubkey,
115 options: Option<PaginatedOptions>,
116 config: Option<IndexerRpcConfig>,
117 ) -> Result<Response<ItemsWithCursor<SignatureWithMetadata>>, IndexerError>;
118
119 async fn get_compression_signatures_for_token_owner(
122 &self,
123 owner: &Pubkey,
124 options: Option<PaginatedOptions>,
125 config: Option<IndexerRpcConfig>,
126 ) -> Result<Response<ItemsWithCursor<SignatureWithMetadata>>, IndexerError>;
127
128 async fn get_indexer_health(&self, config: Option<RetryConfig>) -> Result<bool, IndexerError>;
132
133 async fn get_indexer_slot(&self, config: Option<RetryConfig>) -> Result<u64, IndexerError>;
135
136 async fn get_multiple_compressed_account_proofs(
144 &self,
145 hashes: Vec<[u8; 32]>,
146 config: Option<IndexerRpcConfig>,
147 ) -> Result<Response<Items<MerkleProof>>, IndexerError>;
148
149 async fn get_multiple_compressed_accounts(
151 &self,
152 addresses: Option<Vec<Address>>,
153 hashes: Option<Vec<Hash>>,
154 config: Option<IndexerRpcConfig>,
155 ) -> Result<Response<Items<Option<CompressedAccount>>>, IndexerError>;
156
157 async fn get_multiple_new_address_proofs(
159 &self,
160 merkle_tree_pubkey: [u8; 32],
161 addresses: Vec<[u8; 32]>,
162 config: Option<IndexerRpcConfig>,
163 ) -> Result<Response<Items<NewAddressProofWithContext>>, IndexerError>;
164
165 async fn get_validity_proof(
169 &self,
170 hashes: Vec<Hash>,
171 new_addresses_with_trees: Vec<AddressWithTree>,
172 config: Option<IndexerRpcConfig>,
173 ) -> Result<Response<ValidityProofWithContext>, IndexerError>;
174
175 async fn get_address_queue_with_proofs(
179 &mut self,
180 merkle_tree_pubkey: &Pubkey,
181 zkp_batch_size: u16,
182 start_offset: Option<u64>,
183 config: Option<IndexerRpcConfig>,
184 ) -> Result<Response<BatchAddressUpdateIndexerResponse>, IndexerError>;
185
186 async fn get_queue_elements(
195 &mut self,
196 merkle_tree_pubkey: [u8; 32],
197 output_queue_start_index: Option<u64>,
198 output_queue_limit: Option<u16>,
199 input_queue_start_index: Option<u64>,
200 input_queue_limit: Option<u16>,
201 config: Option<IndexerRpcConfig>,
202 ) -> Result<Response<QueueElementsResult>, IndexerError>;
203
204 async fn get_queue_info(
207 &self,
208 config: Option<IndexerRpcConfig>,
209 ) -> Result<Response<QueueInfoResult>, IndexerError>;
210
211 async fn get_queue_elements_v2(
214 &mut self,
215 merkle_tree_pubkey: [u8; 32],
216 options: super::QueueElementsV2Options,
217 config: Option<IndexerRpcConfig>,
218 ) -> Result<Response<super::QueueElementsV2Result>, IndexerError>;
219 async fn get_subtrees(
220 &self,
221 merkle_tree_pubkey: [u8; 32],
222 config: Option<IndexerRpcConfig>,
223 ) -> Result<Response<Items<[u8; 32]>>, IndexerError>;
224}