use async_trait::async_trait;
use solana_pubkey::Pubkey;
use super::{
response::{Items, ItemsWithCursor, Response},
types::{
CompressedAccount, CompressedTokenAccount, OwnerBalance, QueueInfoResult,
SignatureWithMetadata, TokenBalance, ValidityProofWithContext,
},
Address, AddressWithTree, GetCompressedAccountsByOwnerConfig,
GetCompressedTokenAccountsByOwnerOrDelegateOptions, Hash, IndexerError, IndexerRpcConfig,
MerkleProof, NewAddressProofWithContext, PaginatedOptions, QueueElementsV2Options, RetryConfig,
};
use crate::indexer::QueueElementsResult;
#[async_trait]
pub trait Indexer: std::marker::Send + std::marker::Sync {
async fn get_compressed_account(
&self,
address: Address,
config: Option<IndexerRpcConfig>,
) -> Result<Response<Option<CompressedAccount>>, IndexerError>;
async fn get_compressed_account_by_hash(
&self,
hash: Hash,
config: Option<IndexerRpcConfig>,
) -> Result<Response<Option<CompressedAccount>>, IndexerError>;
async fn get_compressed_accounts_by_owner(
&self,
owner: &Pubkey,
options: Option<GetCompressedAccountsByOwnerConfig>,
config: Option<IndexerRpcConfig>,
) -> Result<Response<ItemsWithCursor<CompressedAccount>>, IndexerError>;
async fn get_compressed_balance(
&self,
address: Option<Address>,
hash: Option<Hash>,
config: Option<IndexerRpcConfig>,
) -> Result<Response<u64>, IndexerError>;
async fn get_compressed_balance_by_owner(
&self,
owner: &Pubkey,
config: Option<IndexerRpcConfig>,
) -> Result<Response<u64>, IndexerError>;
async fn get_compressed_mint_token_holders(
&self,
mint: &Pubkey,
options: Option<PaginatedOptions>,
config: Option<IndexerRpcConfig>,
) -> Result<Response<ItemsWithCursor<OwnerBalance>>, IndexerError>;
async fn get_compressed_token_account_balance(
&self,
address: Option<Address>,
hash: Option<Hash>,
config: Option<IndexerRpcConfig>,
) -> Result<Response<u64>, IndexerError>;
async fn get_compressed_token_accounts_by_delegate(
&self,
delegate: &Pubkey,
options: Option<GetCompressedTokenAccountsByOwnerOrDelegateOptions>,
config: Option<IndexerRpcConfig>,
) -> Result<Response<ItemsWithCursor<CompressedTokenAccount>>, IndexerError>;
async fn get_compressed_token_accounts_by_owner(
&self,
owner: &Pubkey,
options: Option<GetCompressedTokenAccountsByOwnerOrDelegateOptions>,
config: Option<IndexerRpcConfig>,
) -> Result<Response<ItemsWithCursor<CompressedTokenAccount>>, IndexerError>;
async fn get_compressed_token_balances_by_owner_v2(
&self,
owner: &Pubkey,
options: Option<GetCompressedTokenAccountsByOwnerOrDelegateOptions>,
config: Option<IndexerRpcConfig>,
) -> Result<Response<ItemsWithCursor<TokenBalance>>, IndexerError>;
async fn get_compression_signatures_for_account(
&self,
hash: Hash,
config: Option<IndexerRpcConfig>,
) -> Result<Response<Items<SignatureWithMetadata>>, IndexerError>;
async fn get_compression_signatures_for_address(
&self,
address: &[u8; 32],
options: Option<PaginatedOptions>,
config: Option<IndexerRpcConfig>,
) -> Result<Response<ItemsWithCursor<SignatureWithMetadata>>, IndexerError>;
async fn get_compression_signatures_for_owner(
&self,
owner: &Pubkey,
options: Option<PaginatedOptions>,
config: Option<IndexerRpcConfig>,
) -> Result<Response<ItemsWithCursor<SignatureWithMetadata>>, IndexerError>;
async fn get_compression_signatures_for_token_owner(
&self,
owner: &Pubkey,
options: Option<PaginatedOptions>,
config: Option<IndexerRpcConfig>,
) -> Result<Response<ItemsWithCursor<SignatureWithMetadata>>, IndexerError>;
async fn get_indexer_health(&self, config: Option<RetryConfig>) -> Result<bool, IndexerError>;
async fn get_indexer_slot(&self, config: Option<RetryConfig>) -> Result<u64, IndexerError>;
async fn get_multiple_compressed_account_proofs(
&self,
hashes: Vec<[u8; 32]>,
config: Option<IndexerRpcConfig>,
) -> Result<Response<Items<MerkleProof>>, IndexerError>;
async fn get_multiple_compressed_accounts(
&self,
addresses: Option<Vec<Address>>,
hashes: Option<Vec<Hash>>,
config: Option<IndexerRpcConfig>,
) -> Result<Response<Items<Option<CompressedAccount>>>, IndexerError>;
async fn get_multiple_new_address_proofs(
&self,
merkle_tree_pubkey: [u8; 32],
addresses: Vec<[u8; 32]>,
config: Option<IndexerRpcConfig>,
) -> Result<Response<Items<NewAddressProofWithContext>>, IndexerError>;
async fn get_validity_proof(
&self,
hashes: Vec<Hash>,
new_addresses_with_trees: Vec<AddressWithTree>,
config: Option<IndexerRpcConfig>,
) -> Result<Response<ValidityProofWithContext>, IndexerError>;
async fn get_queue_elements(
&mut self,
merkle_tree_pubkey: [u8; 32],
options: QueueElementsV2Options,
config: Option<IndexerRpcConfig>,
) -> Result<Response<QueueElementsResult>, IndexerError>;
async fn get_queue_info(
&self,
config: Option<IndexerRpcConfig>,
) -> Result<Response<QueueInfoResult>, IndexerError>;
async fn get_subtrees(
&self,
merkle_tree_pubkey: [u8; 32],
config: Option<IndexerRpcConfig>,
) -> Result<Response<Items<[u8; 32]>>, IndexerError>;
}