1use async_trait::async_trait;
2use light_merkle_tree_metadata::QueueType;
3use solana_pubkey::Pubkey;
4
5use super::{
6 response::{Items, ItemsWithCursor, Response},
7 types::{
8 CompressedAccount, CompressedTokenAccount, OwnerBalance, QueueElementsResult,
9 SignatureWithMetadata, TokenBalance, ValidityProofWithContext,
10 },
11 Address, AddressWithTree, BatchAddressUpdateIndexerResponse,
12 GetCompressedAccountsByOwnerConfig, GetCompressedTokenAccountsByOwnerOrDelegateOptions, Hash,
13 IndexerError, IndexerRpcConfig, MerkleProof, NewAddressProofWithContext, PaginatedOptions,
14 RetryConfig,
15};
16#[async_trait]
18pub trait Indexer: std::marker::Send + std::marker::Sync {
19 async fn get_compressed_account(
21 &self,
22 address: Address,
23 config: Option<IndexerRpcConfig>,
24 ) -> Result<Response<Option<CompressedAccount>>, IndexerError>;
25
26 async fn get_compressed_account_by_hash(
28 &self,
29 hash: Hash,
30 config: Option<IndexerRpcConfig>,
31 ) -> Result<Response<Option<CompressedAccount>>, IndexerError>;
32
33 async fn get_compressed_accounts_by_owner(
35 &self,
36 owner: &Pubkey,
37 options: Option<GetCompressedAccountsByOwnerConfig>,
38 config: Option<IndexerRpcConfig>,
39 ) -> Result<Response<ItemsWithCursor<CompressedAccount>>, IndexerError>;
40
41 async fn get_compressed_balance(
43 &self,
44 address: Option<Address>,
45 hash: Option<Hash>,
46 config: Option<IndexerRpcConfig>,
47 ) -> Result<Response<u64>, IndexerError>;
48
49 async fn get_compressed_balance_by_owner(
51 &self,
52 owner: &Pubkey,
53 config: Option<IndexerRpcConfig>,
54 ) -> Result<Response<u64>, IndexerError>;
55
56 async fn get_compressed_mint_token_holders(
58 &self,
59 mint: &Pubkey,
60 options: Option<PaginatedOptions>,
61 config: Option<IndexerRpcConfig>,
62 ) -> Result<Response<ItemsWithCursor<OwnerBalance>>, IndexerError>;
63
64 async fn get_compressed_token_account_balance(
66 &self,
67 address: Option<Address>,
68 hash: Option<Hash>,
69 config: Option<IndexerRpcConfig>,
70 ) -> Result<Response<u64>, IndexerError>;
71
72 async fn get_compressed_token_accounts_by_delegate(
74 &self,
75 delegate: &Pubkey,
76 options: Option<GetCompressedTokenAccountsByOwnerOrDelegateOptions>,
77 config: Option<IndexerRpcConfig>,
78 ) -> Result<Response<ItemsWithCursor<CompressedTokenAccount>>, IndexerError>;
79
80 async fn get_compressed_token_accounts_by_owner(
81 &self,
82 owner: &Pubkey,
83 options: Option<GetCompressedTokenAccountsByOwnerOrDelegateOptions>,
84 config: Option<IndexerRpcConfig>,
85 ) -> Result<Response<ItemsWithCursor<CompressedTokenAccount>>, IndexerError>;
86
87 async fn get_compressed_token_balances_by_owner_v2(
89 &self,
90 owner: &Pubkey,
91 options: Option<GetCompressedTokenAccountsByOwnerOrDelegateOptions>,
92 config: Option<IndexerRpcConfig>,
93 ) -> Result<Response<ItemsWithCursor<TokenBalance>>, IndexerError>;
94
95 async fn get_compression_signatures_for_account(
97 &self,
98 hash: Hash,
99 config: Option<IndexerRpcConfig>,
100 ) -> Result<Response<Items<SignatureWithMetadata>>, IndexerError>;
101
102 async fn get_compression_signatures_for_address(
105 &self,
106 address: &[u8; 32],
107 options: Option<PaginatedOptions>,
108 config: Option<IndexerRpcConfig>,
109 ) -> Result<Response<ItemsWithCursor<SignatureWithMetadata>>, IndexerError>;
110
111 async fn get_compression_signatures_for_owner(
114 &self,
115 owner: &Pubkey,
116 options: Option<PaginatedOptions>,
117 config: Option<IndexerRpcConfig>,
118 ) -> Result<Response<ItemsWithCursor<SignatureWithMetadata>>, IndexerError>;
119
120 async fn get_compression_signatures_for_token_owner(
123 &self,
124 owner: &Pubkey,
125 options: Option<PaginatedOptions>,
126 config: Option<IndexerRpcConfig>,
127 ) -> Result<Response<ItemsWithCursor<SignatureWithMetadata>>, IndexerError>;
128
129 async fn get_indexer_health(&self, config: Option<RetryConfig>) -> Result<bool, IndexerError>;
133
134 async fn get_indexer_slot(&self, config: Option<RetryConfig>) -> Result<u64, IndexerError>;
136
137 async fn get_multiple_compressed_account_proofs(
145 &self,
146 hashes: Vec<[u8; 32]>,
147 config: Option<IndexerRpcConfig>,
148 ) -> Result<Response<Items<MerkleProof>>, IndexerError>;
149
150 async fn get_multiple_compressed_accounts(
152 &self,
153 addresses: Option<Vec<Address>>,
154 hashes: Option<Vec<Hash>>,
155 config: Option<IndexerRpcConfig>,
156 ) -> Result<Response<Items<Option<CompressedAccount>>>, IndexerError>;
157
158 async fn get_multiple_new_address_proofs(
160 &self,
161 merkle_tree_pubkey: [u8; 32],
162 addresses: Vec<[u8; 32]>,
163 config: Option<IndexerRpcConfig>,
164 ) -> Result<Response<Items<NewAddressProofWithContext>>, IndexerError>;
165
166 async fn get_validity_proof(
170 &self,
171 hashes: Vec<Hash>,
172 new_addresses_with_trees: Vec<AddressWithTree>,
173 config: Option<IndexerRpcConfig>,
174 ) -> Result<Response<ValidityProofWithContext>, IndexerError>;
175
176 async fn get_address_queue_with_proofs(
180 &mut self,
181 merkle_tree_pubkey: &Pubkey,
182 zkp_batch_size: u16,
183 start_offset: Option<u64>,
184 config: Option<IndexerRpcConfig>,
185 ) -> Result<Response<BatchAddressUpdateIndexerResponse>, IndexerError>;
186
187 async fn get_queue_elements(
195 &mut self,
196 merkle_tree_pubkey: [u8; 32],
197 queue_type: QueueType,
198 num_elements: u16,
199 start_queue_index: Option<u64>,
200 config: Option<IndexerRpcConfig>,
201 ) -> Result<Response<QueueElementsResult>, IndexerError>;
202
203 async fn get_subtrees(
204 &self,
205 merkle_tree_pubkey: [u8; 32],
206 config: Option<IndexerRpcConfig>,
207 ) -> Result<Response<Items<[u8; 32]>>, IndexerError>;
208}