Skip to content

Commit 561f53b

Browse files
authored
Merge pull request #75 from ChainSafe/irubido/addChainsafeScope
project scope changed to chainsafe, packages naming changed to webzjs
2 parents 3935396 + 665149b commit 561f53b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+263
-285
lines changed

Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
resolver = "2"
33

44
members = [
5-
"crates/webz-common",
6-
"crates/webz-keys",
7-
"crates/webz-requests",
8-
"crates/webz-wallet",
5+
"crates/webzjs-common",
6+
"crates/webzjs-keys",
7+
"crates/webzjs-requests",
8+
"crates/webzjs-wallet",
99
]
1010

1111
[profile.release]
@@ -16,7 +16,7 @@ codegen-units = 1
1616

1717
[workspace.dependencies]
1818
## Web dependencies
19-
wasm-bindgen = "0.2.99" # higher versions has an issues with attachment of the file: webz-wallet/snippets/wasm-bindgen-rayon-3e04391371ad0a8e/src/workerHelpers.worker.js
19+
wasm-bindgen = "0.2.99" # higher versions has an issues with attachment of the file: webzjs-wallet/snippets/wasm-bindgen-rayon-3e04391371ad0a8e/src/workerHelpers.worker.js
2020
js-sys = "0.3.77"
2121
wasm-bindgen-futures = "0.4.43"
2222
web-sys = { version = "0.3.70", features = [

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Being a private blockchain Zcash places a lot more demands on the wallet than a
1313

1414
## Quickstart
1515

16-
Add the `@webzjs/webz-wallet` package to your javascript project.
16+
Add the `@chainsafe/webzjs-wallet` package to your javascript project.
1717

1818
Before using the library it is important to initialize the Wasm module and the thread pool.
1919

@@ -22,7 +22,7 @@ Before using the library it is important to initialize the Wasm module and the t
2222
> Failing to call them or calling them more than once per page load will result in an error
2323
2424
```javascript
25-
import initWasm, { initThreadPool, WebWallet } from "@webzjs/webz-wallet";
25+
import initWasm, { initThreadPool, WebWallet } from "@chainsafe/webzjs-wallet";
2626

2727
initWasm();
2828
initThreadPool(8); // can set any number of threads here, ideally match it to window.navigator.hardwareConcurrency
@@ -66,7 +66,7 @@ For more details check out the hosted docs at https://chainsafe.github.io/WebZjs
6666

6767
### Building WebZjs
6868

69-
This just script uses wasm-pack to build a web-ready copy of `webz-wallet` and `webz-keys` into the `packages` directory
69+
This just script uses wasm-pack to build a web-ready copy of `webzjs-wallet` and `webzjs-keys` into the `packages` directory
7070

7171
```shell
7272
just build

add-worker-module.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
#!/bin/bash
22

3-
# Create the directory if it doesn't exist
4-
mkdir -p packages/webz-wallet/snippets/wasm_thread-8ee53d0673203880/src/wasm32/js
3+
# Find the wasm_thread directory regardless of the hash
4+
WASM_THREAD_DIR=$(find packages/webzjs-wallet/snippets -type d -name "wasm_thread-*" | head -n 1)
5+
6+
if [ -z "$WASM_THREAD_DIR" ]; then
7+
echo "Error: Could not find wasm_thread directory"
8+
exit 1
9+
fi
10+
11+
# Create the directory structure
12+
mkdir -p "$WASM_THREAD_DIR/src/wasm32/js"
513

614
# Create the worker module file
7-
cat > packages/webz-wallet/snippets/wasm_thread-8ee53d0673203880/src/wasm32/js/web_worker_module.bundler.js << 'EOL'
15+
cat > "$WASM_THREAD_DIR/src/wasm32/js/web_worker_module.bundler.js" << 'EOL'
816
// synchronously, using the browser, import wasm_bindgen shim JS scripts
917
import init, { wasm_thread_entry_point } from "../../../../../";
1018
// Wait for the main thread to send us the shared module/memory and work context.
@@ -41,4 +49,6 @@ self.onended = function(e) {
4149
console.error('Worker ended:', e.message);
4250
throw e;
4351
}
44-
EOL
52+
EOL
53+
54+
echo "Added worker module to: $WASM_THREAD_DIR/src/wasm32/js/web_worker_module.bundler.js"

crates/webz-common/Cargo.toml renamed to crates/webzjs-common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "webz-common"
2+
name = "webzjs-common"
33
version = "0.1.0"
44
authors = ["ChainSafe Systems"]
55
license = "MIT OR Apache-2.0"
File renamed without changes.
File renamed without changes.
File renamed without changes.

crates/webz-keys/Cargo.toml renamed to crates/webzjs-keys/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "webz-keys"
2+
name = "webzjs-keys"
33
version = "0.1.0"
44
authors = ["ChainSafe Systems"]
55
license = "MIT OR Apache-2.0"
@@ -14,7 +14,7 @@ crate-type = ["cdylib", "rlib"]
1414
wasm-opt = ["-O4", "-O4"]
1515

1616
[dependencies]
17-
webz-common = { path = "../webz-common" }
17+
webzjs-common = { path = "../webzjs-common" }
1818

1919
js-sys.workspace = true
2020
thiserror.workspace = true

crates/webz-keys/src/error.rs renamed to crates/webzjs-keys/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use wasm_bindgen::JsValue;
22

33
#[derive(thiserror::Error, Debug)]
44
pub enum Error {
5-
#[error("webz-common crate gives error: {0}")]
6-
WebzCommon(#[from] webz_common::Error),
5+
#[error("webzjs-common crate gives error: {0}")]
6+
WebzJSCommon(#[from] webzjs_common::Error),
77
#[error("Invalid account id")]
88
AccountIdConversion(#[from] zcash_primitives::zip32::TryFromIntError),
99
#[error("Failed to derive key from seed")]

crates/webz-keys/src/keys.rs renamed to crates/webzjs-keys/src/keys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use wasm_bindgen::prelude::*;
66

77
use crate::error::Error;
88
use bip0039::{Count, English, Mnemonic};
9-
use webz_common::Network;
9+
use webzjs_common::Network;
1010
use zcash_primitives::zip32::AccountId;
1111

1212
/// A ZIP32 seed fingerprint. Essentially a Blake2b hash of the seed.
File renamed without changes.

crates/webz-keys/src/pczt_sign.rs renamed to crates/webzjs-keys/src/pczt_sign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::collections::BTreeMap;
66
use std::convert::Infallible;
77
use std::str::FromStr;
88
use wasm_bindgen::prelude::wasm_bindgen;
9-
use webz_common::{Network, Pczt};
9+
use webzjs_common::{Network, Pczt};
1010
use zcash_primitives::consensus::{NetworkConstants, Parameters};
1111
use zcash_primitives::legacy::keys::{NonHardenedChildIndex, TransparentKeyScope};
1212

crates/webz-requests/Cargo.toml renamed to crates/webzjs-requests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "webz-requests"
2+
name = "webzjs-requests"
33
version = "0.1.0"
44
authors = ["ChainSafe Systems"]
55
license = "MIT OR Apache-2.0"
File renamed without changes.

crates/webz-wallet/Cargo.toml renamed to crates/webzjs-wallet/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "webz-wallet"
2+
name = "webzjs-wallet"
33
version = "0.1.0"
44
authors = ["ChainSafe Systems"]
55
license = "MIT OR Apache-2.0"
@@ -28,8 +28,8 @@ console_error_panic_hook = ["dep:console_error_panic_hook"]
2828
no-bundler = ["wasm-bindgen-rayon?/no-bundler", "wasm_thread/no-bundler"]
2929

3030
[dependencies]
31-
webz-common = { path = "../webz-common" }
32-
webz-keys = { path = "../webz-keys" }
31+
webzjs-common = { path = "../webzjs-common" }
32+
webzjs-keys = { path = "../webzjs-keys" }
3333
## Web dependencies
3434
wasm-bindgen.workspace = true
3535
js-sys.workspace = true

crates/webz-wallet/src/bindgen/wallet.rs renamed to crates/webzjs-wallet/src/bindgen/wallet.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use crate::error::Error;
1212
use crate::wallet::usk_from_seed_str;
1313
use crate::{bindgen::proposal::Proposal, Wallet, PRUNING_DEPTH};
1414
use wasm_thread as thread;
15-
use webz_common::{Network, Pczt};
16-
use webz_keys::{ProofGenerationKey, SeedFingerprint, UnifiedSpendingKey};
15+
use webzjs_common::{Network, Pczt};
16+
use webzjs_keys::{ProofGenerationKey, SeedFingerprint, UnifiedSpendingKey};
1717
use zcash_address::ZcashAddress;
1818
use zcash_client_backend::data_api::{AccountPurpose, InputSource, WalletRead, Zip32Derivation};
1919
use zcash_client_backend::proto::service::{

crates/webz-wallet/src/error.rs renamed to crates/webzjs-wallet/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use wasm_bindgen::JsValue;
66

77
#[derive(thiserror::Error, Debug)]
88
pub enum Error {
9-
#[error("webz-common crate gives error: {0}")]
10-
WebzCommon(#[from] webz_common::Error),
9+
#[error("webzjs-common crate gives error: {0}")]
10+
WebzJSCommon(#[from] webzjs_common::Error),
1111
#[error("Invalid account id")]
1212
AccountIdConversion(#[from] zcash_primitives::zip32::TryFromIntError),
1313
#[error("Failed to derive key from seed")]
File renamed without changes.
File renamed without changes.

crates/webz-wallet/src/wallet.rs renamed to crates/webzjs-wallet/src/wallet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use tonic::{
1212

1313
use crate::error::Error;
1414
use crate::BlockRange;
15-
use webz_common::Network;
15+
use webzjs_common::Network;
1616

1717
use pczt::roles::combiner::Combiner;
1818
use pczt::roles::prover::Prover;

docs/docusaurus.config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ const config = {
4545
projectRoot: join(__dirname, '..'),
4646
// Monorepo
4747
packages: [ {
48-
path: 'packages/webz-wallet',
49-
entry: 'webz_wallet.d.ts',
48+
path: 'packages/webzjs-wallet',
49+
entry: 'webzjs_wallet.d.ts',
5050
},{
51-
path: 'packages/webz-keys',
52-
entry: 'webz_keys.d.ts',
51+
path: 'packages/webzjs-keys',
52+
entry: 'webzjs_keys.d.ts',
5353
}, {
54-
path: 'packages/webz-requests',
55-
entry: 'webz_requests.d.ts',
54+
path: 'packages/webzjs-requests',
55+
entry: 'webzjs_requests.d.ts',
5656
}],
5757
minimal: false,
5858
debug: true,

justfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ build:
77
just build-requests
88

99
build-wallet *features:
10-
cd crates/webz-wallet && wasm-pack build -t web --release --scope webzjs --out-dir ../../packages/webz-wallet --no-default-features --features="wasm wasm-parallel {{features}}" -Z build-std="panic_abort,std"
10+
cd crates/webzjs-wallet && wasm-pack build -t web --release --scope chainsafe --out-dir ../../packages/webzjs-wallet --no-default-features --features="wasm wasm-parallel {{features}}" -Z build-std="panic_abort,std"
1111
./add-worker-module.sh
1212

1313
build-keys *features:
14-
cd crates/webz-keys && wasm-pack build -t web --release --scope webzjs --out-dir ../../packages/webz-keys --no-default-features --features="{{features}}" -Z build-std="panic_abort,std"
14+
cd crates/webzjs-keys && wasm-pack build -t web --release --scope chainsafe --out-dir ../../packages/webzjs-keys --no-default-features --features="{{features}}" -Z build-std="panic_abort,std"
1515

1616
build-requests *features:
17-
cd crates/webz-requests && wasm-pack build -t web --release --scope webzjs --out-dir ../../packages/webz-requests --no-default-features --features="{{features}}" -Z build-std="panic_abort,std"
17+
cd crates/webzjs-requests && wasm-pack build -t web --release --scope chainsafe --out-dir ../../packages/webzjs-requests --no-default-features --features="{{features}}" -Z build-std="panic_abort,std"
1818

1919
# All Wasm Tests
2020
test-web *features:

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
},
1515
"packageManager": "yarn@4.5.1",
1616
"scripts": {
17-
"dev": "yarn workspace @webzjs/web-wallet run dev & yarn run snap:start",
18-
"demo-wallet:serve": "yarn workspace @webzjs/demo-wallet run serve",
17+
"dev": "yarn workspace @chainsafe/webzjs-web-wallet run dev & yarn run snap:start",
18+
"demo-wallet:serve": "yarn workspace @chainsafe/webzjs-demo-wallet run serve",
1919
"demo-wallet:dev": "yarn run just:build-keys && yarn run snap:start & yarn run web-wallet:dev",
20-
"demo-wallet:build": "yarn workspace @webzjs/demo-wallet run build",
21-
"web-wallet:dev": "yarn workspace @webzjs/web-wallet run dev & yarn run snap:start",
22-
"web-wallet:build": "yarn workspace @webzjs/web-wallet run build",
23-
"test:e2e": "yarn workspace @webzjs/e2e-tests test",
24-
"snap:start": "yarn workspace @webzjs/zcash-snap run start",
25-
"snap:build": "yarn workspace @webzjs/zcash-snap run build",
20+
"demo-wallet:build": "yarn workspace @chainsafe/webzjs-demo-wallet run build",
21+
"web-wallet:dev": "yarn workspace @chainsafe/webzjs-web-wallet run dev & yarn run snap:start",
22+
"web-wallet:build": "yarn workspace @chainsafe/webzjs-web-wallet run build",
23+
"test:e2e": "yarn workspace @chainsafe/webzjs-e2e-tests test",
24+
"snap:start": "yarn workspace @chainsafe/webzjs-zcash-snap run start",
25+
"snap:build": "yarn workspace @chainsafe/webzjs-zcash-snap run build",
2626
"just:build": "just build",
2727
"just:build-keys": "just build-keys"
2828
}

packages/demo-wallet/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@webzjs/demo-wallet",
2+
"name": "@chainsafe/webzjs-demo-wallet",
33
"source": "index.html",
44
"version": "0.1.0",
55
"scripts": {
@@ -9,11 +9,11 @@
99
},
1010
"type": "module",
1111
"dependencies": {
12+
"@chainsafe/webzjs-keys": "workspace:^",
13+
"@chainsafe/webzjs-wallet": "workspace:^",
1214
"@metamask/providers": "^18.1.0",
1315
"@types/react": "^18.3.9",
1416
"@types/react-dom": "^18.3.0",
15-
"@webzjs/webz-keys": "workspace:^",
16-
"@webzjs/webz-wallet": "workspace:^",
1717
"bootstrap": "^5.3.3",
1818
"idb-keyval": "^6.2.1",
1919
"react": "^18.2.0",

packages/demo-wallet/src/App/Actions.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import initWebzWallet, { initThreadPool, WebWallet } from '@webzjs/webz-wallet';
2-
import initWebzKeys from '@webzjs/webz-keys';
1+
import initWebzJSWallet, { initThreadPool, WebWallet } from '@chainsafe/webzjs-wallet';
2+
import initWebzJSKeys from '@chainsafe/webzjs-keys';
33

44
import { get, set } from 'idb-keyval';
55

66
import { State, Action } from './App';
77
import { MAINNET_LIGHTWALLETD_PROXY } from './Constants';
88

99
export async function init(state: State, dispatch: React.Dispatch<Action>) {
10-
await initWebzWallet();
11-
await initWebzKeys();
10+
await initWebzJSWallet();
11+
await initWebzJSKeys();
1212

1313
await initThreadPool(10);
1414

packages/demo-wallet/src/App/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Stack from 'react-bootstrap/Stack';
99
import Container from 'react-bootstrap/Container';
1010
import LoadingOverlay from 'react-loading-overlay';
1111

12-
import { WebWallet, WalletSummary } from '@webzjs/webz-wallet';
12+
import { WebWallet, WalletSummary } from '@chainsafe/webzjs-wallet';
1313

1414
import { init, triggerRescan } from './Actions';
1515
import { Header } from './components/Header';

packages/demo-wallet/src/App/components/AddAccount.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { FormEvent, useContext, useEffect, useState } from 'react';
33
import Button from 'react-bootstrap/Button';
44
import Form from 'react-bootstrap/Form';
55
import { toast, ToastContainer } from 'react-toastify';
6-
import { generate_seed_phrase } from '@webzjs/webz-keys';
6+
import { generate_seed_phrase } from '@chainsafe/webzjs-keys';
77

88
import { WalletContext } from '../App';
99
import {

packages/demo-wallet/src/App/components/Summary.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { WalletSummary } from "@webzjs/webz-wallet";
2+
import { WalletSummary } from "@chainsafe/webzj-wallet";
33

44
export function Summary({
55
summary,

packages/demo-wallet/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default defineConfig({
1515
rollupOptions: {
1616
input: {
1717
main: "index.html",
18-
worker: "node_modules/@webzjs/webz-wallet/snippets/wasm-bindgen-rayon-3e04391371ad0a8e/src/workerHelpers.worker.js",
18+
worker: "node_modules/@chainsafe/webzjs-wallet/snippets/wasm-bindgen-rayon-3e04391371ad0a8e/src/workerHelpers.worker.js",
1919
},
2020
},
2121
manifest: true,

packages/e2e-tests/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# WebZ e2e Tests
1+
# WebZJS e2e Tests
22

33
This package uses playwright to test the highest level API of WebZjs running in a browser. This allows testing the interaction of different WebWorkers with the page, as well as testing on different browsers.
44

@@ -9,7 +9,7 @@ New tests should be added as files named `.spec.ts` inside the `e2e` directory.
99
Tests should use the `page.evaluate` method from playwright to execute javascript code in the browser page where the wallet exists and return a result to the test runner to check. e.g.
1010

1111
```typescript
12-
test('Test some webz functionality..', async ({ page }) => {
12+
test('Test some webzjs functionality..', async ({ page }) => {
1313
// code here runs in the test runner (node), not in the browser
1414
let result = await page.evaluate(async () => {
1515
// everything here executes in the web page

0 commit comments

Comments
 (0)