1515from pyinjective .client .indexer .grpc .indexer_grpc_account_api import IndexerGrpcAccountApi
1616from pyinjective .client .indexer .grpc .indexer_grpc_auction_api import IndexerGrpcAuctionApi
1717from pyinjective .client .indexer .grpc .indexer_grpc_derivative_api import IndexerGrpcDerivativeApi
18+ from pyinjective .client .indexer .grpc .indexer_grpc_explorer_api import IndexerGrpcExplorerApi
1819from pyinjective .client .indexer .grpc .indexer_grpc_insurance_api import IndexerGrpcInsuranceApi
1920from pyinjective .client .indexer .grpc .indexer_grpc_meta_api import IndexerGrpcMetaApi
2021from pyinjective .client .indexer .grpc .indexer_grpc_oracle_api import IndexerGrpcOracleApi
@@ -271,6 +272,13 @@ def __init__(
271272 ),
272273 )
273274
275+ self .exchange_explorer_api = IndexerGrpcExplorerApi (
276+ channel = self .explorer_channel ,
277+ metadata_provider = lambda : self .network .exchange_metadata (
278+ metadata_query_provider = self ._explorer_cookie_metadata_requestor
279+ ),
280+ )
281+
274282 async def all_tokens (self ) -> Dict [str , Token ]:
275283 if self ._tokens is None :
276284 async with self ._tokens_and_markets_initialization_lock :
@@ -601,10 +609,22 @@ async def listen_keepalive(
601609 # Explorer RPC
602610
603611 async def get_tx_by_hash (self , tx_hash : str ):
612+ """
613+ This method is deprecated and will be removed soon. Please use `fetch_tx_by_tx_hash` instead
614+ """
615+ warn ("This method is deprecated. Use fetch_tx_by_tx_hash instead" , DeprecationWarning , stacklevel = 2 )
616+
604617 req = explorer_rpc_pb .GetTxByTxHashRequest (hash = tx_hash )
605618 return await self .stubExplorer .GetTxByTxHash (req )
606619
620+ async def fetch_tx_by_tx_hash (self , tx_hash : str ) -> Dict [str , Any ]:
621+ return await self .exchange_explorer_api .fetch_tx_by_tx_hash (tx_hash = tx_hash )
622+
607623 async def get_account_txs (self , address : str , ** kwargs ):
624+ """
625+ This method is deprecated and will be removed soon. Please use `fetch_account_txs` instead
626+ """
627+ warn ("This method is deprecated. Use fetch_account_txs instead" , DeprecationWarning , stacklevel = 2 )
608628 req = explorer_rpc_pb .GetAccountTxsRequest (
609629 address = address ,
610630 before = kwargs .get ("before" ),
@@ -616,19 +636,66 @@ async def get_account_txs(self, address: str, **kwargs):
616636 )
617637 return await self .stubExplorer .GetAccountTxs (req )
618638
639+ async def fetch_account_txs (
640+ self ,
641+ address : str ,
642+ before : Optional [int ] = None ,
643+ after : Optional [int ] = None ,
644+ message_type : Optional [str ] = None ,
645+ module : Optional [str ] = None ,
646+ from_number : Optional [int ] = None ,
647+ to_number : Optional [int ] = None ,
648+ status : Optional [str ] = None ,
649+ pagination : Optional [PaginationOption ] = None ,
650+ ) -> Dict [str , Any ]:
651+ return await self .exchange_explorer_api .fetch_account_txs (
652+ address = address ,
653+ before = before ,
654+ after = after ,
655+ message_type = message_type ,
656+ module = module ,
657+ from_number = from_number ,
658+ to_number = to_number ,
659+ status = status ,
660+ pagination = pagination ,
661+ )
662+
619663 async def get_blocks (self , ** kwargs ):
664+ """
665+ This method is deprecated and will be removed soon. Please use `fetch_blocks` instead
666+ """
667+ warn ("This method is deprecated. Use fetch_blocks instead" , DeprecationWarning , stacklevel = 2 )
620668 req = explorer_rpc_pb .GetBlocksRequest (
621669 before = kwargs .get ("before" ),
622670 after = kwargs .get ("after" ),
623671 limit = kwargs .get ("limit" ),
624672 )
625673 return await self .stubExplorer .GetBlocks (req )
626674
675+ async def fetch_blocks (
676+ self ,
677+ before : Optional [int ] = None ,
678+ after : Optional [int ] = None ,
679+ pagination : Optional [PaginationOption ] = None ,
680+ ) -> Dict [str , Any ]:
681+ return await self .exchange_explorer_api .fetch_blocks (before = before , after = after , pagination = pagination )
682+
627683 async def get_block (self , block_height : str ):
684+ """
685+ This method is deprecated and will be removed soon. Please use `fetch_block` instead
686+ """
687+ warn ("This method is deprecated. Use fetch_block instead" , DeprecationWarning , stacklevel = 2 )
628688 req = explorer_rpc_pb .GetBlockRequest (id = block_height )
629689 return await self .stubExplorer .GetBlock (req )
630690
691+ async def fetch_block (self , block_id : str ) -> Dict [str , Any ]:
692+ return await self .exchange_explorer_api .fetch_block (block_id = block_id )
693+
631694 async def get_txs (self , ** kwargs ):
695+ """
696+ This method is deprecated and will be removed soon. Please use `fetch_txs` instead
697+ """
698+ warn ("This method is deprecated. Use fetch_txs instead" , DeprecationWarning , stacklevel = 2 )
632699 req = explorer_rpc_pb .GetTxsRequest (
633700 before = kwargs .get ("before" ),
634701 after = kwargs .get ("after" ),
@@ -639,6 +706,28 @@ async def get_txs(self, **kwargs):
639706 )
640707 return await self .stubExplorer .GetTxs (req )
641708
709+ async def fetch_txs (
710+ self ,
711+ before : Optional [int ] = None ,
712+ after : Optional [int ] = None ,
713+ message_type : Optional [str ] = None ,
714+ module : Optional [str ] = None ,
715+ from_number : Optional [int ] = None ,
716+ to_number : Optional [int ] = None ,
717+ status : Optional [str ] = None ,
718+ pagination : Optional [PaginationOption ] = None ,
719+ ) -> Dict [str , Any ]:
720+ return await self .exchange_explorer_api .fetch_txs (
721+ before = before ,
722+ after = after ,
723+ message_type = message_type ,
724+ module = module ,
725+ from_number = from_number ,
726+ to_number = to_number ,
727+ status = status ,
728+ pagination = pagination ,
729+ )
730+
642731 async def stream_txs (self ):
643732 req = explorer_rpc_pb .StreamTxsRequest ()
644733 return self .stubExplorer .StreamTxs (req )
@@ -648,6 +737,10 @@ async def stream_blocks(self):
648737 return self .stubExplorer .StreamBlocks (req )
649738
650739 async def get_peggy_deposits (self , ** kwargs ):
740+ """
741+ This method is deprecated and will be removed soon. Please use `fetch_peggy_deposit_txs` instead
742+ """
743+ warn ("This method is deprecated. Use fetch_peggy_deposit_txs instead" , DeprecationWarning , stacklevel = 2 )
651744 req = explorer_rpc_pb .GetPeggyDepositTxsRequest (
652745 sender = kwargs .get ("sender" ),
653746 receiver = kwargs .get ("receiver" ),
@@ -656,7 +749,23 @@ async def get_peggy_deposits(self, **kwargs):
656749 )
657750 return await self .stubExplorer .GetPeggyDepositTxs (req )
658751
752+ async def fetch_peggy_deposit_txs (
753+ self ,
754+ sender : Optional [str ] = None ,
755+ receiver : Optional [str ] = None ,
756+ pagination : Optional [PaginationOption ] = None ,
757+ ) -> Dict [str , Any ]:
758+ return await self .exchange_explorer_api .fetch_peggy_deposit_txs (
759+ sender = sender ,
760+ receiver = receiver ,
761+ pagination = pagination ,
762+ )
763+
659764 async def get_peggy_withdrawals (self , ** kwargs ):
765+ """
766+ This method is deprecated and will be removed soon. Please use `fetch_peggy_withdrawal_txs` instead
767+ """
768+ warn ("This method is deprecated. Use fetch_peggy_withdrawal_txs instead" , DeprecationWarning , stacklevel = 2 )
660769 req = explorer_rpc_pb .GetPeggyWithdrawalTxsRequest (
661770 sender = kwargs .get ("sender" ),
662771 receiver = kwargs .get ("receiver" ),
@@ -665,7 +774,23 @@ async def get_peggy_withdrawals(self, **kwargs):
665774 )
666775 return await self .stubExplorer .GetPeggyWithdrawalTxs (req )
667776
777+ async def fetch_peggy_withdrawal_txs (
778+ self ,
779+ sender : Optional [str ] = None ,
780+ receiver : Optional [str ] = None ,
781+ pagination : Optional [PaginationOption ] = None ,
782+ ) -> Dict [str , Any ]:
783+ return await self .exchange_explorer_api .fetch_peggy_withdrawal_txs (
784+ sender = sender ,
785+ receiver = receiver ,
786+ pagination = pagination ,
787+ )
788+
668789 async def get_ibc_transfers (self , ** kwargs ):
790+ """
791+ This method is deprecated and will be removed soon. Please use `fetch_ibc_transfer_txs` instead
792+ """
793+ warn ("This method is deprecated. Use fetch_ibc_transfer_txs instead" , DeprecationWarning , stacklevel = 2 )
669794 req = explorer_rpc_pb .GetIBCTransferTxsRequest (
670795 sender = kwargs .get ("sender" ),
671796 receiver = kwargs .get ("receiver" ),
@@ -678,6 +803,26 @@ async def get_ibc_transfers(self, **kwargs):
678803 )
679804 return await self .stubExplorer .GetIBCTransferTxs (req )
680805
806+ async def fetch_ibc_transfer_txs (
807+ self ,
808+ sender : Optional [str ] = None ,
809+ receiver : Optional [str ] = None ,
810+ src_channel : Optional [str ] = None ,
811+ src_port : Optional [str ] = None ,
812+ dest_channel : Optional [str ] = None ,
813+ dest_port : Optional [str ] = None ,
814+ pagination : Optional [PaginationOption ] = None ,
815+ ) -> Dict [str , Any ]:
816+ return await self .exchange_explorer_api .fetch_ibc_transfer_txs (
817+ sender = sender ,
818+ receiver = receiver ,
819+ src_channel = src_channel ,
820+ src_port = src_port ,
821+ dest_channel = dest_channel ,
822+ dest_port = dest_port ,
823+ pagination = pagination ,
824+ )
825+
681826 # AccountsRPC
682827
683828 async def stream_subaccount_balance (self , subaccount_id : str , ** kwargs ):
@@ -2390,6 +2535,10 @@ def _exchange_cookie_metadata_requestor(self) -> Coroutine:
23902535 request = exchange_meta_rpc_pb .VersionRequest ()
23912536 return self .stubMeta .Version (request ).initial_metadata ()
23922537
2538+ def _explorer_cookie_metadata_requestor (self ) -> Coroutine :
2539+ request = explorer_rpc_pb .GetBlocksRequest ()
2540+ return self .stubExplorer .GetBlocks (request ).initial_metadata ()
2541+
23932542 def _initialize_timeout_height_sync_task (self ):
23942543 self ._cancel_timeout_height_sync_task ()
23952544 self ._timeout_height_sync_task = asyncio .get_event_loop ().create_task (self ._timeout_height_sync_process ())
0 commit comments