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

ENUM as ABI type #47

Closed
alexvandesande opened this issue Dec 18, 2015 · 9 comments
Closed

ENUM as ABI type #47

alexvandesande opened this issue Dec 18, 2015 · 9 comments
Labels

Comments

@alexvandesande
Copy link

A FAQ on the solidity docs:

If I return an enum, I only get integer values in web3.js. How to get the named values?
Enums are not supported by the ABI, they are just supported by Solidity. You have to do the mapping yourself for now, we might provide some help later.

Enums would actually very useful types to be exposed on the ABI, specially for auto generated interfaces on the wallet and on abi2html, for example. On the read side, properties could be exposed as words instead of meaningless integers. On the execute side, enums could be rendered as drop down or radio boxes.

This would make interface creation easier.

@chriseth
Copy link
Contributor

Any ideas for the notation? As we kind of settled for anonymous structs in the other EIP, enums should also be anonymous.
Brainstorming:
[Val1,Val2,Val3]
(Val1|Val2|Val3)

@alexvandesande
Copy link
Author

Well it's an array of strings right? Shouldn't it be [ 'value 1', 'value 2', ...] ?

@chriseth
Copy link
Contributor

I would say that it is rather a list of identifiers instead of strings. Furthermore, I think it would be a good idea to differentiate enums from a tuple/struct types.
If enum or similar keywords are not used, the common way to notate such types is using |:
https://en.wikipedia.org/wiki/Sum_type

@wanderer wanderer added the ABI label Dec 23, 2015
@tgerring
Copy link

tgerring commented Jan 8, 2016

On first glance, [Val1,Val2,Val3] appears to be a collection of objects. To avoid confusion with that common notation, I'd personally prefer the pipe-delimiter or something that is difficult to confuse with another type.

@axic
Copy link
Member

axic commented Feb 3, 2016

As we kind of settled for anonymous structs in the other EIP, enums should also be anonymous.

Which other EIP are you referring to? I've only found the timestamps prior to this one.

Would it be any harm making it more explicit such as enum(Val1|Val2|Val3) or enum(Val1,Val2,Val3) ?

Just trying to avoid a situation where new types will have a weird notation to avoid collisions.

@chriseth
Copy link
Contributor

chriseth commented Feb 3, 2016

I was referring to this proposal here: #21

My reasoning behind not using explicit enum and struct strings was that names are always hard to get consensus on and different languages might use different names for these type constructs. You are right that explicit enum and struct prefixes avoid collisions (and also makes it easier to parse), but having to use struct at the inner level and not at the outermost level makes it a bit less elegant.

@axic
Copy link
Member

axic commented Feb 3, 2016

I don't think it would hurt to have struct written out on all levels, but as it is a more frequent construct I can understand if that won't be the case.

However, usually enum is less frequently used and I think it makes sense to be explicit in that case.

@github-actions
Copy link

There has been no activity on this issue for two months. It will be closed in a week if no further activity occurs. If you would like to move this EIP forward, please respond to any outstanding feedback or add a comment indicating that you have addressed all required feedback and are ready for a review.

@github-actions github-actions bot added the stale label Jan 17, 2022
@github-actions
Copy link

This issue was closed due to inactivity. If you are still pursuing it, feel free to reopen it and respond to any feedback or request a review in a comment.

bumblefudge pushed a commit to bumblefudge/EIPs that referenced this issue Feb 16, 2024
to address solana/caip2 inconsistencies pointed out online
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants