Skip to content

Represent each data model type as a class #214

@0x009922

Description

@0x009922

Creating this issue as a paper trail.

Poorly organised notes:

  • Currently, most of the generated data model types are plain objects. Some "special", manually written types are represented as classes, like Json, Timestamp, AccountId. This isn't consistent.
  • Due to most types being plain objects, when you want to encode something, you have to write getCodec(AccountId).encode(accountId). Making all types as classes would allow putting codecs into their prototypes, allowing to do accountId.encode() instead.
  • For sorted structures, there is an Ord type, and it is most convenient to put on the prototype of the objects. Since there are currently almost none, you have to pass Ord codecs alongside somewhere.
  • There was some problem with representation of HashOf<T> and SignatureOf<T> with the current model, which could be solved with the class-based approach.
  • However, it is not clear how to represent discriminated unions with classes. Could be ugly.

Metadata

Metadata

Assignees

No one assigned

    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