Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "bdk-cli"]
path = playground/bdk-cli
url = https://www.github.com/bitcoindevkit/bdk-cli
Binary file not shown.
8 changes: 4 additions & 4 deletions docs/.vuepress/public/bdk-cli/playground/1.playground.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/.vuepress/public/bdk-cli/playground/2.playground.js

Large diffs are not rendered by default.

Binary file not shown.
2 changes: 1 addition & 1 deletion docs/.vuepress/public/bdk-cli/playground/playground.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions playground/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ Cargo.lock
bin/
pkg/
wasm-pack.log
dist/
36 changes: 0 additions & 36 deletions playground/Cargo.toml

This file was deleted.

71 changes: 22 additions & 49 deletions playground/README.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,42 @@
<div align="center">
# BDK playground

<h1><code>wasm-pack-template</code></h1>
The playground is a porting of certain functions of `bdk-cli` over wasm32,
deployed at https://bitcoindevkit.org/bdk-cli/playground/

<strong>A template for kick starting a Rust and WebAssembly project using <a href="https://github.com/rustwasm/wasm-pack">wasm-pack</a>.</strong>
## Compiling and running

<p>
<a href="https://travis-ci.org/rustwasm/wasm-pack-template"><img src="https://img.shields.io/travis/rustwasm/wasm-pack-template.svg?style=flat-square" alt="Build Status" /></a>
</p>

<h3>
<a href="https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html">Tutorial</a>
<span> | </span>
<a href="https://discordapp.com/channels/442252698964721669/443151097398296587">Chat</a>
</h3>

<sub>Built with 🦀🕸 by <a href="https://rustwasm.github.io/">The Rust and WebAssembly Working Group</a></sub>
</div>

## About

[**📚 Read this template tutorial! 📚**][template-docs]

This template is designed for compiling Rust libraries into WebAssembly and
publishing the resulting package to NPM.

Be sure to check out [other `wasm-pack` tutorials online][tutorials] for other
templates and usages of `wasm-pack`.

[tutorials]: https://rustwasm.github.io/docs/wasm-pack/tutorials/index.html
[template-docs]: https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html

## 🚴 Usage

### 🐑 Use `cargo generate` to Clone this Template

[Learn more about `cargo generate` here.](https://github.com/ashleygwilliams/cargo-generate)
Update the [bdk-cli](./bdk-cli) submodule:

```
cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project
cd my-project
git submodule update --init --recursive
```

### 🛠️ Build with `wasm-pack build`
Compile bdk-cli using the right features and the WASM target:

```
wasm-pack build
cd bdk-cli
RUSTFLAGS="-C opt-level=s -C strip=symbols" cargo build --release --no-default-features --features esplora-reqwest,async-interface,compiler --target wasm32-unknown-unknown
```

### 🔬 Test in Headless Browsers with `wasm-pack test`
From inside the `bdk-cli` directory, run `wasm-bindgen`

```
wasm-pack test --headless --firefox
wasm-bindgen --target bundler --out-dir target/wasm32-unknown-unknown/release/ target/wasm32-unknown-unknown/release/bdk-cli.wasm
```

### 🎁 Publish to NPM with `wasm-pack publish`
Come back to the playground directory, and build the javascript code:

```
wasm-pack publish
cd ..
rm dist/*
npm run build
```

## 🔋 Batteries Included
Last step! Now we substitute the old playground files with the freshly generated ones.
```
rm ../docs/.vuepress/public/bdk-cli/playground/*.wasm
cp dist/* ../docs/.vuepress/public/bdk-cli/playground/
```

* [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) for communicating
between WebAssembly and JavaScript.
* [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook)
for logging panic messages to the developer console.
* [`wee_alloc`](https://github.com/rustwasm/wee_alloc), an allocator optimized
for small code size.
Now you can come back to the project root, and start the website following the instructions
in the [`README.md`](../README.md)
1 change: 1 addition & 0 deletions playground/bdk-cli
Submodule bdk-cli added at e23a89
File renamed without changes.
Loading