Skip to content

Commit

Permalink
padding wip
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout committed Jan 15, 2025
1 parent a2f3e3a commit 224c335
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/dipdup/runtimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def decode_event_args(
spec_version: str,
) -> dict[str, Any]:
from scalecodec.base import ScaleBytes
from scalecodec.exceptions import RemainingScaleBytesNotEmptyException

spec_obj = self.get_spec_version(spec_version)
event_abi = spec_obj.get_event_abi(
Expand Down Expand Up @@ -178,6 +179,9 @@ def decode_event_args(
if isinstance(value, int):
payload[key] = value
continue
if isinstance(value, dict) and '__kind' in value:
payload[key] = value['__kind']
continue

scale_obj = self.runtime_config.create_scale_object(
type_string=type_,
Expand All @@ -186,8 +190,18 @@ def decode_event_args(
)

# FIXME: padding
try:
scale_obj.decode(check_remaining=False)
except RemainingScaleBytesNotEmptyException:
padded_value = value + ('00' * (scale_obj.data.offset - scale_obj.data.length))
print(padded_value)
scale_obj = self.runtime_config.create_scale_object(
type_string=type_,
data=ScaleBytes(padded_value),
metadata=spec_obj._metadata,
)
scale_obj.decode(check_remaining=False)

scale_obj.decode(check_remaining=False)
payload[key] = scale_obj.value_serialized

return payload

0 comments on commit 224c335

Please sign in to comment.