Skip to content

Enable Custom Scale Methods #525

@ansermino

Description

@ansermino

Due to inconsistencies between how Rust and Go handle types, SCALE sometimes requires custom encoding definitions. It would be quite simple for us to enable types to have a custom encode/decode method defined, while using the standard encode/decode for all types that do not.

For every type we encode/decode, we can use the reflect package to check if a method with the correct name exists:

someType := reflect.TypeOf(interface)
_, ok := someType.MethodByName("EncodeScale")
if ok {
    return someType.EncodeScale()
} else {
    return Encode(someType)
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions