diff --git a/README.md b/README.md index e996dd934b6..2ec30d07a52 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,16 @@ This repo is the home of BitGo's WASM libraries. # Developer Setup +Enter the repository's Nix development shell to load the pinned toolchains: + +```bash +nix develop +``` + +The shell provides Node.js 24.11.0 (matching `.nvmrc`), Rust nightly +2025-10-23 (matching CI), and the WASM build tools. Install the JavaScript +workspace dependencies from the repository root: + ```bash npm install ``` @@ -19,6 +29,26 @@ This will: - Install all dependencies - Set up pre-commit hooks via Husky +# wasm-ton Verification + +The wasm-ton npm tests import generated WebAssembly bindings, so build them +before running the package tests: + +```bash +npm run build:wasm --prefix packages/wasm-ton +npm test --prefix packages/wasm-ton +``` + +Run the Rust parser tests and TypeScript build with: + +```bash +cargo test --manifest-path packages/wasm-ton/Cargo.toml parser_tests +npm run build:ts --prefix packages/wasm-ton +``` + +TypeScript and test tools are installed as npm workspace dependencies; no +global TypeScript compiler is required. + Pre-commit hooks automatically run on staged files: - **JS/TS**: Prettier formatting + ESLint diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000000..5a315eadb3d --- /dev/null +++ b/flake.lock @@ -0,0 +1,65 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1790185690, + "narHash": "sha256-xJ+X4hBtOcAFGBOe5nAMyMUeF9foJBmIOu3NjBqBycU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4975466d324710c576dc11ad614684e6bd8cad8e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-nodejs": { + "locked": { + "lastModified": 1763191728, + "narHash": "sha256-esRhOS0APE6k40Hs/jjReXg+rx+J5LkWw7cuWFKlwYA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1d4c88323ac36805d09657d13a5273aea1b34f0c", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1d4c88323ac36805d09657d13a5273aea1b34f0c", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "nixpkgs-nodejs": "nixpkgs-nodejs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1790321428, + "narHash": "sha256-JQBGEZDY6up5yu0ehQeDDnjvsw7MP8d4AlaBd9RxZVI=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "84fb3c79e477d5e7ec4eff9c24dbc5d5c99b0fd1", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000000..d1b023067e8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,52 @@ +{ + description = "Development environment for BitGoWASM"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs-nodejs.url = "github:nixos/nixpkgs/1d4c88323ac36805d09657d13a5273aea1b34f0c"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { + nixpkgs, + nixpkgs-nodejs, + rust-overlay, + ... + }: let + systems = [ + "aarch64-darwin" + "aarch64-linux" + "x86_64-darwin" + "x86_64-linux" + ]; + forEachSystem = nixpkgs.lib.genAttrs systems; + in { + devShells = forEachSystem (system: let + pkgs = import nixpkgs { + inherit system; + overlays = [rust-overlay.overlays.default]; + }; + rustToolchain = pkgs.rust-bin.nightly."2025-10-23".default.override { + extensions = ["clippy" "rustfmt"]; + targets = ["wasm32-unknown-unknown"]; + }; + in { + default = pkgs.mkShell { + packages = [ + nixpkgs-nodejs.legacyPackages.${system}.nodejs_24 + rustToolchain + pkgs.binaryen + pkgs.gnumake + pkgs.wasm-pack + ]; + + shellHook = '' + export PATH="$(pwd)/node_modules/.bin:$PATH" + ''; + }; + }); + }; +}