Skip to content

Commit

Permalink
Catch exception during init
Browse files Browse the repository at this point in the history
  • Loading branch information
arjanz committed Dec 28, 2023
1 parent 0c51858 commit 3c09172
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions substrateinterface/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 3c09172

Please sign in to comment.