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

The wasm_bindgen support of fuel-asm and fuel-types #499

Merged
merged 8 commits into from
Jul 24, 2023

Conversation

xgreenx
Copy link
Collaborator

@xgreenx xgreenx commented Jul 3, 2023

Added wasm_bindgen for fuel-types and fuel-asm. The wasm_bindgen requires C-style enums. So I removed all constant variables and merged the enum definition with the TryFrom or From implementation to use the values directly.

The wasm_bindgen doesn't support non C-style enums, so I created a wrapper around Instruction - typescript::Instruction.

The wasm_bindgen doesn't work with constant functions and generics, so I created non-constant and non-generic analogs for methods.

The wasm_bindgen doesn't support constants, so I created non-constant methods.

Replaced the Self with actual type's name because it is required by wasm_bindgen.

I removed the usage of fuel-types from fuel-asm to generate less code for fuels-ts.

@xgreenx xgreenx requested review from arboleya and a team July 3, 2023 16:49
@xgreenx xgreenx self-assigned this Jul 3, 2023
@xgreenx xgreenx requested a review from digorithm July 3, 2023 16:50
Copy link
Member

@Dentosal Dentosal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only minor issues, but lets fix those before merging

@xgreenx xgreenx requested a review from Dentosal July 6, 2023 16:49
@arboleya
Copy link
Member

@xgreenx How can I build these two locally?

I'd assume it is done via wasm-pack (?), but I couldn't find any single-liner to do it with the CI scripts.

@xgreenx
Copy link
Collaborator Author

xgreenx commented Jul 10, 2023

One time install:

cargo install wasm-bindgen-cli

And to build the rust to WASM and WASM to js/ts:

rustc --target wasm32-unknown-unknown -p fuel-types --features typescript --crate-type=cdylib
rustc --target wasm32-unknown-unknown -p fuel-asm --features typescript --crate-type=cdylib
wasm-bindgen --target nodejs --typescript ./target/wasm32-unknown-unknown/release/fuel_types.wasm --out-dir ./typescript_types
wasm-bindgen --target nodejs --typescript ./target/wasm32-unknown-unknown/release/fuel_asm.wasm --out-dir ./typescript_asm

Voxelot
Voxelot previously approved these changes Jul 11, 2023
Dentosal
Dentosal previously approved these changes Jul 12, 2023
arboleya
arboleya previously approved these changes Jul 21, 2023
* Drafting NodeJS package template for publishing to NPM

* Adding boilerplate for `fuel-types` package

* Encapsulating commands as a function for optimal reuse

* Adding `fuel-types` to the build/publish script routine

* Removing all boilerplate files

* Moving .gitignore one directory up

* Turning all boilerplate files into reusable templates

* Refactoring the main script for WASM generation and NPM pkg assembling

* Tyop

* Fixing template tags for package `name` and `version`

* Moving template around

* Renaming templates directory

* DRY-refactoring script; formatting; fetching version from `Cargo.toml`

* Renaming method and removing TODO - publishing routine should be in CI

* Renaming and moving script inside `.npm` dir (decluttering root dir)

* Cd’ing to the previous dir without echoing its path

* Adjusting templates, using `@fuels/` org prefix for NPM packages

* Re-shaping `.npm` directory as a workspace for easier maintenance

* Linting - removing extraneous whitespaces

* Adjusting `package.json`

* Drafting CI action for NPM publishing

* Adjusting nomenclature

* Commenting requirements temporarily

* Adjusting order of CI job steps

* Debugging CI

* Debugging CI

* Debugging CI

* Debugging CI

* Debugging CI

* Debugging CI

* Debugging CI

* Adjusting sed flags; updating lock file

* Debugging CI

* Debugging CI

* Debugging CI

* Debugging CI

* Debugging CI

* Debugging CI

* Debugging CI

* Adding step to ensure NPM access is ok

* Adding README

* Docs

* Tyop

* Debugging CI

* Removing `dryRun` flag, preparing for real publishing

* Fixing package title, adding `@fuels` suffix

* Setting up job constrains

* Validating real publishing flow

* Scoped packages needs to be explicitly published with `--access public`

* Rolling back release constrains

* Renaming dubious files and scripts

* Docs

* Trimming jobs dependencies; formatting

* Rolling back git checks

* Update .npm/.scripts/prepare-wasm-packages.sh

Co-authored-by: Green Baneling <XgreenX9999@gmail.com>

---------

Co-authored-by: Green Baneling <XgreenX9999@gmail.com>
@xgreenx xgreenx dismissed stale reviews from arboleya, Dentosal, and Voxelot via e7642d0 July 24, 2023 12:02
@arboleya arboleya self-requested a review July 24, 2023 19:02
@xgreenx xgreenx added this pull request to the merge queue Jul 24, 2023
Merged via the queue into master with commit 9079849 Jul 24, 2023
@xgreenx xgreenx deleted the feature/typescript-wasm-bindings branch July 24, 2023 19:09
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.

4 participants