From 3c09172d84822fbc3ed30e1d24772d223d2315b7 Mon Sep 17 00:00:00 2001 From: Arjan Zijderveld <5286904+arjanz@users.noreply.github.com> Date: Thu, 28 Dec 2023 16:24:59 +0100 Subject: [PATCH] Catch exception during init --- substrateinterface/contracts.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/substrateinterface/contracts.py b/substrateinterface/contracts.py index 5d5f307..89425e3 100644 --- a/substrateinterface/contracts.py +++ b/substrateinterface/contracts.py @@ -22,7 +22,7 @@ from .utils import version_tuple from substrateinterface.exceptions import ExtrinsicFailedException, DeployContractFailedException, \ - ContractReadFailedException, ContractMetadataParseException + ContractReadFailedException, ContractMetadataParseException, StorageFunctionNotFound from scalecodec.base import ScaleBytes, ScaleType from scalecodec.types import GenericContractExecResult from substrateinterface.base import SubstrateInterface, Keypair, ExtrinsicReceipt @@ -722,12 +722,19 @@ def __init__(self, contract_address: str, metadata: ContractMetadata = None, sub def init(self): # Determine ContractExecResult according to PalletVersion - pallet_version = self.substrate.query("Contracts", "PalletVersion") + try: + pallet_version = self.substrate.query("Contracts", "PalletVersion") - if pallet_version.value <= 9: - self.substrate.runtime_config.update_type_registry_types({"ContractExecResult": "ContractExecResultTo267"}) - else: - self.substrate.runtime_config.update_type_registry_types({"ContractExecResult": "ContractExecResultTo269"}) + if pallet_version.value <= 9: + self.substrate.runtime_config.update_type_registry_types( + {"ContractExecResult": "ContractExecResultTo267"} + ) + else: + self.substrate.runtime_config.update_type_registry_types( + {"ContractExecResult": "ContractExecResultTo269"} + ) + except StorageFunctionNotFound: + pass @classmethod def create_from_address(cls, contract_address: str, metadata_file: str,