Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions jamcodec/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def encode(self, value: dict) -> JamBytes:
if name not in value:
raise ScaleEncodeException(f'Argument "{name}" of Struct is missing in given value')

data += scale_obj.new().encode(value[name])
data += scale_obj.encode(value[name])

if value[name] and issubclass(value[name].__class__, JamCodecType):
value[name] = value[name].serialize()
Expand Down Expand Up @@ -280,7 +280,7 @@ def encode(self, value: tuple) -> JamBytes:
data = JamBytes(bytearray())
for idx, scale_obj in enumerate(self.values):

data += scale_obj.new().encode(value[idx])
data += scale_obj.encode(value[idx])
return data

def decode(self, data: JamBytes) -> tuple:
Expand Down Expand Up @@ -377,7 +377,7 @@ def encode(self, value: Union[str, dict]) -> JamBytes:

if variant_obj is not None:

data += variant_obj.new().encode(enum_value)
data += variant_obj.encode(enum_value)

return data

Expand Down Expand Up @@ -603,9 +603,12 @@ def encode(self, value: list) -> JamBytes:
data = VarInt64.encode(len(value))

for idx, item in enumerate(value):
data += self.type_def.new().encode(item)
if item and issubclass(item.__class__, JamCodecType):
value[idx] = item.serialize()
if type(item) is JamBytes:
data += item
else:
data += self.type_def.encode(item)
if item and issubclass(item.__class__, JamCodecType):
value[idx] = item.serialize()

return data

Expand Down