-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Types Folder as an Alias Hub, not a types hub #1123
Comments
Is the sole motivation reduction of import statements for integrators? Referencing the Go Code Review Comments on package names here. There was an internal discussion on this before, just to surface it again, what are the requirements and needs from integrators (how many consumers of the SDK exists) we optimise for here? |
Yeah a large motivation of the types packages is to make it dead-simple straight forward to import any public type - shouldn't have to think about this as a developer I don't think.
Yeah I'm also aware of the merit of limiting the variable definition length through the use of separated packages (more imports) as the link points out - it's really just a tradeoff with number of imports. But yeah also it's not a huge issue for the sdk, browsing through the types packages it's mostly just the |
summarizing a discussion with @xlaThere are really three elements which need to be considered:
we came to the conclusion that we should:
|
So we can actually keep the repo-name as Cosmos-Sdk and just name the package |
After having a convo with @jaekwon about this issue - we decided that this is a minor priority for the time being, however there are a couple offshoot issues #3928 #3929 It would be really great if we had the opportunity to import from the repo level without requiring a giant alias file... I don't think go allows this though |
Rather than having the types directory be a mish mash of all the possible types which are defined in other packages (typically either root sdk packages or
x/
packages) types should be reorganized in the following way:x/
(can't be statically depended on) in keep them as in the types folderx/
) package where it's implementations functionality is defined, and then create and alias to it in thetypes/
directory. This way as a new user you can still simply importtypes/
- however the definition of the type is now grouped with it's implementation (neater)types/
) has substantial associated logic (such as rational IMO) right there in the types directory a good practice could be to move it to a new package, maybe as a subpackage in types, and then alias it just like the previous bullet.CC @jaekwon @xla @ebuchman @cwgoes @sunnya97
EDIT: Another consideration - "loose" helper functions sitting in
types
such asPrefixEndBytes
intypes/store.go
should be moved to their categorical package and then referenced with a function alias - this particular example:types/store.go/PrefixEndBytes
moves tostore/helpers.go/PrefixEndBytes
types/store.go
adds:var PrefixEndBytes = store.PrefixEndBytes
kapoosh!
The text was updated successfully, but these errors were encountered: