- Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
At this time, many of the constructors (or constructing functions) for ECKey, Address, and probably most of the modules, all accept a variety of parameter types, with branching to handle each possibility.
This goes against the separation of concern principles for these functions, and ensures that each function has the responsibility of correctly handling each possible set of inputs; which may be out of order.
A possible solution would be that rather than having catch-all constructor/builder functions, we could better separate the functions into their own responsibilities.
That is, rather than supply the developer with the behemoth: ECKey(hex | base64 | WIF | byteArray | base58) etc, we provide: ECKey.fromWIF, ECKey.fromBuffer and so on.
This allows for simpler verification and testing of these functions also.