From fa153ae12b3182478789b004e87987fcc847c36c Mon Sep 17 00:00:00 2001 From: zcmmwbd Date: Fri, 6 Dec 2024 09:54:13 +0800 Subject: [PATCH] Fix bug for nested struct array --- borsh/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/borsh/__init__.py b/borsh/__init__.py index 09f082b..6c432c9 100644 --- a/borsh/__init__.py +++ b/borsh/__init__.py @@ -324,7 +324,7 @@ def _deserialize_single(key: object, _schema: schema, _type: object, data: bytes # check for a schema elif isinstance(_type, types.struct): # get the corresponding struct definition as a schema - struct_schema = schema(_schema[key].struct_dict) + struct_schema = schema(_type.struct_dict) # loop through all of the keys in the struct struct_data = {} @@ -504,7 +504,7 @@ def _serialize_single(key, _type, _schema, data: object) -> bytes: elif isinstance(_type, types.struct): # get a reference to the struct and its schema struct_obj = data[key] - struct_schema = schema(_schema[key].struct_dict) + struct_schema = schema(_type.struct_dict) # loop over all of the keys in the struct for key in struct_obj.struct_dict.keys(): @@ -517,4 +517,4 @@ def _serialize_single(key, _type, _schema, data: object) -> bytes: else: raise NotImplementedError('serializing \'' + str(_type) + '\' not implemented yet') - return results \ No newline at end of file + return results