Skip to content

Commit

Permalink
Fix/decoded results with results types (#65)
Browse files Browse the repository at this point in the history
* fix: decode results by default when provided with results types

* fix: wrong example

* Bump version: 2.1.0-dev0 → 2.1.0-dev1

---------

Co-authored-by: github-actions <[email protected]>
  • Loading branch information
EtienneWallet and github-actions[bot] authored Feb 29, 2024
1 parent f5071f4 commit cba35e7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/source/user_documentation/steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ arguments: []
results_save_keys: # optional, key(s) under which save the results of the query
- EsdtIdentifier
results_types: # mandatory if results are to be saved and no ABI have been provided for this contract
- TokenIdentifier
- type: TokenIdentifier
print_results: true # optional, if the query results should be printed in the console
```

Expand Down
23 changes: 10 additions & 13 deletions mxops/execution/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This module contains the classes used to execute scenes in a scenario
"""

from __future__ import annotations
import base64
from dataclasses import dataclass, field
Expand Down Expand Up @@ -539,18 +540,8 @@ def save_results(self):
if self.results_save_keys is None:
return

# decode results if specified
if self.results_types is None:
if self.decoded_results is None:
raise ValueError(
"No result were decoded due to lack of ABI but `results_types` was "
"not specified either"
)
else:
data_parts = self.query_response.get_return_data_parts()
self.decoded_results = AbiSerializer().decode_io(
self.results_types, data_parts
)
if self.decoded_results is None:
raise ValueError("No decoded results to save")

LOGGER.info("Saving query results")
sub_keys = self.results_save_keys.sub_keys
Expand Down Expand Up @@ -619,7 +610,13 @@ def execute(self):
self._interpret_return_data(data)
for data in self.query_response.return_data
]
if serializer is not None:
if self.results_types is not None:
data_parts = self.query_response.get_return_data_parts()
print(self.results_types, data_parts)
self.decoded_results = AbiSerializer().decode_io(
self.results_types, data_parts
)
elif serializer is not None:
self.decoded_results = serializer.decode_contract_query_response(
self.endpoint, self.query_response
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "mxops"
version = "2.1.0-dev0"
version = "2.1.0-dev1"
authors = [
{name="Etienne Wallet"},
]
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.1.0-dev0
current_version = 2.1.0-dev1
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(-(?P<release>\w+)(?P<build>\d+))?
serialize =
{major}.{minor}.{patch}-{release}{build}
Expand Down

0 comments on commit cba35e7

Please sign in to comment.