aeternity / aepp-calldata-js

Aeternity data serialization library
ISC License
3 stars 4 forks source link

Consider an approach to specify exported interface with less duplication #198

Open davidyuk opened 1 year ago

davidyuk commented 1 year ago

Currently, all exported classes are stored in a separate api folder. Each class actually a wrapper around the corresponding "private" class with some methods/arguments removed.

Pros of this approach:

Cons:

In some cases there is the same interface of "private" class and exposed one, for example, AciContractCallEncoder can be exported as

module.exports = require('../AciContractCallEncoder')

without exposing anything extra.

Additionally, traditional approaches to specify visibility of a class method may be used, like prefixing with _ (to be able to access in other library classes), or prefixing with # to make it a proper private method. Then wrapping classes won't be necessary.

dincho commented 1 year ago

Yes, # is the way to go. However, https://github.com/aeternity/aepp-calldata-js/pull/114 We should probably try again, as it is 2023 already :)

I definitely don't want any lib/user/app to be able to use private methods/data.

davidyuk commented 1 year ago

114 still may be the case. But I have no problems with # in sdk, maybe because it gets transpiled to something compatible.