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

feature: Add SCALE custom type functionality for Result, VaryingDataType, and VaryingDataTypeSlice #1819

Closed
timwu20 opened this issue Sep 30, 2021 · 1 comment
Assignees

Comments

@timwu20
Copy link
Contributor

timwu20 commented Sep 30, 2021

Task summary

  • SCALE requires the destination data structure to be known before decoding. This isn't a problem when we deal with initialised Result, VaryingDataType and VaryingDataTypeSlice instances.
  • The issue is when Result, VaryingDataType and VaryingDataTypeSlice are used as attributes in structs. The zero case for the Result, VaryingDataType and VaryingDataTypeSlice have not been intialized with their associated value types, which causes a decode error.
  • The proposed solution is to allow for shadowing (custom types) of Result, VaryingDataType and VaryingDataTypeSlice, and to utilise the constructor pattern (ex. func NewMyResult() *NewResult) which will be called by the scale decoding process to initialise these special types. In the event that there is no constructor defined in the package we could throw a friendly error to notify the developer.

Specification reference

Other information and links

@danforbes
Copy link
Contributor

Is this a place where we could be able to make use of generics?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants