| ⚠️ 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