Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
Rpc v0.3.0 update (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekryba authored Jun 1, 2023
1 parent 744e9b3 commit 3618d77
Show file tree
Hide file tree
Showing 11 changed files with 602 additions and 151 deletions.
6 changes: 3 additions & 3 deletions starknet_devnet/blueprints/rpc/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ async def call(request: RpcFunctionCall, block_id: BlockId) -> List[Felt]:
return [rpc_felt(res) for res in result["result"]]
except StarkException as ex:
if ex.code.name == "TRANSACTION_FAILED" and ex.code.value == 39:
raise RpcError.from_spec_name("INVALID_CALL_DATA") from ex
raise RpcError.from_spec_name("CONTRACT_ERROR") from ex
if (
f"Entry point {gateway_felt(request['entry_point_selector'])} not found"
in ex.message
):
raise RpcError.from_spec_name("INVALID_MESSAGE_SELECTOR") from ex
raise RpcError.from_spec_name("CONTRACT_ERROR") from ex
if "While handling calldata" in ex.message:
raise RpcError.from_spec_name("INVALID_CALL_DATA") from ex
raise RpcError.from_spec_name("CONTRACT_ERROR") from ex
raise RpcError(
code=PredefinedRpcErrorCode.INTERNAL_ERROR.value, message=ex.message
) from ex
10 changes: 7 additions & 3 deletions starknet_devnet/blueprints/rpc/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
def check_address(address, event):
"""
Check address.
If no address is set in the filter, it returns True.
"""
return event.from_address == int(address, 0)
return address is None or event.from_address == int(address, 0)


def _check_keys(keys: List[List[Felt]], event):
Expand Down Expand Up @@ -135,8 +137,10 @@ async def get_events(
and chunk it later which is not an optimal solution.
"""
# Required parameters
from_block = await get_block_by_block_id(filter.get("from_block"))
to_block = await get_block_by_block_id(filter.get("to_block"))
from_block = await get_block_by_block_id(
filter.get("from_block", {"block_number": 0})
)
to_block = await get_block_by_block_id(filter.get("to_block", "latest"))
block_range = await _get_events_range(from_block, to_block)

try:
Expand Down
Loading

0 comments on commit 3618d77

Please sign in to comment.