Skip to content

Commit

Permalink
add comments to UserOpFoundException and UserOpReceiptFoundException
Browse files Browse the repository at this point in the history
  • Loading branch information
sherifahmed990 committed Dec 30, 2024
1 parent f7849d1 commit 6025447
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions voltaire_bundler/bundle/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions voltaire_bundler/execution_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 6025447

Please sign in to comment.