Python

scalecodec

Latest version: v1.1.1

PyUp actively tracks 471,271 Python packages for vulnerabilities to keep your Python environments secure.

Scan your dependencies

1.1.1

What's Changed
* Added max recursion to type decomposition by arjanz in https://github.com/polkascan/py-scale-codec/pull/92


**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.1.0...v1.1.1

1.1.0

| ⚠️ This release has some data structure changes |
|-----------------------------------------|

Potential breaking changes

* Type registry `default` renamed to `legacy` (for runtimes prior to `MetadataV14`)
* Type registry `metadata_types` renamed to `core` (for runtimes `MetadataV14` and higher)
* Named fields in composite fields are now respected, which means that types can be rendered differently. What used to be a `tuple` of values can now be a `dict` with named fields (for example `EventRecord`).

What's Changed
* New type decomposition by arjanz in https://github.com/polkascan/py-scale-codec/pull/90

This introduces a new function

The function `generate_type_decomposition()` can be
used when more information is needed how to encode a certain SCALE type:

_Example 1_
python
scale_obj = runtime_config.create_scale_object("RawBabePreDigest")

type_info = scale_obj.generate_type_decomposition()

print(type_info)
{
'Phantom': None,
'Primary': {'authority_index': 'u32', 'slot_number': 'u64', 'vrf_output': '[u8; 32]', 'vrf_proof': '[u8; 64]'},
'SecondaryPlain': {'authority_index': 'u32', 'slot_number': 'u64'},
'SecondaryVRF': {'authority_index': 'u32', 'slot_number': 'u64', 'vrf_output': '[u8; 32]', 'vrf_proof': '[u8; 64]'}
}


_Example 2_
python
pallet = metadata.get_metadata_pallet("Tokens")
storage_function = pallet.get_storage_function("TotalIssuance")

param_type_string = storage_function.get_params_type_string()
param_type_obj = runtime_config.create_scale_object(param_type_string[0])

type_info = param_type_obj.generate_type_decomposition()

print(type_info)
[{
'Token': ('ACA', 'AUSD', 'DOT', 'LDOT', 'RENBTC', 'CASH', 'KAR', 'KUSD', 'KSM', 'LKSM', 'TAI', 'BNC', 'VSKSM', 'PHA', 'KINT', 'KBTC'),
'DexShare': ({'Token': ('ACA', 'AUSD', 'DOT', 'LDOT', 'RENBTC', 'CASH', 'KAR', 'KUSD', 'KSM', 'LKSM', 'TAI', 'BNC', 'VSKSM', 'PHA', 'KINT', 'KBTC'), 'Erc20': '[u8; 20]', 'LiquidCrowdloan': 'u32', 'ForeignAsset': 'u16'}, {'Token': ('ACA', 'AUSD', 'DOT', 'LDOT', 'RENBTC', 'CASH', 'KAR', 'KUSD', 'KSM', 'LKSM', 'TAI', 'BNC', 'VSKSM', 'PHA', 'KINT', 'KBTC'), 'Erc20': '[u8; 20]', 'LiquidCrowdloan': 'u32', 'ForeignAsset': 'u16'}),
'Erc20': '[u8; 20]',
'StableAssetPoolToken': 'u32',
'LiquidCrowdloan': 'u32',
'ForeignAsset': 'u16'
}]


* Runtime API call definitions by arjanz in https://github.com/polkascan/py-scale-codec/pull/91



**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.48...v1.1.0

1.1.0a1

| ⚠️ This release has some data structure changes |
|-----------------------------------------|

Potential breaking changes

* Type registry `default` renamed to `legacy` (for runtimes prior to `MetadataV14`)
* Type registry `metadata_types` renamed to `core` (for runtimes `MetadataV14` and higher)
* Named fields in composite fields are now respected, which means that types can be rendered differently. What used to be a `tuple` of values can now be a `dict` with named fields.

What's Changed
* New type decomposition by arjanz in https://github.com/polkascan/py-scale-codec/pull/90

This introduces a new function

The function `generate_type_decomposition` can be
used when more information is needed how to encode a certain SCALE type:

_Example 1_
python
scale_obj = runtime_config.create_scale_object("RawBabePreDigest")

type_info = scale_obj.generate_type_decomposition()

