Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No std upstream working #90

Closed
wants to merge 77 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
ee655f3
nostr: add std feature
OverOrion Mar 23, 2023
598f99b
nostr: use thiserror-core with alloc feature
OverOrion Mar 23, 2023
23ce7a0
nostr: make time module `no_std` compatible
OverOrion Mar 23, 2023
c018213
nostr: make nostr crate no_std compatible
OverOrion Mar 23, 2023
20cffbf
nostr: no_std support
OverOrion Mar 24, 2023
1380fe9
nostr: port nip26
OverOrion Mar 24, 2023
2d4d690
nostr: port nip13
OverOrion Mar 24, 2023
d7c6469
nostr: port nip65
OverOrion Mar 24, 2023
98374cd
nostr: outsourcing time for no_std
OverOrion Mar 24, 2023
67cc842
nostr: implement TimeSupplier trait for std environments
OverOrion Mar 27, 2023
6edffb3
nostr: compiling with --no-default-features --features=alloc
OverOrion Mar 30, 2023
33a6d0f
nostr: `EventBuilder` cleanup
OverOrion Mar 30, 2023
77b08b2
nostr: add missing documentation comments
OverOrion Mar 30, 2023
32c2975
nostr: make sure dependencies are no_std compatible
OverOrion Mar 31, 2023
501b2b5
nostr: adjust secp256k1 related things in no_std
OverOrion Mar 31, 2023
7c16daa
no_std: switch back to upstream rust-url
OverOrion Apr 3, 2023
0c80a80
nostr: compiling
OverOrion Apr 4, 2023
0196a15
nostr: accept that other crates don't implement error
clangenb Apr 6, 2023
1ddbbb2
add no std test crate
clangenb Apr 6, 2023
084354f
make it work
clangenb Apr 6, 2023
3add655
ensure_no_std
OverOrion Apr 6, 2023
128b67e
nostr: fix std only imports
OverOrion Apr 11, 2023
a71817e
nostr: remove feature duplicates
OverOrion Apr 11, 2023
ee2443d
emergency backup
OverOrion Apr 11, 2023
69d3d2e
nostr: std feature fixed
OverOrion Apr 11, 2023
92bb83d
nostr: followup for TimeSupplier changes
OverOrion Apr 12, 2023
703581f
nostr: remove duplicate feature
OverOrion Apr 12, 2023
0b0f6ab
nostr: switch to rust-url no_std PR
OverOrion Apr 12, 2023
64913a5
nostr: nip19 port to no_std
OverOrion Apr 13, 2023
77c56f6
nostr: switch rust-url to personal fork for easier testing
OverOrion Apr 18, 2023
837f0e0
nostr: remove commented out code which was not used
OverOrion Apr 18, 2023
38b4b1d
nostr: remove commented out wildcard exports as they interfered with …
OverOrion Apr 18, 2023
5fb5292
ensure_no_std: remove commented out dependencies
OverOrion Apr 20, 2023
565d3c6
nostr: fix prelude wildcard import
OverOrion Apr 20, 2023
4ae7a3e
nostr: add back wasm32 dependencies
OverOrion Apr 20, 2023
3215e57
ensure_no_std: add link to GlobalAlloc implementation source
OverOrion Apr 20, 2023
12e4759
fix rebase issues
OverOrion Apr 20, 2023
3de5f83
deps: remove default features for bitcoin_hashes
OverOrion Apr 21, 2023
b0ac2e1
deps: add missing feature to secp256k1
OverOrion Apr 21, 2023
d6bc1dc
event: compress imports from the secp256k1
OverOrion Apr 21, 2023
6665889
nostr: compress secp256k1 imports
OverOrion Apr 21, 2023
ab80328
fix event/unsigned.rs file
OverOrion May 11, 2023
c0c007c
fixed tests/examples
OverOrion Apr 21, 2023
a1224ca
nostr: fix std::error::Error import in url
OverOrion May 8, 2023
98603db
nostr/event: make is_expired method no_std compatible
OverOrion May 8, 2023
d5b2408
nostr/event/builder: fix EventBuilder in no_std
OverOrion May 8, 2023
b6a4d38
fix import in time.rs
OverOrion May 8, 2023
e193255
fix import in url.rs
OverOrion May 8, 2023
8e4b91b
nostr: move ensure_no_std test crate to example
OverOrion May 9, 2023
d98e11e
remove rand_core dep
OverOrion May 10, 2023
4bf5dd7
remove thiserror from Cargo.toml
OverOrion May 11, 2023
1cdbd76
fix event/mod.rs file
OverOrion May 11, 2023
c3ba426
fix event/id.rs file
OverOrion May 11, 2023
05352e5
fix event/id.rs file
OverOrion May 11, 2023
ccd238f
fix event/id.rs file
OverOrion May 11, 2023
ccca677
fix nips/nip58.rs file
OverOrion May 11, 2023
9d4e542
nostr: use core::error::Error where possible
OverOrion May 11, 2023
94647c2
remove duplicate impl froms
OverOrion May 11, 2023
f041765
fix missing import in nip58.rs
OverOrion May 11, 2023
8e05474
nostr/nips: port NIP58 to no_std
OverOrion May 11, 2023
0135ca7
minor fixes
OverOrion May 11, 2023
f1f518a
gha: add job for no_std nostr
OverOrion May 12, 2023
1ac775e
examples format, should be dropped
OverOrion May 12, 2023
44987eb
fix ensure_no_std ci
OverOrion May 12, 2023
41de424
gha: fix std build
OverOrion May 12, 2023
a37e0ca
fix std::error::Error in vanity.rs
OverOrion May 12, 2023
26759e7
nostr-*: add nostr with std feature
OverOrion May 12, 2023
15c5de1
nostr: fix vanity feature
OverOrion May 12, 2023
da450d0
fix clippy warnings
OverOrion May 12, 2023
2af0f3f
nostr: vanity.rs fix
OverOrion May 12, 2023
a2d86bd
nostr: fix clippy warning
OverOrion May 12, 2023
7b82286
nostr/examples/nip65: fix example
OverOrion May 12, 2023
fd736df
fix bech32 imports
OverOrion May 12, 2023
d264da8
nostr: fix WASM build
OverOrion May 12, 2023
7b1a4f3
partially revert examples modification
OverOrion May 12, 2023
2add303
fix preludes
OverOrion May 12, 2023
b389fdb
nostr/message/subscription: remove duplicate fmt import
OverOrion May 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
build-args:
[
-p nostr,
-p nostr --no-default-features,
-p nostr --no-default-features --features all-nips,
-p nostr --no-default-features --features vanity,
-p nostr --no-default-features --features std,
-p nostr --no-default-features --features 'std all-nips',
-p nostr --no-default-features --features 'std vanity',
-p nostr --features blocking,
-p nostr-sdk,
-p nostr-sdk --no-default-features,
Expand Down Expand Up @@ -95,4 +95,39 @@ jobs:
run: cargo build ${{ matrix.build-args }} --target wasm32-unknown-unknown
- name: Clippy
run: cargo clippy ${{ matrix.build-args }} --target wasm32-unknown-unknown -- -D warnings

buld-no-std:
name: Build the `no_std` crate (ensure_no_std)
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- version: nightly
build-args:
[
--no-default-features,
]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-wasm32-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
- name: Set default toolchain
run: rustup default ${{ matrix.rust.version }}
- name: Add WASM
run: rustup target add wasm32-unknown-unknown
- name: Set profile
run: rustup set profile minimal && rustup component add clippy
- name: Build
run: cargo build ${{ matrix.build-args }}
working-directory: ./crates/nostr/examples/ensure_no_std
- name: Clippy
run: cargo clippy ${{ matrix.build-args }} -- -D warnings
working-directory: ./crates/nostr/examples/ensure_no_std

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ members = [
"crates/nostr-sdk",
"crates/nostr-sdk-net",
]
default-members = ["crates/*"]
default-members = ["crates/nostr*"]
resolver = "2"

[workspace.package]
Expand All @@ -19,4 +19,8 @@ rust-version = "1.64.0"

[profile.release]
lto = true
codegen-units = 1
codegen-units = 1
panic = "abort"

[profile.dev]
panic = "abort"
2 changes: 1 addition & 1 deletion bindings/nostr-js/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crate-type = ["lib", "cdylib"]
[dependencies]
console_error_panic_hook = "0.1"
js-sys = "0.3"
nostr = { path = "../../crates/nostr" }
nostr = { path = "../../crates/nostr", features = ["std"]}
serde-wasm-bindgen = "0.5"
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion crates/nostr-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ nip46 = ["nostr/nip46"]

[dependencies]
log = "0.4"
nostr = { version = "0.21", path = "../nostr", default-features = false }
nostr = { version = "0.21", path = "../nostr", default-features = false, features = ["std"]}
nostr-sdk-net = { version = "0.21", path = "../nostr-sdk-net" }
once_cell = { version = "1.17", optional = true }
thiserror = "1.0"
Expand Down
36 changes: 18 additions & 18 deletions crates/nostr-sdk/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ impl Client {
///
/// # Example
/// ```rust,no_run

/// use nostr_sdk::prelude::*;
///
/// let my_keys = Keys::generate();
Expand Down Expand Up @@ -222,6 +223,7 @@ impl Client {
///
/// # Example
/// ```rust,no_run

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
Expand Down Expand Up @@ -260,6 +262,7 @@ impl Client {
///
/// # Example
/// ```rust,no_run

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
Expand Down Expand Up @@ -305,8 +308,8 @@ impl Client {
///
/// # Example
/// ```rust,no_run

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -351,6 +354,7 @@ impl Client {
///
/// # Example
/// ```rust,no_run

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
Expand Down Expand Up @@ -381,6 +385,7 @@ impl Client {
///
/// # Example
/// ```rust,no_run

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
Expand Down Expand Up @@ -409,8 +414,8 @@ impl Client {
///
/// # Example
/// ```rust,no_run

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand All @@ -426,8 +431,8 @@ impl Client {
///
/// # Example
/// ```rust,no_run

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand All @@ -443,8 +448,8 @@ impl Client {
///
/// # Example
/// ```rust,no_run

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -472,9 +477,8 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use std::time::Duration;
///

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -605,8 +609,8 @@ impl Client {
///
/// # Example
/// ```rust,no_run

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand All @@ -632,8 +636,8 @@ impl Client {
///
/// # Example
/// ```rust,no_run

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand All @@ -658,8 +662,8 @@ impl Client {
///
/// # Example
/// ```rust,no_run

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -722,9 +726,8 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use std::time::Duration;
///

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -821,8 +824,8 @@ impl Client {
///
/// # Example
/// ```rust,no_run

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -907,9 +910,8 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use std::str::FromStr;
///

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -941,9 +943,8 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use std::str::FromStr;
///

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -975,9 +976,8 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use std::str::FromStr;
///

/// use nostr_sdk::prelude::*;
///
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down
62 changes: 50 additions & 12 deletions crates/nostr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,76 @@ rust-version.workspace = true
keywords = ["nostr", "protocol", "sdk"]

[features]
default = ["all-nips"]
default = ["all-nips", "std"]
std = [
"bitcoin_hashes/std",
"serde/std",
"serde_json/std",
"url",
"secp256k1/global-context",
"secp256k1/rand-std",
]
alloc = [
"bitcoin_hashes/alloc",
"serde/alloc",
"serde_json/alloc",
"url_no_std",
"secp256k1/alloc",
"secp256k1/rand",
"rand/alloc",
"rand/getrandom",
]
blocking = ["reqwest?/blocking"]
vanity = ["nip19"]
vanity = ["nip19-std"]
all-nips = ["nip04", "nip05", "nip06", "nip11", "nip19", "nip21", "nip46"]
nip03 = ["dep:nostr-ots"]
nip04 = ["dep:aes", "dep:base64", "dep:cbc"]
nip05 = ["dep:reqwest"]
nip06 = ["dep:bip39", "dep:bitcoin"]
nip11 = ["dep:reqwest"]
nip19 = ["dep:bech32"]
nip19 = ["bech32/alloc"]
nip19-std = ["bech32/std"]
nip21 = ["nip19"]
nip46 = ["nip04"]

[dependencies]
aes = { version = "0.8", optional = true }
base64 = { version = "0.21", optional = true }
bech32 = { version = "0.9", optional = true }
bech32 = { git = "https://github.com/rust-bitcoin/rust-bech32", rev = "360af7e0647fa94bce892fa69f31c0ef02452b63", optional = true, default-features = false }
bip39 = { version = "2.0", optional = true }
bitcoin = { version = "0.30", optional = true }
bitcoin_hashes = { version = "0.12", features = ["serde"] }
bitcoin_hashes = { version = "0.12", default-features = false, features = [
"serde",
] }
cbc = { version = "0.1", features = ["alloc"], optional = true }
log = "0.4"
log = "0.4" # no_std compatible by-default
nostr-ots = { version = "0.2", optional = true }
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls-webpki-roots", "socks"], optional = true }
secp256k1 = { version = "0.27", features = ["global-context", "rand-std", "serde"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
url = { version = "2", features = ["serde"] }
reqwest = { version = "0.11", default-features = false, features = [
"json",
"rustls-tls-webpki-roots",
"socks",
], optional = true }
secp256k1 = { version = "0.27", default-features = false, features = ["serde"] }

serde = { version = "1.0", features = [
"derive",
], default-features = false, optional = true }
serde_json = { version = "1.0", optional = true, default-features = false }

url = { version = "2", features = ["serde"], optional = true }
url_no_std = { package = "url", features = [
"alloc",
], git = "https://github.com/OverOrion/rust-url", branch = "no_std_net", optional = true, default-features = false }

rand = { version = "0.8", features = [
"alloc",
"getrandom",
], default-features = false, optional = true }


[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"] }
instant = { version = "0.1", features = [ "wasm-bindgen", "inaccurate" ] }
instant = { version = "0.1", features = ["wasm-bindgen", "inaccurate"] }

[dev-dependencies]
csv = "1.1.5"
Expand Down
15 changes: 15 additions & 0 deletions crates/nostr/examples/ensure_no_std/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "ensure_no_std"
version = "0.7.0"
authors = ["Supercomputing Systems AG <[email protected]>"]
license = "Apache-2.0"
edition = "2021"

[dependencies]
libc = { version = "0.2.119", default-features = false }

nostr = { path = "../../../nostr", default-features = false, features = [
"alloc",
] }

[workspace]
Loading