Skip to content

Commit

Permalink
Update to workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
yukibtc committed Jan 19, 2024
1 parent 88045f1 commit df175f7
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 18 deletions.
21 changes: 9 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
[package]
name = "webln"
version = "0.1.0"
edition = "2021"
description = "WebLN - Lightning Web Standard"
[workspace]
members = [
"webln",
]
resolver = "2"

[workspace.package]
authors = ["Yuki Kishimoto <[email protected]>"]
homepage = "https://github.com/yukibtc/rust-webln"
repository = "https://github.com/yukibtc/rust-webln.git"
license = "MIT"
#rust-version = "1.64.0" TODO: check MSRV
keywords = ["webln", "lightning", "bitcoin"]
rust-version = "1.64.0" # TODO: check MSRV

[dependencies]
js-sys = "0.3"
wasm-bindgen = { version = "0.2", default-features = false }
wasm-bindgen-futures = "0.4"
web-sys = { version = "0.3", default-features = false, features = ["Window"] }
[workspace.dependencies]

[profile.release]
lto = true
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# WebLN
# WebLN - Lightning Web Standard

* [webln](./webln/): Rust implementation of WebLN

## License

Expand Down
39 changes: 39 additions & 0 deletions contrib/scripts/check-crates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Needed to exit from script on error
set -e

# MSRV
msrv="1.64.0"

is_msrv=false
version=""

# Check if "msrv" is passed as an argument
if [[ "$#" -gt 0 && "$1" == "msrv" ]]; then
is_msrv=true
version="+$msrv"
fi

# Check if MSRV
if [ "$is_msrv" == true ]; then
# Install MSRV
rustup install $msrv
rustup component add clippy --toolchain $msrv
rustup target add wasm32-unknown-unknown --toolchain $msrv
fi

buildargs=(
"-p webln --target wasm32-unknown-unknown"
)

for arg in "${buildargs[@]}"; do
if [[ $version == "" ]]; then
echo "Checking '$arg' [default]"
else
echo "Checking '$arg' [$version]"
fi
cargo $version check $arg
cargo $version clippy $arg -- -D warnings
echo
done
14 changes: 14 additions & 0 deletions contrib/scripts/check-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Needed to exit from script on error
set -e

buildargs=(
"-p webln --target wasm32-unknown-unknown"
)

for arg in "${buildargs[@]}"; do
echo "Checking '$arg' docs"
cargo doc $arg --all-features
echo
done
17 changes: 13 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
fmt:
cargo fmt --all -- --config format_code_in_doc_comments=true

check:
cargo check
cargo clippy
cargo doc
check: fmt check-crates check-crates-msrv check-docs

check-fmt:
cargo fmt --all -- --config format_code_in_doc_comments=true --check

check-crates:
@bash contrib/scripts/check-crates.sh

check-crates-msrv:
@bash contrib/scripts/check-crates.sh msrv

check-docs:
@bash contrib/scripts/check-docs.sh
18 changes: 18 additions & 0 deletions webln/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "webln"
version = "0.1.0"
edition = "2021"
description = "WebLN - Lightning Web Standard"
authors.workspace = true
homepage.workspace = true
repository.workspace = true
license.workspace = true
readme = "README.md"
rust-version.workspace = true
keywords = ["webln", "lightning", "bitcoin"]

[dependencies]
js-sys = "0.3"
wasm-bindgen = { version = "0.2", default-features = false }
wasm-bindgen-futures = "0.4"
web-sys = { version = "0.3", default-features = false, features = ["Window"] }
11 changes: 11 additions & 0 deletions webln/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# WebLN

## License

This project is distributed under the MIT software license - see the [LICENSE](../LICENSE) file for details

## Donations

⚡ Tips: https://getalby.com/p/yuki

⚡ Lightning Address: [email protected]
2 changes: 1 addition & 1 deletion src/lib.rs → webln/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl WebLN {
.map_err(|_| Error::ObjectKeyNotFound(key.to_string()))
} */

/// Check if `webln` is enabled without explicitly enabling it through `webln.enable()`
/// Check if `webln` is enabled without explicitly enabling it through `webln.enable()`
/// (which may cause a confirmation popup in some providers)
pub async fn is_enabled(&self) -> Result<bool, Error> {
let func: Function = self.get_func(&self.webln_obj, "isEnabled")?;
Expand Down

0 comments on commit df175f7

Please sign in to comment.