print(type_info)
{
'Phantom': None,
'Primary': {'authority_index': 'u32', 'slot_number': 'u64', 'vrf_output': '[u8; 32]', 'vrf_proof': '[u8; 64]'},
'SecondaryPlain': {'authority_index': 'u32', 'slot_number': 'u64'},
'SecondaryVRF': {'authority_index': 'u32', 'slot_number': 'u64', 'vrf_output': '[u8; 32]', 'vrf_proof': '[u8; 64]'}
}


_Example 2_
python
pallet = metadata.get_metadata_pallet("Tokens")
storage_function = pallet.get_storage_function("TotalIssuance")

param_type_string = storage_function.get_params_type_string()
param_type_obj = runtime_config.create_scale_object(param_type_string[0])

type_info = param_type_obj.generate_type_decomposition()

print(type_info)
[{
'Token': ('ACA', 'AUSD', 'DOT', 'LDOT', 'RENBTC', 'CASH', 'KAR', 'KUSD', 'KSM', 'LKSM', 'TAI', 'BNC', 'VSKSM', 'PHA', 'KINT', 'KBTC'),
'DexShare': ({'Token': ('ACA', 'AUSD', 'DOT', 'LDOT', 'RENBTC', 'CASH', 'KAR', 'KUSD', 'KSM', 'LKSM', 'TAI', 'BNC', 'VSKSM', 'PHA', 'KINT', 'KBTC'), 'Erc20': '[u8; 20]', 'LiquidCrowdloan': 'u32', 'ForeignAsset': 'u16'}, {'Token': ('ACA', 'AUSD', 'DOT', 'LDOT', 'RENBTC', 'CASH', 'KAR', 'KUSD', 'KSM', 'LKSM', 'TAI', 'BNC', 'VSKSM', 'PHA', 'KINT', 'KBTC'), 'Erc20': '[u8; 20]', 'LiquidCrowdloan': 'u32', 'ForeignAsset': 'u16'}),
'Erc20': '[u8; 20]',
'StableAssetPoolToken': 'u32',
'LiquidCrowdloan': 'u32',
'ForeignAsset': 'u16'
}]



**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.48...v1.1.0a1

1.0.48

What's Changed
* ScaleInfo path changed for BoundedVec by arjanz in https://github.com/polkascan/py-scale-codec/pull/89


**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.47...v1.0.48

1.0.47

What's Changed
* GenericVote available for all pallets by arjanz in https://github.com/polkascan/py-scale-codec/pull/88


**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.46...v1.0.47

1.0.46

What's Changed
* Added Acala specific `MultiSignature` type by arjanz in https://github.com/polkascan/py-scale-codec/pull/85
* `WeightV2` type


**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.45...v1.0.46

1.0.45

What's Changed
* Extended type path wildcard search (Thanks to Neopallium)
* Added new ink! path by arjanz in https://github.com/polkascan/py-scale-codec/pull/83


**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.44...v1.0.45

1.0.44

What's Changed
* Added paths for `RuntimeCall` and `RuntimeEvent` by arjanz in https://github.com/polkascan/py-scale-codec/pull/81


**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.43...v1.0.44

1.0.43

Add `RawAuraPreDigest` to metadata_types.json - In order to use this type for `PortableRegistry` runtimes

1.0.42

Added signatories and threshold to `MultiAccountId`

1.0.41

What's Changed
* Added Karura override for runtime_common type by arjanz in https://github.com/polkascan/py-scale-codec/pull/78


**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.40...v1.0.41

1.0.40

What's Changed
* Added get_param_info function to Variant by arjanz in https://github.com/polkascan/py-scale-codec/pull/76


**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.39...v1.0.40

1.0.39

Updated Crust network type registry 75

1.0.38

* Added Polymesh type registry 74
* Allow bytes for encoding of `FixedLengthArray`

1.0.37

Added type registry for Crust Network 73

1.0.36

What's Changed
* Support for F32 and F64 by arjanz in https://github.com/polkascan/py-scale-codec/pull/72


**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.35...v1.0.36

1.0.35

Fixed BTreeSet implementation

1.0.34

What's Changed
* Added type decomposition for storage functions by arjanz in https://github.com/polkascan/py-scale-codec/pull/70


**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.33...v1.0.34

1.0.33

* Added `RawBytes` type
* Also generate extrinsic_hash for unsigned extrinsics 69

1.0.32

* Set value_object to raw bytes in case of `Vec<u8>`
* Added gas_required to `GenericContractExecResult`

1.0.31

Fixed missing get_module_error implementation for MetadataV14+

1.0.30

Also accept derived classes as encoding input

