Tag v1.0.2 cannot create an extrinsic using the Utility.batch call using polkadot v.0.9.11
See original GitHub issueThe following code works when connecting to polkadot 0.9.10 but not 0.9.11
Fails when trying compose the batch call
from substrateinterface import SubstrateInterface, Keypair
from substrateinterface.exceptions import SubstrateRequestException
try:
substrate = SubstrateInterface(
url="ws://127.0.0.1:9944",
type_registry_preset='development'
)
except ConnectionRefusedError:
print("⚠️ No local Substrate node running, try running 'start_local_substrate_node.sh' first")
exit()
keypair = Keypair.create_from_uri('//Alice')
call_1 = {
'call_module': 'Balances',
'call_function': 'transfer',
'call_args': {
'dest': '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty',
'value': 1 * 10**15
}
}
call_2 = {
'call_module': 'Balances',
'call_function': 'transfer',
'call_args': {
'dest': '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty',
'value': 1 * 10**15
}
}
batch_call = substrate.compose_call(
call_module='Utility',
call_function='batch',
call_params={
'calls': [call_1, call_2]
}
)
batched_extrinsic = substrate.create_signed_extrinsic(
call=batch_call,
keypair=keypair,
era={'period': 64}
)
try:
receipt = substrate.submit_extrinsic(batched_extrinsic, wait_for_inclusion=True)
print('Extrinsic "{}" included in block "{}"'.format(
receipt.extrinsic_hash, receipt.block_hash
))
if receipt.is_success:
print('✅ Success, triggered events:')
for event in receipt.triggered_events:
print(f'* {event.value}')
else:
print('⚠️ Extrinsic Failed: ', receipt.error_message)
except SubstrateRequestException as e:
print("Failed to send: {}".format(e))
Stacktrace is :
Traceback (most recent call last):
File "thing2.py", line 36, in <module>
batch_call = substrate.compose_call(
File "...pyenvs/core2/lib/python3.8/site-packages/substrateinterface/base.py", line 1422, in compose_call
call.encode({
File "...pyenvs/core2/lib/python3.8/site-packages/scalecodec/base.py", line 698, in encode
self.data = self.process_encode(self.value_serialized)
File "...pyenvs/core2/lib/python3.8/site-packages/scalecodec/types.py", line 1428, in process_encode
data += arg_obj.encode(param_value)
File "...pyenvs/core2/lib/python3.8/site-packages/scalecodec/base.py", line 698, in encode
self.data = self.process_encode(self.value_serialized)
File "...pyenvs/core2/lib/python3.8/site-packages/scalecodec/types.py", line 846, in process_encode
data += element_obj.encode(element)
File "...pyenvs/core2/lib/python3.8/site-packages/scalecodec/base.py", line 698, in encode
self.data = self.process_encode(self.value_serialized)
File "...pyenvs/core2/lib/python3.8/site-packages/scalecodec/types.py", line 1055, in process_encode
raise ValueError("Value for enum with type_mapping can only have one value")
ValueError: Value for enum with type_mapping can only have one value
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Wow, that was fast! Thank you @arjanz, all works. This issue can be closed
Issue will be addressed in https://github.com/polkascan/py-scale-codec/issues/80