ink
ink copied to clipboard
Allow enum to implement SpreadAllocate
Recently, the contract implementation style has changed so that the contract struct
derives SpreadAllocate
.
This causes a compilation error in contracts that make use of enum
with more than one variant. This is because it is not possible to determine a default value, so SpreadAllocate
is not defined for enum
.
It would be nice if enum
was allowed if the Default
trait was implemented.
e.g. https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=21d9e01c332a660d9e5ab22634250f1a
Here is my hacked version of making this work in ink: https://github.com/prosopo-io/ink/commit/bdc676d61804a3fd88f76cb8045238250b3db166
@forgetso do you know in current version of Ink if we still need to implement SpreadAllocate for enum?
Yes, you still need to implement SpreadAllocate
for all types that are part of the storage(For enums it should be done manually). It will be changed after resolving https://github.com/paritytech/ink/issues/1134
This is not an issue in ink! 4.0 anymore due to https://github.com/paritytech/ink/issues/1134