1.0.29

Added `WrapperKeepOpaque` type

**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.28...v1.0.29

1.0.28

What's Changed
* Corrected number of storage function params based on hashers by arjanz in https://github.com/polkascan/py-scale-codec/pull/65


**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.27...v1.0.28

1.0.27

Added Moonbeam type registry

1.0.26

Added missing `EthereumAddress` type in Moonriver type registry

1.0.25

Added `ChargeAssetTxPayment` extension support

1.0.24

Fixed missing param type check in `ScaleInfoStorageEntryMetadata`

1.0.23

Added missing (legacy) signed extensions

1.0.22

Added missing signed extensions

1.0.21

Added signed extensions to metadata

**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.20...v1.0.21

1.0.20

* Check signed extensions in metadata for ExtrinsicV4
* Removed obsolete LogDigest class 62

1.0.19

Added Moonbase Alpha type registry preset

1.0.18

Summary

* Treat `Moment` consistently as an `u64` as per the Substrate codebase
* Added `GenericEthereumAccountId` decoding class
* Removed long overdue deprecated kwargs in ss58 module (breaking)

**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.17...v1.0.18

1.0.17

Summary

Added Karura and Moonriver type registry

**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.16...v1.0.17

1.0.16

* Added variable prefix as type registry namespace for ScaleInfoTypes
* Added ScaleInfo path for ink `AccountId` type

**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.15...v1.0.16

1.0.15

* Fixed 'fallback' to 'default' element for StorageEntryMetadataV9
* Westend type registry fixes

**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.14...v1.0.15

1.0.14

Fixed missing entry in StorageHasherV9

1.0.13

Added modifier and docs properties to GenericStorageEntryMetadata

1.0.12

Changes

* Fixed issues decoding nested Calls polkascan/py-substrate-interface143
* Skip unnecessary type conversion for scale_info type registries (performance boost `MetadataV14`)
* Decode Compact bytes to int directly 58

**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.11...v1.0.12

1.0.11

Added docs property to `GenericEventMetadata`

1.0.10

Fixed issue with LookupSource arg decoding in GenericCall 56

**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.9...v1.0.10

1.0.9

Add RawBabePreDigest types to ScaleInfo base registry

**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.8...v1.0.9

1.0.8

* Incorrect processing of BTreeMap types in MetadataV14

**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.7...v1.0.8

1.0.7

* Fixed exception when event had no attributes 54
* Fixed exception when `Call` has no args 56

**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.6...v1.0.7

1.0.6

Pallet index is explicitly stored in metadata

**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v0.11.24...v1.0.6

1.0.5

Added alias for type `xcm::latest::Outcome`

1.0.4

What's Changed
* Keep value_object of Enum consistent with type_mapping
* Fixed GenericEventRecord processing

**Full Changelog**: https://github.com/polkascan/py-scale-codec/compare/v1.0.3...v1.0.4

1.0.3

Kusama and Rococo type registry update

1.0.2

Added missing Contract types to ScaleInfo type registry

1.0.1

Changed base URL to online type registries

1.0.0

| ⚠️ This new major release is not fully backwards compatible with v0.11 releases |
|-----------------------------------------|

Support for `MetadataV14` and `PortableRegistry`.

It has the following breaking changes:

- All properties of `Struct` objects in existing type-registries are now converted from CamelCase to snake_case, to be compatible with generated `PortableRegistry` structs
- `scale_obj.value` always contains a serialised version in Python primitives
- `scale_obj.serialize()` will contain a human readable format
- `scale_obj.value_object` contains the full nested SCALE objects if applicable. A short-hand of `scale_obj.value_object[‘accounts’].value_object[0].ss58_address` is `scale_obj[‘accounts’][0].ss58_address`. If the `scale_obj` is a `Vec` this will also act as an iterable.
- Reformatting of value attributes of many `ScaleType` classes; in particular `Extrinsic` and `Event`
- Metadata decoding has been completely refactored and should use `MetadataVersioned` in stead of removed `MetadataDecoder`
- All `ScaleType` classes moved to `types` sub-package; `block` sub-package is removed

1.0.0a3

| ⚠️ This alpha release is not backwards compatible with earlier releases |
|-----------------------------------------|

This version is a pre-release and compatible with upcoming `MetadataV14` and `PortableRegistry`.

It has the following breaking changes:

