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

fix(sdk): Return Bytes when using Vec<u8> in params and result #428

Merged
merged 1 commit into from
Nov 1, 2024

Conversation

shekohex
Copy link
Contributor

@shekohex shekohex commented Nov 1, 2024

This pull request includes an improvement to the ValueIntoFieldType implementation in the sdk/src/event_listener/tangle/mod.rs file. The main change is the addition of a type check to handle Vec<u8> more efficiently and safely.

Enhancements to ValueIntoFieldType implementation:

  • Added a type check for Vec<u8> in the ValueIntoFieldType implementation to convert it directly to Field::Bytes using Vec::from_raw_parts, ensuring proper memory management and avoiding double-freeing issues.

Note that this a hot-fix, to get myself unblocked in my current task. However this won't be needed once #424 is fully implemented.

Closes #427

Copy link
Contributor

@drewstone drewstone left a comment

Choose a reason for hiding this comment

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

What if it's a Vec?

@shekohex
Copy link
Contributor Author

shekohex commented Nov 1, 2024

What if it's a Vec?

What Vec? you mean anything other than a Vec<u8>? like a Vec<u32> or a Vec<Something>? These are treated as Field::List we have that type for those. Vec<u8> is just treated special because it is bytes.

@tbraun96
Copy link
Collaborator

tbraun96 commented Nov 1, 2024

What if it's a Vec?

Looks like if it's not immediately a Vec<u8>, it will call each element's ValueIntoFieldType recursively until it is resolved.

@drewstone drewstone merged commit 4a5f4a1 into main Nov 1, 2024
12 of 13 checks passed
@drewstone drewstone deleted the shady/fix-field-types branch November 1, 2024 18:10
@webb-spider webb-spider bot mentioned this pull request Nov 1, 2024
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.

[BUG] My blueprint Job returns Bytes but it gets somehow transalated into an Array.
4 participants