Cadence should have in built support for Enums with String raw type, instead of only integer based raw type. This is a standard feature of Enums expected of high level languages. This enables developers to avoid having to explicitly write out custom functions to convert String representations of Enum values to Enum object and vice versa within the smart contract. This will also simplify logic for developers on the frontend who will no longer have to map Enum raw int values to the string representation.
Suggested Solution
Developers should be able to simply use String type for enums when defining them in the smart contract. This should implicitly map Enum value to string representation unless explicitly defined. Cadence should expose basic functionality for mapping from enum value to string representation and vice versa.
Developers should be able to do something like rarity.toString() and Rarity(rarityStr) to convert easily between Enum values and string representation.
Issue To Be Solved
Cadence should have in built support for Enums with String raw type, instead of only integer based raw type. This is a standard feature of Enums expected of high level languages. This enables developers to avoid having to explicitly write out custom functions to convert String representations of Enum values to Enum object and vice versa within the smart contract. This will also simplify logic for developers on the frontend who will no longer have to map Enum raw int values to the string representation.
Suggested Solution
Developers should be able to simply use String type for enums when defining them in the smart contract. This should implicitly map Enum value to string representation unless explicitly defined. Cadence should expose basic functionality for mapping from enum value to string representation and vice versa.
Eg.
OR
Developers should be able to do something like
rarity.toString()
andRarity(rarityStr)
to convert easily between Enum values and string representation.