- All properties of `Struct` objects in existing type-registries are now converted from CamelCase to snake_case, to be compatible with generated `PortableRegistry` structs
- `scale_obj.value` always contains a serialised version in Python primitives
- `scale_obj.serialize()` will contain a human readable format
- `scale_obj.value_object` contains the full nested SCALE objects if applicable. A short-hand of `scale_obj.value_object[‘accounts’].value_object[0].ss58_address` is `scale_obj[‘accounts’][0].ss58_address`. If the `scale_obj` is a `Vec` this will also act as an iterable.
- Reformatting of value attributes of many `ScaleType` classes; in particular `Extrinsic` and `Event`
- Metadata decoding has been completely refactored and should use `MetadataVersioned` in stead of removed `MetadataDecoder`
- All `ScaleType` classes moved to `types` sub-package; `block` sub-package is removed

1.0.0a2

| ⚠️ This alpha release is not backwards compatible with earlier releases |
|-----------------------------------------|

This version is a pre-release and compatible with upcoming `MetadataV14` and `PortableRegistry`.

It has the following breaking changes:

- All properties of `Struct` objects in existing type-registries are now converted from CamelCase to snake_case, to be compatible with generated `PortableRegistry` structs
- `scale_obj.value` always contains a serialised version in Python primitives
- `scale_obj.serialize()` will contain a human readable format
- `scale_obj.value_object` contains the full nested SCALE objects if applicable. A short-hand of `scale_obj.value_object[‘accounts’].value_object[0].ss58_address` is `scale_obj[‘accounts’][0].ss58_address`. If the `scale_obj` is a `Vec` this will also act as an iterable.
- Reformatting of value attributes of many `ScaleType` classes; in particular `Extrinsic` and `Event`
- Metadata decoding has been completely refactored and should use `MetadataVersioned` in stead of removed `MetadataDecoder`
- All `ScaleType` classes moved to `types` sub-package; `block` sub-package is removed

1.0.0a1

| ⚠️ This alpha release is not backwards compatible with earlier releases |
|-----------------------------------------|

This version is a pre-release and compatible with upcoming `MetadataV14` and `PortableRegistry`.

It has the following breaking changes:

- All properties of `Struct` objects in existing type-registries are now converted from CamelCase to snake_case, to be compatible with generated `PortableRegistry` structs
- `scale_obj.value` always contains a serialised version in Python primitives
- `scale_obj.serialize()` will contain a human readable format
- `scale_obj.value_object` contains the full nested SCALE objects if applicable. A short-hand of `scale_obj.value_object[‘accounts’].value_object[0].ss58_address` is `scale_obj[‘accounts’][0].ss58_address`. If the `scale_obj` is a `Vec` this will also act as an iterable.
- Reformatting of value attributes of many `ScaleType` classes; in particular `Extrinsic` and `Event`
- Metadata decoding has been completely refactored and should use `MetadataVersioned` in stead of removed `MetadataDecoder`
- All `ScaleType` classes moved to `types` sub-package; `block` sub-package is removed

0.11.24

Added alias for type `xcm::latest::Outcome`

0.11.23

Kusama and Rococo type registry update

0.11.22

Changed base URL to online type registries

0.11.21

Type registry update

0.11.20

Support for `Enum` types with explicit specified index numbers

0.11.19

* Fixed `ValidDisputeStatementKind`
* Updated Polkadot runtime upgrade history

0.11.18

Type registry update

0.11.17

* Added SubmissionIndicesOf, SignedSubmissionOf types
* Added BoundedBTreeMap
* Kusama upgrade 9080

0.11.16

Added `Emergency` to `ElectionPhase`

0.11.15

