Skip to content

Commit

Permalink
Add initial version of wasm-miniscript package
Browse files Browse the repository at this point in the history
Issue: BTC-1317
  • Loading branch information
OttoAllmendinger committed Jul 12, 2024
1 parent 677d2f8 commit e148c7a
Show file tree
Hide file tree
Showing 21 changed files with 5,848 additions and 1 deletion.
67 changes: 67 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: wasm-miniscript

on:
push:
branches:
- master
pull_request:
branches:
- master
- rel/**

workflow_dispatch:

jobs:
unit-test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup node:${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
override: true

- name: Install wasm-pack
run: |
cargo install wasm-pack
- name: Build Info
run: |
echo "node $(node --version)"
echo "npm $(npm --version)"
echo "yarn $(yarn --version)"
git --version
echo "base ref $GITHUB_BASE_REF"
echo "head ref $GITHUB_HEAD_REF"
- name: Fetch Base Ref
run: |
git fetch origin $GITHUB_BASE_REF
- name: Install Packages
run: yarn install --with-frozen-lockfile

- name: build packages
run: yarn run build

- name: Check Source Code Formatting
run: yarn lerna exec 'prettier --check .'

- name: Unit Test
run: yarn lerna run test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
.idea/
*.iml
Empty file added .prettierrc.yaml
Empty file.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# wasm-miniscript
WebAssembly bindings for rust-miniscript

This is a wrapper around the [rust-miniscript](https://github.com/rust-bitcoin/rust-miniscript) crate that is compiled
to WebAssembly. It allows you to use Miniscript in NodeJS and in the browser.


# Dependencies

- [Rust](https://www.rust-lang.org/) nightly
- [wasm-pack](https://rustwasm.github.io/wasm-pack/) (install with `cargo install wasm-pack`)
- [NodeJS](https://nodejs.org/en/)
4 changes: 4 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "0.0.0"
}
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "root",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"check-fmt": "lerna run check-fmt"
},
"devDependencies": {
"lerna": "^8.1.6",
"prettier": "^3.3.2"
}
}
9 changes: 9 additions & 0 deletions packages/wasm-miniscript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
target/
js/wasm/
js/browser/
node_modules/
# we actually only track the .ts files
js/*.js
js/*.d.ts
test/*.js
test/*.d.ts
4 changes: 4 additions & 0 deletions packages/wasm-miniscript/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extension": ["js", "ts"],
"require": "ts-node/register"
}
2 changes: 2 additions & 0 deletions packages/wasm-miniscript/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
js/wasm
target/
254 changes: 254 additions & 0 deletions packages/wasm-miniscript/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions packages/wasm-miniscript/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "wasm-miniscript"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
wasm-bindgen = "0.2"
js-sys = "0.3"
miniscript = "12"
Loading

0 comments on commit e148c7a

Please sign in to comment.