Skip to content

Commit

Permalink
update: for getUserOperationReceipt, search in ep v0.07 and v0.06 con…
Browse files Browse the repository at this point in the history
…currently
  • Loading branch information
sherifahmed990 committed Dec 30, 2024
1 parent ee4c1fd commit f7849d1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
5 changes: 5 additions & 0 deletions voltaire_bundler/bundle/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,8 @@ class MethodNotFoundException(Exception):
@dataclass
class UserOpFoundException(Exception):
user_op_by_hash_result: dict


@dataclass
class UserOpReceiptFoundException(Exception):
user_op_receipt_result: dict
36 changes: 23 additions & 13 deletions voltaire_bundler/execution_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from voltaire_bundler.bundle.exceptions import \
ExecutionException, OtherJsonRpcErrorCode, OtherJsonRpcErrorException, \
UserOpFoundException, ValidationException, ValidationExceptionCode
UserOpFoundException, UserOpReceiptFoundException, ValidationException, ValidationExceptionCode
from voltaire_bundler.cli_manager import ConditionalRpc
from voltaire_bundler.event_bus_manager.endpoint import Client, Endpoint
from voltaire_bundler.typing import Address
Expand Down Expand Up @@ -408,23 +408,33 @@ async def _event_rpc_getUserOperationReceipt(
ValidationExceptionCode.InvalidFields,
"Missing/invalid userOpHash",
)
user_operation_receipt_info_json_ops = []
if self.user_operation_handler_v6 is not None:
user_operation_receipt_info_json = (
await self.user_operation_handler_v6.get_user_operation_receipt_rpc(
user_operation_receipt_info_json_ops.append(asyncio.create_task(
self.user_operation_handler_v6.get_user_operation_receipt_rpc(
user_operation_hash,
LocalMempoolManagerV6.entrypoint,
)
))
)
if user_operation_receipt_info_json is not None:
return user_operation_receipt_info_json

user_operation_receipt_info_json = (
await self.user_operation_handler_v7.get_user_operation_receipt_rpc(
user_operation_hash,
LocalMempoolManagerV7.entrypoint,
)
)
return user_operation_receipt_info_json
user_operation_receipt_info_json_ops.append(asyncio.create_task(
self.user_operation_handler_v7.get_user_operation_receipt_rpc(
user_operation_hash,
LocalMempoolManagerV7.entrypoint,
))
)
done, _ = await asyncio.wait(
user_operation_receipt_info_json_ops,
return_when=asyncio.FIRST_EXCEPTION
)

for res in done:
excep = res.exception()
if isinstance(excep, UserOpReceiptFoundException):
return excep.user_op_receipt_result
elif excep is not None:
raise excep
return None

async def _event_debug_bundler_sendBundleNow(self, _) -> str:
await self.bundle_manager.send_next_bundle()
Expand Down
4 changes: 2 additions & 2 deletions voltaire_bundler/user_operation/user_operation_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging

from eth_abi import encode, decode
from voltaire_bundler.bundle.exceptions import UserOpReceiptFoundException
from voltaire_bundler.typing import Address
from voltaire_bundler.utils.eth_client_utils import \
get_latest_block_info, send_rpc_request_to_eth_client
Expand Down Expand Up @@ -118,8 +119,7 @@ async def get_user_operation_receipt_rpc(
"logs": user_operation_receipt_info.logs,
"receipt": receipt_info_json,
}

return user_operation_receipt_rpc_json
raise UserOpReceiptFoundException(user_operation_receipt_rpc_json)

async def get_user_operation_event_log_info(
self, user_operation_hash: str, entrypoint: str
Expand Down

0 comments on commit f7849d1

Please sign in to comment.