Closed wowvwow closed 1 year ago
I tried many times and read the code of scalecodec, but I still can't find a suitable way to convert this type, I need your help, pls
A pointer I can give is that in the latest version of SubstrateInterface there is a function that can provide type composition info for storage functions: https://github.com/polkascan/py-substrate-interface#type-decomposition-information
Last week I actually took some effort to collect this information it generates for well-known Substrate runtimes into a extensive Substrate metadata website, so this is the information about the storage function you mentioned:
https://polkascan.github.io/py-substrate-metadata-docs/khala/#properties
You should read this as follows:
call = substrate.query(
'RmrkCore', 'Properties', ['u32', (None, 'u32'), 'Bytes']
)
u32
is obviously a 32-bit integer
(None, 'u32')
means either None
or a u32
(This is an Option
in RUST)
Bytes
is an arbitrary str
, bytes
or hex-string
Let me know if this helps
result = Substrate().substrate.query('RmrkCore', 'Properties',
['10324', (None, '31'), '0x068500be5822de000000000000000000']
)
print(result)
Traceback (most recent call last):
File "/usr/lib/python3.8/code.py", line 90, in runcode
exec(code, self.locals)
File "", line 1, in
Before that, I tried https://polkascan.github.io/py-substrate-metadata-docs/khala/#properties to pass parameters, but the above error will appear
result = Substrate().substrate.query('RmrkCore', 'Properties', ['10324', (None, '31'), '0x068500be5822de000000000000000000'] ) print(result)
It should be either None
or 31
, that parameter is a Option
:
result = Substrate().substrate.query('RmrkCore', 'Properties',
[10324, 31, '0x068500be5822de000000000000000000']
)
<substrateinterface.base.QueryMapResult object at 0x7f637357fac0> description <class 'abc.scale_info::134'> Khala - Stakepool - #265 <class 'abc.scale_info::135'> createtime <class 'abc.scale_info::134'> 1671991536 <class 'abc.scale_info::135'> name <class 'abc.scale_info::134'> Khala - Stakepool Delegation NFT - #265 - 31 <class 'abc.scale_info::135'> stake-info <class 'abc.scale_info::134'> 0xa45d3830020000000000000000000000 <class 'abc.scale_info::135'> 0xa45d3830020000000000000000000000
Traceback (most recent call last): File "/root/.pycharm_helpers/pydev/pydevconsole.py", line 364, in runcode coro = func() File "", line 1, in
File "/root/.pycharm_helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/root/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/opt/01x/src/phala.py", line 3778, in
print(Substrate().substrate.decode_scale(type_string='scale_info::135', scale_bytes=ScaleBytes(v)))
File "/usr/local/lib/python3.8/dist-packages/scalecodec/base.py", line 537, in init
raise ValueError("Provided data is not in supported format: provided '{}'".format(type(data)))
ValueError: Provided data is not in supported format: provided '<class 'abc.scale_info::135'>'