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 struct unpacking in libraries #892

Merged
merged 4 commits into from
Nov 26, 2024
Merged

Fix struct unpacking in libraries #892

merged 4 commits into from
Nov 26, 2024

Conversation

palinatolmach
Copy link
Collaborator

@palinatolmach palinatolmach commented Nov 25, 2024

Solidity unpacks struct elements in function signatures only as long as the function is not defined as part of the library, otherwise the struct is referenced by libName.structName. This PR adds an additional check on whether the contract is a library when generating a method signature to look up its selector in methodIdentifiers.

E.g., Solidity generates

_calc(DLib.InitialParams)

and not

_calc((uint256,uint256,uint256,uint256,uint256,(uint256,uint256,uint256,uint256,uint256)))

as we expected.

This PR also adds a struct and a function taking it as a parameter to an existing library in a test suite.

Note: storage is being added to the struct name if the location of the input parameter is storage; that is not implemented in this PR, I'll open a separate issue.

@palinatolmach palinatolmach marked this pull request as ready for review November 25, 2024 13:43
@palinatolmach palinatolmach self-assigned this Nov 25, 2024
@rv-jenkins rv-jenkins merged commit 27e4914 into master Nov 26, 2024
12 checks passed
@rv-jenkins rv-jenkins deleted the fix-library-structs branch November 26, 2024 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants