Layr-Labs / eigensdk-go

Go SDK for building AVSs on Eigenlayer
https://www.eigenlayer.xyz/
Other
61 stars 41 forks source link

Change all type aliases to type definitions #207

Open samlaf opened 4 months ago

samlaf commented 4 months ago

We shouldn't have used type aliases in types (see for example OperatorId). See quote below.

Problem it creates is that when another pkg uses the sdk and calls a function which returns an Aliased type, vscode (and probably other editors?) show the returned type as the underneath type definition (instead of the type alias name).

So for eg getOperatorsAvsStateAtBlock will show

image

instead of its actual definition in the sdk as

image

Note the key type is Bytes32 instead of OperatorId, so it lost its semantics.

Type aliases are not meant for everyday use. They were introduced to support gradual code repair while moving a type between packages during large-scale refactoring. Codebase Refactoring (with help from Go) covers this in detail.

From https://yourbasic.org/golang/type-alias/ (and see the linked https://go.dev/talks/2016/refactor.article)

0xpanicError commented 4 months ago

Hey @samlaf can I take up this issue?

samlaf commented 4 months ago

Hey @samlaf can I take up this issue?

yes sir

mohitsethia commented 1 month ago

Hey @samlaf , I see that it is still not resolved. Can I contribute to it? And do I need to change all the type alias to the actual datatypes?

samlaf commented 1 month ago

Hey @samlaf , I see that it is still not resolved. Can I contribute to it? And do I need to change all the type alias to the actual datatypes?

There’s a PR open for it, I haven’t had time to review it though :/