Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different entrypoints in @iroha2/crypto & dependency inversion #77

Merged
merged 4 commits into from
Sep 29, 2021
Merged

Different entrypoints in @iroha2/crypto & dependency inversion #77

merged 4 commits into from
Sep 29, 2021

Conversation

0x009922
Copy link
Contributor

@0x009922 0x009922 commented Sep 26, 2021

The problem

At this point in time deploying Rust and WebAssembly to the web or other locations unfortunately isn't a trivial task to do.
wasm-pack docs about deployment

Before this I was sure that web target works fine both in web and nodejs environment, and it was! But unfortunately not in all cases and with some reservations and pitfalls. It is ok, so why not just expose different entrypoints in the same library? Because such approach produces huge problems for the libraries that would depend on this one and be target-agnostic, e.g. @iroha2/client pkg.

The solution

In this PR library contains main "types" entrypoint in /types and target-specific ones in sub-directories. It has the main type - IrohaCryptoInterface, and each target-specific implementation exports the same crypto object that is compatible with this type (it is included into type-check of the monorepo as test). And with this type it is possible to write libraries that depends on it and injects a particular implementation in runtime.

What not to check

wasm-pack outputs at packages/iroha-crypto/(web|node|bundler) dirs. Btw there are index.js and index.d.ts files generated separately from it but also automatically.

@0x009922 0x009922 marked this pull request as ready for review September 27, 2021 07:50
@0x009922 0x009922 merged commit b603ae7 into hyperledger:iroha2-dev Sep 29, 2021
@0x009922 0x009922 deleted the fix/crypto-for-sure branch September 29, 2021 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants