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

Event declared twice #37

Closed
Psyf opened this issue Sep 16, 2022 · 2 comments
Closed

Event declared twice #37

Psyf opened this issue Sep 16, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@Psyf
Copy link
Contributor

Psyf commented Sep 16, 2022

The following event is declared twice, one in the Subscriptions.sol Library and once in the ISubscription.sol interface (implemented by Fund.sol).
event Deposit(address subscriber, uint256 subIdx, address token, uint256 balance);

When a Contract uses a library, underneath the hood it is a delegateCall. So when Fund calls a library function from SubLib, it's a delegateCall from Fund to SubLib (which is why libraries can't access storage directly, and have to be passed a pointer specifically).

If we don't include the event in ISubscription however, the event is never emitted (since the abi for Fund doesn't have the event?)

A similar problem arises when we're emitting events from Utils.create_position and Utils.close_positions.

Not having the event in the abi manifests problems in Matcha Tests and The Graph's subgraphs.

There are 2 solutions:

  • copypasta the events in 2 places. Manual and error-prone labour of making sure they're synced.
  • modify the contract such that the library is not responsible for emitting events.
@Psyf Psyf added the bug Something isn't working label Sep 16, 2022
@Psyf
Copy link
Contributor Author

Psyf commented Sep 16, 2022

@Psyf
Copy link
Contributor Author

Psyf commented Sep 16, 2022

Fixed in graph::1c271cf

@Psyf Psyf closed this as completed Sep 16, 2022
@Psyf Psyf mentioned this issue Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant