From 6025447827b7dcba14af58faa92a3bdfb5392d6d Mon Sep 17 00:00:00 2001 From: Sherif Abdelmoatty Date: Mon, 30 Dec 2024 11:36:44 +0300 Subject: [PATCH] add comments to UserOpFoundException and UserOpReceiptFoundException --- voltaire_bundler/bundle/exceptions.py | 4 ++++ voltaire_bundler/execution_endpoint.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/voltaire_bundler/bundle/exceptions.py b/voltaire_bundler/bundle/exceptions.py index 7e915c2..2b0fa60 100644 --- a/voltaire_bundler/bundle/exceptions.py +++ b/voltaire_bundler/bundle/exceptions.py @@ -46,11 +46,15 @@ class MethodNotFoundException(Exception): exception_code: ExecutionExceptionCode +# This exception to use with asyncio.wait() to return a successful result with for +# eth_getUserOperationByHash @dataclass class UserOpFoundException(Exception): user_op_by_hash_result: dict +# This exception to use with asyncio.wait() to return a successful result with for +# eth_getUserOperationReceipt @dataclass class UserOpReceiptFoundException(Exception): user_op_receipt_result: dict diff --git a/voltaire_bundler/execution_endpoint.py b/voltaire_bundler/execution_endpoint.py index d7126aa..b98c192 100644 --- a/voltaire_bundler/execution_endpoint.py +++ b/voltaire_bundler/execution_endpoint.py @@ -393,9 +393,12 @@ async def _event_rpc_getUserOperationByHash( for res in done: excep = res.exception() + # UserOpFoundException raised means a successful result was returned if isinstance(excep, UserOpFoundException): + # there can only be one successful result, so return the first result return excep.user_op_by_hash_result elif excep is not None: + # reraise the exception if it is not UserOpFoundException raise excep return None @@ -430,9 +433,12 @@ async def _event_rpc_getUserOperationReceipt( for res in done: excep = res.exception() + # UserOpReceiptFoundException raised means a successful result was returned if isinstance(excep, UserOpReceiptFoundException): + # there can only be one successful result, so return the first result return excep.user_op_receipt_result elif excep is not None: + # reraise the exception if it is not UserOpReceiptFoundException raise excep return None