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

Align Python serialization #650

Closed
Thoralf-M opened this issue Jun 21, 2023 · 1 comment · Fixed by #1824
Closed

Align Python serialization #650

Thoralf-M opened this issue Jun 21, 2023 · 1 comment · Fixed by #1824
Assignees
Labels
b-python Bindings - Python

Comments

@Thoralf-M
Copy link
Member

Thoralf-M commented Jun 21, 2023

Description

Currently in the wallet we have MyEncoder

class MyEncoder(JSONEncoder):
which converts the types to a dict, but in the client not
def _call_method(self, name, data=None):
"""Dumps json string and calls `call_client_method()`
"""
message = {
'name': name
}
if data:
message['data'] = data
message = dumps(message)
# Send message to the Rust library
response = call_client_method(self.handle, message)
, so in the client methods we make sure that the types are converted to dicts if required already before like here
unlock_conditions = [unlock_condition.as_dict()
for unlock_condition in unlock_conditions]
if native_tokens:
native_tokens = [native_token.as_dict()
for native_token in native_tokens]
if features:
features = [feature.as_dict() for feature in features]
if amount:
amount = str(amount)

For some types like the amount where we change the type from int to str it might be required, but to convert classes to dicts it shouldn't be necessary to do that manually.

Motivation

Aligned/cleaner code

Open questions (optional)

What's the best way to do it?

Are you planning to do it yourself in a pull request?

No.

@Thoralf-M Thoralf-M added the b-python Bindings - Python label Jun 21, 2023
@github-project-automation github-project-automation bot moved this to Product Backlog in iota-sdk Jun 21, 2023
@thibault-martinez thibault-martinez added this to the v1.1.0 milestone Jul 11, 2023
@thibault-martinez thibault-martinez modified the milestones: v1.1.0, v2.0.0 Sep 18, 2023
@thibault-martinez thibault-martinez moved this from Product Backlog to Sprint Backlog in iota-sdk Jan 8, 2024
@Thoralf-M Thoralf-M moved this from Sprint Backlog to In Progress in iota-sdk Jan 10, 2024
@Thoralf-M Thoralf-M moved this from In Progress to In Review in iota-sdk Jan 10, 2024
@Thoralf-M Thoralf-M linked a pull request Jan 11, 2024 that will close this issue
@thibault-martinez
Copy link
Member

Closed by #1824

@github-project-automation github-project-automation bot moved this from In Review to Done in iota-sdk Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
b-python Bindings - Python
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants