diff --git a/README.md b/README.md index 5fe00af..ee58ac7 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,6 @@ https://polkascan.github.io/py-substrate-interface/ pip install substrate-interface ``` -## Examples - ### Initialization The following examples show how to initialize for supported chains: @@ -104,6 +102,19 @@ substrate = SubstrateInterface( ``` +## Keeping type registry presets up to date + +When on-chain runtime upgrades occur, types used in call- or storage functions can be added or modified. Therefor it is +important to keep the type registry presets up to date. At the moment the type registry for Polkadot, Kusama and Kulupu + are being actively maintained for this library and an check and update procedure can be triggered with: + +```python +substrate.update_type_registry_presets() +``` + +## Examples + + ### Get extrinsics for a certain block diff --git a/requirements.txt b/requirements.txt index 940eae2..e9350e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,15 +1,15 @@ -docker>=4.2.2 +docker>=4.3.1 websockets==8.1 -base58>=1.0.3 +base58>=2.0.1 certifi>=2020.6.20 chardet>=3.0.4 idna>=2.10 requests==2.24.0 -urllib3>=1.25.9 +urllib3>=1.25.11 xxhash>=1.3.0 -pytest>=4.4.0 +pytest>=6.1.1 -scalecodec>=0.10.26 +scalecodec>=0.10.27 py-sr25519-bindings>=0.1.2 py-ed25519-bindings>=0.1.1 py-bip39-bindings>=0.1.6 diff --git a/setup.py b/setup.py index 9771d7c..1f29aa8 100644 --- a/setup.py +++ b/setup.py @@ -183,7 +183,7 @@ 'requests>=2.24.0', 'urllib3>=1.25.10', 'xxhash>=1.3.0', - 'scalecodec>=0.10.26', + 'scalecodec>=0.10.27', 'py-sr25519-bindings>=0.1.2', 'py-ed25519-bindings>=0.1.1', 'py-bip39-bindings>=0.1.6' diff --git a/substrateinterface/__init__.py b/substrateinterface/__init__.py index bee6eb6..1702079 100644 --- a/substrateinterface/__init__.py +++ b/substrateinterface/__init__.py @@ -28,6 +28,7 @@ from scalecodec.block import ExtrinsicsDecoder, EventsDecoder, LogDigest from scalecodec.metadata import MetadataDecoder from scalecodec.type_registry import load_type_registry_preset +from scalecodec.updater import update_type_registries from .subkey import Subkey from .utils.hasher import blake2_256, two_x64_concat, xxh64, xxh128, blake2_128, blake2_128_concat, identity @@ -1902,3 +1903,10 @@ def serialize_module_error(self, module, error, spec_version): "module_name": module.name, "spec_version": spec_version } + + def update_type_registry_presets(self): + try: + update_type_registries() + return True + except Exception: + return False