polkascan / py-substrate-interface

Python Substrate Interface
https://polkascan.github.io/py-substrate-interface/
Apache License 2.0
240 stars 116 forks source link

get_metadata_constant return value not decoded #103

Closed carumusan closed 3 years ago

carumusan commented 3 years ago
substrate_connection.get_metadata_constant(
        module_name='Staking',
        constant_name='SessionsPerEra'
    )

Returns the value "0x060000" which has yet to be decoded from scale.

arjanz commented 3 years ago

As a workaround until fix is released:

constant = substrate_connection.get_metadata_constant("Staking", "SessionsPerEra")
decoded_value = substrate_connection.decode_scale(constant.type, ScaleBytes(constant.constant_value))
arjanz commented 3 years ago

Released fix in 0.13.0

arjanz commented 3 years ago

since v0.13.4 there is a dedicated function to return the decoded value of runtime constants:

constant = substrate.get_constant("Balances", "ExistentialDeposit")

print(constant.value) # 10000000000