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.
Creating this issue as a paper trail.
Poorly organised notes:
Json,Timestamp,AccountId. This isn't consistent.getCodec(AccountId).encode(accountId). Making all types as classes would allow putting codecs into their prototypes, allowing to doaccountId.encode()instead.Ordtype, and it is most convenient to put on the prototype of the objects. Since there are currently almost none, you have to passOrdcodecs alongside somewhere.HashOf<T>andSignatureOf<T>with the current model, which could be solved with the class-based approach.