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

Proposal to move types and errors files to dedicated folders #145

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AmadiMichael
Copy link
Member

This design doc proposes moving types and errors files out of */libraries/ and */lib/ files and into dedicated folders named */types/ and */errors/.

Issues:


## Proposed Solution

The proposed solution is to move these error and types files to dedicated folders e.g `L1/errors/`, `L1/types/`, `L2/errors/`, `L2/types/` etc.
Copy link
Contributor

Choose a reason for hiding this comment

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

We should consider how this relates to #143

I think there may be a future where errors are always defined in the contracts themselves, especially since #143 suggests having the error format be ContractName_SomeError.

Copy link
Contributor

@maurelian maurelian Nov 1, 2024

Choose a reason for hiding this comment

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

Agree with the principle here. There's a reason we wanted error strings to be prefixed with the contract name, and I find generic Unauthorized errors less helpful unless you're printing the trace (which requires more careful re

That said, I do like the idea of consolidating errors into a few locations, so what we could do is:

error Unauthorized(string location);

// and called as: 
revert Unauthorized(type(SomeContract).name);

// this would be nice too, but for some reason is failing for me in `chisel`: 
revert Unauthorized(type(this).name);

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, can you bring this up on #143?

Copy link
Contributor

Choose a reason for hiding this comment

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

For how many errors do you think we could actually consolidate like that? I do like this syntax but if its just like 3 errors or so I think it might be fine to duplicate, but will continue discussion on #143

Copy link
Contributor

Choose a reason for hiding this comment

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

I generally agree here. If it's just a few errors then I don't think it's worth it. Having a single unified standard is valuable.

@AmadiMichael
Copy link
Member Author

Here's a recap and conclusion of the discussion between @smartcontracts, @ControlCplusControlV and I on discord

  1. Error Files: We agreed to remove error files altogether, embedding errors directly in contracts and possibly following Standardize on Custom errors #143 if the proposal is accepted. This has the advantage of also simplifying imports.
  2. Type Files: For now, types files will remain as is, until the discussion for moving dispute/cannon folders into the L1 folder commences. #Issue

@AmadiMichael
Copy link
Member Author

Discussed in #150. Conclusion was

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

Successfully merging this pull request may close these issues.

4 participants