Skip to content

Commit

Permalink
fix parsing Vec<>
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout committed Jan 16, 2025
1 parent 7d72bf1 commit b432e28
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/dipdup/runtimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ def decode_event_args(
qualname=name,
)
# FIXME: Do we need original type names?
arg_types = event_abi.get('args_type_name') or event_abi['args']
# arg_types = event_abi.get('args_type_name') or event_abi['args']
arg_types = event_abi['args']
arg_names = get_event_arg_names(event_abi)

if isinstance(args, list):
Expand All @@ -187,17 +188,17 @@ def decode_event_args(
payload[key] = value['__kind']
continue

# NOTE: Scale decoder expects vec length at the beginning
if type_.startswith('Vec<'):
value_len = len(value[2:]) * 2
value = f'0x{value_len:02x}{value[2:]}'

scale_obj = self.runtime_config.create_scale_object(
type_string=type_,
data=ScaleBytes(value),
metadata=spec_obj._metadata,
)

# NOTE: Exception is raised after decoding is over
with suppress(RemainingScaleBytesNotEmptyException):
scale_obj.decode(check_remaining=False)

payload[key] = scale_obj.value_serialized
payload[key] = scale_obj.process()

# NOTE: Subsquid camelcases arg keys for some reason
for key in copy(payload):
Expand Down

0 comments on commit b432e28

Please sign in to comment.