Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codecs (part 14): abi-based encoding & decoding #63

Merged
merged 4 commits into from
Jun 14, 2024

Conversation

andreibancioiu
Copy link
Contributor

@andreibancioiu andreibancioiu commented Jun 13, 2024

This is part of a series of pull requests.

See: #32.

Changes:

  • Define the Abi component, able to encode & decode endpoint parameters. When the component is initialized, it reads the ABI definitions and prepares value prototypes (typed values) for endpoint parameters & custom types. Then, when appropriate, it clones these prototypes and populates them with native Python values / gets Python values out of them.
  • Add missing tests for tuples etc.

@andreibancioiu andreibancioiu self-assigned this Jun 13, 2024
@andreibancioiu andreibancioiu marked this pull request as ready for review June 13, 2024 14:43
Copy link

github-actions bot commented Jun 13, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  multiversx_sdk/abi
  abi.py 77, 97, 144, 169, 177, 189, 195, 197, 199, 203
  tuple_value.py 37, 51
Project Total  

This report was generated by python-coverage-comment-action

@andreibancioiu andreibancioiu changed the base branch from main to feat/codecs June 13, 2024 14:48
@@ -30,3 +30,22 @@ def decode_top_level(self, data: bytes):
reader = io.BytesIO(data)
self.decode_nested(reader)

def set_payload(self, value: Any):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot about this in previous PRs.

from multiversx_sdk.abi.tuple_value import TupleValue


def test_set_payload_and_get_payload():
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot about tuples in the previous PRs.

popenta
popenta previously approved these changes Jun 14, 2024
assert encoded_values == expected_encoded_values


def test_decode_endpoint_output_parameters_real_world_multisig_get_pending_action_full_info():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could have skipped _real_world_ from the name here and above, but not a big deal :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, removed (remained in the Go test, for the moment).

https://github.com/multiversx/mx-sdk-abi-go/blob/main/abi/serializer_test.go

@andreibancioiu andreibancioiu merged commit 120c5b5 into feat/codecs Jun 14, 2024
5 checks passed
@andreibancioiu andreibancioiu deleted the codecs-june-14 branch June 14, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants