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: return DecodedReturn instead of any[] #1540

Merged
merged 6 commits into from
Aug 14, 2023
Merged

Conversation

LHerskind
Copy link
Contributor

Return a single DecodedReturn instead of the any[] that we are currently returning when as the return values in execution results. As noir let you have one return value (that return value can be an array or struct etc) we should just return that directly instead of wrapping it inside an array for the return values. This makes it more straight-forward to use view functions as well as you can get structs directly that way (example from lending contract)

Fixes a naming from interestAccumulator -> interest_accumulator as well.

Checklist:

Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge.

  • If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag.
  • I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code.
  • Every change is related to the PR description.
  • I have linked this pull request to relevant issues (if any exist).

@LHerskind LHerskind force-pushed the lh/single-decoded-return branch from 3be7089 to 080415d Compare August 12, 2023 08:55
@LHerskind LHerskind marked this pull request as ready for review August 14, 2023 06:48
returnValues.push(this.decodeReturn(this.abi.returnTypes[i]));
public decode(): DecodedReturn {
if (this.abi.returnTypes.length > 1) {
throw new Error('Multiple return values not supported');
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be different return types from one function is not supported since you are checking returnTypes.length?

Copy link
Contributor

Choose a reason for hiding this comment

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

Update - add a comment how an array is not [Field, Field] but [array{size:2, type:field}]

Copy link
Contributor

@rahul-kothari rahul-kothari left a comment

Choose a reason for hiding this comment

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

WOOP WOOP!!

Copy link
Member

@Maddiaa0 Maddiaa0 left a comment

Choose a reason for hiding this comment

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

Overall looks good to me, however I have concerns over how this will collide with my current pr #1515.

In this PR i alter public function's return values by pushing them into the return_values object in the kernel. I'm overall not sure what the long term solution will be in regards to this as soon as we move public execution to the VM model.

You should be good to merge this, I think it will be my work that needs to change

@spalladino
Copy link
Collaborator

Maybe we can get this into the typechain generator as well, so we get typed return types? I can tackle it after this PR is merged.

@LHerskind LHerskind force-pushed the lh/single-decoded-return branch from 25b97f1 to 8b1f1e9 Compare August 14, 2023 12:48
@LHerskind LHerskind enabled auto-merge (squash) August 14, 2023 12:51
@LHerskind LHerskind merged commit 2e344e1 into master Aug 14, 2023
@LHerskind LHerskind deleted the lh/single-decoded-return branch August 14, 2023 13:38
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.

4 participants