Skip to content

Commit

Permalink
Added update type registry presets function
Browse files Browse the repository at this point in the history
  • Loading branch information
Arjan Zijderveld committed Oct 28, 2020
1 parent e720198 commit 1d25fb2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 8 additions & 0 deletions substrateinterface/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 1d25fb2

Please sign in to comment.