baking-bad / pytezos

🐍 Python SDK for Tezos | Michelson VM in Python
https://pytezos.org
MIT License
111 stars 36 forks source link

Pytezos does not allow to decode parameters for intermediate entrypoints, just for terminate ones #330

Closed m-kus closed 1 year ago

m-kus commented 1 year ago
Say my contract has a an entrypoint my_entrypoint that takes a sum type as input (say type my_sum_type = my_sum_type_element | my_other_sum_type_element). Then, I end up with [contract_ci.my](http://contract_ci.my/)_method.encode({"my_sum_type_element": some_value}) == {"my_sum_type_element": some_value} whereas I would have expected to get {"my_method": {"my_sum_type_element": some_value}}.
Indeed, when my parameter doesn't take a variant argument, the returned value looks like {entrypoint: value}. As an example: [contract_ci.my](http://contract_ci.my/)_method.encode(True) == {"my_method": True}.
The decode behaves the same way. I get {"variant_element": argument} when decoding my micheline argument rather than {"my_entrypoint": {"variant_element": argument}}. And I found that to be quite unexpected.