Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
willemolding committed Oct 14, 2024
2 parents e611b14 + d00cec4 commit 80fbe3f
Show file tree
Hide file tree
Showing 24 changed files with 556 additions and 337 deletions.
18 changes: 17 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,20 @@ node_modules
.DS_STORE
.idea
.parcel-cache
dist

.pnp.*
.yarn/*

!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.parcel-cache

packages/demo-wallet/dist/*
packages/e2e-tests/dist/*

!packages/demo-wallet/dist/serve.json
!packages/e2e-tests/dist/serve.json
File renamed without changes.
36 changes: 24 additions & 12 deletions Cargo.lock

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

15 changes: 7 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ native = ["tonic/channel", "tonic/gzip", "tonic/tls-webpki-roots", "tokio/macros
sqlite-db = ["dep:zcash_client_sqlite"]
console_error_panic_hook = ["dep:console_error_panic_hook"]
no-bundler = ["wasm-bindgen-rayon?/no-bundler", "wasm_thread/no-bundler"]
sync2 = []

[dependencies]
## Web dependencies
Expand All @@ -61,12 +60,12 @@ tokio_with_wasm = { version = "0.7.1", features = ["rt", "rt-multi-thread", "syn

## Zcash dependencies

zcash_keys = { git = "https://github.com/ChainSafe/librustzcash", rev = "d1fa3e846c5e61de3f1df23dd9f4d5416915631a", features = ["transparent-inputs", "orchard", "sapling", "unstable"] }
zcash_client_backend = { git = "https://github.com/ChainSafe/librustzcash", rev = "d1fa3e846c5e61de3f1df23dd9f4d5416915631a", default-features = false, features = ["sync", "lightwalletd-tonic", "wasm-bindgen", "orchard"] }
zcash_client_memory = { git = "https://github.com/ChainSafe/librustzcash", rev = "d1fa3e846c5e61de3f1df23dd9f4d5416915631a", features = ["orchard"] }
zcash_primitives = { git = "https://github.com/ChainSafe/librustzcash", rev = "d1fa3e846c5e61de3f1df23dd9f4d5416915631a" }
zcash_address = { git = "https://github.com/ChainSafe/librustzcash", rev = "d1fa3e846c5e61de3f1df23dd9f4d5416915631a" }
zcash_proofs = { git = "https://github.com/ChainSafe/librustzcash", rev = "d1fa3e846c5e61de3f1df23dd9f4d5416915631a", default-features = false, features = ["bundled-prover"] }
zcash_keys = { git = "https://github.com/ChainSafe/librustzcash", rev = "9673cc2859e8a2528d1efd3c74795363f87ddf8f", features = ["transparent-inputs", "orchard", "sapling", "unstable"] }
zcash_client_backend = { git = "https://github.com/ChainSafe/librustzcash", rev = "9673cc2859e8a2528d1efd3c74795363f87ddf8f", default-features = false, features = ["sync", "lightwalletd-tonic", "wasm-bindgen", "orchard"] }
zcash_client_memory = { git = "https://github.com/ChainSafe/librustzcash", rev = "9673cc2859e8a2528d1efd3c74795363f87ddf8f", features = ["orchard"] }
zcash_primitives = { git = "https://github.com/ChainSafe/librustzcash", rev = "9673cc2859e8a2528d1efd3c74795363f87ddf8f" }
zcash_address = { git = "https://github.com/ChainSafe/librustzcash", rev = "9673cc2859e8a2528d1efd3c74795363f87ddf8f" }
zcash_proofs = { git = "https://github.com/ChainSafe/librustzcash", rev = "9673cc2859e8a2528d1efd3c74795363f87ddf8f", default-features = false, features = ["bundled-prover"] }

## gRPC Web dependencies
prost = { version = "0.12", default-features = false }
Expand All @@ -77,7 +76,7 @@ tonic = { version = "0.12", default-features = false, features = [

# Used in Native tests
tokio = { version = "1.0" }
zcash_client_sqlite = { git = "https://github.com/ChainSafe/librustzcash", rev = "d1fa3e846c5e61de3f1df23dd9f4d5416915631a", default-features = false, features = ["unstable", "orchard"], optional = true }
zcash_client_sqlite = { git = "https://github.com/ChainSafe/librustzcash", rev = "9673cc2859e8a2528d1efd3c74795363f87ddf8f", default-features = false, features = ["unstable", "orchard"], optional = true }

getrandom = { version = "0.2", features = ["js"] }
thiserror = "1.0.63"
Expand Down
44 changes: 21 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,72 +10,70 @@ WebZjs aims to make it simple to securely interact with Zcash from within the br

Being a private blockchain Zcash places a lot more demands on the wallet than a public blockchain like Ethereum. WebZjs uses everything at its disposal to give efficient sync times and a good user experience.

## Usage

```typescript
// TODO
```

## Building

### Prerequisites

- [Rust and Cargo](https://www.rust-lang.org/tools/install)
- This repo uses [just](https://github.com/casey/just) as a command runner. Please install this first.
- Install [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/)
- [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/)
- Requires clang 17 or later
- On Mac this can be installed by updating LLVM using your preferred package manager (e.g. macports, brew)
- Tested with Rust nightly-2024-08-07

### Building for Browser
### Building WebZjs

This just script uses wasm-pack to build a web-ready javascript library.
This just script uses wasm-pack to build a web-ready copy of `webz-core` into the `packages` directory

```shell
just build-web
just build
```

After building the resulting lib can be found in `packages/webz-core`.

### Building the example web-wallet
### Building and running the demo-wallet

#### Prerequisites

[Install pnpm](https://pnpm.io/installation)

### Building

Install dependencies with
First build WebZjs with

```shell
just build
```

Install js dependencies with

```shell
pnpm i
```

Build WebZjs with
Build the demo wallet with

```shell
just build
pnpm build
```

Start a dev server with the page
Serve it with

```shell
pnpm start:dev
pnpm serve
```

## Development
> [!IMPORTANT]
> For unknown reasons it is currently not possible to use the parcel dev server to serve the demo-wallet hence the build and then serve steps
The [`.cargo/config.toml`](./.cargo/config.toml) file sets the build target to `wasm32-unknown-unknown` so the regular cargo commands (e.g. `check`, `build`) will run against this target.
## Development

### Testing

Tests are run in a headless browser environment and can be run with
Browser tests are run in a headless browser environment and can be run with

```shell
just test-web
```



## Security Warnings

These libraries are currently under development, have received no reviews or audit, and come with no guarantees whatsoever.
Expand Down
10 changes: 5 additions & 5 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ default:
just --list

build *features:
wasm-pack build --no-opt -t web --scope webzjs --release --out-dir ./packages/webz-core --no-default-features --features="wasm wasm-parallel sync2 {{features}}" -Z build-std="panic_abort,std"
wasm-pack build --no-opt -t web --scope webzjs --release --out-dir ./packages/webz-core --no-default-features --features="wasm wasm-parallel {{features}}" -Z build-std="panic_abort,std"

# All Wasm Tests
test-web *features:
WASM_BINDGEN_TEST_TIMEOUT=99999 wasm-pack test --release --firefox --no-default-features --features "wasm no-bundler {{features}}" -Z build-std="panic_abort,std"

# sync message board in the web: addigional args: sync2
# sync message board in the web: addigional args:
test-message-board-web *features:
WASM_BINDGEN_TEST_TIMEOUT=99999 wasm-pack test --release --chrome --no-default-features --features "wasm no-bundler {{features}}" -Z build-std="panic_abort,std" --test message-board-sync

# simple example in the web: additional args: sync2
# simple example in the web: additional args:
test-simple-web *features:
WASM_BINDGEN_TEST_TIMEOUT=99999 wasm-pack test --release --chrome --no-default-features --features "wasm no-bundler {{features}}" -Z build-std="panic_abort,std" --test simple-sync-and-send


# simple example: additional args: sync2, sqlite-db
# simple example: additional args:, sqlite-db
example-simple *features:
RUST_LOG="info,zcash_client_backend::sync=debug" cargo run -r --example simple-sync --features "native {{features}}"

# sync the message board: additional args: sync2, sqlite-db
# sync the message board: additional args:, sqlite-db
example-message-board *features:
RUST_LOG=info,zcash_client_backend::sync=debug cargo run -r --example message-board-sync --features "native {{features}}"

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"scripts": {
"preinstall": "npx only-allow pnpm",
"start:dev": "parcel --no-autoinstall packages/demo-wallet",
"build": "parcel build --no-cache --no-autoinstall packages/demo-wallet",
"serve": "pnpm --filter ./packages/demo-wallet run serve",
"start:dev": "parcel --no-autoinstall packages/demo-wallet",
"test": "pnpm -r test"
},
"dependencies": {
Expand Down
4 changes: 3 additions & 1 deletion packages/demo-wallet/.gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
.pnp.*
.yarn/*
dist/*

!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
!dist/serve.json

dist
.parcel-cache
wasm-pkg
2 changes: 2 additions & 0 deletions packages/demo-wallet/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# WebZjs Demo Web Wallet

Please see the root README for instructions
18 changes: 18 additions & 0 deletions packages/demo-wallet/dist/serve.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"headers": [
{
"source": "**/*",
"headers": [
{
"key": "Cross-Origin-Opener-Policy",
"value": "same-origin"
},
{
"key": "Cross-Origin-Embedder-Policy",
"value": "require-corp"
}
]
}
]
}

Loading

0 comments on commit 80fbe3f

Please sign in to comment.