Electric-Coin-Company / zcash-android-wallet-sdk

Native Android SDK for Zcash
MIT License
5 stars 9 forks source link

Consider Repackaging SDK Classes #257

Open ccjernigan opened 3 years ago

ccjernigan commented 3 years ago

What is your feature request? Currently the SDK public APIs, as well as SDK internal implementation details, are not clearly disambiguated in the package structure of the SDK. This is a feature request to make that more clear.

It could be implemented by moving the public APIs to their own package (e.g. .api) or moving the internal APIs to their own package (e.g. .internal).

Using the .internal approach is more likely to be able to avoid breaking changes to SDK consumers.

How would this feature help you? As an SDK maintainer, it will be much more clear what changes would be a breaking API for SDK clients. We could also choose to apply ProGuard to the non-public package when publishing, further obfuscating it so that it isn't readily visible to touch.

As an SDK consumer, it will be much more clear what is the actual surface area of the SDK.

Below is an initial rough draft plan on how to go about this. This plan could be broken up into multiple sub issues and done in multiple pull requests. For now, this is intended to be an outline for the overall approach.

Phase 1 #293 Refactor the truly private APIs that aren't being used by the wallet

Phase 2 #294 Copy and paste utilities from the SDK into the wallet app's codebase. They're useful, but not part of the SDK's public API.

Phase 3 #295 Refactoring with minor public API changes

Phase 4 #296 Refactor with major API changes

pacu commented 3 years ago

I'd like to pair up with you to know which are the public APIs you are referring and also evaluating making those changes in the iOS SDK too if applicable

ccjernigan commented 3 years ago

Looking forward to collaborating.

To make the idea more clear, this is an example using the entry point to the SDK: Synchronizer is an interface and SdkSynchronizer is the default implementation of that interface. Both are public and in the same package. A top level function is used as the factory to create SdkSynchronizer and this function lives in the SdkSynchronizer.kt file.

One possible refactoring of this:

Clients would then call Synchronizer.new().

The public API now lives in Synchronizer, and both maintainers and consumers have a much clearer idea as to the public API contract.

This would be a breaking API change. There are some things we can do, such as keeping the existing top level initializer and marking it as deprecated during a migration period.

This is just one example, and we'll need to work through the public API surface area on both platforms to identify what other APIs we should consider doing this for.

pacu commented 2 years ago

I think these two components. will actually be used in the next app. so they might stay where they are

cash.z.ecc.android.sdk.type.UnifiedAddressAccount
cash.z.ecc.android.sdk.type.UnifiedAddress

I see the rest being fine. Nobody actually used the compact block processor on it's own so I think it's fair to actually make it an internal component