Skip to content

Commit

Permalink
Rename the light-client to web-client
Browse files Browse the repository at this point in the history
Rename the `light-client` crate to `web-client` and re-write the
client code to be `wasm` friendly.
  • Loading branch information
jsdanielh committed Jan 23, 2023
1 parent 91ee8a3 commit a5acd75
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 191 deletions.
23 changes: 12 additions & 11 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ members = [
"keys",
"lib",
"light-blockchain",
"light-client",
"log",
"macros",
"mempool",
Expand Down Expand Up @@ -58,6 +57,7 @@ members = [
"validator-network",
"vrf",
"wallet",
"web-client",
"zkp-component",
]

Expand Down
14 changes: 0 additions & 14 deletions light-client/nimiq-client.service

This file was deleted.

154 changes: 0 additions & 154 deletions light-client/src/main.rs

This file was deleted.

2 changes: 1 addition & 1 deletion log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pub static NIMIQ_MODULES: &[&str] = &[
"nimiq_keys",
"nimiq_lib",
"nimiq_light_blockchain",
"nimiq_light_client",
"nimiq_log",
"nimiq_macros",
"nimiq_mempool",
Expand Down Expand Up @@ -60,6 +59,7 @@ pub static NIMIQ_MODULES: &[&str] = &[
"nimiq_validator_network",
"nimiq_vrf",
"nimiq_wallet",
"nimiq_web_client",
"nimiq_zkp_component",
];

Expand Down
16 changes: 6 additions & 10 deletions light-client/Cargo.toml → web-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "nimiq-light-client"
name = "nimiq-web-client"
version = "0.1.0"
authors = ["The Nimiq Core Development Team <info@nimiq.com>"]
edition = "2021"
description = "Nimiq's Rust light client"
description = "Nimiq's Rust to wasm web client"
homepage = "https://nimiq.com"
repository = "https://github.com/nimiq/core-rs-albatross"
license = "Apache-2.0"
Expand All @@ -19,21 +19,17 @@ maintenance = { status = "experimental" }

[dependencies]
futures = { package = "futures-util", version = "0.3" }
gloo-timers = "0.2"
log = { package = "tracing", version = "0.1", features = ["log"] }
tokio = { version = "1.24", features = ["macros", "rt-multi-thread", "time"] }
tokio-metrics = "0.1"
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"

[dependencies.nimiq]
package = "nimiq-lib"
path = "../lib"
version = "0.1"
default-features = false
features = [
"deadlock",
"logging",
"metrics-server",
"panic",
"rpc-server",
"signal-handling",
"wallet",
"web-logging",
]
25 changes: 25 additions & 0 deletions web-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Nimiq web client

This client is a very light client that only includes the necessary dependencies and constructs
to compile a client to WebAssembly and to run it in a web browser. This is a web-client intended
to be used in web browsers only (no WASI support). Although it can be built for other targets,
it will panic if it is executed outside a web browser.


To build the client, the recommended way is to use `wasm-pack`. This tool can be obtained using:

```
cargo install wasm-pack
```

Once installed, the client can be built using:

```
wasm-pack build --target web
```

The above command will compile the Rust code to WebAssembly and generate the corresponding JS
bindings required to run the client in a web browser.

After the client has been built, the root directory of this crate can be served with a web server
(e.g. `python3 -m http.server`) and then the `index.html` file can be loaded from the server.
16 changes: 16 additions & 0 deletions web-client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<title>Nimiq Web client example</title>
</head>
<body>
<script type="module">
import init, { nimiq_web_client } from "./pkg/nimiq_web_client.js";
init().then(() => {
nimiq_web_client();
});
</script>
</body>
</html>

Loading

0 comments on commit a5acd75

Please sign in to comment.