1use async_trait::async_trait;
2use solana_pubkey::Pubkey;
3
4use super::{
5 response::{Items, ItemsWithCursor, Response},
6 types::{
7 CompressedAccount, CompressedTokenAccount, OwnerBalance, QueueInfoResult,
8 SignatureWithMetadata, TokenBalance, ValidityProofWithContext,
9 },
10 Address, AddressWithTree, GetCompressedAccountsByOwnerConfig,
11 GetCompressedTokenAccountsByOwnerOrDelegateOptions, Hash, IndexerError, IndexerRpcConfig,
12 MerkleProof, NewAddressProofWithContext, PaginatedOptions, QueueElementsV2Options, RetryConfig,
13};
14use crate::indexer::QueueElementsResult;
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_queue_elements(
178 &mut self,
179 merkle_tree_pubkey: [u8; 32],
180 options: QueueElementsV2Options,
181 config: Option<IndexerRpcConfig>,
182 ) -> Result<Response<QueueElementsResult>, IndexerError>;
183
184 async fn get_queue_info(
187 &self,
188 config: Option<IndexerRpcConfig>,
189 ) -> Result<Response<QueueInfoResult>, IndexerError>;
190
191 async fn get_subtrees(
192 &self,
193 merkle_tree_pubkey: [u8; 32],
194 config: Option<IndexerRpcConfig>,
195 ) -> Result<Response<Items<[u8; 32]>>, IndexerError>;
196}