event
event copied to clipboard
Refactor proposal regarding model classes
Many (all?) model classes use BaseModel as base class which assigns all properties of the given data object to the model object. This creates some problems:
- Currently the model classes don't have all the properties declared although they are used. Example: In Invoice.ts, the properties
amount_received_msat
andamount_msat
are used but not declared. It took me a while to find out how this could work. - The data object might have properties which have the same name as functions in the model class. In this case, the function would be overwritten with the data object value.
- The data objects seem to be coming directly from the various backends. This explains why there are sometimes multiple properties with the same meaning (like in Invoice: expiry/expires_atexpire_time).
To solve these problems I suggest the following approach:
Create interfaces for the data objects for every backend describing exactly what properties are provided by the regarding backend. Then, remove duplicated properties from the model classes and create converters for every backend which create the model objects and fill the properties from the data objects.