Get account info with predefined generic call
See original GitHub issueLet’s assume that I have an instance of GenericCall
(balances.Transfer
), obtained by some other means (e.g. via a different SubstrateInterface instance).
Now I want to use it to get the payment info. The overall code looks similar to this:
call = ... # get an instance of GenericCall
addr_from = ... # some address, represented as str
s = SubstrateInterface('wss://westend-rpc.polkadot.io')
print(s.get_payment_info(call=call, keypair=Keypair(ss58_address=addr_from)))
The code throws the following exception:
File "example.py", line 7, in <module>
print(s.get_payment_info(call=call, keypair=Keypair(ss58_address=addr_from)))
File ".../venv/lib/python3.8/site-packages/substrateinterface/base.py", line 1689, in get_payment_info
extrinsic = self.create_signed_extrinsic(
File ".../venv/lib/python3.8/site-packages/substrateinterface/base.py", line 1559, in create_signed_extrinsic
extrinsic.encode({
File ".../venv/lib/python3.8/site-packages/scalecodec/base.py", line 698, in encode
self.data = self.process_encode(self.value_serialized)
File ".../venv/lib/python3.8/site-packages/scalecodec/types.py", line 2400, in process_encode
data += extrinsic.encode(value)
File ".../venv/lib/python3.8/site-packages/scalecodec/base.py", line 698, in encode
self.data = self.process_encode(self.value_serialized)
File ".../venv/lib/python3.8/site-packages/scalecodec/types.py", line 491, in process_encode
data += element_obj.encode(value[key])
File ".../venv/lib/python3.8/site-packages/scalecodec/base.py", line 698, in encode
self.data = self.process_encode(self.value_serialized)
File ".../venv/lib/python3.8/site-packages/scalecodec/types.py", line 1381, in process_encode
if self.metadata.portable_registry:
AttributeError: 'NoneType' object has no attribute 'portable_registry'
As far as I see, this is a kind of dynamic initialization, which fails to work, when I call get_payment_info
method first.
Is it a bug? If no, how can I work this around?
The use case is pretty simple. I see, that I can’t use SubstrateInterface
in a concurrent way because this class has a state (see https://github.com/polkascan/py-substrate-interface/issues/82#issuecomment-937803341 ). So I maintain a pool of SubstrateInterface instances with pre-defined lock for each to allow this abstraction work in a parallel way.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
This was because of a missing passthrough of metadata in
GenericCall
(https://github.com/polkascan/py-scale-codec/commit/b497d5f02de544c97b14f0add076755a66e00b23)A fix is release in https://github.com/polkascan/py-scale-codec/releases/tag/v1.0.12
Ok, obviously it’s not a bug. I just have been misled by the interface, which does not enforce me to call one method after another. So, closing this.