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

Handle return data larger than a word #112

Merged
merged 2 commits into from
Feb 25, 2022
Merged

Conversation

digorithm
Copy link
Member

When the returned data from a contract call is larger than a word,
it isn't stored in Return.val, but in ReturnData.data.

Before the changes in here, we were pulling the data only from
Return.val, which fortunately handled most cases. Until now,
with some methods returning, for instance, a b256, which would cause
the data to not be in Return.val as we expected, leading to errors.

This PR introduces some changes to fix this by looking whether the
expected return type is larger than a word, if it is, we fetch the
returned data from ReturnData.data instead of Return.val.

When the returned data from a contract call is larger than a word,
it isn't stored in `Return.val`, but in `ReturnData.data`.

Before the changes in here, we were pulling the data only from
`Return.val`, which fortunately handled most cases. Until now,
with some methods returning, for instance, a `b256`, which would cause
the data to _not_ be in `Return.val` as we expected, leading to errors.

This PR introduces some changes to fix this by looking whether the
expected return type is larger than a word, if it is, we fetch the
returned data from `ReturnData.data` instead of `Return.val`.
@digorithm
Copy link
Member Author

@nfurfaro tagging you in this PR because it fixes the issue you found and includes the test cases you used to find the problem. These test cases are now part of the test suite for the SDK.

nfurfaro
nfurfaro previously approved these changes Feb 25, 2022
Copy link

@nfurfaro nfurfaro left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@iqdecay iqdecay left a comment

Choose a reason for hiding this comment

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

Nitpicks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants