From 224c335806c76380c2dcde9147b5bde5e596eff2 Mon Sep 17 00:00:00 2001 From: Lev Gorodetskiy Date: Wed, 15 Jan 2025 00:40:02 -0300 Subject: [PATCH] padding wip --- src/dipdup/runtimes.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/dipdup/runtimes.py b/src/dipdup/runtimes.py index 3fc8d6d5b..d37bb9d0c 100644 --- a/src/dipdup/runtimes.py +++ b/src/dipdup/runtimes.py @@ -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( @@ -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_, @@ -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