@@ -682,6 +682,33 @@ def response_callback(payload: Dict[str, Any]):
682682
683683 return await f
684684
685+ async def query_auth (self , id : str ) -> Dict [str , Any ]:
686+ request_id = random_string (16 )
687+ loop = asyncio .get_running_loop ()
688+ f : asyncio .Future [Dict [str , Any ]] = loop .create_future ()
689+
690+ def response_callback (payload : Dict [str , Any ]):
691+ if payload .get ("request_id" ) != request_id :
692+ return
693+ self .__mainframe .remove_request_response_callback (self .session_id , request_id , response_callback )
694+ if payload .get ("result" ) is not None :
695+ loop .call_soon_threadsafe (lambda : f .set_result (payload .get ("result" , {})))
696+ elif payload .get ("error" ) is not None :
697+ loop .call_soon_threadsafe (lambda : f .set_exception (ValueError (payload .get ("error" , "Unknown error occurred while querying the auth." ))))
698+
699+ self .__mainframe .add_request_response_callback (self .session_id , request_id , response_callback )
700+
701+ self .__mainframe .send (self .job_info , {
702+ "type" : "BlockRequest" ,
703+ "action" : "QueryAuth" ,
704+ "id" : id ,
705+ "session_id" : self .session_id ,
706+ "job_id" : self .job_id ,
707+ "request_id" : request_id ,
708+ })
709+
710+ return await f
711+
685712 async def query_block (self , block : str ) -> QueryBlockResponse :
686713 """
687714 this is a experimental api, it is used to query the block information..
0 commit comments