Skip to content

Commit

Permalink
adding getter method for get_class
Browse files Browse the repository at this point in the history
  • Loading branch information
elicbarbieri committed May 18, 2024
1 parent 80e0d21 commit 273ff93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
13 changes: 0 additions & 13 deletions starknet_abi/decoding_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@ class DecodedEvent:
data: dict[str, Any]


@dataclass(slots=True)
class DecodedOperation:
"""
Dataclass representing a decoded user operation. If operation is unknown, the name will be set to
'Unknown' and params set to the raw calldata inputs.
"""

operation_name: str
operation_params: dict[str, Any]


@dataclass(slots=True)
class AbiFunction:
"""
Expand Down
10 changes: 8 additions & 2 deletions starknet_abi/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class EventDispatchInfo:
class ClassDispatcher:
"""
Dispatcher Entry for a Class. Contains a mapping from function_ids -> FunctionDispatchInfo and a mapping from
event_ids -> EventDispatchInfo. Also contains full class hash, abi name, and will later include additional
metadata fields/classifications ie. Proxy or ArgentAccount
event_ids -> EventDispatchInfo
"""

function_ids: dict[bytes, FunctionDispatchInfo]
Expand Down Expand Up @@ -93,6 +92,13 @@ def __init__(self):
self.event_types = {}
self.function_types = {}

def get_class(self, class_hash: bytes) -> ClassDispatcher | None:
"""
Returns a ClassDispatcher for a given class_hash, or None if the class_hash is not present in the dispatcher.
will work with both a full class hash, or an 8-byte class-id
"""
return self.class_ids.get(class_hash[-8:])

def _add_abi_functions(self, abi: StarknetAbi) -> dict[bytes, FunctionDispatchInfo]:
"""
Parse the list of ABI Functions to a dictionary of FunctionDispatchInfo objects.
Expand Down

0 comments on commit 273ff93

Please sign in to comment.