From ef8ae3d3c122035d2b32eb124e4a4dac77f404dc Mon Sep 17 00:00:00 2001 From: Arjan Zijderveld <5286904+arjanz@users.noreply.github.com> Date: Mon, 2 Aug 2021 12:43:38 +0200 Subject: [PATCH] Refactored all Struct properties to snake_case To ensure compatibility with generated `PortableRegistry` Structs --- substrateinterface/base.py | 21 +++++++++------------ test/test_query.py | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/substrateinterface/base.py b/substrateinterface/base.py index 4928106..a345212 100644 --- a/substrateinterface/base.py +++ b/substrateinterface/base.py @@ -1494,13 +1494,13 @@ def generate_signature_payload(self, call, era=None, nonce=0, tip=0, include_cal 'era': era, 'nonce': nonce, 'tip': tip, - 'specVersion': self.runtime_version, - 'genesisHash': genesis_hash, - 'blockHash': block_hash + 'spec_version': self.runtime_version, + 'genesis_hash': genesis_hash, + 'block_hash': block_hash } if self.transaction_version is not None: - payload_dict['transactionVersion'] = self.transaction_version + payload_dict['transaction_version'] = self.transaction_version signature_payload.encode(payload_dict) @@ -2264,7 +2264,7 @@ def decode_block(block_data): if log_digest.value['PreRuntime']['engine'] == 'BABE': validator_set = self.query("Session", "Validators", block_hash=block_hash) - rank_validator = log_digest.value['PreRuntime']['data']['authorityIndex'] + rank_validator = log_digest.value['PreRuntime']['data']['authority_index'] block_author = validator_set.elements[rank_validator] block_data['author'] = block_author.value @@ -2621,13 +2621,13 @@ def serialize_storage_item(self, storage_item, module, spec_version_id): storage_dict["type_value"] = type_info["value"] storage_dict["type_keys"] = [type_info["key"]] storage_dict["type_hashers"] = [type_info["hasher"]] - storage_dict["type_is_linked"] = type_info["isLinked"] + storage_dict["type_is_linked"] = type_info["is_linked"] elif type_class == 'DoubleMapType': storage_dict["type_value"] = type_info["value"] storage_dict["type_keys"] = [type_info["key1"], type_info["key2"]] - storage_dict["type_hashers"] = [type_info["hasher"], type_info["key2Hasher"]] + storage_dict["type_hashers"] = [type_info["hasher"], type_info["key2_hasher"]] elif type_class == 'NMapType': @@ -2977,15 +2977,12 @@ def process_events(self): elif event.value['module_id'] == 'System' and event.value['event_id'] == 'ExtrinsicFailed': self.__is_success = False - raise NotImplementedError() elif event.value['module_id'] == 'Treasury' and event.value['event_id'] == 'Deposit': - self.__total_fee_amount += event.params[0]['value'] - raise NotImplementedError() + self.__total_fee_amount += event.value['attributes'] elif event.value['module_id'] == 'Balances' and event.value['event_id'] == 'Deposit': - self.__total_fee_amount += event.params[0]['value'] - raise NotImplementedError() + self.__total_fee_amount += event.value['attributes'] else: if event.event_module.name == 'System' and event.event.name == 'ExtrinsicSuccess': diff --git a/test/test_query.py b/test/test_query.py index 1bcfd1b..9c691c3 100644 --- a/test/test_query.py +++ b/test/test_query.py @@ -60,7 +60,7 @@ def test_system_account_non_existing(self): { 'nonce': 0, 'consumers': 0, 'providers': 0, 'sufficients': 0, 'data': { - 'free': 0, 'reserved': 0, 'miscFrozen': 0, 'feeFrozen': 0 + 'free': 0, 'reserved': 0, 'misc_frozen': 0, 'fee_frozen': 0 } }, result.value)