CompactAssignmentsWith16` for Polkadot 9050

0.11.14

Polkadot, Kusama and Westend runtime upgrades

0.11.13

Type registry update

0.11.12

Runtime upgrades 9050

0.11.11

Type registry update

0.11.10

Type registry update

0.11.9

Bump Kusama runtime_id

0.11.8

Updated development type registry

0.11.7

* GenericMultiAddress encode/decode did not correctly detect SS58 encoded values
* Include type_string in RemainingScaleBytesNotEmptyException
* Type registry update

0.11.6

Update field names in `FundInfo` to match Polkadot definition

0.11.5

* Added new bridge types
* Fixed NMap hasher in MetadataV13

0.11.4

* Westend has `CompactAssignments` with 16 nominators
* Updated `FundInfo` type (thanks to antonkhvorov)

0.11.3

Support for CompactSolution with 24 nominees

0.11.2

Kusama runtime upgrade 9010

0.11.1

* Added Statemint and Statemine type registry presets
* Bumped westend and rococo runtime id
* Type registry update

0.11.0

A tuple is now decoded as `(1, 2)` in stead of `{"col1": 1, "col2": 2}`

0.10.88

* Updated Cumulus types
* Added BTreeSet class
* Automatically convert AccountId to SS58 format if set

0.10.87

0.10.86

* MetadataV13 support
* Added HashMap, BTreeMap and Map types

0.10.85

0.10.84

0.10.83

0.10.82

0.10.81

0.10.80

0.10.79

0.10.78

0.10.77

0.10.76

* XCM types
* Fixed case related inconsistencies
* Unwrap Box types

0.10.75

0.10.74

0.10.73

0.10.72

0.10.71

0.10.70

0.10.69

0.10.68

0.10.67

0.10.66

0.10.65

0.10.64

0.10.63

0.10.62

0.10.61

* Implemented Address20, Address32 and Bytes MultiAddress variants
* Bumped Polkadot type registry

0.10.60

0.10.59

0.10.58

0.10.57

0.10.56

0.10.55

0.10.54

0.10.53

Updated runtime upgrade versioning for Polkadot, Kusama, Rococo and Westend

0.10.52

0.10.51

0.10.50

* Bumped and updated type registries for Rococo and Kusama
* Updated type reformatting rules

0.10.49

0.10.48

0.10.47

0.10.46

0.10.45

0.10.44

0.10.43

0.10.42

0.10.41

* Add missing parachain types
* Added properties to GenericContractExecResult

0.10.40

0.10.39

0.10.38

Updated Westend type versioning
Added development type registry
Updated MultiAddress decoding and unit test

0.10.37

0.10.36

* Added module error index and lookup function Arjan Zijderveld 2 minutes ago
* Added canvas type registry
* Updated GenericMultiAddress
* Type registry update

0.10.35

0.10.34

Refactored `RuntimeConfiguration` so multiple runtime configurations can exist in one context

0.10.33

0.10.32

0.10.31

0.10.30

Type registry update to latest Substrate and versioning correction for Kusama, Polkadot and Westend

0.10.29

0.10.28

0.10.27

0.10.26

0.10.25

0.10.24

0.10.23

0.10.22

0.10.21

0.10.20

0.10.19

- MetadataV12 fix
- Dependency version bump

0.10.18

Added Bounty pallet types
Updated refCount to u32

0.10.17

0.10.16

0.10.15

0.10.14

0.10.13

0.10.12

0.10.11

0.10.10

0.10.9

Type registry update: Kusama to 2019, Polkadot to 17
Fixed duplicated type entry for StakingLedger

0.10.8

0.10.7

0.10.6

0.10.5

0.10.4

0.10.3

0.10.2

0.10.1

0.10.0

There are some struct property name changes to be more consistent with Polkadot-JS scalecodec, so there could be breaking changes when you use these structs in for example building an extrinsic

0.9.58

0.9.57

0.9.56

0.9.55

0.9.54

0.9.53

0.9.52

0.9.51

0.9.50

0.9.49

0.9.48

0.9.47

0.9.46

0.9.45

0.9.44

0.9.43

0.9.42

0.9.41

0.9.40

0.9.39

0.9.38

0.9.37

0.9.36

Type registry update
Added dynamic FixedArray decoder

0.9.35

0.9.34

0.9.33

0.9.32

0.9.31

0.9.30

0.9.29

0.9.28

Updated democracy types

0.9.27

Updated type registry
Throw exception if no more scale-bytes available

0.9.26

0.9.25

0.9.24

0.9.23

0.9.22

0.9.21

Quick fix Kusama

0.9.20

0.9.19

Fixed wrong fixed-length assumption of SS58 encoded addresses;
Added AccountInfo to type registry

0.9.18

0.9.17

0.9.16

0.9.15

0.9.14

0.9.13

0.9.9

0.9.7

Added i8, i16, i32, i64, i128 and i256 primitive types
Updated Acala and default type registries

0.9.2

Added MetadataV11

0.9.1

- Fixed float conversion by large numbers when encoding Compact<u32>
- Updated type registry
- Added numeric check for uint encoding

0.9.0

- Generic encoder support
- Generic decoder support
- Type-registry support
- Versioned types support
- Added documentation
- Added unit tests

Links

Releases

Has known vulnerabilities