polkascan / py-substrate-interface

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

AttributeError: 'NoneType' object has no attribute 'get_type_string' #377

Closed arjanz closed 5 months ago

arjanz commented 5 months ago

Discussed in https://github.com/polkascan/py-substrate-interface/discussions/376

Originally posted by **klemendrobnic** February 6, 2024 I would need help with resolving an error that occurs when im trying to use compose_call function. ``` from substrateinterface import SubstrateInterface substrate = SubstrateInterface(url="wss://ws.framenode-7.s4.stg1.sora2.soramitsu.co.jp") call = substrate.compose_call(call_module='Balances',call_function='transfer',call_params={'dest': '5CvxUr1gXDvAN8qEDPBFVdnF7QcPwNfYCQLYDDr3cCzC45Vt','value': 1 * 10**12}) ``` I get the following error: ``` Traceback (most recent call last): File "", line 1, in File "/home/klemendrobnic/.local/lib/python3.10/site-packages/substrateinterface/base.py", line 1408, in compose_call call.encode({ File "/home/klemendrobnic/.local/lib/python3.10/site-packages/scalecodec/base.py", line 929, in encode self.data = self.process_encode(self.value_serialized) File "/home/klemendrobnic/.local/lib/python3.10/site-packages/scalecodec/types.py", line 1652, in process_encode call_type_string = self.call_module['calls'].value_object.get_type_string() AttributeError: 'NoneType' object has no attribute 'get_type_string' ``` When i print the call_module that is called in the process_encode method i get the object printed, however the parameter calls is not included (call_type_string = self.call_module['calls'].value_object.get_type_string()) -> the code fails here Thanks for any suggestions

After examining the metadata of the runtime, I found out that the Balances pallet for the endpoint you provided has in fact no runtime calls at all (so call transfer couldn't be found). You can also check PolkadotJS

However, the error handler could be improved here, the current thrown exception is indeed confusing and should be something like Call function 'transfer' not found. I'll make an issue for this.

arjanz commented 5 months ago

Fix released in https://github.com/polkascan/py-scale-codec/releases/tag/v1.2.8