[BUG] Can't pass felt252 array param
HorseXInsectCoder opened this issue · 2 comments
What happened
data = [11,22]
felt_serializer = FeltSerializer()
array_serializer = ArraySerializer(felt_serializer)
res = array_serializer.serialize(data)
call = Call(
to_addr=address, selector=get_selector_from_name("ins"), calldata=res
)
resp = await account.execute(calls=call, max_fee=int(1e16))
await account.client.wait_for_tx(resp.transaction_hash)
The contract method ins
param is core::array::Array::core::felt252
ValueError: Shortstring cannot be longer than 31 characters, got: 66.
Stack trace
Traceback (most recent call last):
File "/Volumes/Apple_SSD/starknet_new/sn.py", line 106, in
asyncio.run(test())
File "/Users/voyager-1/opt/anaconda3/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/Users/voyager-1/opt/anaconda3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/Volumes/Apple_SSD/starknet_new/sn.py", line 99, in test
resp = await account.execute(calls=call, max_fee=int(1e16))
File "/Users/voyager-1/opt/anaconda3/lib/python3.9/site-packages/starknet_py/net/account/account.py", line 409, in execute
execute_transaction = await self.sign_invoke_transaction(
File "/Users/voyager-1/opt/anaconda3/lib/python3.9/site-packages/starknet_py/net/account/account.py", line 277, in sign_invoke_transaction
execute_tx = await self._prepare_invoke(
File "/Users/voyager-1/opt/anaconda3/lib/python3.9/site-packages/starknet_py/net/account/account.py", line 180, in _prepare_invoke
wrapped_calldata = _execute_payload_serializer.serialize(
File "/Users/voyager-1/opt/anaconda3/lib/python3.9/site-packages/starknet_py/serialization/data_serializers/cairo_data_serializer.py", line 44, in serialize
return self.remove_units_from_serialized_data(serialized_data)
File "/Users/voyager-1/opt/anaconda3/lib/python3.9/contextlib.py", line 137, in exit
self.gen.throw(typ, value, traceback)
File "/Users/voyager-1/opt/anaconda3/lib/python3.9/site-packages/starknet_py/serialization/_context.py", line 104, in create
yield context
File "/Users/voyager-1/opt/anaconda3/lib/python3.9/contextlib.py", line 137, in exit
self.gen.throw(typ, value, traceback)
File "/Users/voyager-1/opt/anaconda3/lib/python3.9/site-packages/starknet_py/serialization/_context.py", line 81, in _wrap_errors
raise InvalidValueException(f"{self._error_prefix}: {err}") from err
starknet_py.serialization.errors.InvalidValueException: Error at path 'call_array.[0].to': Shortstring cannot be longer than 31 characters, got: 66.
Steps to reproduce
when send the transaction
SDK Version
lastest
Python version
3.9
What operating system are you using?
Mac
Is there an existing issue for this?
- I have searched the existing issues and verified no issue exits for this problem.
Could you please try executing the following code and let us know if it works for you?
call = Call(
to_addr=address, selector=get_selector_from_name("ins"), calldata=[11, 22]
)
resp = await account.execute(calls=call, max_fee=int(1e16))
await account.client.wait_for_tx(resp.transaction_hash)
@HorseXInsectCoder
Since there hasn't been a response for some time, I will be closing this issue. If you're still encountering this problem in the latest version, please don't hesitate to reopen it with updated details.