Skip to content

Commit

Permalink
Merge pull request #43 from ChainSafe/willem/switch-to-vite
Browse files Browse the repository at this point in the history
Switch to vite for demo-wallet and add deployment
  • Loading branch information
willemolding authored Oct 18, 2024
2 parents 8706d23 + d84a1d4 commit 78a63fa
Show file tree
Hide file tree
Showing 18 changed files with 1,014 additions and 254 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/deploy-demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build and Deploy demo to Netlify

on:
# Runs on pushes targeting the default branch
push:
branches: ['main']
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Install Just
uses: extractions/setup-just@v2

- name: install wasm-pack
uses: jetli/[email protected]
with:
version: latest

- name: build pkg
run: just build

- uses: actions/setup-node@v4
with:
node-version: lts/*

- uses: pnpm/action-setup@v4

- name: Install dependencies
run: pnpm i

- name: Build
run: pnpm build

- name: Deploy to Netlify
uses: nwtgck/[email protected]
with:
publish-dir: './packages/demo-wallet/dist'
production-branch: main
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
enable-pull-request-comment: false
enable-commit-comment: true
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ packages/demo-wallet/dist/*
packages/e2e-tests/dist/*
./dist/*

!packages/demo-wallet/dist/serve.json
!packages/demo-wallet/dist/_headers
!packages/e2e-tests/dist/serve.json
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ zcash_client_backend = { git = "https://github.com/ChainSafe/librustzcash", rev
zcash_client_memory = { git = "https://github.com/ChainSafe/librustzcash", rev = "37c765025386912c6152ba5e9816099a067497e5", features = ["orchard"] }
zcash_primitives = { git = "https://github.com/ChainSafe/librustzcash", rev = "37c765025386912c6152ba5e9816099a067497e5" }
zcash_address = { git = "https://github.com/ChainSafe/librustzcash", rev = "37c765025386912c6152ba5e9816099a067497e5" }
zcash_proofs = { git = "https://github.com/ChainSafe/librustzcash", rev = "37c765025386912c6152ba5e9816099a067497e5", default-features = false, features = ["bundled-prover"] }
zcash_proofs = { git = "https://github.com/ChainSafe/librustzcash", rev = "37c765025386912c6152ba5e9816099a067497e5", default-features = false, features = ["bundled-prover", "multicore"] }
zip321 = { git = "https://github.com/ChainSafe/librustzcash", rev = "37c765025386912c6152ba5e9816099a067497e5" }


Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ Browser tests are run in a headless browser environment and can be run with
just test-web
```

## Known Issues

You might notice the demo-wallet builds using parcel despite being configured to use Vite for development. This is due to a [known issue](https://github.com/vitejs/vite/issues/7015) with vite where it cannot correctly handle what it deems to be a cyclic dependency introduced by `wasm_bindgen_rayon` webworkers. Other bundlers tested to not seem to be affected.

## Security Warnings

These libraries are currently under development, have received no reviews or audit, and come with no guarantees whatsoever.
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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 {{features}}" -Z build-std="panic_abort,std"
wasm-pack build -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:
Expand Down
13 changes: 4 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
{
"scripts": {
"preinstall": "npx only-allow pnpm",
"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",
"dev": "pnpm --filter ./packages/demo-wallet run dev",
"build": "pnpm --filter ./packages/demo-wallet run build",
"test:e2e": "pnpm --filter ./packages/e2e-tests test"
},
"dependencies": {
"@webzjs/webz-core": "workspace:^",
"@webzjs/demo-wallet": "workspace:^"
},
"devDependencies": {
"@parcel/core": "^2.12.0",
"parcel": "^2.12.0",
"process": "^0.11.10"
"@webzjs/demo-wallet": "workspace:^",
"@webzjs/webz-core": "workspace:^"
},
"packageManager": "[email protected]+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b"
}
3 changes: 3 additions & 0 deletions packages/demo-wallet/dist/_headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
18 changes: 0 additions & 18 deletions packages/demo-wallet/dist/serve.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
<head>
<meta charset="utf-8" />
<title>WebZjs Wallet Demo</title>
<script src="enable-threads.js"></script>
</head>
<body>
<div id="app"></div>
<script type="module" src="index.js"></script>
<script type="module" src="./src/index.jsx"></script>
</body>
</html>
13 changes: 9 additions & 4 deletions packages/demo-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "@webzjs/demo-wallet",
"source": "src/index.html",
"source": "index.html",
"scripts": {
"serve": "serve dist"
"dev": "vite",
"serve": "vite preview",
"build": "parcel build index.html"
},
"dependencies": {
"@types/react": "^18.3.9",
Expand All @@ -15,10 +17,13 @@
"react-dom": "^18.2.0",
"react-qr-code": "^2.0.15",
"react-toastify": "^10.0.5",
"typescript": "^5.6.2",
"usehooks-ts": "^3.1.0"
},
"devDependencies": {
"serve": "^14.2.3"
"@vitejs/plugin-react": "^4.3.2",
"typescript": "^5.6.2",
"vite": "^5.4.9",
"@parcel/core": "^2.12.0",
"parcel": "^2.12.0"
}
}
1 change: 1 addition & 0 deletions packages/demo-wallet/src/App/Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export async function init(state: State, dispatch: React.Dispatch<Action>) {
dispatch({ type: "set-account-seeds", payload: seeds });
}
} else {
console.info("No saved wallet detected. Creating new wallet");
wallet = new WebWallet("main", MAINNET_LIGHTWALLETD_PROXY, 1);
}

Expand Down
76 changes: 0 additions & 76 deletions packages/demo-wallet/src/enable-threads.js

This file was deleted.

File renamed without changes.
24 changes: 24 additions & 0 deletions packages/demo-wallet/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
// "strict": true,
// "noUnusedLocals": true,
// "noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}
1 change: 1 addition & 0 deletions packages/demo-wallet/tsconfig.tsbuildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"root":["./src/utils.ts","./src/app/actions.tsx","./src/app/app.tsx","./src/app/constants.tsx","./src/app/components/addaccount.tsx","./src/app/components/header.tsx","./src/app/components/receivefunds.tsx","./src/app/components/sendfunds.tsx","./src/app/components/settings.tsx","./src/app/components/summary.tsx"],"version":"5.6.2"}
23 changes: 23 additions & 0 deletions packages/demo-wallet/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
server: {
headers: {
// required to support web-workers spawning web-workers
"Cross-Origin-Opener-Policy": "same-origin",
"Cross-Origin-Embedder-Policy": "require-corp",
},
},
build: {
rollupOptions: {
input: {
main: "index.html",
worker: "node_modules/@webzjs/webz-core/snippets/wasm-bindgen-rayon-3e04391371ad0a8e/src/workerHelpers.worker.js",
},
},
manifest: true,
},
});
4 changes: 3 additions & 1 deletion packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"@playwright/test": "^1.47.2",
"@types/node": "^22.7.4",
"@webzjs/webz-core": "workspace:^",
"serve": "^14.2.3"
"serve": "^14.2.3",
"@parcel/core": "^2.12.0",
"parcel": "^2.12.0"
}
}
Loading

1 comment on commit 78a63fa

@github-actions
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.