Open hugocaillard opened 1 month ago
Attention: Patch coverage is 37.50000% with 180 lines in your changes missing coverage. Please review. |
Files | Patch % | Lines |
---|---|---|---|
components/clarity-repl/src/repl/session.rs | 38.97% | 166 Missing :warning: | |
components/clarity-repl/src/frontend/terminal.rs | 0.00% | 10 Missing :warning: | |
components/clarinet-deployments/src/lib.rs | 40.00% | 3 Missing :warning: | |
components/clarity-repl/src/bin.rs | 0.00% | 1 Missing :warning: |
:loudspeaker: Thoughts on this report? Let us know!
Description
Closes: #1432
This is a pretty important PR that brings the Clarinet SDK for the browser.
Two new packages
@hirosystems/clarinet-sdk-wasm-browser
@hirosystems/clarinet-sdk-browser
They are the equivalent of these existing packages (but for the browser)
@hirosystems/clarinet-sdk-wasm
@hirosystems/clarinet-sdk
Enhancement
This PR also brings some enhancement to the SDK and some new methods useful for the browser use case (such as
initEmptySession()
andclearCache()
).Improved typing
Some Rust structs are encoded in JS objects, and the TS types for those were in
clarinet-sdk
. They have been moved tocomponents/clarinet-sdk-wasm/src/ts_types.rs
Review
A good first step to review this PR is to look at these 4 READMEs:
Caveats
It brings complexity to an already complicated architecture.
The
clarinet-sdk-wasm
component remain almost the same, except that it now requires a build script that runswasm-pack
twice targetingnodejs
andweb
. It will also rename the web package to@hirosystems/clarinet-sdk-wasm-browser
.The src directory of the
clarinet-sdk
component has been split into 3 directoriescommon/src
,node/src
,browser/src
. With a bit of code duplication betweennode/src/sdkProxy.ts
andbrowser/src/sdkProxy.ts
. But thanks to NPM workspace, it still easy to build and publish the two components.