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

refactor: do not generate SolCall for return values #134

Merged
merged 9 commits into from
Jun 24, 2023

Conversation

prestwich
Copy link
Member

Closes #95

Motivation

Generating SolCal for return values led to bad outcomes like traits with incorrect signatures.

Solution

Instead this PR simply treats the return type as a tuple (as solidity does), and adds decode_returns and encode_returns functions to the SolCall trait

PR Checklist

  • Updated Tests
  • Added Documentation
  • Breaking changes

@prestwich prestwich added the enhancement New feature or request label Jun 21, 2023
@prestwich prestwich self-assigned this Jun 21, 2023
crates/sol-types/src/types/call.rs Outdated Show resolved Hide resolved
crates/sol-types/src/types/call.rs Outdated Show resolved Hide resolved
crates/sol-types/src/types/call.rs Outdated Show resolved Hide resolved
crates/sol-types/tests/doc_function_like.rs Outdated Show resolved Hide resolved
crates/sol-macro/src/expand/function.rs Outdated Show resolved Hide resolved
crates/sol-types/src/types/call.rs Show resolved Hide resolved
crates/sol-types/src/types/call.rs Outdated Show resolved Hide resolved
crates/sol-types/src/types/call.rs Show resolved Hide resolved
prestwich and others added 5 commits June 23, 2023 14:55
Comment on lines 22 to 28
/// pub struct #{name}Return {
/// #(pub #return_name: #return_type,)*
/// }
///
/// impl SolCall for #{name}Return {
/// impl SolFunction for #{name}Return {
/// ...
/// }
Copy link
Member

Choose a reason for hiding this comment

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

tbd

Comment on lines +33 to +34
/// For example the following input:
/// `function foo(uint256 a, uint256 b) external view returns (uint256);`
Copy link
Member

Choose a reason for hiding this comment

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

this is the doc comment's function

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah the rest of it was generic about macro functionality so i decided to be as explicit as possible

crates/sol-types/tests/doctests/function_like.rs Outdated Show resolved Hide resolved
Comment on lines +123 to +124
{ #converts }
{ #return_converts }
Copy link
Member

Choose a reason for hiding this comment

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

what's the block for

Copy link
Member Author

Choose a reason for hiding this comment

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

both generate a type alias named UnderlyingSolTuple. the scope prevents a name conflict

Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
@prestwich prestwich merged commit 8e3b17f into main Jun 24, 2023
@DaniPopes DaniPopes deleted the prestwich/sol-call-cleanup branch June 27, 2023 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Differentiate SolCall and SolReturn
2 participants