`ecashaddrjs` has limped and served well despite numerous legacy dependencies and an older structure. Aside from some maintenance headaches, this was acceptable and "good enough."
However, we would like to
- Add more address lib features
- Optionally support more address types
- Reduce the use of third-party dependencies
In starting to reduce the use of third-party dependencies, it was discovered that basic `hash` methods available in `ecash-lib` after `initWasm` were needed to match existing `ecashaddrjs` functionality without third-party dependencies. It would not make sense to have `ecashaddrjs` work only if `initWasm()` were called in `ecash-lib` -- so we move the address functions to `ecash-lib`. Then, though, we still would like to not require the entire `ecash-lib` dependency for apps like `chronik-client` which barely use `ecashaddrjs` functionality.
The way js deps work, users who need only the address functions from `ecash-lib` will end up only installing those in the published version of their app. Users who want legacy `ecashaddrjs` features without dealing with `initWasm` may use the legacy `ecashaddrjs`, though it will be deprecated.
**What this diff does**
- Match the functionality of `ecashaddrjs` but with no third-party dependencies (well, one dev-dependency for generating random hashes...we could lose it but it is useful to show we pass the same tests as the old lib)
- Replace `ecashaddrjs` with now-local functions in `ecash-lib`Solution
- Update- Remove all dependencies from `ecash-lib` dockerfile to account for changeaddrjs`; this requires getting rid of `toLegacy`, which we add into `ecash-lib`
- Update CI to account for everything that uses `ecash-lib` now needing `b58-ts`
**Breaking changes when migrating from `ecashaddrjs` to `ecash-lib`**Breaking change version bump for `ecashaddrjs` to get rid of other technical debt (tree-shakeable exports so apps only pull in the functions they need, not the whole thing, and better typing, no more `chronikReady` param which confused typescript about return types)
When I first started adding functionality to `ecashaddrjs`, I was hesitant to introduce any breaking changes. This led to a bunch of baggage. In this version,- New `Address` class in `ecash-lib` with full-featured address management
- We only support lowercase address types i.e. `p2pkh` or `p2sh`New `legacyaddr.ts` functions in `ecash-lib` for handling legacy addresses with zero deps (since we have hashing available in ecash-lib, as this is what `ChronikClient` supportsand now also b58-ts with no deps)
- We store `hash` as a string. `ecash-lib` offers `fromHex` method to trivially convert this to a `Uint8Array`. But the string is also what `ChronikClient` expects and what most of my apps expect. Just picking one greatly enhances the effectiveness of `typescript` with these address methods. I considered storing both formats -- but that gets complicated as many helper functions also work with hash as a string.
- We no longer validate against a small whitelist of accepted prefixes. We will encode any prefix.
- We no longer decode prefixless addresses against a whitelist of accepted prefixes. We decode prefixless addresses against `ecash` prefix only.
Going forward, will replace `ecashaddrjs` with `ecash-lib` methods everywhere.Implement `ecashaddrjs` with breaking change in all monorepo apps